/* Builder HQ: the studio's own control panel. Quiet dark shell, amber for the one thing that matters. */
:root {
  --bg: oklch(0.16 0.012 290);
  --bg-2: oklch(0.19 0.012 290);
  --surface: oklch(0.215 0.012 290);
  --surface-2: oklch(0.25 0.012 290);
  --border: oklch(0.31 0.012 290);
  --border-strong: oklch(0.4 0.012 290);
  --text: oklch(0.93 0.008 80);
  --muted: oklch(0.68 0.012 290);
  --faint: oklch(0.52 0.012 290);
  --accent: oklch(0.8 0.13 78);
  --accent-ink: oklch(0.2 0.04 78);
  --accent-soft: oklch(0.8 0.13 78 / 0.14);
  --good: oklch(0.78 0.14 150); --good-soft: oklch(0.78 0.14 150 / 0.14);
  --warn: oklch(0.8 0.13 78); --warn-soft: var(--accent-soft);
  --bad: oklch(0.72 0.18 25); --bad-soft: oklch(0.72 0.18 25 / 0.16);
  --info: oklch(0.75 0.1 240); --info-soft: oklch(0.75 0.1 240 / 0.14);
  --font: "General Sans", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --text-xs: 0.75rem; --text-sm: 0.875rem; --text-base: 1rem; --text-lg: 1.125rem; --text-xl: 1.375rem;
  --s1: 0.25rem; --s2: 0.5rem; --s3: 0.75rem; --s4: 1rem; --s5: 1.25rem; --s6: 1.5rem; --s8: 2rem; --s10: 2.5rem; --s12: 3rem;
  --r: 10px; --r-sm: 6px; --r-lg: 14px;
  --sidebar: 232px;
  --shadow: 0 20px 50px -20px oklch(0 0 0 / 0.6);
}
*, *::before, *::after { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--text-base); line-height: 1.5; color: var(--text); background: var(--bg); min-height: 100dvh; }
body.has-drawer { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: var(--text-lg); font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: var(--text-base); font-weight: 600; }
a { color: var(--accent); text-decoration: none; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums lining-nums; font-size: 0.92em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; overscroll-behavior: contain; background: var(--bg-2); border-right: 1px solid var(--border); padding: var(--s5) var(--s4); display: flex; flex-direction: column; gap: var(--s6); }
.brand { display: flex; align-items: center; gap: var(--s3); color: var(--text); }
.brand svg { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand b { font-weight: 600; letter-spacing: -0.01em; }
.brand small { display: block; font-size: var(--text-xs); color: var(--faint); margin-top: -2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: var(--s3); padding: 8px 10px; border-radius: var(--r-sm); color: var(--muted); font-size: var(--text-sm); font-weight: 500; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav a:hover { background: var(--surface); color: var(--text); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav a .count { margin-left: auto; font-family: var(--mono); font-size: var(--text-xs); color: var(--faint); }
.nav__group { font-size: var(--text-xs); letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); padding: var(--s3) 10px var(--s1); }
.nav a.is-next { opacity: 0.55; }
.nav a.is-next .count { font-family: var(--font); }
.sidebar__foot { margin-top: auto; display: grid; gap: var(--s3); font-size: var(--text-xs); color: var(--faint); }
.mode { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 999px; border: 1px solid var(--border); font-size: var(--text-xs); color: var(--muted); width: fit-content; }
.mode::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.mode--live::before { background: var(--good); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s6); background: oklch(from var(--bg) l c h / 0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); min-height: 58px; }
.topbar h1 { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .timer-pill { display: none; }
.content { padding: var(--s6); display: grid; gap: var(--s5); align-content: start; }
.content > .grid { display: grid; gap: var(--s5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s4); min-width: 0; }
.kpi__label { font-size: var(--text-xs); color: var(--muted); letter-spacing: 0.02em; }
.kpi__value { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.5rem; font-weight: 500; margin-top: 2px; line-height: 1.2; }
.kpi__sub { font-size: var(--text-xs); color: var(--faint); margin-top: 4px; }
.kpi--bad .kpi__value { color: var(--bad); } .kpi--good .kpi__value { color: var(--good); } .kpi--accent .kpi__value { color: var(--accent); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.panel__head { display: flex; align-items: center; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.panel__head h2 { flex: 1; min-width: 0; }
.panel__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.panel__body { padding: var(--s5); display: grid; gap: var(--s4); }
.panel .empty { padding: var(--s8) var(--s5); text-align: center; color: var(--muted); font-size: var(--text-sm); }
.toolbar { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; padding: var(--s3) var(--s5); border-bottom: 1px solid var(--border); background: var(--bg-2); }
.toolbar input[type="search"], .toolbar select { height: 34px; padding-top: 0; padding-bottom: 0; line-height: 32px; }
.toolbar::before { content: "Filter"; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-right: var(--s1); }
.toolbar.toolbar--plain::before { content: none; }
.toolbar .spacer { flex: 1; }

/* Tables */
.table-wrap { overflow-x: auto; overscroll-behavior-x: contain; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
th, td { text-align: left; padding: 10px var(--s4); border-bottom: 1px solid var(--border); vertical-align: top; white-space: nowrap; }
td { white-space: normal; }
th { font-size: var(--text-xs); font-weight: 500; color: var(--muted); letter-spacing: 0.02em; position: sticky; top: 0; background: var(--surface); z-index: 1; }
th.num, td.num { text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--border-strong); background: var(--bg-2); }
.row--link { cursor: pointer; }
.row--link:hover td { background: var(--surface-2); }
td .sub { display: block; color: var(--faint); font-size: var(--text-xs); margin-top: 1px; }

/* Badges, buttons, inputs */
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge--good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge--bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.badge--warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge--info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge--accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge--muted { opacity: 0.75; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-size: var(--text-sm); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background 120ms, border-color 120ms, transform 80ms; }
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn--accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { background: oklch(0.84 0.13 78); }
.btn--ghost { background: transparent; }
.btn--danger { background: transparent; border-color: oklch(0.72 0.18 25 / 0.5); color: var(--bad); }
.btn--danger:hover { background: var(--bad-soft); }
.btn--sm { height: 30px; padding: 0 10px; font-size: var(--text-xs); }
.btn svg { width: 16px; height: 16px; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: var(--r-sm); border: 1px solid transparent; background: transparent; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
input, select, textarea { font: inherit; font-size: var(--text-sm); color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: var(--r-sm); padding: 8px 10px; width: 100%; min-width: 0; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); padding: 0; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 28px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.money-in { position: relative; }
.money-in span { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); font-size: var(--text-sm); }
.money-in input { padding-left: 22px; font-family: var(--mono); }

/* Drawer */
.scrim { position: fixed; inset: 0; background: oklch(0 0 0 / 0.5); opacity: 0; transition: opacity 160ms; z-index: 40; }
.scrim.is-open { opacity: 1; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--bg-2); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 50; display: flex; flex-direction: column; transform: translateX(100%); transition: transform 200ms cubic-bezier(.2,.8,.2,1); }
.drawer.is-open { transform: none; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border); }
.drawer__form { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--s5); display: flex; flex-direction: column; gap: var(--s5); }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }
.field { display: grid; gap: 6px; grid-column: 1 / -1; }
.field.half { grid-column: auto; }
.field label { font-size: var(--text-sm); font-weight: 500; }
.field label small { display: block; font-weight: 400; color: var(--faint); font-size: var(--text-xs); }
.field .req { color: var(--accent); }
.field--check { display: flex; align-items: flex-start; gap: var(--s3); font-size: var(--text-sm); cursor: pointer; }
.field--check input { margin-top: 3px; flex: none; }
.form-error { color: var(--bad); font-size: var(--text-sm); }
.drawer__actions { display: flex; gap: var(--s2); flex-wrap: wrap; padding-top: var(--s2); border-top: 1px solid var(--border); margin-top: auto; }

/* Confirm, toast */
.confirm-wrap { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: oklch(0 0 0 / 0.55); padding: var(--s5); }
.confirm { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s6); width: min(380px, 100%); display: grid; gap: var(--s3); box-shadow: var(--shadow); }
.confirm p { color: var(--muted); font-size: var(--text-sm); }
.confirm__actions { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }
.toast { position: fixed; left: 50%; bottom: calc(var(--s6) + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 16px; border-radius: 999px; font-size: var(--text-sm); z-index: 70; transition: 180ms; pointer-events: none; box-shadow: var(--shadow); }
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--good { border-color: var(--good); } .toast--bad { border-color: var(--bad); }

/* Timer */
.timer { display: flex; align-items: center; gap: var(--s4); padding: var(--s4) var(--s5); background: linear-gradient(135deg, var(--accent-soft), transparent 60%); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.timer__clock { font-family: var(--mono); font-size: 2rem; font-weight: 500; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; min-width: 5.2ch; }
.timer__what { flex: 1; min-width: 200px; display: grid; gap: 2px; }
.timer__what .sub { color: var(--muted); font-size: var(--text-sm); }
.timer-pill { display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-family: var(--mono); font-size: var(--text-sm); font-variant-numeric: tabular-nums; border: 1px solid transparent; cursor: pointer; }
.timer-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .timer-pill::before { animation: none; } .drawer, .scrim, .toast { transition: none; } }

/* Dashboard bits */
.list { display: grid; }
.list__item { display: flex; gap: var(--s3); align-items: center; padding: 10px var(--s5); border-bottom: 1px solid var(--border); font-size: var(--text-sm); }
.list__item:last-child { border-bottom: 0; }
.list__item .grow { flex: 1; min-width: 0; }
.list__item .sub { display: block; color: var(--faint); font-size: var(--text-xs); }
.list__item .num { color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.bar.over > i { background: var(--bad); }
.note { font-size: var(--text-sm); color: var(--muted); padding: var(--s3) var(--s5); border-top: 1px solid var(--border); background: var(--bg-2); }
.inline-form { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; padding: var(--s4) var(--s5); }
.inline-form .field { grid-column: auto; }
.inline-form .wide { grid-column: 1 / -1; }
.stack { display: grid; gap: var(--s2); }
.detail { display: grid; grid-template-columns: max-content 1fr; gap: 6px var(--s4); font-size: var(--text-sm); }
.detail dt { color: var(--faint); }
.detail dd { margin: 0; }
.prose { max-width: 62ch; font-size: var(--text-sm); color: var(--muted); display: grid; gap: var(--s3); }
.prose code { font-family: var(--mono); background: var(--bg); padding: 1px 5px; border-radius: 4px; font-size: 0.9em; color: var(--text); }
.prose ol { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--s6); }
.login form { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s8); display: grid; gap: var(--s4); }

/* Mobile: bottom tab bar, no sidebar */
@media (max-width: 859px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding-inline: var(--s4); }
  .topbar .brand-mini { display: inline-flex; }
  .content { padding: var(--s4) var(--s4) calc(76px + env(safe-area-inset-bottom)); gap: var(--s4); }
  .tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(6, 1fr); background: oklch(from var(--bg-2) l c h / 0.92); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 6px; font-size: 0.66rem; color: var(--muted); font-weight: 500; }
  .tabbar a svg { width: 20px; height: 20px; }
  .tabbar a[aria-current="page"] { color: var(--accent); }
  .kpi__value { font-size: 1.3rem; }
  .fields { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
  th, td { padding: 9px 12px; }
  .hide-m { display: none !important; }
}
@media (min-width: 860px) { .tabbar { display: none; } .brand-mini { display: none !important; } }

/* Additions: topbar timer pill when running, settings form, list links */
.topbar .timer-pill.is-on { display: inline-flex; }
a.list__item { color: inherit; } a.list__item:hover { background: var(--surface); }
.panel > .drawer__form { overflow: visible; }
.panel .drawer__form h3 { font-size: var(--text-md, 1rem); font-weight: 600; }
.brand-mini { display: none; align-items: center; color: var(--accent); } .brand-mini svg { width: 22px; height: 22px; }
.nav a .count { margin-left: auto; }
.topbar .btn--primary-action svg { width: 16px; height: 16px; }
.fields--3 { grid-template-columns: repeat(3, 1fr); } .fields--3 .field { grid-column: auto; }
.plan-row { display: grid; gap: var(--s2); } .plan-row__name { font-weight: 600; font-size: var(--text-sm); }
@media (max-width: 859px) { .fields--3 { grid-template-columns: 1fr; } }
.m-only { display: none; } @media (max-width: 859px) { a.icon-btn.m-only { display: inline-grid; } } .icon-btn.m-only svg { width: 18px; height: 18px; }
@media (max-width: 859px) { .m-only { display: inline-flex; } }
.icon-btn.is-active { background: var(--accent-soft); color: var(--accent); }

/* Rooms 6–10 */
.tabbar { grid-template-columns: repeat(6, 1fr); }
.tabbar__more { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 6px; font: inherit; font-size: 0.66rem; color: var(--muted); font-weight: 500; background: none; border: 0; cursor: pointer; }
.tabbar__more svg { width: 20px; height: 20px; }
.tabbar__more.is-active, .tabbar__more[aria-expanded="true"] { color: var(--accent); }
.sheet-scrim { position: fixed; inset: 0; background: oklch(0 0 0 / 0.5); z-index: 45; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 46; background: var(--bg-2); border-top: 1px solid var(--border); border-radius: var(--r-lg) var(--r-lg) 0 0; padding: var(--s3) var(--s4) calc(var(--s6) + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform 200ms cubic-bezier(.2,.8,.2,1); box-shadow: var(--shadow); }
.sheet.is-open { transform: none; }
.sheet__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.sheet__grid a { display: grid; justify-items: center; gap: 6px; padding: var(--s3) var(--s2); border-radius: var(--r); background: var(--surface); color: var(--muted); font-size: var(--text-xs); font-weight: 500; text-align: center; border: 1px solid var(--border); }
.sheet__grid a svg { width: 22px; height: 22px; }
.sheet__grid a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }

/* Pipeline board */
.board { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: var(--s3); padding: var(--s4) var(--s5); overflow-x: auto; overscroll-behavior-x: contain; }
.board__col { display: grid; gap: var(--s2); align-content: start; min-width: 0; }
.board__col h3 { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); font-size: var(--text-sm); padding: 2px 2px 6px; }
.board__empty { color: var(--faint); font-size: var(--text-xs); padding: var(--s3); border: 1px dashed var(--border); border-radius: var(--r-sm); text-align: center; }
.lead { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s3); display: grid; gap: 6px; cursor: pointer; font-size: var(--text-sm); }
.lead:hover { border-color: var(--border-strong); }
.lead--wait { border-left: 3px solid var(--bad); }
.lead header { display: flex; justify-content: space-between; gap: var(--s2); align-items: baseline; }
.lead header .num { color: var(--muted); }
.lead__who { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: var(--text-xs); }
.lead__want { color: var(--text); font-size: var(--text-xs); }
.lead footer { display: grid; gap: 4px; font-size: var(--text-xs); }
.lead footer .bad { color: var(--bad); }
.lead footer .btn { justify-self: start; margin-top: 2px; }
@media (max-width: 859px) { .board { grid-template-columns: 1fr; padding: var(--s3) var(--s4); } }
.panel__head small { flex-basis: 100%; }
.drawer textarea[name="body"] { font-family: var(--mono); font-size: var(--text-xs); line-height: 1.5; }

/* Reply promises */
.bad { color: var(--bad); } .good { color: var(--good); } .warn { color: var(--warn); }
.field[hidden] { display: none; }
