/* Posh Wash Stats. Brand: #38B6FF fills (navy text on it), #0A6FAE blue text on white, navy #0B1F33 text. */
:root {
  --blue: #38B6FF;
  --blue-ink: #0A6FAE;
  --blue-tint: #E9F6FF;
  --navy: #0B1F33;
  --text: #0B1F33;
  --muted: #51647A;
  --bg: #FFFFFF;
  --card: #F5F8FB;
  --line: #E1E8F0;
  --line-strong: #CBD6E2;
  --grey-series: #AEBBC8;
  --good: #1A7F4B;
  --bad: #B93A2E;
  --radius: 14px;
  --nav-w: 216px;
  --top-h: 65px;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; overflow-x: hidden; }
a { color: var(--blue-ink); }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue-ink); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--blue); color: var(--navy); padding: 8px 12px; border-radius: 8px; z-index: 100; font-weight: 600; }
.skip:focus { left: 8px; }

/* ---------- buttons & inputs ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 10px; padding: 9px 16px; background: var(--blue); color: var(--navy); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: #22A9F7; }
.btn.ghost { background: #fff; border: 1px solid var(--line-strong); color: var(--text); }
.btn.ghost:hover { border-color: var(--blue-ink); color: var(--blue-ink); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--blue-ink); font-weight: 600; cursor: pointer; text-decoration: underline; font-size: inherit; }
select, input[type=date], input[type=email], input[type=password] {
  font-size: 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--text); padding: 8px 12px; min-height: 38px;
}
select { appearance: none; -webkit-appearance: none; padding-right: 34px; font-weight: 500; cursor: pointer;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%230B1F33' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type=date] { min-width: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 500; user-select: none; white-space: nowrap; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; flex: none; transition: background .15s; }
.switch .track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(11, 31, 51, .25); transition: transform .15s; }
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--blue-ink); outline-offset: 2px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); grid-template-rows: auto 1fr; min-height: 100vh; }
.topbar {
  grid-column: 1 / -1; position: sticky; top: 0; z-index: 20; background: #fff;
  border-bottom: 1px solid var(--line); display: grid; grid-template-columns: calc(var(--nav-w) - 24px) minmax(0, 1fr) auto;
  grid-template-areas: "brand controls who"; align-items: center; gap: 12px 16px; padding: 12px 24px; min-height: var(--top-h);
}
.brand { grid-area: brand; display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--navy); }
.brand img { display: block; height: 32px; width: auto; }
.brand span { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; padding-left: 10px; border-left: 1px solid var(--line-strong); line-height: 22px; }
.controls { grid-area: controls; display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; min-width: 0; }
.custom { display: flex; align-items: center; gap: 8px; }
.custom[hidden] { display: none; }
.custom .to { color: var(--muted); font-size: 14px; }
.custom .btn { padding: 8px 14px; }
.who { grid-area: who; display: flex; align-items: center; justify-content: flex-end; gap: 14px; min-width: 0; font-size: 14px; }
.user { flex: 0 1 auto; min-width: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.logout { flex: none; font-weight: 600; white-space: nowrap; }
.mockpill { flex: none; background: #FFF3D6; color: #6B4500; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.mockpill[hidden] { display: none; }

.nav { grid-column: 1; grid-row: 2; position: sticky; top: var(--top-h); align-self: start; display: flex; flex-direction: column; gap: 4px; padding: 20px 12px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; font-size: 15px; }
.nav a:hover { background: var(--card); }
.nav a[aria-current=page] { background: var(--blue); color: var(--navy); font-weight: 600; }
.nav svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

main { grid-column: 2; grid-row: 2; min-width: 0; padding: 24px 32px 40px; max-width: 1400px; width: 100%; }
#main:focus { outline: none; } /* skip-link target; a 1000px focus ring helps no one */
.page-head { display: flex; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 24px; }
.range-text { margin: 0; color: var(--muted); font-size: 14px; font-weight: 500; }
.vsrange { color: var(--muted); font-weight: 400; }
.lede { margin: -6px 0 16px; color: var(--muted); font-size: 14px; }
.fresh { color: var(--muted); font-size: 12.5px; padding: 8px 2px 0; }

/* ---------- cards ---------- */
.card { background: var(--card); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 20px; min-width: 0; }
.card-head { margin-bottom: 14px; }
.card-head h2 { font-size: 16px; }
.card-head .hint { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }
.grid2 > .card { margin-bottom: 0; }
.foot { margin: 12px 0 0; color: var(--muted); font-size: 12.5px; }
.empty { color: var(--muted); text-align: center; padding: 20px 8px; margin: 0; }
.dim { color: var(--muted); font-weight: 400; }
.nd { color: var(--muted); cursor: help; }
.more { display: inline-block; margin-top: 14px; font-weight: 600; font-size: 14px; text-decoration: none; }
.more:hover { text-decoration: underline; }
.tag { display: inline-block; vertical-align: 1px; font-size: 11px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: #fff; border: 1px solid var(--line-strong); color: var(--muted); }
.ask-host { width: 100%; min-width: 0; }
.ask-missing { max-width: 560px; }
.ask-missing h2 { font-size: 17px; }
.ask-missing p { margin: 6px 0 16px; color: var(--muted); }
.banner { background: var(--blue-tint); color: var(--navy); border-radius: 12px; padding: 12px 16px; font-size: 14px; margin-bottom: 20px; }

/* ---------- KPI tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--card); border-radius: 12px; padding: 16px 18px; min-height: 108px; min-width: 0; }
.tile-label { font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-label[title] { cursor: help; }
.tile-value { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-err { margin-top: 10px; font-size: 13px; color: var(--bad); }
.delta { margin-top: 6px; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: help; }
.delta.good { color: var(--good); }
.delta.bad { color: var(--bad); }
.delta.neutral { color: var(--muted); }
.delta .vs { color: var(--muted); font-weight: 500; }

/* hero number inside a card */
.hero { display: flex; align-items: baseline; gap: 4px 10px; flex-wrap: wrap; }
.hero-v { font-size: 36px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
.hero-k { color: var(--muted); font-size: 14px; font-weight: 500; }
.hero-sub { margin-top: 8px; color: var(--muted); font-size: 13.5px; }
.card .delta { font-size: 13px; }
.mini .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.mini .card-head .hint { margin: 0; }

/* ---------- charts ---------- */
.chart { position: relative; height: 280px; width: 100%; margin-top: 4px; }
.chart.sm { height: 180px; margin-top: 16px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; }
.sw { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; }
.sw.line { width: 16px; height: 2px; border-radius: 1px; }
.sw.dash { width: 0; height: 12px; border-left: 1.5px dashed var(--navy); border-radius: 0; margin-left: 4px; margin-right: 9px; }
.sw.band { width: 14px; height: 12px; border-radius: 2px; border: 1px solid var(--line-strong); }
.sw.before { background: var(--grey-series); }
.sw.after { background: var(--blue); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -6px; padding: 0 6px; }
.tablewrap:focus-visible { outline-offset: -2px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
table.data th.txt, table.data td.txt { text-align: left; }
table.data td.txt:first-child { white-space: normal; min-width: 140px; max-width: 360px; overflow-wrap: anywhere; font-weight: 500; }
table.data th { padding-top: 0; font-size: 12px; }
table.data th button { background: none; border: 0; padding: 0; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
table.data th button:hover, table.data th[aria-sort=ascending] button, table.data th[aria-sort=descending] button { color: var(--navy); }
table.data th .arr { font-size: 9px; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: #EEF3F8; }
table.data td.empty { text-align: center; }

/* ---------- funnel ---------- */
.funnel { display: grid; gap: 4px; }
.f-row { display: grid; grid-template-columns: 170px minmax(0, 1fr) 84px 110px; gap: 14px; align-items: center; padding: 6px 0; font-size: 14px; }
.f-head { font-size: 12px; font-weight: 600; color: var(--muted); padding-top: 0; }
.f-label { font-weight: 500; }
.f-label sup { color: var(--muted); }
.f-bar { height: 24px; background: #E6EDF4; border-radius: 4px; overflow: hidden; }
.f-bar i { display: block; height: 100%; background: var(--blue); border-radius: 0 4px 4px 0; }
.f-n, .f-pct { text-align: right; font-variant-numeric: tabular-nums; }
.f-pct { font-weight: 600; }

/* ---------- before / after ---------- */
.ba { background: #fff; border: 1px solid var(--line); }
.ba-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 4px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--blue-ink); }
.ba-head h2 { font-size: 18px; margin-top: 2px; }
.ba-when { color: var(--muted); font-size: 13.5px; font-weight: 500; }
.ba-row { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, .9fr); gap: 16px 24px; align-items: start; padding: 18px 0 4px; border-top: 1px solid var(--line); margin-top: 14px; }
.ba-metric b { font-weight: 600; }
.ba-metric p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.ba-k { font-size: 12px; font-weight: 600; color: var(--muted); display: flex; align-items: center; flex-wrap: wrap; gap: 2px 6px; }
.ba-k .sw { margin-right: 0; }
.ba-k span { font-weight: 500; }
.ba-v { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; margin-top: 4px; white-space: nowrap; }
.ba-bar { height: 8px; border-radius: 4px; background: #EEF2F6; margin-top: 8px; overflow: hidden; }
.ba-bar i { display: block; height: 100%; border-radius: 4px; }
.before .ba-bar i { background: var(--grey-series); }
.after .ba-bar i { background: var(--blue); }
.ba-d { margin-top: 8px; color: var(--muted); font-size: 13px; }
.ba-change .ba-v { font-size: 22px; padding-top: 6px; }
.ba-change.good .ba-v { color: var(--good); }
.ba-change.bad .ba-v { color: var(--bad); }
.ba-change.neutral .ba-v { color: var(--muted); }
.ba-note { margin: 16px 0 0; background: #FFF6E0; color: #5C3D00; border-radius: 10px; padding: 10px 14px; font-size: 13.5px; font-weight: 500; }
.ba-sk { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }

/* ---------- loading / error ---------- */
.sk { background: #E4EAF1; border-radius: 6px; animation: pulse 1.4s ease-in-out infinite; }
.sk-chart { height: 260px; }
.sk-line { height: 12px; margin-top: 12px; }
.sk-row { height: 14px; margin-top: 14px; }
.sk-label { height: 12px; width: 55%; }
.sk-value { height: 26px; width: 70%; margin-top: 12px; }
.mini .sk-value { height: 36px; width: 40%; }
@keyframes pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }
.err { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; background: #FFF5F4; border: 1px solid #F2CDC8; border-radius: 10px; padding: 14px 16px; }
.err b { display: block; font-weight: 600; }
.err p { margin: 2px 0 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: var(--card); }
.login-page main { grid-column: auto; grid-row: auto; width: 100%; max-width: none; padding: 0; display: flex; justify-content: center; }
.login-card { width: 100%; max-width: 380px; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 32px 28px; display: grid; gap: 16px; }
.login-card img { height: 48px; width: auto; justify-self: center; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.login-card input[type=email], .login-card input[type=password] { width: 100%; font-size: 16px; padding: 11px 14px; min-height: 46px; }
.login-card input:focus-visible { outline: 2px solid var(--blue-ink); outline-offset: 1px; }
.login-card .btn { width: 100%; padding: 13px 16px; font-size: 15px; margin-top: 4px; }
.login-err { margin: 0; background: #FFF5F4; border: 1px solid #F2CDC8; color: #8A2A20; border-radius: 10px; padding: 10px 12px; font-size: 14px; font-weight: 500; }
.login-err[hidden] { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ba-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, .8fr); }
  .ba-metric { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .topbar { position: static; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "brand who" "controls controls"; }
  .nav { top: 12px; }
  .who { justify-self: stretch; }
}
@media (max-width: 760px) {
  :root { --radius: 12px; }
  .app { display: block; }
  .topbar { position: static; padding: 10px 16px 12px; gap: 10px 12px; }
  .brand { flex: none; }
  .brand img { height: 28px; }
  .who { gap: 10px; }
  .mockpill { padding: 2px 8px; font-size: 11px; }
  .brand span { font-size: 16px; padding-left: 8px; }
  .user { max-width: none; font-size: 13px; }
  .controls { gap: 10px; }
  .controls select { flex: 1 1 auto; min-width: 0; font-size: 16px; }
  .switch .long, .long-nav { display: none; }
  .custom { flex: 1 1 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; }
  .custom .to { display: none; }
  .custom input[type=date] { width: 100%; font-size: 16px; }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 30; flex-direction: row; gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, .98); border-top: 1px solid var(--line);
  }
  .nav a { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 7px 2px 6px; font-size: 11px; border-radius: 10px; text-align: center; line-height: 1.2; }
  .nav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  main { padding: 16px 16px calc(88px + env(safe-area-inset-bottom)); }
  .page-head h1 { font-size: 21px; }
  .card { padding: 16px; margin-bottom: 16px; }
  .grid2 { gap: 16px; margin-bottom: 16px; }
  .tiles { gap: 10px; margin-bottom: 16px; }
  .tile { padding: 13px 14px; min-height: 0; }
  .tile-value { font-size: 22px; }
  .delta { font-size: 12px; }
  .delta .vs { display: none; }
  .hero-v { font-size: 30px; }
  table.data { font-size: 13.5px; }
  table.data th, table.data td { padding: 8px 7px; }
  table.data td.txt:first-child { min-width: 96px; }
  .chart { height: 230px; }
  .chart.sm { height: 160px; }
  .f-row { grid-template-columns: minmax(0, 1fr) 64px 64px; gap: 4px 10px; }
  .f-row .f-bar { grid-column: 1 / -1; grid-row: 2; height: 18px; }
  .f-head > div:nth-child(2) { display: none; }
  .ba-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px 16px; }
  .ba-change { grid-column: 1 / -1; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
  .ba-change .ba-v { padding-top: 0; font-size: 20px; }
  .ba-change .ba-d { margin-top: 0; }
  .ba-v { font-size: 26px; }
}
@media (max-width: 380px) {
  .tile-value { font-size: 20px; }
  .ba-v { font-size: 22px; }
}
