/* Coastal Coffee sales dashboard. Light on phones by default, dark at night and on the HQ TV.
   Type: Barlow (roadside-sign letterforms, fitting for drive-thrus) with its semi-condensed cut for figures. */
:root {
  color-scheme: light;
  --page: #eef3f3;          /* sea fog */
  --surface: #fbfcfc;
  --surface-2: #e4ecee;
  --ink: #1f3b4d;           /* Coastal navy */
  --ink-2: #4c6474;
  --muted: #7d909b;
  --grid: #dde5e8;
  --axis: #c3d0d5;
  --ring: rgba(31, 59, 77, 0.12);
  --shop-0: #1a8db3;        /* Coquille - teal */
  --shop-1: #c08a1e;        /* Myrtle Point - gold */
  --shop-2: #b0457a;        /* North Bend - berry */
  --all: #1f3b4d;
  --up: #006300;
  --down: #b42318;
  --good: #0ca30c;
  --warn: #fab219;
  --usual: rgba(31, 59, 77, 0.10);
  --usual-line: rgba(31, 59, 77, 0.45);
  --radius: 14px;
  --sans: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --figs: 'Barlow Semi Condensed', 'Barlow', system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0c1820;
    --surface: #122230;
    --surface-2: #1b3142;
    --ink: #eaf1f3;
    --ink-2: #a9bdc6;
    --muted: #7d939e;
    --grid: #1f3546;
    --axis: #2d475a;
    --ring: rgba(255, 255, 255, 0.08);
    --shop-0: #1f9ac2;
    --shop-1: #b3821c;
    --shop-2: #d9649f;
    --all: #6fc3dd;
    --up: #3ccf4e;
    --down: #ff7b6b;
    --usual: rgba(169, 189, 198, 0.12);
    --usual-line: rgba(169, 189, 198, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c1820;
  --surface: #122230;
  --surface-2: #1b3142;
  --ink: #eaf1f3;
  --ink-2: #a9bdc6;
  --muted: #7d939e;
  --grid: #1f3546;
  --axis: #2d475a;
  --ring: rgba(255, 255, 255, 0.08);
  --shop-0: #1f9ac2;
  --shop-1: #b3821c;
  --shop-2: #d9649f;
  --all: #6fc3dd;
  --up: #3ccf4e;
  --down: #ff7b6b;
  --usual: rgba(169, 189, 198, 0.12);
  --usual-line: rgba(169, 189, 198, 0.55);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 400 16px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--shop-0); outline-offset: 2px; border-radius: 6px; }
.app { max-width: 1240px; margin: 0 auto; padding: 18px 16px 48px; }
.boot { padding: 30vh 0; text-align: center; color: var(--muted); }
.fig { font-family: var(--figs); font-weight: 600; letter-spacing: -0.01em; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- Top bar ---------- */
.top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; text-decoration: none; color: inherit; }
.brand img { width: 40px; height: 40px; border-radius: 50%; background: #fff; object-fit: contain; box-shadow: 0 0 0 1px var(--ring); }
.brand b { font: 600 19px/1.1 var(--figs); display: block; }
.brand span { font-size: 13px; color: var(--ink-2); }
.stamp { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.5); animation: pulse 2.4s infinite; }
.dot.stale { background: var(--warn); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0.45); } 70% { box-shadow: 0 0 0 8px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }
@media (prefers-reduced-motion: reduce) { .dot { animation: none; } }
.btn {
  border: 1px solid var(--axis); background: var(--surface); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; font-weight: 500; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }

/* ---------- Day headline ---------- */
.day { margin: 26px 0 22px; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 32px; align-items: end; }
.day h1 { margin: 0; font: 600 15px/1.2 var(--sans); color: var(--ink-2); }
.day .total { font: 700 clamp(56px, 11vw, 96px)/0.95 var(--figs); letter-spacing: -0.02em; margin: 6px 0 0; }
.day .sub { color: var(--ink-2); font-size: 15px; margin-top: 10px; }
.day .sub b { color: var(--ink); font-weight: 600; }
.projbox { text-align: right; padding-bottom: 6px; }
.projbox .lbl { font-size: 14px; color: var(--ink-2); }
.projbox .val { font: 600 40px/1 var(--figs); margin-top: 4px; }
.projbox .pace { margin-top: 10px; justify-content: flex-end; }
@media (max-width: 640px) {
  .day { grid-template-columns: 1fr; }
  .projbox { text-align: left; }
  .projbox .pace { justify-content: flex-start; }
}

/* Pace chip: icon + words, never color alone */
.pace { display: flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.pace i { font-style: normal; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; font-size: 11px; color: #fff; background: var(--muted); }
.pace.ahead i { background: var(--good); }
.pace.behind i { background: var(--warn); color: #1f2a30; }
.pace b { color: var(--ink); font-weight: 600; }

/* ---------- Shop cards ---------- */
.shops { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .shops { grid-template-columns: 1fr; } }
.shop {
  background: var(--surface); border-radius: var(--radius); padding: 18px 18px 12px;
  box-shadow: 0 0 0 1px var(--ring); position: relative; overflow: hidden;
}
.shop::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.shop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.shop h2 { margin: 0; font: 600 21px/1.1 var(--figs); }
.status { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.status.closed { color: var(--muted); }
.shop .amt { font: 700 46px/1 var(--figs); margin: 12px 0 2px; letter-spacing: -0.015em; }
.shop .meta { font-size: 14px; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.shop .meta b { color: var(--ink); font-weight: 600; }
.merch { font-size: 13px; color: var(--muted); margin-top: 6px; }
.meter { margin: 14px 0 6px; }
.meter .track { position: relative; height: 8px; border-radius: 4px; background: var(--surface-2); }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--c); }
.meter .notch { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.meter .cap { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin-top: 7px; gap: 8px; }
.meter .cap b { color: var(--ink); font-weight: 600; }
.shop .pace { margin: 10px 0 4px; }
.mini { margin-top: auto; padding-top: 8px; }
.crew { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--grid); font-size: 13px; color: var(--ink-2); }
.team .row, .labor { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.team .lbl, .labor .lbl { color: var(--muted); min-width: 74px; }
.team .who b { color: var(--ink); font-weight: 600; }
.muted { color: var(--muted); }
.lab { display: inline-flex; align-items: center; gap: 5px; color: var(--ink-2); }
.lab i { font-style: normal; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; font-size: 9px; color: #fff; background: var(--good); }
.lab.over i { background: var(--warn); color: #1f2a30; }
.lab b { color: var(--ink); font-weight: 600; }
.shop { display: flex; flex-direction: column; }

/* ---------- Panels ---------- */
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--ring); padding: 18px; margin-top: 18px; }
.panel-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.panel h2 { margin: 0 auto 0 0; font: 600 22px/1.15 var(--figs); }
.panel .note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 13px; font-size: 14px; font-weight: 500; cursor: pointer; color: var(--ink-2); display: inline-flex; align-items: center; gap: 7px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--ring); }
.seg .sw { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 12px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin: 4px 0 6px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.key-bar { width: 12px; height: 12px; border-radius: 3px 3px 0 0; background: var(--c); }
.key-bar.partial { opacity: 0.45; }
.key-tide { width: 18px; height: 12px; border-radius: 2px; background: var(--usual); border-top: 2px solid var(--usual-line); }
.key-tick { width: 16px; height: 2px; background: var(--ink); }
.key-line { width: 18px; height: 2px; background: var(--c); border-radius: 1px; }
.key-line.muted { background: var(--muted); }

svg.chart { display: block; width: 100%; overflow: visible; }
svg.chart text { font: 500 12px var(--sans); fill: var(--muted); font-variant-numeric: tabular-nums; }
svg.chart .grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
svg.chart .tide { fill: var(--usual); stroke: none; }
svg.chart .tide-line { fill: none; stroke: var(--usual-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .now { stroke: var(--ink); stroke-width: 1.5; }
svg.chart .now-lbl { fill: var(--ink); font-weight: 600; }
svg.chart .bar { transition: opacity .15s; }
svg.chart .hit { fill: transparent; cursor: default; }
svg.chart .hit:hover + .bar, svg.chart .bar.hl { opacity: 0.78; }
svg.chart .tick { stroke: var(--ink); stroke-width: 2; stroke-linecap: round; }
svg.chart .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
svg.chart .cross { stroke: var(--axis); stroke-width: 1; }
svg.chart .val { fill: var(--ink-2); font-weight: 600; }

/* ---------- Table ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 15px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-size: 13px; font-weight: 500; color: var(--ink-2); }
th:first-child, td:first-child { text-align: left; }
td .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--c); margin-right: 8px; vertical-align: 0; }
td b { font-weight: 600; font-variant-numeric: tabular-nums; }
tr.total td { border-bottom: 0; font-weight: 600; }
.delta { font-size: 13px; margin-left: 6px; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.na { color: var(--muted); }

.banner { margin-top: 16px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); font-size: 14px; }
.banner.err { background: rgba(180, 35, 24, 0.12); color: var(--ink); }

/* ---------- Tooltip ---------- */
.tip {
  position: fixed; z-index: 50; pointer-events: none; min-width: 150px; max-width: 260px;
  background: var(--surface); color: var(--ink); border-radius: 10px; padding: 10px 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22), 0 0 0 1px var(--ring); font-size: 13px;
}
.tip .t { color: var(--ink-2); margin-bottom: 6px; }
.tip .r { display: flex; align-items: center; gap: 8px; margin-top: 3px; }
.tip .r i { width: 12px; height: 2px; background: var(--c); border-radius: 1px; flex: none; }
.tip .r b { font: 600 16px var(--figs); margin-right: auto; }
.tip .r span { color: var(--ink-2); }

/* ---------- Code screen ---------- */
.gate { max-width: 360px; margin: 18vh auto 0; text-align: center; }
.gate img { width: 76px; height: 76px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 1px var(--ring); }
.gate h1 { font: 600 28px/1.15 var(--figs); margin: 16px 0 6px; }
.gate p { color: var(--ink-2); margin: 0 0 18px; }
.gate input {
  width: 100%; font: 600 26px var(--figs); text-align: center; letter-spacing: 0.2em;
  padding: 12px; border-radius: 12px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink);
}
.gate button { margin-top: 12px; width: 100%; padding: 13px; border-radius: 12px; border: 0; background: var(--ink); color: var(--page); font-weight: 600; font-size: 17px; cursor: pointer; }
.gate .err { color: var(--down); min-height: 22px; margin-top: 10px; font-size: 14px; }

/* ---------- HQ TV mode ---------- */
body.tv { overflow: hidden; height: 100vh; }
body.tv .app { transition: transform 2s ease; max-width: none; height: 100vh; padding: 2.2vh 2.2vw; display: grid; grid-template-rows: auto 1fr auto; gap: 2vh; }
.tv-top { display: flex; align-items: center; gap: 2vw; }
.tv-top .brand img { width: 5.2vh; height: 5.2vh; }
.tv-top .brand b { font-size: 3vh; }
.tv-top .brand span { font-size: 1.9vh; }
.tv-clock { font: 600 4.2vh/1 var(--figs); }
.tv-all { text-align: right; }
.tv-all .lbl { font-size: 1.9vh; color: var(--ink-2); }
.tv-all .val { font: 700 6.4vh/1 var(--figs); letter-spacing: -0.02em; }
.tv-all .p { font-size: 2vh; color: var(--ink-2); margin-top: .4vh; }
.tv-all .p b { color: var(--ink); }
.tv-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.6vw; min-height: 0; }
.tv-shop { background: var(--surface); border-radius: 1.6vh; box-shadow: 0 0 0 1px var(--ring); padding: 2.4vh 1.6vw 1.4vh; display: grid; grid-template-rows: auto auto auto auto 1fr auto auto; min-height: 0; position: relative; overflow: hidden; }
.tv-shop::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: .7vh; background: var(--c); }
.tv-shop h2 { margin: 0; font: 600 3.6vh/1.1 var(--figs); display: flex; justify-content: space-between; align-items: baseline; gap: 1vw; }
.tv-shop h2 .status { font: 500 1.8vh var(--sans); }
.tv-shop .amt { font: 700 11vh/1 var(--figs); letter-spacing: -0.025em; margin: 1.4vh 0 .4vh; }
.tv-shop .proj { font-size: 2.3vh; color: var(--ink-2); }
.tv-shop .proj b { color: var(--ink); font: 600 3vh var(--figs); }
.tv-shop .pace { font-size: 2.3vh; margin: 1.4vh 0 1vh; gap: .8vw; }
.tv-shop .pace i { width: 3.2vh; height: 3.2vh; font-size: 1.5vh; }
.tv-shop .chartbox { min-height: 0; position: relative; }
.tv-shop .chartbox svg { position: absolute; inset: 0; height: 100%; }
.tv-shop svg.chart text { font-size: 1.5vh; }
.tv-shop .foot { display: flex; justify-content: space-between; font-size: 1.9vh; color: var(--ink-2); padding-top: 1vh; gap: 1vw; }
.tv-shop .foot b { color: var(--ink); font-weight: 600; }
.tv-rotor { display: grid; margin-top: 1.2vh; border-top: 1px solid var(--grid); padding-top: 1.4vh; height: 19.5vh; overflow: hidden; }
.tv-rotor > * { grid-area: 1 / 1; transition: opacity .8s ease; opacity: 0; }
.tv-rotor > .on { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .tv-rotor > * { transition: none; } }
.tv-crew { font-size: 1.9vh; color: var(--ink-2); }
.tv-crew .team .row, .tv-crew .labor { gap: .6vh 1.2vw; margin-bottom: 1vh; }
.tv-crew .lbl { min-width: 7.5vw; }
.tv-crew .who b { font: 600 2.4vh var(--figs); color: var(--ink); }
.tv-crew .lab b { font: 600 2.6vh var(--figs); }
.tv-crew .lab i { width: 2.4vh; height: 2.4vh; font-size: 1.2vh; }
.tv-periods { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1vw; font-size: 1.7vh; color: var(--ink-2); }
.tv-periods .pl { display: block; }
.tv-periods b { display: block; font: 600 3.2vh/1.15 var(--figs); color: var(--ink); margin: .3vh 0 .2vh; }
.tv-periods .delta { font-size: 1.8vh; margin-left: 0; }
.tv-periods .vs { font-size: 1.5vh; color: var(--muted); }
.tv-strip { display: flex; justify-content: flex-end; padding-right: 9vw; font-size: 1.7vh; color: var(--ink-2); }
.tv-exit { position: fixed; right: 1.2vw; bottom: 1.2vh; opacity: 0; transition: opacity .3s; }
body.tv.awake .tv-exit { opacity: 1; }
body.tv { cursor: none; }
body.tv.awake { cursor: default; }

/* ---------- Background: slow ocean swell along the bottom (both views; a bit stronger on the TV) ---------- */
.app { position: relative; z-index: 1; }
.tip { z-index: 50; }
.sea { position: fixed; left: 0; right: 0; bottom: 0; height: 34vh; z-index: 0; pointer-events: none; overflow: hidden; }
.sea .wave { position: absolute; bottom: 0; left: 0; width: 200%; height: 100%; animation: swell linear infinite; }
.sea .wave path { fill: var(--shop-0); }
.sea .w1 { opacity: .05; animation-duration: 95s; }
.sea .w2 { opacity: .06; animation-duration: 70s; animation-direction: reverse; height: 82%; }
.sea .w3 { opacity: .08; animation-duration: 50s; height: 64%; }
body.tv .sea .w1 { opacity: .08; } body.tv .sea .w2 { opacity: .1; } body.tv .sea .w3 { opacity: .13; }
@keyframes swell { from { transform: translateX(0); } to { transform: translateX(-50%); } }
/* A new sale: the shop's total gives a quick glow. */
.amt.bump { animation: bump 1.4s ease-out; }
@keyframes bump { 0% { text-shadow: 0 0 0 transparent; } 25% { text-shadow: 0 0 24px var(--c); transform: scale(1.025); } 100% { text-shadow: 0 0 0 transparent; transform: none; } }
.amt { transform-origin: left center; }
@media (prefers-reduced-motion: reduce) { .sea .wave, .amt.bump { animation: none; } }

@media print { .btn, .seg, .sea { display: none; } }

/* ---------- Mix, weather, wins ---------- */
.mix .row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 6px; }
.mix .lbl { color: var(--muted); min-width: 74px; }
.mix b { color: var(--ink); font-weight: 600; }
.mix .delta { margin-left: 4px; }
.mix .sep { display: inline-block; width: 14px; }
.mix ol.top { margin: 0; padding-left: 18px; display: flex; flex-direction: column; align-items: flex-start; text-align: left; flex: 1; min-width: 0; gap: 2px; }
.wxrow { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.wx { white-space: nowrap; }
.tv-shop h2 .status { text-align: right; line-height: 1.35; }
.tv-crew .mix .row { gap: .6vh 1.2vw; margin-bottom: .7vh; }
.tv-crew .mix .lbl { min-width: 7.5vw; }
.tv-crew .mix b { font: 600 2.4vh var(--figs); }
.tv-crew .mix .delta { font-size: 1.8vh; }
.tv-crew .mix ol.top { flex-direction: row; flex-wrap: wrap; gap: .4vh 1.4vw; padding-left: 1.4vw; }
.tv-crew .mix ol.top b { font-size: 2.1vh; }
.win { display: flex; align-items: center; gap: 10px; margin: 16px 0 0; padding: 12px 16px; border-radius: 12px; background: var(--surface); box-shadow: 0 0 0 1px var(--ring), inset 4px 0 0 var(--c); font-size: 15px; color: var(--ink-2); }
.win i { font-style: normal; color: var(--warn); font-size: 18px; }
.win b { color: var(--ink); }
body.tv .app.has-wins { grid-template-rows: auto auto 1fr auto; }
.tv-wins { display: flex; gap: 1.6vw; }
.tv-wins .win { margin: 0; flex: 1; font-size: 2vh; padding: 1vh 1.2vw; animation: winglow 3s ease-in-out infinite; }
@keyframes winglow { 50% { box-shadow: 0 0 0 1px var(--ring), inset 6px 0 0 var(--c), 0 0 28px -6px var(--c); } }
@media (prefers-reduced-motion: reduce) { .tv-wins .win { animation: none; } }

/* Boost Back Office screen, shown full-screen on the TV now and then */
.boost { position: fixed; inset: 0; z-index: 40; background: #000; opacity: 0; visibility: hidden; transition: opacity 1s ease, visibility 0s linear 1s; }
.boost.show { opacity: 1; visibility: visible; transition: opacity 1s ease; }
.boost iframe { width: 100%; height: 100%; border: 0; display: block; }
