/* NAJM Tasks
   Layout: fixed navy sidebar carrying the logo, quiet work surface on the right.
   Palette comes from the logo navy (#201D52); no gold, semantic colors only for status. */
:root {
  --navy: #201D52;
  --bg: #F5F5F9;
  --surface: #FFFFFF;
  --surface-2: #EEEEF5;
  --surface-3: #E4E3EE;
  --border: #E1E0EB;
  --border-strong: #C9C7DA;
  --text: #16143A;
  --muted: #5D5B78;
  --faint: #8C8AA6;
  --primary: #201D52;
  --primary-hover: #2E2A72;
  --on-primary: #FFFFFF;
  --accent: #3D38A8;
  --accent-soft: #E9E8F7;
  --focus: #5A54D6;
  --side-bg: #201D52;
  --side-text: #C9C7EA;
  --side-active: rgba(255, 255, 255, .12);
  --side-strong: #FFFFFF;

  --s-todo: #6A6D86;   --s-todo-bg: #ECECF2;
  --s-prog: #2563C9;   --s-prog-bg: #E4EDFB;
  --s-rev: #7346C9;    --s-rev-bg: #EFE8FA;
  --s-done: #1C7F55;   --s-done-bg: #E2F3EA;
  --p-low: #7E809A;
  --p-med: #2563C9;
  --p-high: #C9561F;
  --p-urgent: #C42F43;
  --danger: #C42F43;   --danger-bg: #FBE7EA;
  --ok: #1C7F55;

  --shadow-sm: 0 1px 2px rgba(22, 20, 58, .06);
  --shadow: 0 1px 2px rgba(22, 20, 58, .05), 0 6px 20px rgba(22, 20, 58, .07);
  --shadow-lg: 0 20px 60px rgba(16, 14, 46, .25);
  --overlay: rgba(16, 14, 46, .45);

  --logo-light: block;
  --logo-dark: none;

  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 10px;
  --r-sm: 7px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D0C1C; --surface: #16152B; --surface-2: #1E1D37; --surface-3: #282645;
    --border: #2A2848; --border-strong: #3A3862; --text: #ECEBF8; --muted: #A3A1C2; --faint: #75739A;
    --primary: #B4B0F5; --primary-hover: #C8C5FA; --on-primary: #15133A; --accent: #A9A5F2; --accent-soft: #24224A; --focus: #9C97F0;
    --side-bg: #12112A; --side-text: #A9A7CF; --side-active: rgba(255, 255, 255, .08); --side-strong: #FFFFFF;
    --s-todo: #A3A5BD; --s-todo-bg: #262541; --s-prog: #79A7F2; --s-prog-bg: #1B2849; --s-rev: #B597F2; --s-rev-bg: #2A2049; --s-done: #5FCB98; --s-done-bg: #15322A;
    --p-low: #8F91AC; --p-med: #79A7F2; --p-high: #F08B57; --p-urgent: #F07282; --danger: #F07282; --danger-bg: #3A1A25; --ok: #5FCB98;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55); --overlay: rgba(4, 3, 14, .65);
    --logo-light: none; --logo-dark: block;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D0C1C; --surface: #16152B; --surface-2: #1E1D37; --surface-3: #282645;
  --border: #2A2848; --border-strong: #3A3862; --text: #ECEBF8; --muted: #A3A1C2; --faint: #75739A;
  --primary: #B4B0F5; --primary-hover: #C8C5FA; --on-primary: #15133A; --accent: #A9A5F2; --accent-soft: #24224A; --focus: #9C97F0;
  --side-bg: #12112A; --side-text: #A9A7CF; --side-active: rgba(255, 255, 255, .08); --side-strong: #FFFFFF;
  --s-todo: #A3A5BD; --s-todo-bg: #262541; --s-prog: #79A7F2; --s-prog-bg: #1B2849; --s-rev: #B597F2; --s-rev-bg: #2A2049; --s-done: #5FCB98; --s-done-bg: #15322A;
  --p-low: #8F91AC; --p-med: #79A7F2; --p-high: #F08B57; --p-urgent: #F07282; --danger: #F07282; --danger-bg: #3A1A25; --ok: #5FCB98;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3); --shadow-lg: 0 20px 60px rgba(0, 0, 0, .55); --overlay: rgba(4, 3, 14, .65);
  --logo-light: none; --logo-dark: block;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
#app { min-height: 100%; }
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.ico { width: 16px; height: 16px; flex: none; }
.num, td.n, .tabular { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.boot { display: grid; place-items: center; min-height: 60vh; color: var(--muted); }
.logo-light { display: var(--logo-light); }
.logo-dark { display: var(--logo-dark); }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px; gap: 22px; z-index: 30; }
.side .brand { padding: 2px 10px 0; }
.side .brand img { height: 30px; width: auto; display: block; }
.side .brand small { display: block; margin-top: 8px; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--side-text); opacity: .75; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 500; }
.nav a:hover { color: var(--side-strong); background: var(--side-active); }
.nav a.on { color: var(--side-strong); background: var(--side-active); }
.nav a .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .count { margin-left: auto; font-size: 11.5px; background: rgba(255, 255, 255, .14); color: var(--side-strong); padding: 0 7px; border-radius: 99px; font-variant-numeric: tabular-nums; }
.side .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); }
.side .me .who { min-width: 0; flex: 1; }
.side .me .who b { display: block; color: var(--side-strong); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side .me .who span { font-size: 12px; }
.side .me button { background: none; border: 0; color: var(--side-text); cursor: pointer; padding: 6px; border-radius: 6px; }
.side .me button:hover { color: var(--side-strong); background: var(--side-active); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.top h1 { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .menu-btn { display: none; }
.view { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }

/* ---------- Controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-weight: 550; cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn.danger:hover { background: var(--danger-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn[disabled] { opacity: .55; cursor: default; }
.btn .ico { width: 16px; height: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .hint { font-size: 12px; color: var(--faint); font-weight: 400; }
.input, select.input, textarea.input { width: 100%; min-height: 38px; padding: 8px 11px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
textarea.input { min-height: 96px; resize: vertical; line-height: 1.5; }
.input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--muted); }
select.input { appearance: none; padding-right: 30px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.seg { display: inline-flex; padding: 3px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; height: 28px; padding: 0 12px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 550; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; min-width: 140px; height: 36px; min-height: 36px; padding-top: 0; padding-bottom: 0; }
.toolbar .search { flex: 1 1 200px; min-width: 160px; }

/* ---------- Badges, avatars ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-todo { color: var(--s-todo); background: var(--s-todo-bg); }
.st-in_progress { color: var(--s-prog); background: var(--s-prog-bg); }
.st-review { color: var(--s-rev); background: var(--s-rev-bg); }
.st-done { color: var(--s-done); background: var(--s-done-bg); }
.prio { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.prio i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); background: currentColor; }
.pr-low { color: var(--p-low); } .pr-medium { color: var(--p-med); } .pr-high { color: var(--p-high); } .pr-urgent { color: var(--p-urgent); }
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .sw { width: 8px; height: 8px; border-radius: 3px; background: var(--c, var(--accent)); flex: none; }
.tag { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; font-size: 11px; font-weight: 650; letter-spacing: .03em; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.private { background: var(--accent-soft); color: var(--accent); }
.tag.off { background: var(--danger-bg); color: var(--danger); }
.av { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 11px; font-weight: 700; flex: none; color: #fff; background: var(--av, #4A47A3); letter-spacing: .02em; }
.av.lg { width: 34px; height: 34px; font-size: 13px; }
.due { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.due.late { color: var(--danger); font-weight: 650; }
.due.soon { color: var(--p-high); font-weight: 600; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel-b { padding: 16px 18px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat .k { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat .v { font-size: 28px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .d { font-size: 12.5px; color: var(--muted); }
.stat.alert .v { color: var(--danger); }
.cols2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 20px; align-items: start; }

.tlist { display: flex; flex-direction: column; }
.trow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 11px 18px; border-top: 1px solid var(--border); cursor: pointer; align-items: center; }
.trow:first-child { border-top: 0; }
.trow:hover { background: var(--surface-2); }
.trow .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .m { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; grid-column: 1; font-size: 12px; color: var(--muted); min-width: 0; }
.trow .r { grid-row: 1 / span 2; grid-column: 2; display: flex; align-items: center; gap: 10px; }
.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- Board ---------- */
.board-wrap { overflow-x: auto; margin: 0 -28px; padding: 0 28px 8px; -webkit-overflow-scrolling: touch; }
.board { display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: 14px; min-width: 1040px; align-items: start; }
.col { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; display: flex; flex-direction: column; min-height: 200px; transition: background .12s, border-color .12s; }
.col.over { border-color: var(--focus); background: var(--accent-soft); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.col-h .n { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-b { display: flex; flex-direction: column; gap: 9px; padding: 4px 10px 12px; min-height: 120px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; box-shadow: var(--shadow-sm); cursor: pointer; display: flex; flex-direction: column; gap: 8px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: manipulation; }
.card:hover { border-color: var(--border-strong); }
.card.dragging { opacity: .35; }
.card.ghost { position: fixed; z-index: 100; pointer-events: none; box-shadow: var(--shadow-lg); transform: rotate(1.5deg); opacity: .96; margin: 0; }
.card .t { font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.card .f { display: flex; align-items: center; gap: 8px; }
.card .f .spacer { flex: 1; }
.card .meta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--faint); }
.card .meta .ico { width: 13px; height: 13px; }
.card .meta.ok { color: var(--ok); }
.col .add { margin: 0 10px 12px; border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); border-radius: 9px; height: 34px; cursor: pointer; font-weight: 550; }
.col .add:hover { color: var(--text); background: var(--surface); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl td.n, .tbl th.n { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .title-cell { font-weight: 600; max-width: 340px; }
.tbl tfoot td { font-weight: 650; border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.person { display: flex; align-items: center; gap: 9px; min-width: 0; }
.person b { font-weight: 600; white-space: nowrap; }
.person small { display: block; color: var(--muted); font-size: 12px; }

/* ---------- Clients ---------- */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.client-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; cursor: pointer; display: flex; flex-direction: column; gap: 12px; text-align: left; transition: border-color .12s, box-shadow .12s; }
.client-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.client-card .nm { display: flex; align-items: center; gap: 10px; }
.client-card .mark { width: 34px; height: 34px; border-radius: 9px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.client-card .nm b { font-size: 15px; display: block; }
.bar { display: flex; height: 6px; border-radius: 99px; overflow: hidden; background: var(--surface-2); }
.bar span { display: block; height: 100%; }
.bar .b-todo { background: var(--s-todo); } .bar .b-in_progress { background: var(--s-prog); } .bar .b-review { background: var(--s-rev); } .bar .b-done { background: var(--s-done); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.client-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.client-head .mark { width: 44px; height: 44px; border-radius: 11px; background: var(--c); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; }
.dept-sec .panel-h h2 { font-size: 14.5px; }
.dept-sec .panel-h .n { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }

/* ---------- Performance ---------- */
.score { display: inline-flex; align-items: center; gap: 10px; min-width: 130px; }
.score .meter { flex: 1; height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.score .meter span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.score b { font-variant-numeric: tabular-nums; min-width: 26px; text-align: right; }
.delta { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); } .delta.flat { color: var(--faint); }
.formula { font-size: 12.5px; color: var(--muted); line-height: 1.6; }

/* ---------- Modal & drawer ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 60; display: flex; justify-content: center; align-items: flex-start; padding: 6vh 16px 16px; overflow-y: auto; animation: fade .14s ease-out; }
.modal { background: var(--surface); border-radius: 14px; width: 100%; max-width: 520px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: rise .16s ease-out; }
.modal.wide { max-width: 640px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.modal-h h2 { flex: 1; font-size: 17px; }
.modal-b { padding: 12px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-f { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 18px; flex-wrap: wrap; }
.overlay.drawer { justify-content: flex-end; align-items: stretch; padding: 0; }
.overlay.drawer .modal { max-width: 640px; border-radius: 0; height: 100%; overflow-y: auto; animation: slide .18s ease-out; }
.drawer .modal-h { position: sticky; top: 0; background: var(--surface); z-index: 2; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.drawer .modal-f { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.x-btn { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 8px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.x-btn:hover { background: var(--surface-2); color: var(--text); }
.times { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.times div { background: var(--surface-2); border-radius: 8px; padding: 9px 11px; min-width: 0; }
.times span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.times b { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ro { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 8px 14px; font-size: 13.5px; }
.ro dt { color: var(--muted); font-weight: 600; font-size: 12.5px; padding-top: 1px; }
.ro dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.desc { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); padding: 12px 14px; border-radius: 8px; }
.comments { display: flex; flex-direction: column; gap: 14px; }
.cmt { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; }
.cmt .h { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.cmt .h b { font-weight: 650; }
.cmt .h time { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.cmt p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-top: 6px; }
.link-out { display: inline-flex; align-items: center; gap: 6px; overflow-wrap: anywhere; }
.error-msg { color: var(--danger); font-size: 13px; font-weight: 550; }
.confirm-bar { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); font-weight: 550; flex-wrap: wrap; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 90; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100% - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 9px; box-shadow: var(--shadow-lg); font-weight: 550; animation: rise .16s ease-out; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 34px 30px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.auth-card .logo { display: flex; justify-content: center; padding: 4px 0 8px; }
.auth-card .logo img { width: 220px; height: auto; }
.auth-card h1 { font-size: 18px; text-align: center; }
.auth-card p.lead { margin: -8px 0 0; color: var(--muted); text-align: center; font-size: 13.5px; }
.auth-foot { text-align: center; font-size: 12px; color: var(--faint); }
.theme-fab { position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: 14px; }

.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 0; }
.dept-list { display: flex; flex-wrap: wrap; gap: 8px; }
.dept-list .tag { height: 28px; padding: 0 6px 0 11px; font-size: 12.5px; gap: 4px; }
.dept-list .tag button { border: 0; background: none; color: inherit; cursor: pointer; padding: 2px 4px; border-radius: 4px; line-height: 1; }
.dept-list .tag button:hover { color: var(--danger); }
.demo-bar { background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 8px 28px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.demo-bar select { height: 28px; min-height: 28px; padding: 0 28px 0 8px; width: auto; font-size: 12.5px; }


/* ---------- Bell, notifications, banner ---------- */
.bell { position: relative; }
.bell .dot { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700; display: grid; place-items: center; font-variant-numeric: tabular-nums; }
.bell .ico { width: 18px; height: 18px; }
.nav .count[hidden] { display: none; }
.notif-list { display: flex; flex-direction: column; padding: 4px 8px 12px; max-height: 70vh; overflow-y: auto; }
.notif { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 10px; text-align: left; border: 0; background: transparent; padding: 10px 10px; border-radius: 9px; cursor: pointer; color: var(--text); }
.notif:hover { background: var(--surface-2); }
.notif .ni { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.notif.unread .ni { background: var(--accent-soft); color: var(--accent); }
.notif .nb { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.notif .nb b { font-weight: 600; }
.notif.unread .nb b::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }
.notif .nb span { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.notif .nb time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--accent-soft); color: var(--text); border-radius: var(--r); padding: 12px 14px; font-weight: 550; }
.banner > .ico { color: var(--accent); width: 18px; height: 18px; }
.banner > span:not(.spacer) { flex: 1 1 220px; }
.steps { margin: 6px 0 0; padding-left: 20px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }

/* ---------- Mentions ---------- */
.mention { color: var(--accent); font-weight: 650; }
.mention.me { background: var(--accent-soft); border-radius: 4px; padding: 0 3px; }
.mention-wrap { position: relative; }
.mention-pop { position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 70; width: min(300px, 100%); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; display: flex; flex-direction: column; }
.mention-pop button { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; padding: 7px 8px; border-radius: 7px; cursor: pointer; text-align: left; color: var(--text); }
.mention-pop button.on, .mention-pop button:hover { background: var(--surface-2); }
.mention-pop small { display: block; color: var(--muted); font-size: 11.5px; }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 140px); min-height: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-search { padding: 12px; border-bottom: 1px solid var(--border); }
.chat-convs { overflow-y: auto; flex: 1; padding: 6px; }
.conv { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; width: 100%; border: 0; background: transparent; text-align: left; padding: 9px 8px; border-radius: 9px; cursor: pointer; color: var(--text); }
.conv:hover { background: var(--surface-2); }
.conv.on { background: var(--accent-soft); }
.conv .av, .chat-head .av { width: 34px; height: 34px; font-size: 12px; }
.av.gen { background: var(--primary); color: var(--on-primary); }
.av.gen .ico { width: 17px; height: 17px; }
.conv .cb { min-width: 0; display: flex; flex-direction: column; }
.conv .cb b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv .cb span { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .cb b, .conv.unread .cb span { color: var(--text); font-weight: 650; }
.conv time { font-size: 11.5px; color: var(--faint); white-space: nowrap; }
.conv .un { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: var(--on-primary); font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-head small { display: block; color: var(--muted); font-size: 12px; }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 6px; background: var(--bg); }
.chat-empty { margin: auto; }
.day { display: flex; justify-content: center; margin: 10px 0 4px; }
.day span { font-size: 11.5px; font-weight: 650; color: var(--muted); background: var(--surface-2); padding: 2px 10px; border-radius: 99px; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 78%; }
.msg.grouped { margin-top: -3px; }
.msg .av-sp { width: 26px; flex: none; }
.msg .bub { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 7px 11px 5px; min-width: 0; }
.msg .bub b { display: block; font-size: 12px; color: var(--accent); font-weight: 650; }
.msg .bub p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg .bub time { display: block; text-align: right; font-size: 10.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.msg.mine { align-self: flex-end; }
.msg.mine .bub { background: var(--primary); border-color: var(--primary); color: var(--on-primary); border-radius: 14px 14px 4px 14px; }
.msg.mine .bub time { color: color-mix(in srgb, var(--on-primary) 65%, transparent); }
.msg.mine .mention { color: inherit; text-decoration: underline; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-compose textarea { min-height: 40px; max-height: 140px; resize: none; }
.chat-compose .btn { height: 40px; width: 40px; }
.chat-closed { padding: 14px 16px; border-top: 1px solid var(--border); font-size: 13px; }
@media (max-width: 860px) {
  .chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 120px); height: calc(100dvh - 120px); }
  .chat .chat-main { display: none; }
  .chat.has-conv .chat-list { display: none; }
  .chat.has-conv .chat-main { display: flex; }
  .chat-back { display: inline-flex; }
  .msg { max-width: 88%; }
}


/* ---------- Night-sky sign in ---------- */
.auth.sky {
  position: relative; overflow: hidden; isolation: isolate;
  --sky-top: #05050F; --sky-mid: #0B0B22; --sky-low: #151436;
  --surface: rgba(16, 15, 40, .62); --surface-2: rgba(255, 255, 255, .06); --border: rgba(255, 255, 255, .10); --border-strong: rgba(255, 255, 255, .16);
  --text: #EEEDFB; --muted: #A8A6CC; --faint: #7D7BA6; --primary: #C9C6FF; --primary-hover: #DAD8FF; --on-primary: #13123A; --focus: #A29EF5; --danger: #FF8A97;
  background: radial-gradient(120% 70% at 50% 110%, var(--sky-low) 0%, var(--sky-mid) 45%, var(--sky-top) 100%);
  color: var(--text); color-scheme: dark;
}
.sky .stars { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -2; }
.sky .haze { position: absolute; left: -10%; right: -10%; bottom: -8%; height: 34%; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 55% at 35% 75%, rgba(150, 150, 190, .22), transparent 70%), radial-gradient(45% 45% at 75% 85%, rgba(120, 118, 170, .18), transparent 70%);
  filter: blur(18px); }
.sky .wires { position: absolute; left: 0; right: 0; bottom: 11%; z-index: -1; pointer-events: none; }
.sky .wires i { display: block; height: 1px; background: linear-gradient(90deg, transparent, rgba(190, 196, 255, .55) 20%, rgba(220, 224, 255, .7) 60%, transparent); transform: rotate(-1.1deg); box-shadow: 0 0 6px rgba(170, 176, 255, .35); }
.sky .wires i + i { margin-top: 18px; transform: rotate(-.6deg); opacity: .8; }
.sky .auth-card { background: var(--surface); border-color: var(--border); box-shadow: 0 30px 80px rgba(0, 0, 0, .45); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.sky .auth-card h1 { font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.sky .auth-card .logo img { width: 200px; }
.sky .input { background: rgba(255, 255, 255, .05); border-color: var(--border-strong); color: var(--text); }
.sky .input::placeholder { color: var(--faint); }
.sky .btn { background: rgba(255, 255, 255, .06); color: var(--text); border-color: var(--border-strong); }
.sky .btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.sky .btn.primary:hover { background: var(--primary-hover); }
.sky .auth-foot { color: var(--faint); }
.sky .field > span { color: var(--muted); }

/* ---------- Clock, install, urgent, seen, presence ---------- */
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; padding: 0 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.clock b { font-size: 14px; font-weight: 650; letter-spacing: .01em; }
.clock .sec { color: var(--faint); font-weight: 500; }
.clock small { font-size: 11px; color: var(--muted); }
.install-side { display: flex; align-items: center; gap: 10px; margin-top: -8px; padding: 9px 10px; border-radius: 8px; border: 1px dashed rgba(255, 255, 255, .22); background: transparent; color: var(--side-text); font: inherit; font-weight: 500; cursor: pointer; text-align: left; }
.install-side:hover { color: var(--side-strong); background: var(--side-active); }
.install-side .ico { width: 18px; height: 18px; }
.tag.urgent { background: var(--danger-bg); color: var(--danger); gap: 4px; }
.tag.urgent .ico { width: 12px; height: 12px; }
.card.is-urgent { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); box-shadow: inset 3px 0 0 var(--danger), var(--shadow-sm); }
.btn.urgent-on { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.urgent-on:hover { background: var(--danger); filter: brightness(1.08); }
.urgent-panel { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.urgent-panel h2 { display: flex; align-items: center; gap: 7px; color: var(--danger); }
.card .meta.unseen { color: var(--p-high); }
.seen-row { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; }
.seen-row .ico { color: var(--muted); }
.seen-yes, .seen-no { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; white-space: nowrap; }
.seen-yes { color: var(--ok); } .seen-no { color: var(--p-high); font-weight: 600; }
.seen-yes .ico, .seen-no .ico { width: 14px; height: 14px; }
.presence { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.presence i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); opacity: .6; }
.presence.on { color: var(--ok); font-weight: 600; }
.presence.on i { background: var(--ok); opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.urgent-only { align-items: center; white-space: nowrap; font-size: 13px; }
.urgent-only input { margin-top: 0; }
.av.gen.alt { background: var(--surface-3); color: var(--muted); }
.chat-note { font-size: 11.5px; color: var(--faint); padding: 12px 14px 4px; margin: 0; }

/* ---------- Owner's day dashboard ---------- */
.dash { overflow: hidden; }
.dash-row { display: grid; grid-template-columns: 240px minmax(0, 1fr); border-top: 1px solid var(--border); }
.dash-row:first-child { border-top: 0; }
.dash-who { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-right: 1px solid var(--border); cursor: pointer; min-width: 0; }
.dash-who:hover { background: var(--surface-2); }
.dash-who > div { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 1px; }
.dash-who b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-who small { color: var(--muted); font-size: 12px; }
.dash-n { min-width: 26px; height: 26px; border-radius: 8px; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.dash-tasks { display: flex; gap: 10px; padding: 12px 14px; overflow-x: auto; align-items: stretch; scrollbar-width: thin; }
.dash-none { align-self: center; font-size: 13px; padding-left: 4px; }
.dchip { flex: 0 0 230px; display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 10px 12px 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); position: relative; }
.dchip::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--s-todo); }
.dchip.st-b-in_progress::before { background: var(--s-prog); } .dchip.st-b-review::before { background: var(--s-rev); } .dchip.st-b-done::before { background: var(--s-done); }
.dchip.st-b-done { opacity: .75; }
.dchip.is-urgent { border-color: color-mix(in srgb, var(--danger) 55%, var(--border)); }
.dchip:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.dchip-top { display: flex; gap: 6px; align-items: flex-start; }
.dchip-top b { font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.dchip .flag { color: var(--danger); flex: none; padding-top: 2px; }
.dchip .flag .ico { width: 14px; height: 14px; }
.dchip-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.dchip-meta .meta { display: inline-flex; color: var(--faint); }
.dchip-meta .meta.ok { color: var(--ok); } .dchip-meta .meta.unseen { color: var(--p-high); }
.dchip-meta .ico { width: 14px; height: 14px; }
@media (max-width: 860px) {
  .dash-row { grid-template-columns: minmax(0, 1fr); }
  .dash-who { border-right: 0; border-bottom: 1px dashed var(--border); }
  .dchip { flex-basis: 210px; }
}
@media (max-width: 560px) {
  .clock small, .clock .sec { display: none; }
  .clock b { font-size: 13px; }
}

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes slide { from { transform: translateX(30px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; padding-top: calc(22px + env(safe-area-inset-top, 0px)); }
  .shell.nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  .scrim { position: fixed; inset: 0; background: var(--overlay); z-index: 25; }
  .top { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
  .top .menu-btn { display: inline-flex; }
  .view { padding: 18px 16px 40px; }
  .board-wrap { margin: 0 -16px; padding: 0 16px 8px; scroll-snap-type: x proximity; }
  .board { grid-template-columns: repeat(4, 82vw); min-width: 0; width: max-content; }
  .col { scroll-snap-align: start; }
  .demo-bar { padding: 8px 16px; }
  .toolbar .input { flex: 1 1 140px; min-width: 0; }
}
@media (max-width: 560px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .stats { gap: 10px; }
  .stat { padding: 13px 14px; }
  .stat .v { font-size: 24px; }
  .times { grid-template-columns: minmax(0, 1fr); }
  .overlay { padding: 0; }
  .overlay .modal { border-radius: 0; min-height: 100%; max-width: none; }
  .ro { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .ro dd { margin-bottom: 8px; }
  .top .hide-sm { display: none; }
  .trow { grid-template-columns: minmax(0, 1fr); }
  .trow .t { white-space: normal; }
  .trow .r { grid-row: auto; grid-column: 1; }
  .demo-bar { flex-wrap: nowrap; }
  .demo-bar .lbl, .demo-bar .spacer { display: none; }
  .demo-bar label { flex: 1; min-width: 0; }
  .demo-bar select { flex: 1; min-width: 0; }
  .auth-card { padding: 28px 20px 22px; }
}
