:root {
  --primary: #305090;
  --primary-hover: #204080;
  --primary-soft: #dfe5f3;
  --accent: #e3a71c;
  --bg: #e9ecf4;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --border: #d0d4e4;
  --border-soft: #e6e9ef;
  --text: #2b2f3a;
  --text-2: #5e6473;
  --hover: #dcdfec;
  --row-hover: #f5f6f8;
  --danger: #c93d50;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  --radius: 8px;
  --header-h: 48px;
  --name-col: 340px;
  --col-w: 150px;
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161b2c; --surface: #242b40; --surface-2: #1d2335; --border: #3d4660; --border-soft: #333b52;
    --text: #d8dce6; --text-2: #9aa1b4; --hover: #343d58; --row-hover: #2b3349; --primary-soft: #2a3d6b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #161b2c; --surface: #242b40; --surface-2: #1d2335; --border: #3d4660; --border-soft: #333b52;
  --text: #d8dce6; --text-2: #9aa1b4; --hover: #343d58; --row-hover: #2b3349; --primary-soft: #2a3d6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body, #root { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
[hidden] { display: none !important; }

/* ---------- buttons & inputs ---------- */
.btn { border: 0; border-radius: 4px; padding: 0 12px; height: 32px; display: inline-flex; align-items: center; gap: 6px; background: transparent; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border: 1px solid var(--border); }
.btn-danger { color: var(--danger); }
.btn-sm { height: 28px; padding: 0 8px; font-size: 13px; }
.icon-btn { width: 32px; height: 32px; border: 0; border-radius: 4px; background: transparent; display: inline-grid; place-items: center; color: var(--text-2); }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.input { height: 36px; border: 1px solid var(--border); border-radius: 4px; padding: 0 10px; background: var(--surface); width: 100%; outline: none; }
.input:focus { border-color: var(--primary); }
textarea.input { height: auto; padding: 10px; resize: vertical; min-height: 80px; }
.muted { color: var(--text-2); }
.svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- auth ---------- */
.auth { min-height: 100%; display: grid; grid-template-columns: 1fr 1fr; }
.auth-hero { background: linear-gradient(135deg, #16254a 0%, #204080 55%, #6070a0 130%); color: #fff; padding: 64px; display: flex; flex-direction: column; justify-content: center; gap: 24px; }
.auth-hero h1 { font-size: 44px; line-height: 1.1; margin: 0; }
.auth-hero p { font-size: 18px; opacity: .85; max-width: 460px; margin: 0; }
.hero-board { display: grid; gap: 6px; max-width: 460px; margin-top: 16px; }
.hero-row { display: grid; grid-template-columns: 6px 1fr 110px 110px; gap: 2px; background: rgba(255,255,255,.08); border-radius: 4px; overflow: hidden; height: 34px; align-items: stretch; }
.hero-row > div { display: flex; align-items: center; justify-content: center; font-size: 13px; }
.hero-row > div:nth-child(2) { justify-content: flex-start; padding-left: 10px; }
.auth-form-wrap { display: grid; place-items: center; padding: 32px; background: var(--surface); }
.auth-form { width: 100%; max-width: 380px; display: grid; gap: 14px; }
.auth-form h2 { margin: 0 0 4px; font-size: 28px; }
.auth-form label { display: grid; gap: 6px; font-size: 13px; color: var(--text-2); }
.auth-form .btn-primary { height: 40px; justify-content: center; font-size: 15px; }
.auth-switch { text-align: center; color: var(--text-2); }
.auth-switch button { border: 0; background: none; color: var(--primary); padding: 0; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }
@media (max-width: 860px) { .auth { grid-template-columns: 1fr; } .auth-hero { padding: 32px 16px; } .auth-hero h1 { font-size: 32px; } .hero-board { display: none; } }

/* ---------- logo ---------- */
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; letter-spacing: -0.2px; }
.logo-dots { display: inline-flex; gap: 3px; align-items: flex-end; }
.logo-dots i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.logo-dots i:nth-child(1) { background: #204080; }
.logo-dots i:nth-child(2) { background: #e3a71c; height: 14px; border-radius: 4px; }
.logo-dots i:nth-child(3) { background: #6070a0; }
.logo small { font-weight: 400; color: var(--text-2); font-size: 13px; }

/* ---------- shell ---------- */
.shell { height: 100%; display: grid; grid-template-rows: var(--header-h) 1fr; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; background: var(--surface-2); }
.spacer, .topbar .spacer { flex: 1; }
.avatar { width: 30px; height: 30px; border-radius: 50%; color: #fff; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; flex: none; border: 2px solid var(--surface); }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 36px; height: 36px; font-size: 14px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar + .avatar { margin-left: -8px; }
.avatar.empty { background: transparent; border: 1px dashed var(--border); color: var(--text-2); }

.main-wrap { display: grid; grid-template-columns: 260px 1fr; min-height: 0; padding: 0 8px 8px 0; background: var(--surface-2); }
.sidebar { padding: 8px 8px 8px 12px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.sidebar.collapsed { display: none; }
.side-section { font-size: 12px; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; padding: 12px 8px 4px; display: flex; align-items: center; justify-content: space-between; }
.ws-select { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); width: 100%; text-align: left; }
.ws-badge { width: 28px; height: 28px; border-radius: 6px; background: linear-gradient(135deg, #204080, #6070a0); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.ws-select .name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item { display: flex; align-items: center; gap: 8px; padding: 0 8px; height: 34px; border-radius: 4px; border: 0; background: transparent; width: 100%; text-align: left; color: var(--text); }
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--primary-soft); }
.side-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-search { margin: 4px 0; height: 32px; }

.content { background: var(--surface); border-radius: var(--radius); min-width: 0; min-height: 0; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 0 0 1px var(--border-soft); }
@media (max-width: 800px) {
  .main-wrap { grid-template-columns: 1fr; padding: 0; }
  .sidebar { position: fixed; z-index: 30; top: var(--header-h); bottom: 0; left: 0; width: 260px; background: var(--surface-2); box-shadow: var(--shadow); }
  .content { border-radius: 0; }
  :root { --name-col: 220px; --col-w: 130px; }
}

/* ---------- board header ---------- */
.board-head { padding: 16px 24px 0; }
.board-title-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-title { font-size: 24px; font-weight: 600; border: 1px solid transparent; border-radius: 4px; padding: 2px 6px; margin-left: -7px; background: transparent; min-width: 120px; max-width: 100%; outline: none; }
.board-title:hover { border-color: var(--border); }
.board-title:focus { border-color: var(--primary); }
.board-title-row .spacer { flex: 1; }
.board-desc { color: var(--text-2); border: 1px solid transparent; border-radius: 4px; padding: 2px 6px; margin: 2px 0 0 -7px; width: min(600px, 100%); background: transparent; outline: none; }
.board-desc:hover { border-color: var(--border); }
.board-desc:focus { border-color: var(--primary); }
.tabs { display: flex; gap: 4px; margin-top: 10px; border-bottom: 1px solid var(--border-soft); overflow-x: auto; }
.tab { border: 0; background: transparent; padding: 8px 12px; border-radius: 4px 4px 0 0; color: var(--text); display: flex; gap: 6px; align-items: center; position: relative; white-space: nowrap; }
.tab:hover { background: var(--hover); }
.tab.active::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.toolbar { display: flex; gap: 8px; align-items: center; padding: 12px 24px; flex-wrap: wrap; }
.toolbar .search { width: 200px; height: 32px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border-radius: 4px; border: 0; background: transparent; }
.chip:hover { background: var(--hover); }
.chip.on { background: var(--primary-soft); }

/* ---------- table ---------- */
.board-body { flex: 1; overflow: auto; padding: 0 24px 40px; }
.group { margin-bottom: 36px; --gc: #305090; width: max-content; min-width: 100%; }
.group-head { display: flex; align-items: center; gap: 4px; height: 40px; position: sticky; left: 0; width: max-content; z-index: 4; }
.group-head .caret { color: var(--gc); }
.group-name { color: var(--gc); font-weight: 600; font-size: 17px; border: 1px solid transparent; border-radius: 4px; padding: 2px 6px; background: transparent; outline: none; min-width: 60px; }
.group-name:hover { border-color: var(--border); }
.group-name:focus { border-color: var(--primary); color: var(--text); }
.group-count { color: var(--text-2); font-size: 13px; margin-left: 4px; }
.group-menu { opacity: 0; }
.group-head:hover .group-menu { opacity: 1; }

.grid { display: grid; grid-template-columns: 6px var(--name-col) repeat(var(--ncols), var(--col-w)) 48px; width: max-content; min-width: 100%; }
.grid .cell { border-bottom: 1px solid var(--border-soft); border-right: 1px solid var(--border-soft); height: 37px; display: flex; align-items: center; justify-content: center; background: var(--surface); position: relative; min-width: 0; }
.grid .bar { background: var(--gc); border: 0 !important; position: sticky; left: 0; z-index: 3; }
.grid .bar::before { content: ''; position: absolute; right: 100%; top: -1px; bottom: -1px; width: 24px; background: var(--surface); }
.grid .bar.first { border-top-left-radius: 6px; }
.grid .bar.last { border-bottom-left-radius: 6px; }
.grid .hcell { font-size: 13px; color: var(--text-2); border-top: 1px solid var(--border-soft); }
.grid .hcell.name { justify-content: flex-start; padding-left: 36px; position: sticky; left: 6px; z-index: 2; }
.grid .hcell .col-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 22px; cursor: text; }
.grid .hcell .col-menu { position: absolute; right: 2px; opacity: 0; width: 22px; height: 22px; }
.grid .hcell:hover .col-menu { opacity: 1; }
.grid .add-col { color: var(--text-2); border-top: 1px solid var(--border-soft); }
.grid .filler { border-right: 0; }
.row { display: contents; }
.row:hover > .cell:not(.bar) { background: var(--row-hover); }
.grid .cell.name { justify-content: flex-start; padding: 0 6px 0 8px; gap: 6px; position: sticky; left: 6px; z-index: 1; }
.grid .cell.name .drag { cursor: grab; color: var(--text-2); opacity: 0; width: 18px; display: grid; place-items: center; }
.grid .cell.name:hover .drag { opacity: 1; }
.item-name { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 3px; background: transparent; padding: 3px 5px; outline: none; overflow: hidden; text-overflow: ellipsis; }
.item-name:hover { border-color: var(--border); }
.item-name:focus { border-color: var(--primary); background: var(--surface); }
.open-item { border: 0; background: transparent; color: var(--text-2); display: inline-flex; align-items: center; gap: 3px; height: 26px; padding: 0 6px; border-radius: 4px; font-size: 12px; }
.open-item:hover { background: var(--hover); color: var(--primary); }
.open-item .badge { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 5px; font-size: 11px; line-height: 16px; }
.row-menu { opacity: 0; width: 26px; height: 26px; }
.cell.name:hover .row-menu { opacity: 1; }
.drop-before > .cell { box-shadow: inset 0 2px 0 var(--primary); }
.drop-after > .cell { box-shadow: inset 0 -2px 0 var(--primary); }
.dragging > .cell { opacity: .4; }

.cell-status { width: 100%; height: 100%; border: 0; color: #fff; font-weight: 500; font-size: 13px; padding: 0 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; position: relative; }
.cell-status:hover::after { content: ''; position: absolute; right: 0; top: 0; width: 10px; height: 10px; background: linear-gradient(225deg, var(--surface) 50%, transparent 50%); }
.cell-input { width: 100%; height: 100%; border: 1px solid transparent; background: transparent; padding: 0 8px; outline: none; text-align: center; text-overflow: ellipsis; }
.cell-input:hover { border-color: var(--border); }
.cell-input:focus { border-color: var(--primary); background: var(--surface); }
.cell-input.num { text-align: right; }
.cell-btn { width: 100%; height: 100%; border: 0; background: transparent; display: flex; align-items: center; justify-content: center; gap: 4px; }
.cell-btn:hover { outline: 1px solid var(--border); outline-offset: -1px; }
.cell-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; max-width: 100%; }
.cell .placeholder { color: var(--text-2); opacity: 0; }
.cell:hover .placeholder { opacity: 1; }
.cell input[type=checkbox] { width: 18px; height: 18px; accent-color: #2e9e6b; cursor: pointer; }
.date-overdue { color: var(--danger); }

.add-row > .cell.name { padding-left: 34px; }
.add-row input { border: 1px solid transparent; background: transparent; outline: none; width: 100%; height: 28px; padding: 0 6px; border-radius: 3px; }
.add-row input:focus { border-color: var(--primary); }
.add-row > .cell { border-bottom-color: var(--border-soft); }
.summary > .cell { border: 0; background: transparent !important; height: 34px; }
.summary > .cell.sum { border: 1px solid var(--border-soft); border-top: 0; font-weight: 600; font-size: 13px; padding: 4px; }
.summary .sum:first-of-type { border-left: 1px solid var(--border-soft); }
.dist { display: flex; width: 100%; height: 22px; border-radius: 2px; overflow: hidden; }
.dist i { display: block; height: 100%; }
.add-group { margin-top: -16px; position: sticky; left: 0; }

/* ---------- kanban ---------- */
.kanban { display: flex; gap: 12px; align-items: flex-start; padding-bottom: 24px; min-height: 100%; }
.lane { width: 270px; flex: none; background: var(--surface-2); border-radius: 8px; display: flex; flex-direction: column; max-height: 100%; }
.lane-head { color: #fff; padding: 10px 12px; border-radius: 8px 8px 0 0; font-weight: 600; display: flex; justify-content: space-between; }
.lane-body { padding: 8px; display: grid; gap: 8px; min-height: 80px; overflow: auto; align-content: start; }
.lane.drop .lane-body { outline: 2px dashed var(--primary); outline-offset: -4px; border-radius: 8px; }
.card { background: var(--surface); border-radius: 6px; padding: 10px 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12); cursor: grab; display: grid; gap: 8px; border-left: 4px solid var(--gc, var(--border)); }
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.card-title { font-weight: 500; }
.card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--text-2); font-size: 12px; }
.card-meta .pill { padding: 2px 8px; border-radius: 10px; color: #fff; font-size: 11px; }
.lane-add { border: 0; background: transparent; color: var(--text-2); text-align: left; padding: 8px 12px 12px; }
.lane-add:hover { color: var(--primary); }
.kanban-config { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.kanban-config select { height: 32px; border: 1px solid var(--border); border-radius: 4px; padding: 0 8px; background: var(--surface); }

/* ---------- dashboard ---------- */
.dash { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding-bottom: 24px; }
.widget { border: 1px solid var(--border-soft); border-radius: 8px; padding: 16px 18px; background: var(--surface); }
.widget h3 { margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.kpis { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi { border: 1px solid var(--border-soft); border-radius: 8px; padding: 14px 18px; }
.kpi .label { color: var(--text-2); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.hbar { display: grid; grid-template-columns: 120px 1fr 52px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.hbar .track { background: var(--surface-2); border-radius: 4px; height: 20px; overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; }
.hbar .n { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.list-row { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- popover ---------- */
.popover { position: fixed; z-index: 100; background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); padding: 8px; min-width: 200px; max-width: 320px; max-height: 70vh; overflow: auto; }
.pop-title { font-size: 12px; color: var(--text-2); padding: 4px 6px 8px; }
.label-list { display: grid; gap: 6px; padding: 4px; }
.label-opt { border: 0; color: #fff; height: 32px; border-radius: 2px; font-weight: 500; min-width: 180px; padding: 0 10px; }
.label-opt:hover { opacity: .85; }
.label-edit { display: flex; gap: 6px; align-items: center; }
.label-edit .swatch { width: 26px; height: 26px; border-radius: 4px; border: 0; flex: none; }
.label-edit input { flex: 1; height: 30px; border: 1px solid var(--border); border-radius: 4px; padding: 0 8px; background: var(--surface); }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; height: 34px; padding: 0 10px; border-radius: 4px; text-align: left; color: var(--text); }
.menu-item:hover { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border-soft); margin: 6px 0; }
.swatches { display: grid; grid-template-columns: repeat(6, 26px); gap: 6px; padding: 6px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 0; }
.swatches button.sel { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.person-opt { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 6px 8px; border-radius: 4px; text-align: left; }
.person-opt:hover { background: var(--hover); }
.person-opt.sel { background: var(--primary-soft); }
.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 50; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); z-index: 51; box-shadow: var(--shadow); display: flex; flex-direction: column; animation: slideIn .18s ease-out; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.drawer-head { padding: 16px 20px 0; }
.drawer-head .top { display: flex; align-items: center; gap: 8px; }
.drawer-head input { font-size: 22px; font-weight: 600; flex: 1; border: 1px solid transparent; border-radius: 4px; padding: 4px 6px; background: transparent; outline: none; }
.drawer-head input:hover { border-color: var(--border); }
.drawer-head input:focus { border-color: var(--primary); }
.drawer-body { flex: 1; overflow: auto; padding: 16px 20px; }
.update-box { display: grid; gap: 8px; margin-bottom: 20px; }
.update-box .actions { display: flex; justify-content: flex-end; }
.update { border: 1px solid var(--border-soft); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; }
.update-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.update-head .who { font-weight: 600; }
.update-body { white-space: pre-wrap; line-height: 1.5; }
.act-row { display: flex; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.act-row .when { color: var(--text-2); width: 90px; flex: none; }
.info-grid { display: grid; grid-template-columns: 160px 1fr; border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; }
.info-grid > div { min-height: 40px; display: flex; align-items: center; border-bottom: 1px solid var(--border-soft); }
.info-grid > .k { padding: 0 12px; color: var(--text-2); background: var(--surface-2); font-size: 13px; }
.info-grid > .v { position: relative; }
.info-grid > .v > * { height: 40px; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--text-2); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 17, 40, .5); display: grid; place-items: center; z-index: 80; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); padding: 24px; box-shadow: var(--shadow); display: grid; gap: 16px; max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0; font-size: 22px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }
.tpl-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-scroll { max-height: 42vh; overflow: auto; padding: 2px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tpl { border: 2px solid var(--border-soft); border-radius: 8px; padding: 12px; text-align: left; background: var(--surface); display: grid; gap: 4px; }
.tpl:hover { border-color: var(--border); }
.tpl.sel { border-color: var(--primary); background: var(--primary-soft); }
.tpl strong { font-size: 14px; }
.tpl span { font-size: 12px; color: var(--text-2); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 200; }
.toast { background: #2b2f3a; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: var(--shadow); font-size: 14px; animation: slideIn .2s; }
.toast.error { background: var(--danger); }

.welcome { display: grid; place-items: center; height: 100%; text-align: center; padding: 24px; }
.welcome h2 { font-size: 26px; margin: 8px 0; }

/* ---------- modules ---------- */
.icon-btn.on { background: var(--primary-soft); color: var(--primary); }
.bell { position: relative; }
.bell-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; line-height: 14px; min-width: 14px; padding: 0 3px; text-align: center; }
.brand-logo img { display: block; }
.brand-hero { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.brand-hero img { max-height: 72px; max-width: 280px; background: #fff; padding: 8px 12px; border-radius: 10px; align-self: flex-start; }
.brand-name { font-size: 28px; font-weight: 700; } .brand-tag { opacity: .85; }
.page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.field { display: grid; gap: 6px; margin-bottom: 12px; } .field-label { font-size: 13px; color: var(--text-2); }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; padding-bottom: 32px; }
.settings-grid .widget h4 { margin: 18px 0 6px; font-size: 14px; }
.logo-preview { min-height: 64px; display: flex; align-items: center; } .logo-preview img { max-height: 64px; max-width: 240px; }
.key-reveal { background: var(--primary-soft); border-radius: 8px; padding: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.key-reveal code { background: var(--surface); padding: 6px 8px; border-radius: 4px; word-break: break-all; }
pre.code { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 6px; padding: 12px; font-size: 12.5px; overflow: auto; white-space: pre; }
.chip-code { display: inline-block; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 6px; margin: 2px; cursor: pointer; font-size: 12px; }
.chip-code:hover { border-color: var(--primary); }

/* help */
.help-drawer { width: min(520px, 100%); }
.help-body { padding-top: 0; }
.help-sec { border: 1px solid var(--border-soft); border-radius: 8px; margin-bottom: 8px; overflow: hidden; }
.help-sec-head { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: var(--surface-2); padding: 12px 14px; font-weight: 600; color: var(--text); text-align: left; }
.help-sec.open .help-sec-head { background: var(--primary-soft); }
.help-sec-body { padding: 12px 14px; }
.help-intro { margin: 0 0 12px; color: var(--text-2); line-height: 1.5; }
.help-item { padding: 10px 0; border-top: 1px solid var(--border-soft); }
.help-name { font-weight: 600; margin-bottom: 4px; }
.help-row { display: grid; grid-template-columns: 60px 1fr; gap: 8px; font-size: 13px; line-height: 1.5; margin-top: 2px; }
.help-k { color: var(--text-2); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; padding-top: 3px; }

/* subitems */
.sub-toggle { width: 22px; height: 22px; opacity: .35; margin-left: -4px; position: relative; }
.sub-toggle.has, .cell.name:hover .sub-toggle { opacity: 1; }
.sub-count { position: absolute; right: -4px; top: -4px; background: var(--primary); color: #fff; border-radius: 8px; font-size: 9px; line-height: 12px; padding: 0 3px; }
.sub-row > .cell { background: var(--surface-2); }

/* columns */
.tl-pill { position: relative; width: 100%; height: 24px; border-radius: 12px; background: var(--primary-soft); overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.tl-pill i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary); opacity: .35; }
.tl-pill span { position: relative; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.formula-val { font-variant-numeric: tabular-nums; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.time-cell { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.time-cell .running { color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .4; } }
.link-pills { display: flex; gap: 4px; overflow: hidden; }
.link-pill { background: var(--primary-soft); color: var(--primary); border-radius: 10px; padding: 2px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 110px; }
.mirror-val { font-size: 13px; padding: 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

/* timeline view */
.tl-wrap { display: flex; flex-direction: column; height: 100%; }
.tl-scroll { overflow: auto; flex: 1; border: 1px solid var(--border-soft); border-radius: 8px; }
.tl-canvas { position: relative; }
.tl-head { display: flex; position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.tl-label-col { width: 260px; flex: none; position: sticky; left: 0; background: var(--surface); z-index: 2; padding: 0 12px; display: flex; align-items: center; gap: 8px; border-right: 1px solid var(--border-soft); font-size: 13px; }
.tl-grid { position: relative; height: 40px; background-image: linear-gradient(to right, var(--border-soft) 1px, transparent 1px); background-size: 36px 100%; }
.tl-month { position: absolute; top: 2px; font-size: 11px; font-weight: 600; color: var(--text-2); padding-left: 4px; border-left: 1px solid var(--border); height: 100%; }
.tl-day { position: absolute; top: 22px; font-size: 11px; text-align: center; color: var(--text-2); } .tl-day.wknd { color: var(--border); }
.tl-group { font-weight: 600; padding: 10px 12px 4px; position: sticky; left: 0; display: inline-block; }
.tl-row { display: flex; height: 40px; border-bottom: 1px solid var(--border-soft); }
.tl-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; } .tl-name:hover { color: var(--primary); }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--accent); z-index: 1; }
.tl-bar { position: absolute; top: 8px; height: 24px; border-radius: 6px; color: #fff; font-size: 12px; padding: 0 8px; line-height: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.tl-bar.done { opacity: .5; } .tl-bar.late { outline: 2px solid var(--danger); }

/* calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 12px; color: var(--text-2); text-align: center; padding: 4px; }
.cal-cell { min-height: 96px; border: 1px solid var(--border-soft); border-radius: 6px; padding: 4px; display: flex; flex-direction: column; gap: 3px; background: var(--surface); }
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-day { font-size: 12px; color: var(--text-2); }
.cal-item { border: 0; color: #fff; border-radius: 4px; font-size: 11px; padding: 2px 6px; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-item.done { opacity: .5; text-decoration: line-through; }

/* workload */
.wl-grid { display: grid; gap: 1px; background: var(--border-soft); border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; }
.wl-grid > div { background: var(--surface); padding: 8px 10px; font-size: 13px; }
.wl-head { font-weight: 600; color: var(--text-2); font-size: 12px; }
.wl-person { display: flex; align-items: center; gap: 8px; }
.wl-cell { display: flex; flex-direction: column; gap: 4px; }
.wl-cell.over { background: #fbe9ec; } :root[data-theme="dark"] .wl-cell.over { background: #4a2630; }
.wl-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; } .wl-bar i { display: block; height: 100%; background: var(--primary); } .wl-cell.over .wl-bar i { background: var(--danger); }

/* drawer tabs */
.act-type { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; padding: 2px 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.dropzone { border: 2px dashed var(--border); border-radius: 8px; padding: 20px; text-align: center; color: var(--text-2); cursor: pointer; display: grid; gap: 4px; justify-items: center; }
.dropzone.over, .dropzone:hover { border-color: var(--primary); color: var(--primary); }
.sms-thread { display: grid; gap: 8px; }
.bubble { max-width: 85%; padding: 10px 12px; border-radius: 12px; font-size: 14px; white-space: pre-wrap; }
.bubble.out { background: var(--primary); color: #fff; justify-self: end; border-bottom-right-radius: 4px; } .bubble.out .muted { color: rgba(255,255,255,.75); }
.bubble.in { background: var(--surface-2); justify-self: start; border-bottom-left-radius: 4px; }
.qline { display: grid; grid-template-columns: 1fr 80px 110px 100px 32px; gap: 6px; align-items: center; }
.qline.head { font-size: 11px; color: var(--text-2); text-transform: uppercase; }
.qline .amt { text-align: right; font-variant-numeric: tabular-nums; }

/* automations / forms / campaigns */
.rule-card { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; }
.rule-block { border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px; display: grid; gap: 8px; }
.rule-kw { font-weight: 700; color: var(--primary); text-transform: uppercase; font-size: 12px; letter-spacing: .5px; }
.step-card { border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px; display: grid; gap: 8px; }
.switch { position: relative; width: 36px; height: 20px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; }
.switch i { position: absolute; inset: 0; background: var(--border); border-radius: 10px; transition: .15s; } .switch i::after { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + i { background: var(--accent-strong, #2e9e6b); } .switch input:checked + i::after { transform: translateX(16px); }
@media (max-width: 800px) { .qline { grid-template-columns: 1fr 60px 80px 70px 28px; } .help-drawer { width: 100%; } }

/* platform owner badge + hosted companies */
.platform-badge { position: fixed; right: 14px; bottom: 12px; z-index: 40; display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border-soft); box-shadow: 0 2px 10px rgba(0,0,0,.12); text-decoration: none; color: var(--text); font-size: 11px; line-height: 1.1; }
.platform-badge img { width: 30px; height: 30px; border-radius: 50%; }
.platform-badge small { display: block; color: var(--text-2); font-size: 10px; }
.platform-badge b { font-size: 12px; }
.platform-badge:hover { border-color: var(--primary); }
@media (max-width: 800px) { .platform-badge span { display: none; } .platform-badge { padding: 4px; } }
.company-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; padding-bottom: 60px; }
.company-card { border: 1px solid var(--border-soft); border-top: 4px solid var(--primary); border-radius: 10px; padding: 14px 16px; background: var(--surface); display: grid; gap: 8px; }
.company-card-head { display: flex; gap: 12px; align-items: center; } .company-card-head img { max-height: 40px; max-width: 120px; }
.company-stats { display: flex; gap: 14px; font-size: 13px; color: var(--text-2); }
.toasts { bottom: 64px; }

/* government capture */
.gov-tab .widget { margin-bottom: 12px; }
.req-grid { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; font-size: 13px; }
.gap { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; color: var(--danger); }
.gap.soft { color: var(--text-2); } .gap:last-child { border-bottom: 0; }
.fit-ok { color: #2e9e6b; display: flex; align-items: center; gap: 6px; font-weight: 600; }
.partner-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--border-soft); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.covers { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.cover { display: inline-flex; align-items: center; gap: 4px; background: #e3f3ea; color: #1f6e49; border-radius: 10px; padding: 2px 8px; font-size: 11px; }
:root[data-theme="dark"] .cover { background: #1f3a2d; color: #8fd4ad; }
.qa { padding: 8px 0; border-bottom: 1px solid var(--border-soft); } .qa:last-of-type { border-bottom: 0; }
.qa-q { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.qa-chip { height: 28px; text-transform: capitalize; }

/* ---------- mobile (iPhone / Galaxy) ---------- */
.mobile-nav { display: none; }
.side-backdrop { display: none; }
@media (hover: none) and (pointer: coarse) { .row-menu, .group-menu, .grid .cell.name .drag, .grid .hcell .col-menu { opacity: 1; } }
@media (max-width: 760px) {
  :root { --name-col: 170px; --col-w: 118px; --header-h: 52px; }
  html, body { overscroll-behavior-y: none; }
  .topbar { gap: 4px; padding: 0 6px 0 8px; }
  .topbar .brand-logo img { max-height: 32px !important; max-width: 120px !important; }
  .main-wrap { padding: 0 0 calc(56px + env(safe-area-inset-bottom)) 0; }
  .content { border-radius: 0; box-shadow: none; }
  body.mobile .sidebar { width: min(300px, 86vw); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.mobile .side-backdrop { display: block; position: fixed; inset: var(--header-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 29; }
  .board-head { padding: 10px 12px 0; }
  .board-title-row h2, .board-title-row input.board-title { font-size: 19px; }
  .board-desc { display: none; }
  .tabs { gap: 0; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; min-height: 40px; }
  .toolbar { padding: 8px 12px; gap: 6px; }
  .toolbar .search { width: 100%; }
  .toolbar .chip { height: 36px; }
  .board-body { padding: 0 12px 24px; }
  .group { margin-bottom: 24px; }
  .group-name { font-size: 16px; }
  .btn { min-height: 40px; } .side-item { height: 44px; } .input, .cell-input { font-size: 16px; } /* 16px prevents iOS zoom-on-focus */
  .popover { max-width: calc(100vw - 16px); max-height: 60vh; }
  .drawer { width: 100%; animation: slideUp .2s ease-out; }
  .drawer-head { padding: 12px 14px 0; } .drawer-head input { font-size: 18px; } .drawer-body { padding: 12px 14px calc(16px + env(safe-area-inset-bottom)); }
  .modal-backdrop { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); animation: slideUp .2s ease-out; }
  .modal h2 { font-size: 19px; }
  .tpl-grid { grid-template-columns: 1fr 1fr; } .tpl-scroll { max-height: 36vh; }
  .kanban { gap: 10px; scroll-snap-type: x mandatory; }
  .lane { width: min(84vw, 300px); scroll-snap-align: start; }
  .help-drawer { width: 100%; }
  .platform-badge { bottom: calc(62px + env(safe-area-inset-bottom)); right: 8px; }
  .settings-grid { grid-template-columns: 1fr !important; }
  .widget { padding: 14px; }
  .mobile-nav { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; height: calc(56px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--border-soft); z-index: 45; box-shadow: 0 -2px 10px rgba(0,0,0,.06); }
  .mobile-nav button { border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; gap: 2px; font-size: 11px; padding-top: 6px; }
  .mobile-nav button.active { color: var(--primary); }
  .mobile-nav button .svg { width: 22px; height: 22px; }
  .mobile-nav .fab { position: relative; }
  .mobile-nav .fab span { width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; margin-top: -18px; box-shadow: 0 4px 12px rgba(0,0,0,.2); }
}
@keyframes slideUp { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
/* Cards view (phone-friendly list; also usable on desktop) */
.cards { display: grid; gap: 18px; padding-bottom: 12px; }
.cards-group { display: grid; gap: 8px; }
.cards-group-head { display: flex; align-items: center; gap: 8px; color: var(--gc); font-weight: 600; font-size: 15px; }
.cards-group-head .count { color: var(--text-2); font-weight: 400; font-size: 13px; }
.card-item { display: grid; gap: 8px; padding: 12px 12px 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-soft); border-left: 4px solid var(--gc, var(--border)); text-align: left; width: 100%; color: var(--text); }
.card-item:active { background: var(--hover); }
.card-item .title { font-weight: 500; font-size: 15px; display: flex; gap: 8px; align-items: center; }
.card-item .title .sub { color: var(--text-2); font-size: 12px; font-weight: 400; }
.card-item .chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card-item .pill { padding: 3px 9px; border-radius: 10px; color: #fff; font-size: 12px; white-space: nowrap; }
.card-item .kv { font-size: 12px; color: var(--text-2); display: inline-flex; gap: 4px; align-items: center; background: var(--surface-2); border-radius: 6px; padding: 3px 7px; }
.card-item .kv b { color: var(--text); font-weight: 500; }
.card-item .kv.overdue b { color: var(--danger); }
.cards-add { display: flex; gap: 8px; }
.cards-add .input { flex: 1; }
