:root {
  --bg: #F4F5F7; --surface: #fff; --surface-2: #FAFBFC; --line: #E1E4EA; --line-2: #ECEEF2; --ink: #16181D; --ink-2: #2A2F38; --muted: #5B6370;
  --accent: #1F4FC4; --accent-2: #163A92; --accent-bg: #EEF3FF; --ok-bg: #E3F4EA; --ok: #17663A; --bad-bg: #FDE2DD; --bad: #9B1C0C; --warn-bg: #FDEBD3; --warn: #8A4300;
  --wait-bg: #F3EEFC; --wait: #4E2E8F; --radius: 10px; --font: Inter, system-ui, -apple-system, "Segoe UI", sans-serif; --head: "Space Grotesk", Inter, system-ui, sans-serif;
  --surface-3: #F1F3F6; --chip: #EEF1F6; --field: #D5D9E0; --accent-ink: #1F3B80; --accent-line: #DCE5FA; --link: #1F4FC4; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --bg: #0F1115; --surface: #171A21; --surface-2: #1C2029; --surface-3: #232833; --line: #2A303C; --line-2: #232833; --ink: #E6E8EC; --ink-2: #C9CED6; --muted: #9AA3B2;
  --accent: #3F69D6; --accent-2: #2F56B8; --accent-bg: #1B2747; --accent-ink: #B9CCFF; --accent-line: #2C3F6E; --link: #9DB8FF;
  --ok-bg: #12301F; --ok: #6FD49A; --bad-bg: #3A1611; --bad: #FF9A88; --warn-bg: #352306; --warn: #F2B66B; --wait-bg: #261B3D; --wait: #C4AAF5;
  --field: #363D4B; --chip: #232833; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1115; --surface: #171A21; --surface-2: #1C2029; --surface-3: #232833; --line: #2A303C; --line-2: #232833; --ink: #E6E8EC; --ink-2: #C9CED6; --muted: #9AA3B2;
  --accent: #3F69D6; --accent-2: #2F56B8; --accent-bg: #1B2747; --accent-ink: #B9CCFF; --accent-line: #2C3F6E; --link: #9DB8FF;
  --ok-bg: #12301F; --ok: #6FD49A; --bad-bg: #3A1611; --bad: #FF9A88; --warn-bg: #352306; --warn: #F2B66B; --wait-bg: #261B3D; --wait: #C4AAF5;
  --field: #363D4B; --chip: #232833; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--link); } a:hover { color: var(--accent-2); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { height: 36px; border: 1px solid var(--field); border-radius: 8px; padding: 0 10px; background: var(--surface); min-width: 0; }
input[type=checkbox] { height: auto; width: 16px; }
input[type=color] { width: 36px; padding: 2px; }
input:disabled, select:disabled { background: var(--surface-3); color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.grow { flex: 1; }
.muted { color: var(--muted); } .small { font-size: 12px; } .pad { padding: 24px; } .mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.end { justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--field); background: var(--surface); color: var(--ink-2); cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 500; }
.btn:hover { background: var(--surface-3); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; } .btn.primary:hover { background: var(--accent-2); }
.btn.danger { color: var(--bad); } .btn.sm { height: 30px; padding: 0 9px; font-size: 12px; } .btn.big { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.icon { width: 36px; padding: 0; justify-content: center; } .btn.sm.icon { width: 30px; } .btn.on { background: var(--accent-bg); }
.chip { height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--field); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 11px; font-size: 11px; font-weight: 600; background: var(--chip); color: var(--ink-2); align-self: flex-start; }
.pill.bad { background: var(--bad-bg); color: var(--bad); } .pill.ok { background: var(--ok-bg); color: var(--ok); }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 10px; background: var(--chip); font-size: 11px; font-weight: 500; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.x { border: 0; background: none; padding: 0 2px; cursor: pointer; color: inherit; display: inline-flex; }
.alert { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; flex-wrap: wrap; }
.alert.bad { background: var(--bad-bg); color: var(--bad); } .alert.info { background: var(--accent-bg); color: var(--accent-ink); }
.av { position: relative; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; overflow: hidden; color: var(--accent-ink); font-weight: 600; flex: 0 0 auto; border: 2px solid var(--surface); }
.av img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avs { display: inline-flex; } .avs .av + .av { margin-left: -8px; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font: 600 18px var(--head); }
.top nav { display: flex; gap: 4px; flex-wrap: wrap; }
.top nav a { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.top nav a.on { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.projsel { font-weight: 600; } .langsel { width: auto; }
.me { display: inline-flex; align-items: center; gap: 8px; } .me-name { font-size: 13px; color: var(--ink-2); }
.main { padding: 16px 24px 40px; max-width: 1600px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.h1 { display: flex; align-items: center; gap: 8px; margin: 0; font: 600 22px var(--head); }
.h { margin: 0 0 10px; font: 600 16px var(--head); display: flex; align-items: center; gap: 8px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); flex: 0 1 280px; }
.search input { border: 0; height: 32px; padding: 0; outline: none; flex: 1; }

/* board */
.board-scroll { overflow-x: auto; padding-bottom: 6px; }
.board { min-width: 1000px; display: flex; flex-direction: column; gap: 10px; }
.lane-head, .lane { display: grid; grid-template-columns: 110px repeat(4, minmax(220px, 1fr)); gap: 10px; align-items: start; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px; font: 600 14px var(--head); }
.col-head .count { color: var(--muted); font-weight: 500; } .col-head select { margin-left: auto; height: 28px; font: 12px var(--font); padding: 0 6px; }
.lane { background: var(--surface-3); border: 1px solid var(--line); border-radius: 12px; padding: 8px; }
.lane-blocked { background: var(--bad-bg); border-color: var(--bad-bg); }
.lane-label { padding: 8px 4px; display: flex; flex-direction: column; gap: 6px; }
.lane-label small { color: var(--muted); font-size: 11px; }
.lane-chip { display: inline-flex; align-self: flex-start; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 14px; font: 600 12px var(--font); background: var(--surface); }
.lane-blocked .lane-chip { background: var(--bad-bg); color: var(--bad); }
.cell { display: flex; flex-direction: column; gap: 10px; border-radius: 10px; padding: 6px; min-height: 80px; min-width: 0; }
.cell.over { background: var(--accent-line); outline: 2px dashed var(--accent); }
.card { display: flex; flex-direction: column; gap: 7px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 0 12px 12px; overflow: hidden; cursor: grab; }
.card.locked { cursor: default; opacity: .85; } .card.dragging { opacity: .5; }
.card .band { height: 5px; margin: 0 -12px; }
.card-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.key { font-weight: 600; text-decoration: none; }
.card-title { color: var(--ink); text-decoration: none; font-weight: 500; line-height: 1.35; } .card-title:hover { text-decoration: underline; }
.prio { padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.prio-urgent { background: var(--bad-bg); color: var(--bad); } .prio-high { background: var(--warn-bg); color: var(--warn); } .prio-medium { background: var(--accent-bg); color: var(--accent-ink); } .prio-low { background: var(--surface-3); color: var(--ink-2); }
.waitbox { display: flex; gap: 6px; font-size: 12px; padding: 6px 8px; border-radius: 6px; background: var(--wait-bg); color: var(--wait); }
.card-foot { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.card-foot .due, .card-foot .muted { display: inline-flex; align-items: center; gap: 3px; } .card-foot .avs { margin-left: auto; }
.due.overdue { color: var(--bad); font-weight: 600; }

/* ticket */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13px; }
.crumbs a:first-child { display: inline-flex; align-items: center; gap: 4px; }
.tpanel { padding: 0; overflow: hidden; }
.tband { height: 8px; display: flex; align-items: center; gap: 8px; padding: 0 20px; overflow: hidden; transition: height .15s ease; }
.tband.editable:hover, .tband.editable:focus-within, .tband.editable:focus { height: 44px; }
.band-swatches { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 600; font-size: 12px; }
.tband .band-swatches { visibility: hidden; }
.tband.editable:hover .band-swatches, .tband.editable:focus-within .band-swatches, .tband.editable:focus .band-swatches { visibility: visible; }
.sw { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255,255,255,.9); cursor: pointer; padding: 0; }
.sw.on { box-shadow: 0 0 0 2px var(--ink); }
.tbody { padding: 16px 20px; display: flex; flex-direction: column; gap: 14px; }
.title-input { flex: 1 1 360px; height: 44px; font: 600 24px var(--head); border-color: transparent; padding: 0 6px; margin-left: -6px; }
.title-input:hover, .title-input:focus { border-color: var(--field); }
.title-static { flex: 1 1 360px; margin: 0; font: 600 24px var(--head); }
.seg { display: flex; flex-wrap: wrap; border: 1px solid var(--field); border-radius: 9px; overflow: hidden; }
.seg button { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border: 0; background: var(--surface); color: var(--ink-2); cursor: pointer; font-weight: 500; }
.seg button.on { background: var(--accent); color: #fff; } .seg button:disabled { cursor: default; }
.seg button:disabled:not(.on) { color: var(--muted); }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px 20px; }
.field .lbl, .lbl { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 500; }
.field input, .field select { width: 100%; }
.field .mini { width: auto; max-width: 180px; }
.field.wide { grid-column: 1 / -1; }
.people { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.person { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.people .person { padding: 2px 6px 2px 2px; border-radius: 16px; background: var(--surface-3); }
.mini { height: 30px; font-size: 12px; width: auto; max-width: 160px; }
.waitpanel { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 10px; background: var(--wait-bg); border: 1px solid var(--wait-bg); color: var(--wait); flex-wrap: wrap; }
.form { display: flex; flex-direction: column; gap: 12px; } .form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.form.inline { flex-direction: row; flex-wrap: wrap; flex: 1; } .form.inline label { flex: 1 1 200px; }
.links { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; }
.linkchip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; }
.linkchip.blocking { border-color: var(--bad-bg); background: var(--bad-bg); } .linkchip b { color: var(--ink-2); font-size: 12px; }
.cols { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.colmain { flex: 999 1 600px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.colside { flex: 1 1 300px; min-width: 0; display: flex; flex-direction: column; gap: 14px; } .colside.narrow { flex: 1 1 240px; max-width: 300px; }
.edwrap { border: 1px solid var(--field); border-radius: 10px; overflow: hidden; background: var(--surface); }
.tb { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.tb button { width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tb button:hover { background: var(--chip); } .tb .sep { width: 1px; height: 20px; background: var(--field); margin: 0 4px; }
.editor { min-height: 90px; padding: 10px 12px; outline: none; }
.rich p { margin: 0 0 6px; } .rich ul, .rich ol, .editor ul, .editor ol { margin: 4px 0; padding-left: 22px; }
.composer .h { margin-bottom: 8px; } .check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.timeline .row { margin-bottom: 10px; flex-wrap: wrap; } .timeline .h { margin: 0 8px 0 0; }
.ev { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.ev::before { content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line); }
.ev:last-child::before { display: none; }
.dot { flex: 0 0 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--ink-2); }
.dot.note { background: var(--warn-bg); color: var(--warn); }
.ev-body { flex: 1; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.ev-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.ev-head b { color: var(--ink); }
.ev-line { font-size: 13px; padding-top: 6px; }
.small-ev .dot { flex-basis: 32px; height: 32px; }
.revs { display: flex; flex-direction: column; gap: 12px; max-height: 60vh; overflow: auto; } .rev { border-left: 3px solid var(--line); padding-left: 10px; }

/* tables / archive / settings */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.plist { display: flex; flex-direction: column; gap: 4px; }
.plist a:not(.btn) { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.plist a.on { background: var(--accent-bg); font-weight: 600; }
.keybadge { min-width: 38px; height: 22px; padding: 0 6px; border-radius: 5px; background: var(--accent); color: #fff; font: 700 10px var(--font); display: inline-flex; align-items: center; justify-content: center; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.fieldset { display: flex; flex-direction: column; gap: 5px; } .fieldset small { font-size: 12px; line-height: 1.4; }
.num { width: 90px; }
.checks { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 36px; padding: 4px 6px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); }
.chips input { flex: 1 1 120px; border: 0; height: 26px; padding: 0 4px; outline: none; }
.gchip { display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 4px 0 10px; border-radius: 13px; background: var(--accent-bg); color: var(--accent-ink); font-size: 13px; font-weight: 500; }
.gchip button { border: 0; background: none; cursor: pointer; color: inherit; display: inline-flex; padding: 2px; }

/* login, dialogs, toasts */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login .card { cursor: default; padding: 32px; max-width: 420px; width: 100%; align-items: center; text-align: center; gap: 12px; }
.login h1 { margin: 0; font: 600 24px var(--head); }
.demo { width: 100%; margin-top: 16px; border-top: 1px solid var(--line); padding-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.demo h2 { margin: 0; font-size: 13px; color: var(--muted); font-weight: 500; }
.demo-user { justify-content: flex-start; height: 44px; }
.dlg { border: 0; border-radius: 14px; padding: 22px; width: min(520px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.dlg::backdrop { background: rgba(22,24,29,.45); } .dlg h2 { margin: 0 0 12px; font: 600 19px var(--head); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #16181D; color: #fff; border: 1px solid var(--line); padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 360px; }
.toast.bad { background: #9B1C0C; color: #fff; border-color: #C0341D; }

@media (max-width: 720px) {
  .top, .main { padding-left: 16px; padding-right: 16px; }
  .me-name { display: none; }
  .search { flex-basis: 100%; }
}

/* files (phase 2) */
.hidden { display: none; }
.nomargin { margin: 0; }
.files.over { outline: 2px dashed var(--accent); background: var(--accent-bg); }
.files > .row { margin-bottom: 12px; }
.dropempty { border: 2px dashed var(--field); border-radius: 10px; padding: 18px; text-align: center; margin: 0; }
.fgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.fcard { display: flex; flex-direction: column; height: 214px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); min-width: 0; }
.thumb { position: relative; flex: 0 0 84px; display: flex; align-items: center; justify-content: center; gap: 2px; }
.thumb .ext { font: 700 11px var(--font); }
.pick { position: absolute; top: 6px; left: 6px; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.9); border-radius: 6px; cursor: pointer; }
.fbody { flex: 1; min-height: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.fname { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.loc { display: flex; align-items: center; gap: 4px; color: var(--muted); } .loc.moved { color: var(--warn); }
.count-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; }
.selbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; border-radius: 10px; background: #16181D; color: #fff; margin-bottom: 12px; font-size: 13px; }
.selbar select { height: 30px; border: 0; max-width: 320px; color: var(--ink); background: var(--surface); }
.segdark { display: flex; border: 1px solid var(--muted); border-radius: 6px; overflow: hidden; }
.sb { height: 28px; padding: 0 10px; border: 0; background: transparent; color: #fff; cursor: pointer; font-size: 12px; font-weight: 500; }
.sb.on { background: var(--surface); color: var(--ink); }
.x.light { color: #fff; }
.menu { position: relative; } .menu summary { list-style: none; } .menu summary::-webkit-details-marker { display: none; }
.menubox { position: absolute; z-index: 6; top: 36px; left: 0; min-width: 320px; max-width: min(480px, 90vw); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.15); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.mi { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 13px; color: var(--ink); background: none; border: 0; text-align: left; cursor: pointer; width: 100%; }
button.mi:hover, .mi:hover { background: var(--surface-3); }
.mi small { display: block; color: var(--muted); font: 11px ui-monospace, Consolas, monospace; word-break: break-all; }
.fbrowse { display: flex; flex-direction: column; max-height: 260px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 4px; }
.hist { list-style: none; margin: 0 0 12px; padding: 0; max-height: 60vh; overflow: auto; }
.hist li { position: relative; display: flex; gap: 12px; padding-bottom: 14px; }
.hist li::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: 0; width: 2px; background: var(--field); }
.hist li:last-child::before { display: none; }
.hist li > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.hdot { flex: 0 0 16px; height: 16px; border-radius: 50%; background: #8B95A5; margin-top: 2px; box-sizing: border-box; }
.hv.current .hdot { background: var(--accent); }
.hr .hdot { background: var(--surface); border: 2px dashed var(--muted); }
.hist code { font: 11px ui-monospace, Consolas, monospace; background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.colors { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.colorchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 4px; border: 1px solid var(--line); border-radius: 16px; font-size: 12px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; }

/* workspace + inbox (phase 3) */
.ws-bar { margin: 0 0 -6px; }
.layoutsw { display: flex; border: 1px solid var(--field); border-radius: 8px; overflow: hidden; background: var(--surface); }
.layoutsw button { width: 36px; height: 32px; border: 0; background: var(--surface); color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.layoutsw button.on { background: var(--ink); color: var(--surface); }
.ws { display: flex; gap: 0; height: calc(100vh - 150px); min-height: 520px; align-items: stretch; }
.ws.side { flex-direction: row; } .ws.stack { flex-direction: column; }
.ws-inbox { min-width: 0; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: auto; }
.ws-board { flex: 1 1 0; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
.ws.side .ws-board { padding-left: 4px; } .ws.stack .ws-board { padding-top: 4px; }
.ws.inbox .ws-inbox { flex: 1 1 auto; } .ws.board .ws-board { flex: 1 1 auto; }
.ws.stack .ws-inbox { max-height: none; }
.sep { flex: 0 0 10px; display: flex; align-items: center; justify-content: center; touch-action: none; border-radius: 6px; }
.ws.side .sep { cursor: col-resize; } .ws.stack .sep { cursor: row-resize; }
.sep:hover, .sep:focus-visible { background: var(--accent-line); }
.grip { background: #8B95A5; border-radius: 2px; }
.ws.side .grip { width: 2px; height: 36px; } .ws.stack .grip { width: 36px; height: 2px; }
.ib { display: flex; flex-direction: column; min-height: 100%; }
.ib-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line-2); }
.segl { display: flex; border: 1px solid var(--field); border-radius: 16px; overflow: hidden; }
.segl button { height: 30px; padding: 0 10px; border: 0; background: var(--surface); font-size: 12px; cursor: pointer; color: var(--ink-2); }
.segl button.on { background: var(--ink); color: var(--surface); }
.search.full { margin: 10px 14px; flex: none; }
.ib-list { max-height: 45%; min-height: 160px; overflow-y: auto; border-top: 1px solid var(--line-2); flex: 0 1 auto; }
.th-row { display: flex; flex-direction: column; gap: 3px; width: 100%; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line-2); background: var(--surface); text-align: left; cursor: pointer; font-size: 13px; color: var(--ink); }
.th-row:hover { background: var(--surface-2); } .th-row.sel { background: var(--accent-bg); }
.th-row.unread .th-subj, .th-row.unread .th-top > .ell { font-weight: 700; }
.th-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.th-subj { font-weight: 500; }
.th-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.cnt { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--line); font-size: 11px; font-weight: 600; }
.mini-tag { display: inline-flex; align-items: center; gap: 3px; padding: 1px 7px; border-radius: 9px; background: var(--chip); font-size: 11px; color: var(--ink-2); text-decoration: none; }
.mini-tag.ok { background: var(--ok-bg); color: var(--ok); } .mini-tag.accent { background: var(--accent-bg); color: var(--accent-ink); } .mini-tag.bad { background: var(--bad-bg); color: var(--bad); }
.subrows { display: flex; flex-direction: column; background: var(--surface-2); border-bottom: 1px solid var(--accent-line); }
.subrow { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 5px 14px 5px 28px; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; text-align: left; cursor: pointer; font-size: 13px; color: var(--ink); }
.subrow.out { background: var(--accent-bg); } .subrow.sel { background: var(--accent-line); box-shadow: inset 3px 0 0 var(--accent); }
.sub-who { flex: 0 1 auto; max-width: 40%; font-weight: 500; }
.dir { display: inline-flex; flex: 0 0 auto; } .dir.in { color: var(--ok); } .dir.out { color: var(--accent); }
.ib-read { border-top: 1px solid var(--line); padding: 14px; background: var(--surface-2); }
.mailview { display: flex; flex-direction: column; gap: 10px; }
.mail-subj { margin: 0; font: 600 16px var(--head); }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 3px 10px; margin: 0; font-size: 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
.bad { color: var(--bad); }
.trust { list-style: none; margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.trust li { display: flex; align-items: flex-start; gap: 6px; } .trust li.ok { color: var(--ok); } .trust li.info { color: var(--ink-2); } .trust li.bad { color: var(--bad); font-weight: 600; }
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--accent-line); border-radius: 8px; background: var(--accent-bg); font-size: 13px; }
.safebar { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.mailframe { width: 100%; height: 360px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; }
.att { display: inline-flex; align-items: center; gap: 4px; padding: 4px 9px; border: 1px solid var(--field); border-radius: 8px; background: var(--surface); font-size: 12px; color: var(--ink); text-decoration: none; }
.btn.flip svg { transform: scaleX(-1); }
.toast { display: flex; align-items: center; gap: 12px; }
.toast-act { border: 0; background: none; color: #9DB8FF; font-weight: 600; cursor: pointer; padding: 0; }
.dlg.wide { width: min(860px, calc(100vw - 32px)); }
.composer-form .editor { min-height: 160px; }
.composer-form .tb select { height: 28px; font-size: 12px; margin-right: 6px; }
.lmails { display: flex; flex-direction: column; }
.lmail { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border: 0; border-bottom: 1px solid var(--line-2); background: none; text-align: left; cursor: pointer; font-size: 13px; color: var(--ink); width: 100%; }
.lmail:hover { background: var(--surface-2); }
.alert.warnbox { background: var(--warn-bg); color: var(--warn); }
.fs { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.fs legend { font-size: 13px; font-weight: 600; padding: 0 4px; }
.mi.on { background: var(--accent-bg); }
@media (max-width: 900px) { .ws { height: auto; } .ws.side { flex-direction: column; } .ws.side .ws-inbox { flex: none !important; } .ws.side .sep { display: none; } }

/* reminders (phase 4) */
.reminders { display: flex; flex-direction: column; gap: 6px; }
.rem { display: flex; align-items: center; gap: 6px; font-size: 13px; padding: 4px 8px; border-radius: 8px; background: var(--wait-bg); color: var(--wait); }
.reminders .mini { max-width: 220px; }

/* ---- bill portal ---- */
.main.portal { display: flex; justify-content: center; padding: 24px 16px; }
.narrowp { width: min(560px, 100%); }
.dropzone { border: 2px dashed var(--line); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-bg); }
.req { color: var(--bad); font-weight: 600; }
input.ro { background: var(--surface-2); color: var(--muted); }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li.done, .steps li.cur { color: inherit; } .steps li.cur { font-weight: 600; }
.steps .sd { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.steps li.done .sd { background: var(--ok); border-color: var(--ok); color: #fff; } .steps li.cur .sd { background: var(--accent); border-color: var(--accent); color: #fff; }
.msgs { display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); max-width: 90%; }
.msg.you { align-self: flex-end; background: var(--accent-bg); }
.kv.wide { grid-template-columns: 120px 1fr; font-size: 13px; }
.pre { white-space: pre-line; }
.end-items { align-items: flex-end; }

/* ---- user menu, placeholder info, folder field ---- */
.umenu-wrap { position: relative; }
.me { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid transparent; border-radius: 20px; padding: 2px 8px 2px 2px; cursor: pointer; }
.me:hover, .me[aria-expanded="true"] { border-color: var(--line); background: var(--surface-2); }
.umenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 50; width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .18); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.umenu[hidden] { display: none; }
.umenu-head { display: flex; align-items: center; gap: 10px; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.umenu .check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.phinfo { display: inline-block; position: relative; font-weight: 400; }
.phinfo summary { list-style: none; cursor: pointer; color: var(--muted); display: inline-flex; padding: 2px; border-radius: 50%; }
.phinfo summary::-webkit-details-marker { display: none; }
.phinfo[open] summary, .phinfo summary:hover { color: var(--accent); }
.phpop { position: absolute; z-index: 40; left: 0; top: 22px; width: 280px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .16); padding: 12px; display: flex; flex-direction: column; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; }
.phpop dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.phpop dd { margin: 0; }
.folderin { display: flex; } .folderin input { flex: 1; }
@media (max-width: 640px) { .me-name { display: none; } .umenu { width: min(280px, calc(100vw - 32px)); } }

/* ---- mailbox form, file type chips, refused types ---- */
.h3 { font: 600 13px var(--font); margin: 6px 0 0; color: var(--ink-2); }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); padding: 4px 0; }
details.more[open] > summary { margin-bottom: 8px; }
input[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-bg); }
.alert.bad { border: 1px solid var(--bad); }
.gchip.mono { font-family: ui-monospace, Consolas, monospace; }
.span2 { grid-column: 1 / -1; }
.stack.tight { gap: 4px; }
.refused { margin-top: 6px; }
.rchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border: 1px dashed var(--field); border-radius: 16px; background: var(--surface-2); }

/* ---- inbox: list fills the height left by the open mail; both scroll on their own (desktop) ---- */
@media (min-width: 901px) {
  .ws-inbox { overflow: hidden; display: flex; flex-direction: column; }
  .ws-inbox > .ib { flex: 1 1 auto; height: 100%; min-height: 0; }
  .ib-list { flex: 1 1 0; max-height: none; min-height: 160px; }
  .ib-read { flex: 0 1 auto; max-height: 68%; overflow-y: auto; }
  .ib.noread .ib-list { flex: 1 1 auto; }
}
.ib-read[hidden] { display: none; }
@media (max-width: 900px) { .ib-list { max-height: 50vh; } }

/* ---- composer ---- */
.crow { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 8px; }
.crow[hidden] { display: none; }
.clbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.copts { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.btn.ghost { background: none; border-color: transparent; color: var(--link); }
.chipwrap { position: relative; display: inline-flex; }
.gchip.rbtn { border: 0; cursor: pointer; gap: 4px; padding: 0 8px 0 10px; font: inherit; font-size: 13px; }
.gchip.rbtn:hover, .gchip.rbtn[aria-expanded="true"] { background: var(--accent-line); }
.chipmenu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 230px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.chipmenu-head { display: flex; flex-direction: column; gap: 2px; padding: 6px 8px 8px; margin-bottom: 2px; border-bottom: 1px solid var(--line-2); overflow-wrap: anywhere; }
.mi.danger { color: var(--bad); }
.sigpreview { border: 1px dashed var(--field); border-radius: 8px; padding: 6px 10px; color: var(--ink-2); font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.sigpreview.off { opacity: .75; }
.sigbody { max-height: calc(1.45em * 5); overflow-y: auto; user-select: none; overscroll-behavior: contain; }
.sigbody p { margin: 0 0 4px; }
.sigpreview[hidden] { display: none; }
.draftbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fbrowse.tall { max-height: 360px; }
.draftrow { padding: 8px 0; border-bottom: 1px solid var(--line-2); }
@media (max-width: 560px) { .crow { grid-template-columns: 1fr; gap: 4px; } }

/* ---- mail view: action bar, meta, ticket bar ---- */
.mailbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); }
.btn-group { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.mailmeta { display: flex; flex-direction: column; gap: 6px; }
.checks-line { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 11.5px; line-height: 1.35; }
.chk { display: inline-flex; align-items: center; gap: 4px; }
.chk.ok { color: var(--ok); } .chk.info { color: var(--muted); } .chk.muted { color: var(--muted); }
.chk.bad { color: var(--bad); font-weight: 600; background: var(--bad-bg); padding: 2px 8px; border-radius: 6px; }
.ticketbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 13px; }
.ticketbar.suggest { border-color: var(--accent-line); background: var(--accent-bg); }
.tb-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-right: 2px; }
/* ---- composer: checkbox labels stay on one line inside forms; footer holds draft + send ---- */
.form label.check { flex-direction: row; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; }
.dlg .row.end { flex-wrap: wrap; align-items: center; }
.dlg .draftbar { gap: 6px; }
.attrow { align-items: center; }

/* Bars adapt to the inbox panel's width, not the window's. */
.ws-inbox { container-type: inline-size; }
@container (max-width: 560px) {
  .mailbar .bt, .ticketbar .bt { display: none; }
  .ticketbar .sg-why { display: none; }
}

/* ---- editor: tables, rules, table tools ---- */
.editor table, .rich table { border-collapse: collapse; margin: 6px 0; max-width: 100%; }
.editor th, .editor td, .rich th, .rich td { border: 1px solid var(--field); padding: 4px 8px; min-width: 48px; vertical-align: top; text-align: left; }
.editor th, .rich th { background: var(--surface-2); font-weight: 600; }
.editor hr, .rich hr { border: 0; border-top: 1px solid var(--field); margin: 10px 0; }
.tabletools { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 4px 6px; border-bottom: 1px solid var(--line-2); background: var(--accent-bg); }
.tabletools .tt { border: 0; background: none; font-size: 12px; padding: 3px 7px; border-radius: 6px; cursor: pointer; color: var(--ink-2); }
.tabletools .tt:hover { background: var(--accent-line); }
.tabletools .sep { width: 1px; height: 16px; background: var(--field); margin: 0 4px; }
.umenu .btn { justify-content: flex-start; }

/* ---- phone header: burger menu behind the icon/app name ---- */
.burger { display: none; }
@media (max-width: 720px) {
  .top { gap: 8px; padding-top: 8px; padding-bottom: 8px; }
  .top .brand { font-size: 16px; padding: 4px 6px 4px 2px; border-radius: 8px; cursor: pointer; min-width: 0; }
  .top .brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top .burger { display: inline-flex; color: var(--ink-2); }
  .top.open .brand { background: var(--surface-2); }
  .top .projsel, .top nav { display: none; }
  .top.open .projsel { display: block; order: 10; flex: 1 1 100%; }
  .top.open nav { display: flex; order: 11; flex: 1 1 100%; flex-direction: column; gap: 2px; padding-bottom: 4px; }
  .top.open nav a { padding: 10px 12px; }
}
