/* ============================================================
   DEEP SHIFT Research Hub V2.0 — design system carried over from the V1
   Research Workspace: graphite · warm black · low-saturation blue-grey ·
   state colours used only as small dots/tints. Dark default + light mode.
   ============================================================ */
:root {
  --bg: #121211; --bg1: #161615; --bg2: #1a1a19; --bg3: #20201e; --bg4: #272725;
  --line: rgba(255,255,255,.065); --line2: rgba(255,255,255,.1); --line3: rgba(255,255,255,.16);
  --tx: #e8e6e1; --tx2: #b3b1aa; --tx3: #8d8b84; --tx4: #6f6d67;
  --acc: #8ea3b8; --acc-bg: rgba(142,163,184,.11); --acc-line: rgba(142,163,184,.38);
  --hover: rgba(255,255,255,.035); --press: rgba(255,255,255,.06);
  --g: #84ab8f; --b: #86a3c6; --a: #c9a66b; --r: #c97f75; --n: #8b8983;
  --g-bg: rgba(132,171,143,.12); --b-bg: rgba(134,163,198,.12); --a-bg: rgba(201,166,107,.12); --r-bg: rgba(201,127,117,.12); --n-bg: rgba(255,255,255,.045);
  --solid-bg: #e6e4df; --solid-tx: #141413;
  --shadow: 0 12px 32px rgba(0,0,0,.38), 0 0 0 1px rgba(255,255,255,.06);
  --r1: 4px; --r2: 6px; --r3: 8px;
  --side: 224px;
  --sans: Inter, "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Menlo, Consolas, "Noto Sans Mono CJK SC", monospace;
  color-scheme: dark;
}
html.light {
  --bg: #f3f2ee; --bg1: #ecebe6; --bg2: #fbfaf7; --bg3: #ffffff; --bg4: #e6e4de;
  --line: rgba(28,27,22,.08); --line2: rgba(28,27,22,.13); --line3: rgba(28,27,22,.2);
  --tx: #1b1b19; --tx2: #4d4c46; --tx3: #66645d; --tx4: #8a8880;
  --acc: #4f667d; --acc-bg: rgba(79,102,125,.09); --acc-line: rgba(79,102,125,.35);
  --hover: rgba(28,27,22,.035); --press: rgba(28,27,22,.06);
  --g: #4c7a59; --b: #4a6e98; --a: #8a6526; --r: #a5564c; --n: #7b7972;
  --g-bg: rgba(76,122,89,.1); --b-bg: rgba(74,110,152,.1); --a-bg: rgba(148,112,47,.11); --r-bg: rgba(165,86,76,.1); --n-bg: rgba(28,27,22,.05);
  --solid-bg: #1d1d1b; --solid-tx: #f6f5f1;
  --shadow: 0 12px 32px rgba(40,36,28,.14), 0 0 0 1px rgba(28,27,22,.08);
  color-scheme: light;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--tx); font: 13px/1.5 var(--sans); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
ul, ol { list-style: none; }
a { color: var(--acc); text-decoration: none; } a:hover { text-decoration: underline; }
[hidden] { display: none !important; }
::selection { background: var(--acc-line); }
.mono { font-family: var(--mono); letter-spacing: .01em; }
.mute { color: var(--tx3); }
.flex1 { flex: 1; }
.sm { font-size: 11.5px; }
.ic { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.c-g-t { color: var(--g); } .c-a-t { color: var(--a); } .c-r-t { color: var(--r); } .c-b-t { color: var(--b); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
* { scrollbar-width: thin; scrollbar-color: var(--line2) transparent; }
:focus-visible { outline: 1.5px solid var(--acc-line); outline-offset: 1px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: var(--side) minmax(0,1fr); height: 100vh; height: 100dvh; }
#side { background: var(--bg1); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 10px 10px; overflow: hidden auto; min-width: 0; }
#col { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
#main { flex: 1; overflow: auto; min-width: 0; position: relative; container: main / inline-size; }
#top { display: none; }
#scrim { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 2px 6px 14px; }
.brand-t { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-t b { font: 600 12.5px/1.2 var(--mono); letter-spacing: .16em; }
.brand-t span { font: 9.5px/1.4 var(--mono); letter-spacing: .2em; color: var(--tx3); margin-top: 2px; }
.mark { flex: none; }
.mark-bg { fill: var(--bg3); stroke: var(--line2); }
.mark-ring { fill: none; stroke: var(--tx2); stroke-width: 1.4; }
.mark-core { fill: var(--acc); }
.mark-line { stroke: var(--tx3); stroke-width: 1.4; stroke-linecap: round; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-i { display: flex; align-items: center; gap: 10px; height: 30px; padding: 0 9px; border-radius: var(--r2); color: var(--tx2); white-space: nowrap; position: relative; }
.nav-i:hover { background: var(--hover); color: var(--tx); text-decoration: none; }
.nav-i.active { background: var(--press); color: var(--tx); }
.nav-i.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--acc); }
.nav-i .ic { color: var(--tx3); }
.nav-i.active .ic { color: var(--acc); }
.nav-l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-c { font: 11px var(--mono); color: var(--a); }
.side-foot { display: flex; align-items: center; gap: 2px; padding: 10px 2px 0; margin-top: 8px; border-top: 1px solid var(--line); }
.who { flex: 1; min-width: 0; padding-left: 6px; }
.who-n { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-r { font-size: 11px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: var(--r2); color: var(--tx2); border: 1px solid var(--line2); background: var(--bg2); white-space: nowrap; font-size: 12.5px; transition: background .12s, border-color .12s, color .12s; cursor: pointer; }
.btn:hover:not(:disabled) { color: var(--tx); border-color: var(--line3); background: var(--bg3); text-decoration: none; }
.btn.solid { background: var(--solid-bg); color: var(--solid-tx); border-color: transparent; font-weight: 500; }
.btn.solid:hover:not(:disabled) { background: var(--solid-bg); color: var(--solid-tx); opacity: .9; }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.danger { color: var(--r); }
.btn.danger:hover:not(:disabled) { color: var(--r); border-color: var(--r); background: var(--r-bg); }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn.xs { height: 22px; padding: 0 7px; font-size: 11.5px; }
.btn.wide { width: 100%; }
.ibtn { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--r1); color: var(--tx3); flex: none; }
.ibtn:hover { background: var(--hover); color: var(--tx); }
.ibtn.sm { width: 22px; height: 22px; }
.inp, .sel { height: 30px; padding: 0 9px; border-radius: var(--r2); border: 1px solid var(--line2); background: var(--bg2); color: var(--tx); outline: none; min-width: 0; transition: border-color .12s; width: 100%; }
textarea.inp { height: auto; padding: 7px 9px; resize: vertical; line-height: 1.55; }
textarea.inp.editor { min-height: 360px; font-size: 12.5px; }
.inp:focus, .sel:focus { border-color: var(--acc-line); }
.inp:disabled, .sel:disabled { opacity: .6; }
.inp::placeholder, textarea::placeholder { color: var(--tx4); }
.inp.sm { height: 26px; font-size: 12px; width: 260px; }
.sel { padding-right: 24px; appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--tx3) 50%), linear-gradient(135deg, var(--tx3) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; cursor: pointer; }
.toolbar .sel { width: auto; max-width: 220px; }
.sel.sm { height: 26px; font-size: 12px; }
.cbl { display: inline-flex; align-items: center; gap: 6px; color: var(--tx2); font-size: 12px; cursor: pointer; user-select: none; }
.cbl input { accent-color: var(--acc); }
.seg { display: inline-flex; padding: 2px; border-radius: var(--r2); background: var(--n-bg); border: 1px solid var(--line); gap: 2px; flex-wrap: wrap; }
.seg-i { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r1); color: var(--tx3); font-size: 12px; }
.seg-i:hover { color: var(--tx); }
.seg-i.on { background: var(--bg3); color: var(--tx); box-shadow: 0 0 0 1px var(--line2); }
.seg.sm .seg-i { height: 22px; padding: 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; color: var(--tx3); font-size: 12px; border: 1px solid var(--line); }
.chip:hover { color: var(--tx); background: var(--hover); text-decoration: none; }
.chip.on { color: var(--tx); background: var(--press); border-color: var(--line2); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 3px; font-size: 11px; color: var(--tx2); background: var(--n-bg); white-space: nowrap; flex: none; }
.tag.a { color: var(--a); background: var(--a-bg); }
.tag.mat { color: var(--tx); background: var(--acc-bg); font-family: var(--mono); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 11.5px; color: var(--tx2); background: var(--n-bg); white-space: nowrap; flex: none; }
.pd { width: 6px; height: 6px; border-radius: 50%; background: var(--n); flex: none; display: inline-block; }
.c-g .pd, .pd.c-g { background: var(--g); } .c-b .pd, .pd.c-b { background: var(--b); } .c-a .pd, .pd.c-a { background: var(--a); } .c-r .pd, .pd.c-r { background: var(--r); }
.pill.c-g { background: var(--g-bg); } .pill.c-b { background: var(--b-bg); } .pill.c-a { background: var(--a-bg); } .pill.c-r { background: var(--r-bg); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack.mt { margin-top: 10px; }
.field { margin-top: 12px; min-width: 0; }
.field > label, .lbl-row label { display: block; font-size: 11px; color: var(--tx3); margin-bottom: 5px; letter-spacing: .02em; }
.lbl-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 5px; }
.lbl-row label { margin-bottom: 0; }
.hint { font-size: 11.5px; color: var(--tx3); margin-top: 5px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 0 12px; }
.grid2 > .field:first-child, .grid2 > .field:nth-child(2), .grid3 > .field { margin-top: 12px; }
.form-err { color: var(--r); font-size: 12px; min-height: 18px; margin-top: 10px; }
.form-a { margin-top: 18px; display: flex; gap: 8px; }

/* ---------- page ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 24px 32px 100px; }
.page.wide { max-width: 1600px; }
.ph { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.ph-t { flex: 1; min-width: 0; }
.ph-k { font: 11px var(--mono); letter-spacing: .14em; color: var(--tx3); text-transform: uppercase; margin-bottom: 4px; }
.ph h1, .task-hero h1, .agent-hero h1 { font-size: 20px; font-weight: 600; letter-spacing: .01em; line-height: 1.3; word-break: break-word; }
.ph-s { color: var(--tx3); font-size: 12.5px; margin-top: 3px; }
.ph-a { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.sec { margin-top: 24px; min-width: 0; }
.sec:first-child { margin-top: 0; }
.sec-h { display: flex; align-items: center; gap: 8px; min-height: 28px; margin-bottom: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; flex-wrap: wrap; }
.sec-h h2 { font-size: 12.5px; font-weight: 600; color: var(--tx); letter-spacing: .02em; }
.sec-c { font: 11px var(--mono); color: var(--tx3); }
.sec-note { font-size: 11.5px; color: var(--tx3); }
.sec-note.mb { margin: -4px 0 8px; }
.empty { padding: 18px 4px; color: var(--tx3); }
.empty.sm { padding: 6px 0; font-size: 12px; }
.empty-t { font-size: 13px; color: var(--tx2); }
.empty-s { font-size: 12px; margin-top: 3px; color: var(--tx3); max-width: 560px; }
.banner { display: flex; align-items: center; gap: 10px; padding: 9px 14px; margin: 0 0 14px; border-radius: var(--r2); background: var(--n-bg); border: 1px solid var(--line2); font-size: 12.5px; color: var(--tx2); flex-wrap: wrap; }
.banner span { flex: 1; min-width: 200px; }
.banner.bad { background: var(--r-bg); border-color: rgba(201,127,117,.3); color: var(--tx); }
.banner.ok { background: var(--g-bg); border-color: rgba(132,171,143,.3); color: var(--tx); }
.banner.warn { background: var(--a-bg); border-color: rgba(201,166,107,.3); color: var(--tx); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--tx3); padding: 40px 0; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line3); border-top-color: var(--acc); animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.kv { display: grid; grid-template-columns: 130px minmax(0,1fr); gap: 7px 16px; font-size: 12.5px; }
.kv > span { color: var(--tx3); }
.kv > b { font-weight: 500; word-break: break-word; min-width: 0; }
.ap-crumb { font-size: 12px; margin-bottom: 10px; display: flex; align-items: center; gap: 4px; color: var(--tx3); }
.ap-crumb .ic { color: var(--tx4); }
.ap-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.ap-body { min-width: 0; }
.ap-side { position: sticky; top: 12px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); min-width: 0; }
.side-b { padding: 14px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.side-b:last-child { border-bottom: 0; }
.side-h { font-size: 11.5px; font-weight: 600; color: var(--tx2); margin-bottom: 10px; letter-spacing: .02em; }
.side-b p { font-size: 12px; margin-bottom: 10px; }
.notes li { font-size: 12px; color: var(--tx2); padding: 3px 0 3px 12px; position: relative; }
.notes li::before { content: ''; position: absolute; left: 0; top: 11px; width: 4px; height: 1px; background: var(--tx4); }

/* ---------- stats / dashboard ---------- */
.stats { display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); overflow: hidden; }
.stats.s4 { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 4px; }
.stat { display: block; text-align: left; padding: 12px 14px 11px; border-right: 1px solid var(--line); min-width: 0; color: inherit; }
.stat:last-child { border-right: 0; }
a.stat[href]:hover { background: var(--hover); text-decoration: none; }
.stat-k { font-size: 11.5px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-v { font: 500 19px/1.35 var(--mono); color: var(--tx); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-s { font-size: 11px; color: var(--tx4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.hot-a .stat-v { color: var(--a); } .stat.hot-r .stat-v { color: var(--r); }
.dash { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(0,1fr); gap: 0 32px; margin-top: 24px; }
.dash-c { min-width: 0; }
.rlist { display: flex; flex-direction: column; }
.ri, .qi { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 8px; margin: 0 -8px; border-radius: var(--r2); text-align: left; min-width: 0; color: var(--tx); }
a.ri:hover, a.qi:hover { background: var(--hover); text-decoration: none; }
.ri.on { background: var(--press); }
.ri.bad { background: var(--r-bg); margin: 2px -8px; }
.ri-k { font-size: 11.5px; color: var(--tx2); flex: none; min-width: 70px; }
.fi-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tx); }
.ri-m { font-size: 11.5px; color: var(--tx3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34%; }
.ri-p { font: 11.5px var(--mono); color: var(--tx2); white-space: nowrap; }
.ri-t { font-size: 11.5px; color: var(--tx3); width: 84px; text-align: right; white-space: nowrap; flex: none; }
.ri-t.l { text-align: left; font-family: var(--mono); }
.ri-bar { width: 64px; height: 3px; border-radius: 2px; background: var(--line2); flex: none; overflow: hidden; }
.ri-bar i { display: block; height: 100%; background: var(--b); }
.fi-more { font-size: 11.5px; color: var(--tx3); padding: 6px 0; }
.qi-n { font: 11px var(--mono); color: var(--tx3); min-width: 60px; flex: none; }
.qi-name { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.qi-v { font: 11.5px var(--mono); color: var(--tx2); white-space: nowrap; }
.qi-cd { font: 11.5px var(--mono); color: var(--g); min-width: 96px; text-align: right; white-space: nowrap; flex: none; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); padding: 12px 14px; margin-bottom: 10px; min-width: 0; display: block; color: inherit; }
a.card.click:hover { border-color: var(--line2); background: var(--bg3); text-decoration: none; }
.card-h { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.card-h .k { font-size: 11.5px; color: var(--tx2); letter-spacing: .06em; }
.card-t { font-weight: 600; font-size: 13.5px; flex: 1; min-width: min(160px, 100%); color: var(--tx); overflow-wrap: anywhere; }
a.card-t:hover { color: var(--acc); }
.card-s { font-size: 12px; color: var(--tx3); margin-top: 6px; overflow-wrap: anywhere; }
.card-s.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card .kv { margin-top: 10px; }
.card-a { margin-top: 12px; display: flex; gap: 8px; }
.card .ftbl { margin-top: 10px; }
.qcards, .wgrid { display: grid; grid-template-columns: minmax(0,1fr); gap: 0; }
.wgrid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 10px; }
.wgrid .card { margin-bottom: 0; }
.wake-msg { margin: 8px 0 6px; padding: 7px 10px; border-radius: var(--r2); background: var(--a-bg); color: var(--tx); font-size: 12px; }
.att { display: inline-flex; margin: 0 6px 4px 0; }
a.att { font-size: 12px; }

/* agents */
.agrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 10px; }
.acard { position: relative; display: flex; flex-direction: column; padding: 12px 13px 11px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); min-width: 0; color: var(--tx); }
.acard:hover { border-color: var(--line2); background: var(--bg3); text-decoration: none; }
.acard.inactive { opacity: .55; }
.ac-top { display: flex; align-items: center; gap: 6px; height: 22px; }
.ac-num { font: 600 11px var(--mono); letter-spacing: .12em; color: var(--tx2); }
.ac-name { font-size: 15px; font-weight: 600; margin-top: 7px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-code { font-size: 11.5px; color: var(--tx3); margin-top: 2px; }
.ac-meta { display: flex; gap: 10px; font: 11.5px var(--mono); color: var(--tx2); margin-top: 10px; white-space: nowrap; overflow: hidden; }
.ac-foot { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--tx3); margin-top: 8px; white-space: nowrap; }
.ac-foot b { font: 500 11.5px var(--mono); color: var(--tx); margin-left: 4px; }
.ac-q { margin-top: 8px; padding-top: 7px; border-top: 1px dashed var(--line); font-size: 11.5px; color: var(--r); display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.agent-hero, .task-hero { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); padding: 16px 18px; margin-bottom: 16px; }
.agent-hero { display: grid; grid-template-columns: minmax(0,1fr) auto auto; gap: 20px; align-items: center; }
.agent-hero .ph-s { margin-bottom: 8px; }
.ah-k { display: grid; grid-template-columns: repeat(4, auto); gap: 4px 22px; }
.ah-k div { display: flex; flex-direction: column; }
.ah-k span { font-size: 11px; color: var(--tx3); }
.ah-k b { font-size: 15px; font-weight: 500; }
.task-hero .chips { margin: 8px 0 12px; }
.qmini { display: flex; flex-direction: column; gap: 6px; }
.qm { display: grid; grid-template-columns: 52px minmax(0,1fr) 44px 92px; gap: 8px; align-items: center; font-size: 11.5px; }
.qbar { display: block; height: 4px; border-radius: 2px; background: var(--line2); overflow: hidden; min-width: 40px; flex: 1; }
.qbar i { display: block; height: 100%; background: var(--acc); }
.qbar i.hi { background: var(--a); }

/* ---------- tables (div grids) ---------- */
.tbl { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); overflow: hidden; }
.tr { display: grid; grid-template-columns: 110px 160px 110px 80px 120px minmax(0,1fr); gap: 12px; align-items: center; min-height: 40px; padding: 6px 12px; border-bottom: 1px solid var(--line); color: var(--tx); min-width: 0; }
.tr > * { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr:last-child { border-bottom: 0; }
a.tr:hover { background: var(--hover); text-decoration: none; }
.tr.th { min-height: 32px; font-size: 11.5px; color: var(--tx3); background: var(--bg1); }
.tr.dim { opacity: .5; }
.tr.bad { background: var(--r-bg); }
.tr .row-a { display: flex; gap: 6px; justify-content: flex-end; overflow: visible; }
.tr.c5 { grid-template-columns: 110px 60px 110px minmax(0,1fr) 110px; }
.tbl.tasks .tr { grid-template-columns: 104px minmax(160px,1fr) 100px 48px 90px 112px 112px 92px; }
.tbl.tasks .tr .t { white-space: nowrap; }
.tbl.reviews .tr { grid-template-columns: 110px 110px 112px 80px minmax(0,1fr) 100px; }
.tbl.users .tr { grid-template-columns: 150px 160px 120px minmax(0,1fr) 200px 170px; }
.tbl.tokens .tr { grid-template-columns: minmax(120px,1fr) 130px 140px 110px 100px 90px 70px; }
.tbl.grants .tr { grid-template-columns: 110px minmax(0,1fr) 100px 100px 70px; }
.tbl.audit .tr { grid-template-columns: 96px 190px 170px 220px minmax(0,1fr); font-size: 12px; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tx3); }

/* file table */
.ftbl { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--r2); background: var(--bg1); }
.fr { display: grid; grid-template-columns: minmax(180px, 1.1fr) minmax(0, 1.6fr) auto; gap: 12px; align-items: center; padding: 7px 10px; border-bottom: 1px solid var(--line); min-width: 0; }
.fr:last-child { border-bottom: 0; }
.fr-n { display: flex; align-items: center; gap: 7px; min-width: 0; }
.fr-n a, .fr-n > span:not(.tag) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.fr-n .ic { color: var(--tx3); }
.fr-m { display: flex; align-items: center; gap: 12px; font-size: 11.5px; color: var(--tx2); min-width: 0; }
.fr-m .sha { color: var(--tx3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.fr-a { display: flex; gap: 6px; justify-content: flex-end; }
.ftbl.repo .fr { grid-template-columns: minmax(200px, 1fr) minmax(0, 1.7fr) auto; }
.vgroup { margin-bottom: 18px; }
.arc-gh { font: 11.5px var(--mono); color: var(--tx2); padding: 6px 2px; letter-spacing: .02em; }
.sha-full { word-break: break-all; }
.scope li { padding: 2px 0; }
pre.cmd { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r2); padding: 10px 12px; overflow: auto; font: 12px/1.6 var(--mono); color: var(--tx2); margin-bottom: 8px; white-space: pre; }
.signed { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }

/* ---------- task page ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs.sticky { position: sticky; top: 0; z-index: 3; background: var(--bg); padding: 6px 0; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; color: var(--tx3); font-size: 12.5px; border-radius: var(--r2); }
.tab:hover { color: var(--tx); background: var(--hover); text-decoration: none; }
.tab.on { color: var(--tx); background: var(--press); }
.tabbody { margin-top: 14px; }
.timeline { position: relative; padding-left: 4px; }
.timeline li { display: grid; grid-template-columns: 148px minmax(0,1fr) auto; gap: 12px; align-items: center; padding: 6px 0 6px 16px; border-left: 1px solid var(--line2); position: relative; font-size: 12px; }
.timeline li::before { content: ''; position: absolute; left: -4px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--bg3); border: 1.5px solid var(--tx4); }
.timeline li.status::before { border-color: var(--acc); }
.timeline li.review::before { border-color: var(--g); }
.tl-t { color: var(--tx3); font-size: 11.5px; }
.tl-x { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.tl-x .ic { color: var(--tx4); }
.tl-n { color: var(--tx2); overflow-wrap: anywhere; }
.tl-w { color: var(--tx4); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.dsp-a { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
details.md-wrap { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 8px; }
details.md-wrap > summary { cursor: pointer; color: var(--tx2); font-size: 12px; margin-bottom: 8px; }
.md-wrap.open { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); padding: 18px 22px; }
.preview { min-height: 360px; }

/* ---------- Markdown ---------- */
.md { font-size: 13.5px; line-height: 1.75; color: var(--tx); overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { font-weight: 600; line-height: 1.35; margin: 1.4em 0 .5em; }
.md h1 { font-size: 19px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.md h2 { font-size: 16px; } .md h3 { font-size: 14.5px; } .md h4, .md h5, .md h6 { font-size: 13.5px; color: var(--tx2); }
.md p { margin: .6em 0; }
.md ul, .md ol { margin: .5em 0; padding-left: 1.5em; }
.md ul { list-style: disc; } .md ol { list-style: decimal; } .md li > ul { list-style: circle; }
.md li { margin: .2em 0; }
.md li.task { list-style: none; margin-left: -1.3em; }
.md-ck { display: inline-grid; place-items: center; width: 14px; height: 14px; border: 1.5px solid var(--tx4); border-radius: 3px; margin-right: 7px; font-size: 10px; vertical-align: -2px; }
.md-ck.on { background: var(--acc); border-color: var(--acc); color: var(--bg); }
.md blockquote { border-left: 2px solid var(--line3); padding: 2px 0 2px 14px; color: var(--tx2); margin: .8em 0; }
.md code { font: 12px var(--mono); background: var(--n-bg); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; }
.md code.math { color: var(--b); background: var(--b-bg); border-color: transparent; }
.md pre { position: relative; background: var(--bg1); border: 1px solid var(--line); border-radius: var(--r2); padding: 12px 14px; overflow: auto; margin: .8em 0; }
.md pre code { background: none; border: 0; padding: 0; font: 12.5px/1.6 var(--mono); white-space: pre; display: block; }
.md pre.math { border-left: 2px solid var(--b); }
.md pre.math code { color: var(--tx); }
.code-lang { position: absolute; right: 8px; top: 6px; font: 10.5px var(--mono); color: var(--tx4); }
.md hr { border: 0; border-top: 1px solid var(--line2); margin: 1.4em 0; }
.md-table { overflow-x: auto; margin: .8em 0; border: 1px solid var(--line); border-radius: var(--r2); }
.md table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md th, .md td { padding: 6px 10px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; vertical-align: top; }
.md th { background: var(--bg1); font-weight: 600; color: var(--tx2); white-space: nowrap; }
.md tr:last-child td { border-bottom: 0; }
.md th:last-child, .md td:last-child { border-right: 0; }
.md .al-center { text-align: center; } .md .al-right { text-align: right; }
.md a { overflow-wrap: anywhere; }
.md-badlink { color: var(--tx3); text-decoration: line-through; }

/* ---------- upload ---------- */
.deliver { display: flex; flex-direction: column; gap: 10px; }
.drop { display: flex; align-items: center; gap: 10px; padding: 16px; border: 1px dashed var(--line3); border-radius: var(--r3); color: var(--tx3); cursor: pointer; background: var(--bg1); font-size: 12.5px; }
.drop:hover, .drop.on { border-color: var(--acc-line); color: var(--tx2); background: var(--acc-bg); }
.up-list { display: flex; flex-direction: column; gap: 6px; }
.up-row { border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 10px; background: var(--bg1); min-width: 0; }
.up-top { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.up-top .ic { color: var(--tx3); }
.up-top .sel { width: auto; }
.up-name { flex: 1; min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-size, .up-pct { font-size: 11.5px; color: var(--tx2); }
.up-st { font-size: 11.5px; color: var(--tx3); }
.up-bar { height: 4px; border-radius: 2px; background: var(--line2); overflow: hidden; margin-top: 7px; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--b); transition: width .15s; }
.up-row.hashing .up-bar i { background: var(--tx3); }
.up-row.ok .up-bar i { background: var(--g); }
.up-row.ok .up-st { color: var(--g); }
.up-row.bad { border-color: rgba(201,127,117,.4); }
.up-row.bad .up-st { color: var(--r); }
.up-row.bad .up-bar i { background: var(--r); }
.up-sha { display: block; font-size: 10.5px; color: var(--tx4); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deliver-a { display: flex; justify-content: flex-end; }
.resume-l { margin-top: 6px; width: 100%; }
.resume-l li { display: flex; align-items: center; gap: 10px; font-size: 12px; padding: 2px 0; }
.resume-l li .mono { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.attach { display: flex; flex-direction: column; gap: 6px; }
.attach > label { align-self: flex-start; }
.ap-side .deliver .grid2 { grid-template-columns: minmax(0,1fr); }

/* ---------- dispatch ---------- */
.dsp-nav { display: grid; grid-template-columns: repeat(6, minmax(0,1fr)); gap: 8px; margin-bottom: 8px; }
.dsp-n { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); text-align: left; }
.dsp-n:hover { border-color: var(--line2); background: var(--bg3); }
.dsp-n b { font-size: 18px; font-weight: 500; }
.dsp-n span { font-size: 11.5px; color: var(--tx3); }
.dsp-n.bad b { color: var(--r); }

/* quota */
.qtable { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); overflow: auto; }
.qrow { display: grid; grid-template-columns: minmax(170px,1.2fr) 90px repeat(4, minmax(150px,1fr)) 64px; gap: 12px; align-items: center; min-height: 54px; padding: 6px 12px; border-bottom: 1px solid var(--line); min-width: 900px; }
.qrow:last-child { border-bottom: 0; }
.qrow.head { min-height: 34px; font-size: 11.5px; color: var(--tx3); background: var(--bg1); }
.qr-a { display: flex; gap: 8px; min-width: 0; overflow: hidden; white-space: nowrap; }
.qr-a .mono { color: var(--tx3); font-size: 12px; }
.qr-m { font-size: 12px; color: var(--tx2); }
.qc-v { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.qc-r { font-size: 11px; color: var(--g); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qc-s { font-size: 10.5px; color: var(--tx4); }
.qc.none { color: var(--tx4); font-size: 12px; }

/* archive */
.round { border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); margin-bottom: 10px; }
.round-h { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 14px; font-size: 12.5px; font-weight: 600; border-bottom: 1px solid var(--line); }
.round-m { font: 400 11px var(--mono); color: var(--tx3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round-b { padding: 4px 14px 8px; }
.arc-item { padding: 4px 0 6px; border-bottom: 1px dashed var(--line); }
.arc-item:last-child { border-bottom: 0; }
.arc-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 2px 0 2px 16px; font-size: 12px; color: var(--tx2); }

/* ---------- login ---------- */
.app-login { min-height: 100vh; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(1200px 600px at 70% -10%, var(--acc-bg), transparent 60%), var(--bg); }
.login-card { width: 380px; max-width: 100%; border: 1px solid var(--line2); border-radius: 12px; background: var(--bg2); padding: 26px 26px 18px; box-shadow: var(--shadow); }
.brand.big { padding: 0 0 14px; }
.brand.big .brand-t b { font-size: 14px; }
.login-sub { font-size: 12px; color: var(--tx3); line-height: 1.6; margin-bottom: 6px; }
.login-f .btn { margin-top: 4px; height: 34px; }
.login-foot { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11px; }

/* ---------- dialogs / toast ---------- */
.dlg-wrap { position: fixed; inset: 0; z-index: 950; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 20px; }
html.light .dlg-wrap { background: rgba(40,36,28,.22); }
.dlg { width: 440px; max-width: 100%; max-height: calc(100vh - 40px); overflow: auto; border-radius: 10px; background: var(--bg2); box-shadow: var(--shadow); padding: 18px 20px 16px; }
.dlg.wide { width: 600px; }
.dlg-h { font-size: 14.5px; font-weight: 600; margin-bottom: 8px; }
.dlg-b { font-size: 12.5px; color: var(--tx2); line-height: 1.6; }
.dlg-b p { margin-bottom: 8px; }
.dlg-a { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.inp.once { font-size: 12px; }
#toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 12px); z-index: 980; padding: 9px 16px; border-radius: var(--r3); background: var(--solid-bg); color: var(--solid-tx); font-size: 12.5px; opacity: 0; pointer-events: none; transition: opacity .16s, transform .16s; max-width: calc(100vw - 40px); }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast.bad { background: var(--r); color: #fff; }

/* ---------- responsive ---------- */
@container main (max-width: 1240px) {
  .stats { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .stats .stat:nth-child(4n) { border-right: 0; }
  .stats .stat:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .stats.s4 .stat { border-bottom: 0; }
  .tbl.tasks .tr { grid-template-columns: 100px minmax(140px,1fr) 90px 44px 112px 88px; }
  .tbl.tasks .tr > :nth-child(5), .tbl.tasks .tr > :nth-child(7) { display: none; }
  .agent-hero { grid-template-columns: minmax(0,1fr) auto; }
  .agent-hero .ah-a { grid-column: 2; grid-row: 1; }
  .agent-hero .ah-k { grid-column: 1 / -1; }
}
@container main (max-width: 980px) {
  .dash { grid-template-columns: minmax(0,1fr); }
  .dash-c + .dash-c > .sec:first-child { margin-top: 24px; }
  .ap-split { grid-template-columns: minmax(0,1fr); }
  .ap-side { position: static; }
  .page { padding: 20px 20px 100px; }
  .dsp-nav { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .fr, .ftbl.repo .fr { grid-template-columns: minmax(0,1fr) auto; }
  .fr-m { grid-column: 1 / -1; grid-row: 2; }
  .tbl.users .tr { grid-template-columns: 130px minmax(0,1fr) 110px 170px; }
  .tbl.users .tr > :nth-child(2), .tbl.users .tr > :nth-child(4) { display: none; }
  .tbl.audit .tr { grid-template-columns: 90px 170px minmax(0,1fr); }
  .tbl.audit .tr > :nth-child(3), .tbl.audit .tr > :nth-child(4) { display: none; }
  .tbl.tokens .tr { grid-template-columns: minmax(0,1fr) 110px 90px 70px; }
  .tbl.tokens .tr > :nth-child(3), .tbl.tokens .tr > :nth-child(4), .tbl.tokens .tr > :nth-child(6) { display: none; }
  .wgrid { grid-template-columns: minmax(0,1fr); }
}
@container main (max-width: 640px) {
  .stats, .stats.s4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .stats .stat { border-bottom: 1px solid var(--line); }
  .stats .stat:nth-child(2n) { border-right: 0; }
  .stats .stat:nth-child(4n) { border-right: 0; }
  .stats .stat:nth-child(odd) { border-right: 1px solid var(--line); }
  .ph { flex-direction: column; align-items: stretch; }
  .ph-a { justify-content: flex-start; }
  .page { padding: 16px 14px 90px; }
  .kv { grid-template-columns: minmax(0,1fr); gap: 1px; }
  .kv > b { margin-bottom: 8px; }
  .grid2, .grid3 { grid-template-columns: minmax(0,1fr); }
  .tbl.tasks .tr { grid-template-columns: 92px minmax(0,1fr) 100px; }
  .tbl.tasks .tr > :nth-child(3), .tbl.tasks .tr > :nth-child(4), .tbl.tasks .tr > :nth-child(8) { display: none; }
  .tbl.reviews .tr { grid-template-columns: 100px minmax(0,1fr) 108px; }
  .tbl.reviews .tr > :nth-child(4), .tbl.reviews .tr > :nth-child(5), .tbl.reviews .tr > :nth-child(6) { display: none; }
  .tr, .tr.c5 { grid-template-columns: minmax(0,1fr) auto; }
  .tr > :nth-child(n+3) { display: none; }
  .tbl.tasks .tr > :nth-child(6) { display: block; }
  .tbl.reviews .tr > :nth-child(3) { display: block; }
  .tbl.users .tr { grid-template-columns: minmax(0,1fr) auto; }
  .tbl.users .tr > :nth-child(6) { display: flex; }
  .ri-m, .ri-p, .ri-bar { display: none; }
  .ri { flex-wrap: wrap; row-gap: 2px; }
  .ri-m.keep { display: block; order: 9; flex-basis: 100%; max-width: 100%; white-space: normal; padding-left: 2px; }
  .dash-c + .dash-c > .sec:first-child { margin-top: 24px; }
  .ri-k { min-width: 0; }
  .ri-t { width: auto; }
  .agent-hero { grid-template-columns: minmax(0,1fr); }
  .agent-hero .ah-a { grid-column: auto; grid-row: auto; }
  .ah-k { grid-template-columns: repeat(2, auto); }
  .dsp-nav { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .timeline li { grid-template-columns: minmax(0,1fr); gap: 2px; }
  .tl-w { max-width: none; }
  .md-wrap.open { padding: 14px; }
  .toolbar .searchbox, .searchbox { width: 100%; }
  .toolbar .sel { max-width: none; flex: 1 1 140px; }
  .fr-m { flex-wrap: wrap; gap: 4px 10px; }
  .fr-m .sha { flex-basis: 100%; }
  .agrid { grid-template-columns: minmax(0,1fr); }
}
.searchbox { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 10px; border: 1px solid var(--line2); border-radius: var(--r2); background: var(--bg2); color: var(--tx3); width: 300px; }
.searchbox:focus-within { border-color: var(--acc-line); }
.searchbox input { flex: 1; border: 0; outline: none; background: transparent; min-width: 0; color: var(--tx); }

@media (max-width: 1100px) { :root { --side: 200px; } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0,1fr); }
  #side { position: fixed; left: 0; top: 0; bottom: 0; width: 250px; z-index: 700; transform: translateX(-105%); transition: transform .18s ease; visibility: hidden; }
  .app.nav-open #side { transform: none; box-shadow: var(--shadow); visibility: visible; }
  .app.nav-open #scrim { display: block; position: fixed; inset: 0; z-index: 690; background: rgba(0,0,0,.4); }
  #top { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 10px; border-bottom: 1px solid var(--line); background: var(--bg1); flex: none; }
  #top .brand { padding: 0; }
  .top-r { font-size: 11.5px; color: var(--tx3); }
}

/* ---------- collab ---------- */
.mt6 { margin-top: 6px; } .mb8 { margin-bottom: 8px; }
.cprog { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-size: 11.5px; color: var(--tx2); }
.cprog .qbar { max-width: 120px; }
.cstats { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); border: 1px solid var(--line); border-radius: var(--r3); background: var(--bg2); overflow: hidden; margin-bottom: 18px; }
.cstats .stat:last-child { border-right: 0; }
button.ri.wide { width: calc(100% + 16px); }
button.ri.wide:hover { background: var(--hover); }
.mem { padding: 6px 0; border-bottom: 1px dashed var(--line); }
.mem:last-of-type { border-bottom: 0; }
.mem-h { display: flex; align-items: center; gap: 6px; font-size: 12.5px; flex-wrap: wrap; }
.mem-h .mono { color: var(--tx3); font-size: 11.5px; }
.mem-d { font-size: 12px; color: var(--tx2); margin-top: 3px; padding-left: 2px; white-space: pre-wrap; }
.card.dim { opacity: .55; }
.vlist { margin-top: 8px; border-top: 1px solid var(--line); padding-top: 6px; }
.vrow { display: grid; grid-template-columns: 40px 120px minmax(0,1fr) 92px auto; gap: 10px; align-items: center; font-size: 12px; padding: 2px 0; }
.vrow.dim { opacity: .5; }
.talk { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.cmt { border: 1px solid var(--line); border-radius: var(--r2); padding: 8px 12px; background: var(--bg1); }
.cmt-h { display: flex; gap: 10px; font-size: 11.5px; margin-bottom: 4px; }
.cmt .md { font-size: 12.5px; }
@container main (max-width: 640px) {
  .cstats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .cstats .stat { border-bottom: 1px solid var(--line); }
  .vrow { grid-template-columns: 40px minmax(0,1fr) auto; }
  .vrow > :nth-child(2), .vrow > :nth-child(4) { display: none; }
}

.dsp-n.hot b { color: var(--a); }
.ap-body > .tabs.sticky { margin-top: 18px; }
.deliver.busy .up-top .ibtn { visibility: hidden; }
.resume-l li .qbar { max-width: 140px; }
.ap-side .ri-m, .ap-side .ri-t { display: none; }
.ap-side .ri-k { min-width: 0; }
.tr > .pill { justify-self: start; }
