:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --surface-3: #e6ebf3;
  --border: #dfe4ec;
  --ink: #172033;
  --ink-2: #4a5568;
  --ink-3: #8a94a6;
  --accent: #1d4ed8;
  --accent-soft: #e6edfd;
  --brand: #1e3a8a;
  --bad: #dc2626;
  --warn: #c2620a;
  --good: #16a34a;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 3px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .22);
  --radius: 12px;
  --label-w: 380px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d;
    --surface: #1a1f2a;
    --surface-2: #222836;
    --surface-3: #2b3243;
    --border: #2e3546;
    --ink: #e7eaf1;
    --ink-2: #aab2c3;
    --ink-3: #7a8396;
    --accent: #6d8dff;
    --accent-soft: #24305a;
    --brand: #6d8dff;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; }
a { color: var(--accent); text-decoration: none; cursor: pointer; }
h2 { font-size: 1.3rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; }
h3 a { margin-left: auto; font-weight: 400; }
h4 { font-size: .82rem; margin: 0 0 8px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
input[type=color] { padding: 2px; height: 36px; width: 60px; }
textarea { resize: vertical; width: 100%; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: .9em; word-break: break-all; }
pre.preview { white-space: pre-wrap; background: var(--surface-2); padding: 12px; border-radius: 8px; font-size: 12.5px; max-height: 360px; overflow: auto; }
.muted { color: var(--ink-3); }
.small { font-size: .85em; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.pad { padding: 14px 4px; }
.hint { color: var(--ink-3); font-size: .85rem; margin: 6px 0; }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
.empty { color: var(--ink-3); text-align: center; padding: 48px 12px; }
.empty .btn { margin-top: 12px; }
.loading { padding: 80px 20px; text-align: center; color: var(--ink-3); }
[hidden] { display: none !important; }

/* Every button gives tactile feedback (owner's rule: no "dead" buttons). */
button { cursor: pointer; transition: transform .08s ease, background .15s, border-color .15s; }
button:active { transform: scale(.95); }
button:disabled { opacity: .5; cursor: default; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; padding: 7px 14px; font-weight: 500; white-space: nowrap; color: var(--ink); transition: transform .08s ease, background .15s; }
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.95); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: var(--bad); filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
.btn.flashed { background: var(--good); border-color: var(--good); color: #fff; }
.btn-done { width: 100%; padding: 11px; font-size: 1rem; background: var(--good); border-color: var(--good); color: #fff; margin: 4px 0 16px; }
.btn-done:hover { background: var(--good); filter: brightness(1.07); }
.icon-btn { border: 0; background: transparent; border-radius: 7px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-2); font-size: 15px; flex: none; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.small { width: 24px; height: 24px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0 4px; }

/* ---------- Header & tabs ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .topbar { background: #18213a; } }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; min-width: 0; }
.logo { background: rgba(255,255,255,.16); border-radius: 8px; padding: 4px 8px; font-weight: 800; letter-spacing: .04em; font-size: 13px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; font-weight: 600; white-space: nowrap; }
.brand-text small { font-weight: 400; opacity: .75; font-size: 11.5px; }
.me-btn { display: flex; align-items: center; gap: 6px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.08); color: #fff; border-radius: 999px; padding: 5px 12px; max-width: 46vw; }
.me-btn.set { background: #fff; color: var(--brand); border-color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .me-btn.set { background: #e7eaf1; color: #18213a; } }
.me-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret-down { font-size: 10px; opacity: .7; }
.admin-btn { border: 1px solid rgba(255,255,255,.3); background: transparent; color: #fff; border-radius: 999px; padding: 5px 11px; white-space: nowrap; }
.admin-btn.on { background: #fbbf24; color: #3b2a00; border-color: #fbbf24; font-weight: 600; }
.tabs { position: sticky; top: 50px; z-index: 29; display: flex; gap: 2px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 11px 13px 9px; color: var(--ink-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--ink); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }
.tab-icon { font-size: 13px; opacity: .7; }

.main { padding: 14px 16px 60px; max-width: 1500px; margin: 0 auto; }
.main.view-gantt { max-width: none; }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.page-hint { margin-top: -4px; margin-bottom: 14px; }

/* ---------- Toolbar & legend ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.search { width: 240px; }
.search.wide { width: 100%; margin-bottom: 10px; }
.dept-filter { max-width: 200px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 7px; font-weight: 500; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.legend { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px 3px 8px; font-size: 12.5px; color: var(--ink-2); }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.legend-item b { color: var(--ink); font-weight: 600; }
.legend-item.on { border-color: var(--c); background: color-mix(in srgb, var(--c) 14%, var(--surface)); color: var(--ink); }
.legend-reset { border: 0; background: none; color: var(--accent); font-size: 12.5px; }
.mine-note { font-size: 12.5px; color: var(--ink-2); background: var(--accent-soft); padding: 6px 10px; border-radius: 8px; margin-bottom: 10px; }

/* ---------- Common atoms ---------- */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); white-space: nowrap; }
.dchip { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 5px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); margin-right: 3px; white-space: nowrap; }
.dchip.more { --c: var(--ink-3); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 9.5px; font-weight: 700; margin-right: 2px; flex: none; }
.avatar.lg { width: 34px; height: 34px; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.num.big { font-size: 1.15rem; color: var(--ink); }
.cnt { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.progress { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.progress i { display: block; height: 100%; background: var(--good); border-radius: 3px; }
.progress.big { width: 100%; height: 9px; border-radius: 5px; }
.progress.time i { background: var(--accent); }
.shift { font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 5px; white-space: nowrap; }
.shift.late { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.shift.early { color: var(--good); background: color-mix(in srgb, var(--good) 13%, transparent); }
.checkbox { width: 22px; height: 22px; border-radius: 50%; border: 2px solid color-mix(in srgb, var(--c, var(--ink-3)) 70%, var(--border)); background: var(--surface); flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; color: #fff; padding: 0; }
.checkbox:hover { background: color-mix(in srgb, var(--good) 18%, var(--surface)); border-color: var(--good); }
.checkbox.checked { background: var(--good); border-color: var(--good); }
.check-spacer { width: 22px; flex: none; }
.caret { border: 0; background: none; width: 22px; height: 22px; border-radius: 5px; color: var(--ink-3); transition: transform .15s; flex: none; padding: 0; font-size: 12px; }
.caret.open { transform: rotate(90deg); }
.caret:hover { background: var(--surface-3); }
.caret.open:active { transform: rotate(90deg) scale(.9); }
.caret-spacer { width: 22px; flex: none; }

/* ---------- Tree ---------- */
.tree { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.trow { display: flex; align-items: center; gap: 10px; padding: 7px 10px 7px calc(8px + var(--depth) * 22px); border-bottom: 1px solid var(--border); border-left: 4px solid var(--c); cursor: pointer; }
.trow:last-child { border-bottom: 0; }
.trow:hover { background: var(--surface-2); }
.trow.group { background: color-mix(in srgb, var(--c) 5%, var(--surface)); }
.trow.depth-0 { padding-top: 10px; padding-bottom: 10px; }
.trow.depth-0 .title { font-weight: 700; font-size: 15px; }
.trow.group .title { font-weight: 600; }
.trow.context { opacity: .55; }
.trow.is-done .title { text-decoration: line-through; color: var(--ink-3); }
.tcell-main { display: flex; align-items: flex-start; gap: 8px; flex: 1; min-width: 0; }
.tcell-main .num { min-width: 30px; padding-top: 1px; }
.tcell-main .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; padding-top: 1px; }
.tcell-meta { display: flex; align-items: center; gap: 8px; flex: none; justify-content: flex-end; }
.tcell-meta .dates { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.tcell-meta .chips { display: flex; align-items: center; flex-wrap: nowrap; }
.tcell-meta .pill { min-width: 86px; justify-content: center; }
.row-menu { opacity: .35; }
.trow:hover .row-menu { opacity: 1; }

/* ---------- Table ---------- */
.table-opts { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.ptable, .dtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.ptable th, .dtable th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 9px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; cursor: pointer; user-select: none; }
.dtable th { cursor: default; }
.ptable td, .dtable td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.ptable tr { cursor: pointer; }
.ptable tbody tr:hover { background: var(--surface-2); }
.ptable tr.grp td { font-weight: 600; background: color-mix(in srgb, var(--c) 5%, var(--surface)); }
.ptable tr.context { opacity: .55; }
.ptable tr.is-done .col-title { text-decoration: line-through; color: var(--ink-3); }
.ptable .col-num { position: relative; padding-left: 12px; white-space: nowrap; font-weight: 600; }
.ptable .col-num .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.ptable .col-title { min-width: 280px; max-width: 520px; }
.num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.dtable tr[data-go-dept] { cursor: pointer; }
.dtable tr[data-go-dept]:hover { background: var(--surface-2); }
.dtable td.bad { font-weight: 700; }
.dtable td.warn { font-weight: 700; }

/* ---------- Board ---------- */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; align-items: start; }
.bcol { background: var(--surface-2); border-radius: var(--radius); border-top: 4px solid var(--c); min-height: 120px; }
.bcol-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; font-weight: 600; }
.bcol-head i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.bcol-head b { margin-left: auto; color: var(--ink-3); font-weight: 600; }
.bcol-body { padding: 0 8px 10px; display: flex; flex-direction: column; gap: 8px; }
.bcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; box-shadow: var(--shadow); cursor: pointer; }
.bcard:hover { border-color: var(--c); }
.bcard-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.bcard-title { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.bcard-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; }
.bcard.is-done .bcard-title { text-decoration: line-through; color: var(--ink-3); }

/* ---------- Summary ---------- */
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.span-2 { grid-column: span 2; }
.hero-title { font-size: 1.25rem; font-weight: 700; margin-bottom: 2px; }
.hero-bars { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 14px; }
.hero-bars > div { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; }
.hero-bars > div > span:first-child { grid-column: span 2; }
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.tile { text-align: left; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; display: flex; flex-direction: column; border-top: 4px solid var(--c); box-shadow: var(--shadow); }
.tile:hover { background: var(--surface-2); }
.tile-v { font-size: 1.9rem; font-weight: 700; color: var(--c); line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-l { color: var(--ink-2); font-size: 13px; }
.tile-s { color: var(--ink-3); font-size: 12px; }
.mini { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-left: 3px solid var(--c); border-radius: 4px; cursor: pointer; margin-bottom: 4px; background: var(--surface-2); }
.mini:hover { background: var(--surface-3); }
.mini-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-note { color: var(--ink-2); font-size: 12px; white-space: nowrap; }
.mini-chips { flex: none; }
.day-group { margin-bottom: 10px; }
.day-label { font-weight: 600; font-size: 12.5px; color: var(--ink-2); margin: 4px 0; }
.srows { display: flex; flex-direction: column; gap: 4px; }
.srow { display: grid; grid-template-columns: minmax(0, 1.6fr) 1fr auto; gap: 14px; align-items: center; padding: 8px 10px; border-left: 4px solid var(--c); border-radius: 4px; cursor: pointer; }
.srow:hover { background: var(--surface-2); }
.srow-title { font-weight: 600; }
.srow-bar { display: flex; align-items: center; gap: 8px; }
.srow-meta { display: flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.feed-row { display: grid; grid-template-columns: 128px 1fr auto; gap: 12px; padding: 7px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.feed-row.clickable { cursor: pointer; }
.feed-row.clickable:hover { background: var(--surface-2); }
.feed-time { color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.feed-by { color: var(--ink-2); white-space: nowrap; }

/* ---------- Gantt ---------- */
.gantt-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.gantt { overflow: auto; max-height: calc(100vh - 220px); min-height: 300px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); position: relative; }
.g-head { position: sticky; top: 0; z-index: 4; display: flex; background: var(--surface-2); border-bottom: 1px solid var(--border); width: calc(var(--label-w) + var(--gw)); }
.g-corner { position: sticky; left: 0; z-index: 5; width: var(--label-w); flex: none; background: var(--surface-2); border-right: 1px solid var(--border); padding: 12px; font-weight: 600; color: var(--ink-2); }
.g-scale { position: relative; height: 48px; flex: none; }
.g-months { position: relative; height: 24px; border-bottom: 1px solid var(--border); }
.g-month { position: absolute; top: 0; height: 24px; padding: 4px 6px; font-size: 12px; font-weight: 600; border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.g-ticks { position: relative; height: 24px; }
.g-tick { position: absolute; top: 0; height: 24px; padding: 4px 0 0 3px; font-size: 11px; color: var(--ink-3); border-left: 1px solid var(--border); }
.g-today-h { position: absolute; bottom: 0; transform: translateX(-50%); background: var(--bad); color: #fff; font-size: 10px; padding: 1px 5px; border-radius: 4px 4px 0 0; z-index: 2; white-space: nowrap; }
.g-tick.we { background: var(--surface-3); }
.g-body { position: relative; width: calc(var(--label-w) + var(--gw)); }
.g-grid { position: absolute; top: 0; bottom: 0; left: var(--label-w); pointer-events: none; z-index: 0; }
.g-line { position: absolute; top: 0; bottom: 0; border-left: 1px dashed var(--border); }
.g-we { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--surface-3) 50%, transparent); }
.g-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--bad); z-index: 2; }
.g-row { display: flex; position: relative; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.g-row.odd { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.g-row:hover { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.g-label { position: sticky; left: 0; z-index: 3; width: var(--label-w); flex: none; display: flex; align-items: center; gap: 6px; padding: 0 8px 0 calc(6px + var(--depth) * 16px); background: var(--surface); border-right: 1px solid var(--border); border-left: 3px solid var(--c); cursor: pointer; overflow: hidden; }
.g-row.odd .g-label { background: color-mix(in srgb, var(--surface-2) 45%, var(--surface)); }
.g-label .g-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.g-label.group .g-title { font-weight: 600; }
.g-label.depth-0 .g-title { font-weight: 700; }
.g-label.context { opacity: .55; }
.g-track { position: relative; flex: none; z-index: 1; }
.g-bar { position: absolute; top: 7px; height: 20px; border-radius: 5px; background: var(--c); color: #fff; font-size: 11.5px; padding: 2px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.g-bar span { overflow: hidden; text-overflow: ellipsis; display: block; }
.g-bar.done { opacity: .6; }
.g-bar:hover { filter: brightness(1.1); }
.g-after { position: absolute; top: 9px; font-size: 11.5px; color: var(--ink-2); white-space: nowrap; pointer-events: none; }
.g-sum { position: absolute; top: 11px; height: 12px; background: color-mix(in srgb, var(--c) 35%, var(--surface-3)); border: 1.5px solid var(--c); border-radius: 3px; cursor: pointer; overflow: hidden; }
.g-sum i { display: block; height: 100%; background: var(--c); opacity: .7; }
.g-base { position: absolute; bottom: 3px; height: 4px; border-radius: 2px; background: var(--ink-3); opacity: .55; }

/* ---------- Drawer (item card) ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .28); z-index: 40; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(600px, 100vw); background: var(--surface); z-index: 41; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: .4; } }
@keyframes fade { from { opacity: 0; } }
.drawer-head { padding: 12px 16px 10px; border-bottom: 1px solid var(--border); border-top: 5px solid var(--c); }
.crumbs { font-size: 12px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.drawer-top { display: flex; align-items: center; gap: 10px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.card-title { font-size: 1.12rem; font-weight: 600; line-height: 1.4; margin-bottom: 14px; }
.facts { display: grid; gap: 10px; margin-bottom: 14px; }
.fact { display: grid; grid-template-columns: 140px 1fr; gap: 2px 10px; align-items: baseline; }
.fact > span:first-child { color: var(--ink-3); font-size: 13px; grid-row: span 2; }
.fact > .muted { grid-column: 2; }
.person-tag { display: inline-block; background: var(--surface-2); border-radius: 6px; padding: 2px 8px; margin: 0 4px 4px 0; }
.done-box { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; background: color-mix(in srgb, var(--good) 12%, var(--surface)); margin-bottom: 16px; }
.done-mark { width: 34px; height: 34px; border-radius: 50%; background: var(--good); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.done-box > div { flex: 1; }
.progress-box { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.progress-box .progress { flex: 1; min-width: 120px; }
.card-section { margin: 18px 0; }
.card-section.drop { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 6px; }
.desc { white-space: normal; color: var(--ink-2); }
.comment { padding: 9px 11px; background: var(--surface-2); border-radius: 10px; margin-bottom: 8px; }
.comment-head { display: flex; gap: 8px; align-items: center; margin-bottom: 2px; }
.comment-head .icon-btn { margin-left: auto; }
.comment-text { overflow-wrap: anywhere; }
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-end; margin-top: 8px; }
.file { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.file-name { flex: 1; min-width: 160px; overflow-wrap: anywhere; }
.upload-btn { margin-top: 10px; cursor: pointer; }
.upload-progress { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.history summary { cursor: pointer; color: var(--ink-2); font-weight: 500; }
.hist { padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.editor { display: flex; flex-direction: column; gap: 12px; }
.editor-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: -16px; background: var(--surface); padding: 10px 0; border-top: 1px solid var(--border); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; }
.row2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.field > select, .field > input:not([type=checkbox]):not([type=color]) { width: 100%; max-width: 100%; }
.field.inline > input:not([type=checkbox]) { width: 110px; flex: none; }
.field.inline > select { width: auto; max-width: 62%; flex: none; }
.field.inline > span { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 4px 0; }
.chip-check { border: 1px solid color-mix(in srgb, var(--c) 35%, var(--border)); border-radius: 7px; padding: 4px 9px; }
.people-checks { max-height: 220px; overflow-y: auto; flex-direction: column; flex-wrap: nowrap; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }

/* ---------- People ---------- */
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 14px; }
.dept-card { border-top: 4px solid var(--c, var(--border)); padding: 12px; }
.dept-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.dept-head b { font-size: 13.5px; }
.prow { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 8px; cursor: pointer; }
.prow:hover { background: var(--surface-2); }
.prow.me { background: var(--accent-soft); }
.prow-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.ch { font-size: 11px; font-weight: 700; color: var(--ink-3); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; opacity: .55; }
.ch.on { color: var(--good); border-color: var(--good); opacity: 1; }
.form-sub { margin-top: 16px; }
.tg-box { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--surface-2); border-radius: 8px; padding: 10px 12px; margin: 10px 0; flex-wrap: wrap; }
.test-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.id-list { max-height: 55vh; overflow-y: auto; }
.id-group { margin-bottom: 8px; }
.id-dept, .id-person { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; }
.id-dept { font-weight: 600; }
.id-person { padding-left: 34px; }
.id-dept:hover, .id-person:hover { background: var(--accent-soft); }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.sform { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.sform > .btn { align-self: flex-start; }
.row-form { flex-direction: row; flex-wrap: wrap; }
.row-form input { flex: 1; min-width: 220px; }
.steps { padding-left: 20px; color: var(--ink-2); font-size: 13.5px; }
.steps li { margin-bottom: 4px; }
.bot-status { padding: 8px 12px; border-radius: 8px; background: var(--surface-2); margin-bottom: 10px; }
.bot-status.on { background: color-mix(in srgb, var(--good) 12%, var(--surface)); }
.bot-status.error { background: color-mix(in srgb, var(--bad) 10%, var(--surface)); }
.checklist { list-style: none; padding: 0; margin: 12px 0; }
.checklist li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.checklist li > span { font-weight: 800; width: 18px; flex: none; }
.checklist li.ok > span { color: var(--good); }
.checklist li.bad > span { color: var(--bad); }
.checklist .small { word-break: break-all; }
.dns-records { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.dns-rec { display: grid; grid-template-columns: auto auto 1fr auto; gap: 8px; align-items: center; background: var(--surface-2); border-radius: 8px; padding: 8px; }
.dns-rec code { font-size: 11.5px; max-height: 70px; overflow: auto; }
.tag { font-size: 11px; font-weight: 700; background: var(--surface-3); border-radius: 4px; padding: 1px 6px; }
.digest { border-bottom: 1px solid var(--border); padding: 8px 0; }
.digest summary { cursor: pointer; }

/* ---------- Modal, menu, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; transition: opacity .12s; }
.modal-backdrop.show { opacity: 1; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal > form { display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 32px); }
.modal-wide { width: min(640px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 8px 16px; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 10px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px 14px; border-top: 1px solid var(--border); margin-top: 6px; flex-wrap: wrap; align-items: center; }
.confirm-text { margin: 10px 0; font-size: 15px; }
.popmenu { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; min-width: 240px; }
.popmenu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 7px 10px; border-radius: 6px; }
.popmenu button:hover:not(:disabled) { background: var(--surface-2); }
.popmenu button.danger { color: var(--bad); }
.popmenu-sep { height: 1px; background: var(--border); margin: 4px 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 90; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); display: flex; gap: 14px; align-items: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-error { background: #b91c1c; }
.toast-success { background: #15803d; }
.toast-action { border: 1px solid rgba(255,255,255,.6); background: transparent; color: #fff; border-radius: 6px; padding: 3px 10px; font-weight: 600; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .settings { grid-template-columns: 1fr; }
  .settings .span-2 { grid-column: auto; }
}
@media (max-width: 900px) {
  .trow { flex-wrap: wrap; row-gap: 4px; }
  .tcell-main { flex-basis: 100%; }
  .tcell-meta { flex-basis: 100%; justify-content: flex-start; padding-left: 60px; flex-wrap: wrap; }
  .summary { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hero-bars { grid-template-columns: 1fr; }
  .srow { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 640px) {
  :root { --label-w: 170px; }
  .main { padding: 10px 10px 60px; }
  .topbar { padding: 8px 10px; }
  .brand-text small { display: none; }
  .brand-text { display: none; }
  .tabs { top: 48px; padding: 0 4px; }
  .tabs a { padding: 10px 9px 8px; }
  .tab-icon { display: none; }
  .search { width: 100%; order: 5; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tcell-meta { padding-left: 30px; }
  .trow { padding-left: calc(4px + var(--depth) * 12px); }
  .fact { grid-template-columns: 1fr; }
  .fact > span:first-child { grid-row: auto; }
  .fact > .muted { grid-column: auto; }
  .feed-row { grid-template-columns: 1fr; gap: 2px; }
  .people-grid { grid-template-columns: 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .dns-rec { grid-template-columns: auto 1fr; }
  .dns-rec code, .dns-rec .btn { grid-column: span 2; }
  .mini { flex-wrap: wrap; }
  .mini-title { white-space: normal; flex-basis: calc(100% - 50px); }
  .field.inline { flex-direction: column; align-items: stretch; }
  .field.inline > input:not([type=checkbox]), .field.inline > select { width: 100%; max-width: none; }
}
