:root {
  --bg: #14161c; --bg2: #1c1f27; --card: #232733; --card2: #2b3040; --line: #3a4052;
  --ink: #f2efe6; --dim: #a9adba; --faint: #7d8292;
  --good: #5fd38d; --bad: #ff6b5e; --warn: #ffc94a; --accent: #ffb020; --blue: #6cb8ff;
  --r: 14px;
  --foot-h: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow-x: hidden; }
body { font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
h2 { font-size: 1.08rem; margin: 0; letter-spacing: .01em; }
b { font-weight: 700; }
[hidden] { display: none !important; }

#app { display: grid; grid-template-columns: 1fr; height: 100dvh; max-width: 100vw; }
#stage { position: relative; background: #2a2e36; overflow: hidden; min-height: 0; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#panel { position: relative; display: flex; flex-direction: column; min-height: 0; overflow: hidden; background: var(--bg); }
.screen { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 10px 12px 0; -webkit-overflow-scrolling: touch; }

/* phones: stage only during the day */
body:not(.phase-day) #stage { display: none; }
body.phase-day #app { grid-template-rows: 1fr auto; }
body.phase-day #topbar { display: none; }
body.phase-day #scrDay { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); flex: none; overflow: hidden; }

@media (min-width: 900px) {
  #app { grid-template-columns: minmax(420px, 1fr) minmax(440px, 560px); grid-template-rows: 1fr !important; }
  body:not(.phase-day) #stage { display: block; }
  body.phase-day #topbar { display: flex; }
  body.phase-day #scrDay { flex: 1; overflow-y: auto; padding: 14px; }
  #panel { border-left: 1px solid var(--line); }
}

#topbar { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--bg2); flex: none; }
.brand { font-weight: 800; letter-spacing: .04em; text-transform: uppercase; font-size: .95rem; color: var(--accent); }
.tb-right { display: flex; gap: 8px; }

.iconbtn { min-width: 48px; height: 48px; border-radius: 12px; border: 1px solid #ffffff22; background: #00000088; color: #fff; font-size: 1.05rem; font-weight: 700; padding: 0 10px; backdrop-filter: blur(4px); }
.iconbtn.small { min-width: 42px; height: 42px; background: var(--card); }
.iconbtn:active { transform: scale(.96); }

button.big { display: block; width: 100%; min-height: 56px; border-radius: var(--r); border: 1px solid var(--line); background: var(--card2); font-size: 1.12rem; font-weight: 700; padding: 10px 16px; }
button.big.primary { background: linear-gradient(#ffbe3d, #f59b0b); color: #1b1300; border-color: #ffd47a; box-shadow: 0 3px 0 #a86200; }
button.big.primary:active { transform: translateY(2px); box-shadow: 0 1px 0 #a86200; }
button.big.ghost { background: transparent; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* title */
#scrTitle { display: flex; padding: 18px; }
/* auto margins centre the card but never push it above the scroll top on short phones (iPhone SE) */
.title-card { max-width: 440px; width: 100%; margin: auto; text-align: center; }
.title-sign { margin: 10px auto 18px; width: 230px; background: #101216; border: 4px solid #d7d9de; border-radius: 10px; padding: 12px 10px 10px; box-shadow: 0 0 40px #ffb02033; }
.ts-top { font-size: .78rem; letter-spacing: .3em; color: #ffb020; font-weight: 800; }
.ts-name { font-size: 1.9rem; font-weight: 900; letter-spacing: .02em; color: #fff; margin: 2px 0 6px; }
.ts-price { font: 800 3rem/1 ui-monospace, "Consolas", monospace; color: #ff5a3c; text-shadow: 0 0 14px #ff5a3c88; }
.ts-price span { color: #ff5a3c; } .ts-price sup { font-size: 1.2rem; }
.intent { font-size: 1.15rem; margin: 0 0 18px; color: var(--ink); }
.title-btns { display: grid; gap: 10px; }
.credit { font-size: .82rem; color: var(--faint); margin-top: 18px; }

/* morning */
.status { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.status .day { font-size: 1.25rem; font-weight: 800; }
.status .sub { color: var(--dim); font-size: .92rem; }
.status .cash { text-align: right; font-size: 1.35rem; font-weight: 800; }
.status .rep { text-align: right; color: var(--dim); font-size: .92rem; }
.status .billline { grid-column: 1 / -1; font-size: .9rem; color: var(--dim); border-top: 1px dashed var(--line); padding-top: 6px; margin-top: 2px; }
.status .billline.soon { color: var(--warn); }
.status .billline.danger { color: var(--bad); font-weight: 700; }

.mnote { margin-top: 8px; padding: 9px 12px; border-radius: 12px; background: var(--card); border-left: 5px solid var(--blue); font-size: .95rem; }
.mnote.bad { border-left-color: var(--bad); }
.mnote.war { border-left-color: var(--bad); background: #3a1f22; font-weight: 700; }
.mnote.tanker { border-left-color: var(--good); }

.ticker { margin-top: 10px; overflow: hidden; white-space: nowrap; background: #0d0f13; border: 1px solid var(--line); border-radius: 10px; height: 34px; position: relative; }
#tickerTrack { display: inline-block; padding-left: 12px; line-height: 34px; font: 600 .95rem/34px ui-monospace, Consolas, monospace; color: var(--warn); animation: tick 38s linear infinite; }
@keyframes tick { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { #tickerTrack { animation: none; padding-left: 10px; } }
.news { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.news li { padding: 8px 10px 8px 34px; position: relative; background: var(--card); border-radius: 10px; font-size: .95rem; color: var(--dim); }
.news li::before { position: absolute; left: 10px; top: 8px; font-weight: 900; }
.news li.up::before { content: "▲"; color: var(--bad); }
.news li.down::before { content: "▼"; color: var(--good); }
.news li.flat::before { content: "■"; color: var(--faint); }
.news li.traffic::before { content: "🚗"; font-size: .85rem; }
.news li.night::before { content: "🌙"; font-size: .85rem; }
.news li.store::before { content: "🛒"; font-size: .85rem; }
.news li.weather::before { content: "☀"; color: var(--warn); }
.news li.flavor::before { content: "•"; color: var(--faint); }
.news li.strong { color: var(--ink); border: 1px solid #ffc94a55; }
.news li.strong2 { color: var(--ink); border: 1px solid var(--warn); background: #2f2a1c; font-weight: 600; }

.coach { margin-top: 10px; padding: 10px 12px; border-radius: 12px; background: #1d2b3a; border: 1px solid #3c6a96; font-size: .95rem; }
.coach b { color: var(--blue); }

.card { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.hint { color: var(--faint); font-size: .85rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.mini { background: var(--bg2); border-radius: 10px; padding: 8px 10px; display: flex; flex-direction: column; }
.mini span { font-size: .8rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.mini b { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.mini em { font-style: normal; font-size: .85rem; color: var(--dim); }
.mini em.up { color: var(--bad); } .mini em.down { color: var(--good); }

.stepper { display: grid; grid-template-columns: 64px 1fr 64px; align-items: center; gap: 8px; }
.st-btn { height: 60px; border-radius: 14px; border: 1px solid var(--line); background: var(--card2); font-size: 2rem; font-weight: 700; line-height: 1; }
.st-btn:active { background: #3b4257; transform: scale(.97); }
.st-val { text-align: center; display: flex; flex-direction: column; }
.st-val b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.st-val small { color: var(--faint); font-size: .82rem; }
.big-step .st-val b { font: 800 2.4rem/1.1 ui-monospace, Consolas, monospace; color: #ff6b4a; }
.stepper.compact { grid-template-columns: 54px 52px 54px; gap: 6px; }
.stepper.compact .st-btn { height: 52px; font-size: 1.7rem; }
.stepper.compact .st-val b { font-size: 1.6rem; }

.chips { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip { flex: 1 1 auto; min-height: 44px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg2); padding: 6px 12px; font-size: .92rem; font-weight: 600; color: var(--dim); }
.chip:active { background: var(--card2); }
.chip.on { background: #3a3220; border-color: var(--warn); color: var(--ink); }
.chip.small { flex: none; min-height: 38px; font-size: .82rem; }

.note { margin: 10px 0 0; font-size: .92rem; color: var(--dim); }
.note b.good, .good { color: var(--good); } .note b.bad, .bad { color: var(--bad); } .warn { color: var(--warn); }

.split { margin-top: 12px; }
.split-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; font-size: .74rem; font-weight: 700; }
.split-bar > div { display: flex; align-items: center; justify-content: center; white-space: nowrap; overflow: hidden; }
.sb-cost { background: #4a5165; color: #d8dbe4; }
.sb-fee { background: #b6533f; color: #fff; }
.sb-mar { background: #2f8f58; color: #fff; }
.sb-neg { background: #8e2b2b; color: #fff; }
.split-lbl { display: flex; justify-content: space-between; font-size: .8rem; color: var(--faint); margin-top: 3px; }

.tank { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; margin-bottom: 10px; }
.tank-bar { position: relative; height: 26px; background: #0d0f13; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
#tankFill { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #d97a14, #ffb020); }
#tankOrder { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #ffb02066 0 6px, #ffb02022 6px 12px); border-left: 2px solid #ffb020; }
.tank-lbl { text-align: right; display: flex; flex-direction: column; }
.tank-lbl b { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tank-lbl span { font-size: .8rem; color: var(--faint); }

.staffrow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; }
.staffrow .lbl { display: flex; flex-direction: column; }
.staffrow small { color: var(--faint); font-size: .82rem; }

.srow { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.srow:first-child { border-top: 0; padding-top: 2px; }
.srow .nm b { display: block; }
.srow .nm small { color: var(--faint); font-size: .82rem; }
.srow .stepper { grid-template-columns: 50px 70px 50px; gap: 6px; }
.srow .st-btn { height: 50px; font-size: 1.6rem; }
.srow .st-val b { font-size: 1.35rem; }
.srow .st-val small { font-size: .74rem; }
.srow .meta { grid-column: 1 / -1; font-size: .84rem; color: var(--dim); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.extra { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.extra:first-child { border-top: 0; }
.extra small { display: block; color: var(--faint); font-size: .84rem; }
.toggle { min-width: 96px; min-height: 48px; border-radius: 24px; border: 1px solid var(--line); background: var(--bg2); font-weight: 700; color: var(--dim); }
.toggle.on { background: #2b4a35; border-color: var(--good); color: #dfffe9; }

.spacer { height: 110px; }
.foot { position: sticky; bottom: 0; margin: 0 -12px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 22%); }
.foot-sum { display: flex; justify-content: space-between; font-size: .95rem; color: var(--dim); margin: 6px 2px 8px; gap: 8px; }
.foot-sum b { color: var(--ink); }

/* day */
#hudTop { position: absolute; z-index: 3; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; align-items: flex-start; padding: 10px; padding-top: max(10px, env(safe-area-inset-top)); pointer-events: none; }
#hudTop > * { pointer-events: auto; }
#clock { background: #000000aa; border-radius: 12px; padding: 6px 12px; display: flex; flex-direction: column; backdrop-filter: blur(4px); }
#clockTime { font: 800 1.45rem/1.1 ui-monospace, Consolas, monospace; }
#clockDay { font-size: .82rem; color: #ccd; }
#dayCtl { display: flex; gap: 8px; }
body:not(.phase-day) #hudTop { display: none; }
#toasts { position: absolute; left: 10px; right: 10px; bottom: 12px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: #101318ee; border: 1px solid #ffffff2a; border-left: 5px solid var(--blue); color: #fff; padding: 8px 14px; border-radius: 12px; font-weight: 600; font-size: .98rem; max-width: 96%; box-shadow: 0 6px 18px #0008; animation: tin .25s ease-out; }
.toast.bad { border-left-color: var(--bad); }
.toast.war { border-left-color: var(--bad); background: #5a1414ee; font-size: 1.1rem; font-weight: 800; }
.toast.comp { border-left-color: var(--warn); }
.toast.tanker { border-left-color: var(--good); }
.toast.rush { border-left-color: var(--accent); }
.toast.out { opacity: 0; transform: translateY(-6px); transition: all .4s; }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }
#pausedVeil { position: absolute; z-index: 2; inset: 0; display: flex; align-items: center; justify-content: center; background: #0008; font-size: 1.6rem; font-weight: 800; text-align: center; }
#pausedVeil small { font-size: .95rem; font-weight: 500; color: #ccd; }

.live { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.lv { background: var(--card); border-radius: 10px; padding: 6px 8px; display: flex; flex-direction: column; min-width: 0; }
.lv span { font-size: .72rem; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.lv b { font-size: 1.12rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.live-sub { font-size: .85rem; color: var(--dim); margin-top: 6px; text-align: center; min-height: 1.2em; }

/* night P&L */
.pnl-h { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 2px 8px; }
.pnl-h h2 { font-size: 1.2rem; }
.pnl-h span { color: var(--dim); font-size: .92rem; }
.pnl-top { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 10px 12px; border: 1px solid var(--line); }
.kpi span { display: block; font-size: .8rem; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }
.kpi b { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.kpi small { display: block; color: var(--dim); font-size: .85rem; }
.driver { margin-top: 10px; padding: 14px 14px 14px 16px; border-radius: var(--r); background: #2a2516; border: 1px solid #806b2a; font-size: 1.16rem; line-height: 1.38; font-weight: 600; position: relative; }
.driver::before { content: "Why today went this way"; display: block; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); margin-bottom: 4px; font-weight: 700; }
.driver.badday { background: #2e1a1a; border-color: #8b3a34; }
.driver.badday::before { color: #ff9a8f; }
.billbox { margin-top: 10px; padding: 10px 12px; border-radius: var(--r); background: #1f2433; border: 1px solid #47507a; font-size: .95rem; }
.billbox.over { background: #3a1a1a; border-color: var(--bad); }
.sec { margin-top: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
.sec h3 { margin: 0 0 6px; font-size: .86rem; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); display: flex; justify-content: space-between; }
.sec h3 b { color: var(--ink); font-size: 1rem; letter-spacing: 0; text-transform: none; }
.ln { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; font-size: .95rem; font-variant-numeric: tabular-nums; }
.ln span:first-child { color: var(--dim); }
.ln.tot { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; font-weight: 700; }
.ln.tot span:first-child { color: var(--ink); }
.ln small { color: var(--faint); font-size: .8rem; }
.recap-k { margin: 8px 0 2px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); }
.recap-note { margin: 8px 0 0; font-size: .85rem; color: var(--dim); line-height: 1.35; }
.neg { color: var(--bad); } .pos { color: var(--good); }
.repl { font-size: .88rem; color: var(--dim); margin-top: 4px; }
.spark { display: block; width: 100%; height: 56px; margin-top: 6px; }

/* end */
.end-hero { text-align: center; padding: 14px 6px 4px; }
.grade { font: 900 5.2rem/1 system-ui, sans-serif; color: var(--accent); text-shadow: 0 0 30px #ffb02055; }
.grade.F { color: var(--bad); text-shadow: 0 0 30px #ff6b5e55; }
.end-hero h2 { font-size: 1.4rem; margin-top: 6px; }
.end-hero p { color: var(--dim); margin: 6px 0; }
.share { width: 100%; min-height: 150px; margin-top: 10px; background: #0d0f13; color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font: .95rem/1.35 ui-monospace, Consolas, monospace; resize: none; }
.end-btns { display: grid; gap: 10px; margin: 12px 0 20px; }
.tip { text-align: center; margin: 4px 0 26px; font-size: .9rem; }
.tip a { color: var(--dim); }

/* modal */
.modal { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; padding: 14px; z-index: 50; }
.modal-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 18px; max-width: 560px; width: 100%; max-height: 92dvh; overflow-y: auto; padding: 16px; }
.help { padding-left: 18px; margin: 10px 0 14px; display: grid; gap: 8px; font-size: .95rem; color: var(--dim); }
.help b { color: var(--ink); }

.daylog { display: none; }
@media (min-width: 900px) { .daylog { display: block; } }
#lvLog { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 4px; font-size: .92rem; color: var(--dim); }
#lvLog li b { color: var(--ink); font-variant-numeric: tabular-nums; margin-right: 6px; }
#lvLog li.bad { color: #ffb3ab; } #lvLog li.war { color: var(--bad); font-weight: 700; } #lvLog li.tanker { color: #b8f0cc; }

.nm small.deal { color: var(--warn); font-weight: 700; }
