/* Biscuits Cafe · Performance — design system */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --border: #e6e8ec;
  --border-strong: #d3d7dd;
  --ink: #1a1d23;
  --ink-2: #545a63;
  --muted: #8a9099;
  --accent: #3b5bdb;
  --accent-ink: #ffffff;
  --up: #12805c;
  --down: #c0392b;
  --goal: #0ea54a;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 8px 24px rgba(16,24,40,.10);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1b1f26; --border: #262b33;
    --border-strong: #333a44; --ink: #eef1f5; --ink-2: #aeb6c1; --muted: #7d8590;
    --accent: #6b8afd; --accent-ink: #0f1115; --up: #34d399; --down: #f87171; --goal: #2fd873;
    --shadow: none; --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
  }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; --bg:#0f1115; --surface:#171a20; --surface-2:#1b1f26; --border:#262b33; --border-strong:#333a44; --ink:#eef1f5; --ink-2:#aeb6c1; --muted:#7d8590; --accent:#6b8afd; --accent-ink:#0f1115; --up:#34d399; --down:#f87171; --goal:#2fd873; --shadow:none; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--sans); background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.02rem; }

/* Boot spinner */
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 50; }
.spinner { width: 22px; height: 22px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Brand mark */
.brand-mark { display: inline-flex; align-items: center; gap: .5rem; font-weight: 650; letter-spacing: -.01em; }
.brand-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
/* Per-client logo (white-label). Single-color logos flip to white in dark mode. */
.brand-logo { height: 26px; width: auto; display: block; }
#login-logo { height: 40px; }
:root[data-theme="dark"] .brand-logo { filter: brightness(0) invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-logo { filter: brightness(0) invert(1); } }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin-top: 6px; }
.login-card p { margin: 0; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; color: var(--ink-2); font-weight: 550; }
.login-card input { font: inherit; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.login-foot { text-align: center; margin-top: 18px; font-size: .8rem; }
.error { color: var(--down); font-size: .82rem; margin: 0; }
.notice { font-size: .82rem; margin: 0; }
.linklike { background: none; border: none; padding: 0; margin: -4px 0 0; color: var(--accent); font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer; align-self: flex-start; }
.linklike:hover { text-decoration: underline; }

/* Buttons */
.btn { font: inherit; font-weight: 600; padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid transparent; cursor: pointer; transition: background .12s, border-color .12s; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

/* Topbar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 24px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--border); }
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.topbar-sub { color: var(--muted); font-size: .82rem; font-weight: 550; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-right #user-email { font-size: .82rem; }
.select-wrap select { font: inherit; font-weight: 550; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--ink); }

/* Segmented control */
.seg { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg-btn { font: inherit; font-weight: 600; font-size: .82rem; padding: 5px 12px; border: none; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer; }
.seg-btn[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.seg-btn:hover:not([aria-selected="true"]) { color: var(--ink); }

/* Control bar (date range / comparison / brand) */
.controlbar { position: sticky; top: 53px; z-index: 9; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--border); }
.controlbar-inner { max-width: 1160px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.ctrl { display: inline-flex; align-items: center; gap: 8px; }
.ctrl-right { margin-left: auto; }
.ctrl-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.date-field { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--ink-2); font-weight: 550; }
.date-field input { font: inherit; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink); }
.date-field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }

/* Subheads inside sections */
.subhead { margin: 6px 0 0; font-size: .92rem; font-weight: 620; letter-spacing: -.01em; }

/* Alerts / opportunities */
.alerts { display: flex; flex-direction: column; gap: 8px; }
.alert { display: flex; align-items: flex-start; gap: 11px; background: var(--surface); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 12px 14px; }
.alert.warn { border-left-color: var(--down); }
.alert.good { border-left-color: var(--up); }
.alert.info { border-left-color: var(--accent); }
.alert-icon { font-size: .9rem; line-height: 1.5; }
.alert.warn .alert-icon { color: var(--down); }
.alert.good .alert-icon { color: var(--up); }
.alert.info .alert-icon { color: var(--accent); }
.alert-body { display: flex; flex-direction: column; gap: 1px; }
.alert-title { font-weight: 620; font-size: .88rem; }
.alert-detail { font-size: .8rem; color: var(--ink-2); }

/* Post activity feed */
.posts-feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.post-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 15px; display: flex; flex-direction: column; gap: 9px; }
.post-thumb { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-sm); background: var(--surface-2); display: block; }
.post-meta { display: flex; align-items: center; gap: 8px; font-size: .74rem; color: var(--muted); }
.post-date { font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.post-loc { margin-left: auto; text-align: right; }
.post-status { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 999px; background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.post-status.scheduled { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.post-text { font-size: .85rem; line-height: 1.5; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.post-link { font-size: .76rem; font-weight: 600; color: var(--accent); text-decoration: none; align-self: flex-start; }
.post-link:hover { text-decoration: underline; }

/* Horizontal comparison bars */
#loc-bars-card { padding-top: 12px; }
.chart .hbar { fill: var(--accent); opacity: .85; }
.chart .hbar-label { fill: var(--ink-2); font-size: 11px; }
.chart .hbar-val { fill: var(--ink); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* Chart */
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.chart-legend { display: flex; align-items: center; gap: 18px; font-size: .8rem; color: var(--ink-2); flex-wrap: wrap; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend #chart-range { margin-left: auto; }
.sw { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.sw-bar { background: var(--accent); height: 12px; width: 8px; border-radius: 2px; }
.sw-line { background: var(--ink-2); }
.sw-target { height: 0; width: 20px; border-top: 3px dashed var(--goal); border-radius: 0; }
.targets { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; font-size: .78rem; color: var(--ink-2); }
.targets strong { color: var(--ink); }
.targets .badge { font-weight: 650; padding: 2px 9px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.badge.good { background: color-mix(in srgb, var(--up) 16%, transparent); color: var(--up); }
.badge.bad { background: color-mix(in srgb, var(--down) 16%, transparent); color: var(--down); }
.targets .note { color: var(--muted); }
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--accent); opacity: .8; }
.chart .laborline { fill: none; stroke: var(--ink-2); stroke-width: 2; }
.chart .target-halo { fill: none; stroke: var(--goal); stroke-width: 8; opacity: .16; stroke-linecap: round; }
.chart .target { fill: none; stroke: var(--goal); stroke-width: 3; stroke-dasharray: 8 4; opacity: 1; stroke-linecap: round; }
.chart .target-label { fill: var(--goal); font-size: 10px; font-weight: 700; }
.chart .dot.ok { fill: var(--up); }
.chart .dot.over { fill: var(--down); }
.chart .grid { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.scorecard td.over { color: var(--down); font-weight: 650; }
.scorecard td.under { color: var(--up); }

/* Banner */
.banner { margin: 0; padding: 8px 24px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--ink-2); font-size: .8rem; border-bottom: 1px solid var(--border); text-align: center; }

/* Content */
.content { max-width: 1160px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 28px; }
.section { display: flex; flex-direction: column; gap: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pill { font-size: .78rem; padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }

/* KPI grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; }
.kpi .label { font-size: .78rem; color: var(--muted); font-weight: 550; }
.kpi .value { font-size: 1.6rem; font-weight: 680; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .value.na { color: var(--muted); font-weight: 500; font-size: 1.1rem; }
.kpi .delta { font-size: .8rem; font-weight: 600; font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 4px; }
.kpi .delta.up { color: var(--up); } .kpi .delta.down { color: var(--down); } .kpi .delta.flat { color: var(--muted); }
.kpi .src { font-size: .72rem; color: var(--muted); }

/* Theme toggle */
.theme-toggle { padding: 7px 10px; line-height: 1; font-size: .95rem; }

/* Hero — yesterday's labor % (Kyle's primary metric) */
.hero { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.hero-primary { display: flex; flex-direction: column; gap: 5px; }
.hero-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.hero-label strong { color: var(--ink-2); }
.hero-value { font-size: 2.7rem; font-weight: 720; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.hero-value.over { color: var(--down); } .hero-value.under { color: var(--up); }
.hero-value.na { color: var(--muted); font-size: 1.4rem; font-weight: 500; }
.hero-sub { font-size: .84rem; color: var(--ink-2); font-weight: 550; }
.hero-stats { display: flex; gap: 26px; flex-wrap: wrap; }
.hero-stat { display: flex; flex-direction: column; gap: 3px; }
.hero-stat-label { font-size: .74rem; color: var(--muted); font-weight: 550; }
.hero-stat-val { font-size: 1.2rem; font-weight: 680; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .hero-value { font-size: 2.2rem; } .hero-stats { gap: 18px; } }

/* Tabs */
.tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.tab { font: inherit; font-weight: 600; font-size: .82rem; padding: 5px 14px; border: none; border-radius: 999px; background: transparent; color: var(--ink-2); cursor: pointer; }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* Scorecard */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto; }
table.scorecard { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.scorecard th, .scorecard td { padding: 12px 16px; text-align: left; white-space: nowrap; }
.scorecard thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); background: var(--surface-2); position: sticky; top: 0; }
.scorecard th.num, .scorecard td.num { text-align: right; }
.scorecard th.sortable { cursor: pointer; user-select: none; }
.scorecard th.sortable:hover { color: var(--ink-2); }
.scorecard th[aria-sort] { color: var(--ink); }
.scorecard tbody tr { border-bottom: 1px solid var(--border); }
.scorecard tbody tr:last-child { border-bottom: none; }
.scorecard tbody tr:hover { background: var(--surface-2); }
.scorecard td .loc-name { font-weight: 600; }
.scorecard td .loc-brand { font-size: .74rem; color: var(--muted); }
.scorecard td.na { color: var(--muted); }
.tag { font-size: .68rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.tag.unmanaged { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--ink-2); }
.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-2); }
.fresh .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--up); }
.fresh.stale .dot { background: var(--muted); }
.empty { padding: 28px; text-align: center; }

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; } .content { padding: 16px; }
  .topbar-right #user-email { display: none; }
}
