/* SFB Console version C - layout on top of tokens.css (control-room skin, light only). */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { min-height: 100vh; line-height: 1.45; font-size: 15px; overflow-x: hidden; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.05rem; }
h2 { font-size: .95rem; }
p { margin: 0; }
a { color: var(--brand-dk); }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- shell: mobile first (bottom tabs) ---- */
.app { min-height: 100vh; }
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--rule); }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.brand .mark { width: 28px; height: 28px; border-radius: var(--r-sm); background: var(--ink); color: #fff; display: grid; place-items: center; font-family: var(--mono); font-size: .7rem; font-weight: 700; letter-spacing: .04em; flex: none; }
.brand .titles { min-width: 0; }
.brand .name { font-family: var(--mono); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 700; white-space: nowrap; }
.brand .sub { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: var(--r-sm); overflow: hidden; flex: none; }
.seg button { border: 0; border-radius: 0; min-width: 56px; padding: 0 10px; background: var(--surface); font-size: .85rem; }
.seg button + button { border-left: 1px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.iconbtn { width: 44px; padding: 0; display: grid; place-items: center; flex: none; }
.acting-lbl { display: none; }

.nav { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px; text-decoration: none; color: var(--muted); font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase; border-top: 2px solid transparent; }
.nav a svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; }
.nav a[aria-current="page"] { color: var(--brand-dk); border-top-color: var(--brand); background: #f3f8fc; }
.nav .side-brand, .nav .side-foot { display: none; }

main { padding: 12px 12px 96px; max-width: 980px; margin: 0 auto; }
.stack > * + * { margin-top: 12px; }
.card { padding: 14px; min-width: 0; }
.card > .lbl:first-child, .card > header { margin-bottom: 10px; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1 1 140px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid2 > * { min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > input, .field > select, .field > textarea { width: 100%; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--brand); flex: none; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.big { font-size: 1.9rem; font-weight: 600; line-height: 1.1; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.btn-primary:disabled, button:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.full { width: 100%; }

.banner { border: 1px solid var(--warn-line); background: var(--warn-sf); color: var(--accent-ink); border-radius: var(--r); padding: 12px 14px; }
.banner.info { border-color: #bcd8ec; background: #e8f2fa; color: var(--brand-dk); }
.banner.good { border-color: var(--good-line); background: var(--good-sf); color: var(--good); }

/* 7-day strip */
.strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 10px; }
.strip button { min-height: 58px; padding: 4px 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: .8rem; }
.strip button .d { font-family: var(--mono); font-size: .62rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.strip button .h { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: .72rem; }
.strip button[aria-pressed="true"] { border-color: var(--brand); background: #e8f2fa; box-shadow: inset 0 0 0 1px var(--brand); }
.strip button.today .n { font-weight: 700; color: var(--brand-dk); }

/* duration chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-width: 56px; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.chips button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }

/* lists */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--rule-soft); }
.list > li:first-child { border-top: 0; padding-top: 2px; }
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item-head .t { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.amt { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: 6px; }

/* stat tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px; min-width: 0; }
.tile .big { font-size: 1.5rem; margin-top: 4px; }
.tile.wide { grid-column: 1 / -1; }

/* balance gauge */
.gauge { position: relative; height: 34px; margin: 14px 0 4px; }
.gauge .track { position: absolute; left: 0; right: 0; top: 12px; height: 10px; background: var(--raised); border: 1px solid var(--rule); border-radius: 3px; }
.gauge .band { position: absolute; top: 12px; height: 10px; background: var(--good-sf); border: 1px solid var(--good-line); }
.gauge .zero { position: absolute; top: 6px; width: 1px; height: 22px; background: var(--muted); }
.gauge .marker { position: absolute; top: 2px; width: 4px; height: 30px; margin-left: -2px; background: var(--ink); border-radius: 2px; }
.gauge-scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .66rem; color: var(--muted); }

table.days { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.days th { text-align: left; font-family: var(--mono); font-size: .66rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--rule); }
table.days td { padding: 8px 4px; border-bottom: 1px solid var(--rule-soft); font-variant-numeric: tabular-nums; }
table.days td.num, table.days th.num { text-align: right; font-family: var(--mono); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.kv .total { border-top: 1px solid var(--rule); padding-top: 6px; font-weight: 600; color: var(--ink); }

.thumb { max-width: 120px; max-height: 120px; border: 1px solid var(--rule); border-radius: var(--r-sm); display: block; }
.timer { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 1.1rem; }

/* toast + dialogs */
#toast { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 50; display: flex; justify-content: center; pointer-events: none; }
#toast .msg { pointer-events: auto; max-width: 560px; background: var(--ink); color: #fff; padding: 12px 14px; border-radius: var(--r); box-shadow: var(--shadow); font-size: .9rem; }
#toast .msg.bad { background: var(--bad); }
dialog { border: 1px solid var(--rule); border-radius: var(--r); padding: 0; width: min(440px, calc(100vw - 24px)); box-shadow: var(--shadow); color: var(--ink); }
dialog::backdrop { background: rgba(20, 32, 43, .35); }
dialog .dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--rule); }
dialog .dlg-body { padding: 14px 16px 16px; }
dialog .menu-list { display: flex; flex-direction: column; gap: 8px; }
dialog .menu-list button { text-align: left; }
dialog img { max-width: 100%; height: auto; display: block; }

/* ---- desktop: left sidebar ---- */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 224px minmax(0, 1fr); }
  .nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; border-top: 0; border-right: 1px solid var(--rule); padding: 0 10px 14px; grid-row: 1; }
  .nav .side-brand { display: flex; align-items: center; gap: 10px; padding: 14px 6px 16px; border-bottom: 1px solid var(--rule); margin-bottom: 10px; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 12px; border-top: 0; border-left: 3px solid transparent; border-radius: var(--r-sm); font-size: .72rem; }
  .nav a[aria-current="page"] { border-left-color: var(--brand); border-top-color: transparent; }
  .nav .side-foot { display: block; margin-top: auto; padding: 10px 6px 0; border-top: 1px solid var(--rule); }
  .top .brand .mark, .top .brand .name { display: none; }
  .acting-lbl { display: inline; }
  main { padding: 20px 24px 40px; }
  #toast { bottom: 20px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile.wide { grid-column: span 2; }
  .cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
  .cols > * + * { margin-top: 0; }
}

@media print {
  .nav, .top, .no-print, #toast, dialog { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { break-inside: avoid; border-color: #999; }
  body { background: #fff; }
}
