:root {
  color-scheme: light dark;
  --bg: #F6F5F1; --surface: #FFFFFF; --soft: #ECEBE7; --line: #D9D5CC;
  --ink: #1C1F21; --body: #3A3F42; --muted: #6F6551;
  --accent: #B8470A; --accent-ink: #FFFFFF; --bar: #B8470A; --track: #E4E1DA;
  --nav: #1C1F21; --nav-ink: #ECEBE7; --nav-muted: #C9C1B1; --nav-active: #2F3437;
  --bad: #C62828; --warn: #8A6A00;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17191B; --surface: #222628; --soft: #2A2E31; --line: #3A3F42;
    --ink: #ECEBE7; --body: #D6D3CB; --muted: #B5AD9D;
    --accent: #FF8A45; --accent-ink: #1C1F21; --bar: #FF8A45; --track: #33383B;
    --nav: #111314; --nav-active: #2A2E31; --bad: #FF7B72; --warn: #E0B93B;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 Inter, "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; }
h2 { font-size: 16px; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: var(--ink); }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; }
textarea { min-height: 96px; resize: vertical; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--body); }
button { min-height: 40px; padding: 8px 14px; background: var(--soft); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--muted); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--bad); }
button.small { min-height: 30px; padding: 3px 9px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100%; }
.nav { background: var(--nav); color: var(--nav-ink); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; letter-spacing: .04em; font-size: 20px; padding: 0 10px; }
.brand span { color: #FF8A45; }
.brand-sub { color: var(--nav-muted); font-size: 12px; padding: 0 10px 18px; }
.nav button, .nav a { display: block; width: 100%; text-align: left; background: transparent; color: var(--nav-ink); border: 0; border-radius: 6px; padding: 9px 10px; min-height: 38px; font-weight: 600; text-decoration: none; }
.nav button:hover, .nav a:hover { background: var(--nav-active); }
.nav button.on { background: var(--nav-active); box-shadow: inset 3px 0 0 #FF6A13; }
.nav .spacer { flex: 1; }
.nav .who { color: var(--nav-muted); font-size: 12px; padding: 4px 10px; overflow-wrap: anywhere; }
main { padding: 28px; min-width: 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.sub { color: var(--muted); font-size: 13px; }
.bar-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bar-row input, .bar-row select { width: auto; min-width: 150px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 15px 16px; }
.tile .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.tile .v { font-size: 28px; font-weight: 750; line-height: 1.2; margin-top: 3px; font-variant-numeric: tabular-nums; }
.tile .n { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.panel h2 { margin-bottom: 12px; }
.panel .note { color: var(--muted); font-size: 12px; margin-top: 10px; }
.columns { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 2px; height: 150px; align-items: end; }
.column { height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding: 0 1px; cursor: default; }
.column i { display: block; width: 100%; max-width: 24px; min-height: 1px; background: var(--bar); border-radius: 4px 4px 0 0; }
.column.zero i { background: var(--line); border-radius: 0; }
.axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.hbar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 62px; gap: 8px; align-items: center; min-height: 28px; font-size: 13px; }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.track { height: 10px; background: var(--track); border-radius: 4px; overflow: hidden; }
.track i { display: block; height: 100%; min-width: 0; background: var(--bar); border-radius: 0 4px 4px 0; }
details { margin-top: 8px; font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
.table-wrap table { min-width: 760px; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--soft); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--soft); font-size: 12px; font-weight: 600; white-space: nowrap; }
.due { color: var(--bad); font-weight: 600; }

.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; align-items: start; }
.lane { background: var(--soft); border-radius: 8px; padding: 10px; min-height: 180px; }
.lane h2 { display: flex; justify-content: space-between; padding: 2px 3px 9px; }
.card { width: 100%; display: block; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px; margin-bottom: 7px; font-weight: 400; }
.card b { display: block; font-weight: 600; }
.card small { display: block; color: var(--muted); margin-top: 3px; }

.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.link { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; text-decoration: none; color: var(--ink); }
.link:hover { border-color: var(--accent); }
.link b { display: block; color: var(--accent); margin-bottom: 3px; }
.link span { color: var(--body); font-size: 13px; }

dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); padding: 20px; }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.form .wide { grid-column: 1 / -1; }
.actions { display: flex; justify-content: space-between; gap: 8px; margin-top: 16px; }
.actions div { display: flex; gap: 8px; }
.err { color: var(--bad); font-size: 13px; min-height: 18px; margin-top: 8px; }

.auth { min-height: 100%; display: grid; place-items: center; padding: 16px; background: #1C1F21; }
.auth-box { width: min(420px, 100%); background: var(--surface); border-radius: 10px; padding: 26px; }
.auth-box h1 { margin-bottom: 4px; }
.auth-box form { display: grid; gap: 12px; margin-top: 16px; }
.auth-box button { width: 100%; }
.qr { display: block; width: 210px; height: 210px; margin: 14px auto; background: #FFFFFF; padding: 6px; border-radius: 6px; }
.secret { font-family: Consolas, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; background: var(--soft); padding: 8px; border-radius: 6px; }
#tip { position: fixed; z-index: 50; pointer-events: none; background: #1C1F21; color: #ECEBE7; padding: 5px 9px; border-radius: 5px; font-size: 12px; }

@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .nav { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px; }
  .nav button, .nav a { width: auto; }
  .brand { width: 100%; padding-bottom: 6px; }
  .brand-sub, .nav .spacer, .nav .who { display: none; }
  main { padding: 16px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid2, .form { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: 104px minmax(0, 1fr) 54px; }
}
