:root {
  --bg: #14161a; --panel: #1c1f25; --panel2: #232730; --line: #2d323c;
  --text: #e6e8ec; --muted: #8b93a1; --accent: #e8a24b;
  --ok: #4fbf8a; --warn: #e8b84b; --crit: #e86a5f; --info: #5aa7c7;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --panel: #fff; --panel2: #eef0f3; --line: #dcdfe5;
  --text: #1c2027; --muted: #636b79; --accent: #b86b0c;
  --ok: #1f8f5f; --warn: #a97a00; --crit: #c2382d; --info: #1f78a0;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f5f7; --panel: #fff; --panel2: #eef0f3; --line: #dcdfe5;
    --text: #1c2027; --muted: #636b79; --accent: #b86b0c;
    --ok: #1f8f5f; --warn: #a97a00; --crit: #c2382d; --info: #1f78a0;
  }
}
* { box-sizing: border-box; }
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) { color-scheme: light; } }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.num, .big, .kv dd, .meta { font-variant-numeric: tabular-nums; }
.big { font-variant-numeric: tabular-nums; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 650; }
.mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }

/* shell */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 15px; }
.brand i { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); display: grid; place-items: center; color: #14161a; font-style: normal; font-size: 12px; font-weight: 800; }
.nav { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px; border: 0; background: none; text-align: left; width: 100%; color: var(--muted); }
.nav:hover { background: var(--panel2); color: var(--text); }
.nav.on { background: var(--panel2); color: var(--text); }
.nav .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sep { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 10px 4px; }
.spacer { flex: 1; }
.main { padding: 24px clamp(16px, 3vw, 36px) 48px; min-width: 0; max-width: 1400px; }
.top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.top h1 { font-size: 22px; }
.top .grow { flex: 1; }

/* controls */
.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #14161a; font-weight: 600; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.danger:hover { border-color: var(--crit); color: var(--crit); }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }

/* cards */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 10px; text-transform: uppercase; letter-spacing: .05em; }
.big { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
.bar { height: 6px; background: var(--panel2); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.stack { display: flex; height: 8px; }
.bar.stack > i { height: 100%; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.pill.ok::before { background: var(--ok); } .pill.crit::before { background: var(--crit); } .pill.warn::before { background: var(--warn); } .pill.info::before { background: var(--info); }
.proj { cursor: pointer; }
.proj::before { content: ""; display: block; width: 28px; height: 4px; border-radius: 2px; background: var(--c, var(--accent)); margin-bottom: 10px; }
.proj:hover { border-color: var(--muted); }
.proj h2 { font-size: 16px; margin-bottom: 4px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; }

/* insights */
.ins { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.ins:first-child { border-top: 0; }
.ins .pill, .ins .btn { align-self: flex-start; margin-top: 1px; flex: none; }
.ins b { display: block; }
.ins .tag { flex: none; width: 52px; text-align: center; font-size: 11px; font-weight: 700; text-transform: uppercase; border-radius: 5px; padding: 2px 0; height: 20px; }
.tag.crit { background: color-mix(in srgb, var(--crit) 22%, transparent); color: var(--crit); }
.tag.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.tag.info { background: color-mix(in srgb, var(--info) 22%, transparent); color: var(--info); }

/* board */
.board { display: grid; grid-template-columns: repeat(5, minmax(178px, 1fr)); gap: 12px; overflow-x: auto; padding-bottom: 8px; align-items: stretch; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; min-height: 58vh; }
.col.over { border-color: var(--accent); }
.col h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 8px; padding: 2px 2px 10px; }
.task { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; margin-bottom: 8px; cursor: grab; }
.task:hover { border-color: var(--muted); }
.task.drag { opacity: .4; }
.task .t { font-weight: 550; margin-bottom: 4px; overflow-wrap: anywhere; }
.task .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.pr-high { color: var(--crit); } .pr-med { color: var(--warn); } .pr-low { color: var(--muted); }
.overdue { color: var(--crit); }

/* code browser */
.code { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 14px; }
.tree { max-height: 560px; overflow: auto; }
.tree button { display: flex; width: 100%; gap: 8px; border: 0; background: none; text-align: left; padding: 4px 6px; border-radius: 6px; align-items: center; }
.tree button:hover { background: var(--panel2); }
.tree .sz { margin-left: auto; color: var(--muted); font-size: 11px; }
pre.view { margin: 0; max-height: 560px; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font: 12.5px/1.5 var(--mono); tab-size: 2; }
.crumbs { font-family: var(--mono); font-size: 12.5px; margin-bottom: 8px; color: var(--muted); }
.crumbs a { cursor: pointer; }
pre.log { margin: 0; max-height: 260px; overflow: auto; background: var(--bg); border-radius: 8px; padding: 10px; font: 12px/1.45 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; }

/* modal + login */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; padding: 16px; z-index: 10; }
.dlg { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(480px, 100%); max-height: 92vh; overflow: auto; }
.dlg h2 { margin-bottom: 6px; }
.dlg .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .dlg { width: min(360px, 100%); }
.err { color: var(--crit); min-height: 20px; margin-top: 8px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--panel2); border: 1px solid var(--line); padding: 9px 16px; border-radius: 8px; z-index: 20; }

@media (max-width: 820px) {
  .col { min-height: 40vh; }
  .toolbar select { flex: 1 1 130px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .brand { padding: 4px 8px; } .sep, .spacer { display: none; }
  .side { flex-wrap: nowrap; overflow-x: auto; gap: 2px; align-items: center; }
  .nav { width: auto; flex: none; white-space: nowrap; }
  .brand { flex: none; }
  .board { scroll-snap-type: x proximity; } .col { scroll-snap-align: start; }
  .top h1 { font-size: 20px; }
  .code { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}

/* soft, tactile response to state (never at rest) */
.proj, .task, .btn, .nav { transition: transform .16s cubic-bezier(.2,.8,.2,1), box-shadow .16s cubic-bezier(.2,.8,.2,1), border-color .16s, background-color .16s; }
.proj:hover, .task:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -8px rgba(0,0,0,.55); }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 10px -6px rgba(0,0,0,.55); }
.btn:active, .proj:active, .task:active { transform: none; box-shadow: none; }
.task.drag { transform: none; box-shadow: none; }
.proj:focus-visible, .task:focus-visible, .tree button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .proj, .task, .btn, .nav { transition: none; } .proj:hover, .task:hover, .btn:hover { transform: none; } }

/* board v2: toolbar, stats, richer cards, list */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 220px; min-width: 160px; width: auto; }
.toolbar select { width: auto; flex: none; padding: 7px 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 12.5px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip:hover { color: var(--text); border-color: var(--muted); }
.chip[aria-pressed="true"] { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--panel2)); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel2); padding: 7px 14px; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #14161a; font-weight: 600; }
[hidden] { display: none !important; }

.stats { display: flex; flex-wrap: wrap; gap: 6px 22px; align-items: center; margin: 0 2px 14px; font-size: 13px; color: var(--muted); }
.stats b { color: var(--text); font-size: 16px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.stats .over b { color: var(--crit); }
.stats .meter { display: block; flex: 1 1 140px; max-width: 240px; }
.stats .meter .bar { margin: 0; }

.sdot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.col h3 .l { display: flex; align-items: center; gap: 8px; }
.st-todo .sdot { background: var(--info); } .st-doing .sdot { background: var(--accent); }
.st-review .sdot { background: #c07ae0; } .st-done .sdot { background: var(--ok); }
.cnt { background: var(--panel2); border-radius: 99px; padding: 0 8px; font-size: 11.5px; letter-spacing: 0; }
.col .add { margin-left: auto; width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); font-size: 16px; line-height: 1; }
.col .add:hover { color: var(--text); border-color: var(--accent); }
.col.over { background: color-mix(in srgb, var(--accent) 7%, var(--panel)); }
.qa { display: grid; gap: 6px; margin-bottom: 10px; }
.qa select { width: auto; flex: 1; min-width: 0; padding: 6px 8px; }

.task { padding: 11px 12px; margin-bottom: 9px; }
.task .tk-top { display: flex; align-items: center; gap: 6px; font-size: 11.5px; margin-bottom: 6px; }
.task .tk-top .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.task .tk-id { margin-left: auto; font-size: 11px; }
.task .t { font-weight: 600; margin-bottom: 8px; line-height: 1.35; }
.labels { display: flex; gap: 4px; flex-wrap: wrap; margin: -2px 0 8px; }
.lbl { font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); }
button.lbl:hover { color: var(--text); border-color: var(--accent); }
.tk-foot { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.tk-foot .grow { flex: 1; }
.prio { padding: 1px 7px; border-radius: 5px; font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.prio.high { background: color-mix(in srgb, var(--crit) 20%, transparent); color: var(--crit); }
.prio.med { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.prio.low { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.due.over { color: var(--crit); font-weight: 600; }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); color: #14161a; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; }

.banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.banner h2 { font-size: 17px; margin-bottom: 4px; }
.banner p { margin: 0; max-width: 56ch; }

.tbl-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.tbl { width: 100%; border-collapse: collapse; min-width: 720px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--panel2); }
.tbl .t { font-weight: 600; margin-bottom: 4px; }
.tbl .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.tbl select { width: auto; padding: 4px 8px; }

.cl { display: grid; gap: 6px; margin-bottom: 6px; }
.cl-row { display: flex; gap: 8px; align-items: center; }
.cl-row input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--accent); }
.cl-row input:not([type="checkbox"]) { flex: 1; }

/* selects: custom chevron with room to breathe (native arrow hugs the border) */
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1.5 1.75 6 6.25l4.5-4.5' fill='none' stroke='%238b93a1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
  cursor: pointer;
}
.toolbar select, .tbl select, .qa select { padding-right: 34px; }
select:hover { border-color: var(--muted); }

.top.sub { justify-content: flex-end; margin-bottom: 14px; }

/* account chip + team */
.me { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel2); text-align: left; margin: 6px 0 2px; }
.me:hover { border-color: var(--muted); }
.me .who { display: grid; min-width: 0; line-height: 1.25; }
.me .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me .who .muted { font-size: 12px; text-transform: capitalize; }
.tbl.static tbody tr { cursor: default; }
.tbl.static tbody tr:hover { background: none; }
@media (max-width: 820px) { .me { width: auto; flex: none; margin: 0; } }

.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--text); font-size: 13px; }
.check input { accent-color: var(--accent); }

.access-list { display: grid; gap: 2px; margin-top: 8px; padding: 6px 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.access-list .check { margin: 0; padding: 6px 0; }
.check .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
input[type="checkbox"] { width: auto; flex: none; padding: 0; }
