/* =====================================================================
   Owner analytics dashboard (templates/analytics/).

   Brewing Tree's dashboard is the standard (Will, 2026-11-03): this is its
   layout — dark brand header, sections under a rule, white stat cards,
   pill toggles, the stacked trend chart, the weekly quarter table, the
   story callout — re-expressed in Basics' own "Lavender & Shutter" tokens.

   STANDALONE: the dashboard loads neither site.css nor theme-soft.css, so
   it never wears the public site's chrome or follows the session's look.
   The token values below are copied from static/css/site.css, which stays
   the source of truth — keep them in step. House discipline holds here
   too: lavender + teal carry the page, sun-yellow is one small highlight
   (the story), door-red is not used.

   Chart colours are set in apps/core/analytics.py (CLIENT.register_colors)
   and validated there; text never wears the data colour.
   ===================================================================== */

:root {
  --cream: #FAF6EC;
  --paper: #FFFDF6;
  --ink: #33302A;
  --ink-soft: #5C564A;
  --lavender: #6B5FA0;
  --lavender-deep: #5C5384;
  --lavender-tint: #E3DFF0;
  --lavender-wash: #F1EEF8;
  --shutter: #2E8B84;
  --shutter-deep: #1F6660;
  --shutter-tint: #D3E8E4;
  --sun: #E9B84C;
  --sun-tint: #F7E9C8;
  --footer-ink: #22423F;
  --footer-soft: #B9CFCA;
  --hairline: #E7E0D0;
  --focus: #5C5384;
  --focus-dark: #FAF6EC;
  --display: "Young Serif", "Iowan Old Style", Georgia, serif;
  --body: "Karla", "Avenir Next", "Segoe UI", Arial, sans-serif;
  --radius: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: var(--body); color: var(--ink); background: var(--hairline);
  line-height: 1.5; -webkit-font-smoothing: antialiased; font-size: 15px;
}
a { color: var(--lavender-deep); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap {
  max-width: 1024px; margin: 0 auto; background: var(--cream); min-height: 100vh;
  box-shadow: 0 0 40px rgba(51, 48, 42, .06);
}

/* ---------- header ---------- */
.head {
  background: var(--footer-ink); color: var(--cream); padding: 26px 32px;
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; }
.brand-word {
  font-family: var(--display); font-size: 30px; line-height: 1.05; color: var(--cream);
  letter-spacing: .005em; white-space: nowrap;
}
.brand-sub {
  font-weight: 700; font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--footer-soft); margin-top: 6px;
}
.head .doc { text-align: right; }
.head :focus-visible { outline-color: var(--focus-dark); }
.kick {
  font-size: 10.5px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase;
  color: var(--footer-soft);
}
.head h1 { font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1.1; margin-top: 3px; }
.head .meta { font-size: 13px; color: var(--footer-soft); margin-top: 6px; }
.signout { margin-top: 6px; }
.signout button {
  background: none; border: 0; padding: 0; color: var(--footer-soft); font: inherit;
  font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.signout button:hover { color: var(--cream); }

/* ---------- body & sections ---------- */
.body { padding: 24px 32px 8px; }
.sec { margin-bottom: 32px; }
.sec-h {
  display: flex; align-items: baseline; gap: .2rem .8rem; flex-wrap: wrap;
  border-bottom: 3px double var(--shutter); padding-bottom: 6px; margin-bottom: 14px;
}
.sec-h h2 { font-family: var(--display); font-weight: 400; font-size: 21px; color: var(--lavender-deep); }
.sec-h .win { font-size: 12.5px; color: var(--ink-soft); margin-left: auto; }

.stats { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat {
  border: 2px solid var(--lavender-tint); border-radius: var(--radius);
  padding: 12px 14px; background: var(--paper); min-width: 0;
}
.stat.muted { opacity: .6; }
.s-val {
  font-family: var(--display); font-size: 26px; line-height: 1.05; color: var(--ink);
  overflow-wrap: anywhere;
}
.s-lbl {
  font-size: 11px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase;
  letter-spacing: .08em; margin-top: 7px;
}
.s-delta { font-size: 12.5px; font-weight: 700; margin-top: 4px; }
.s-delta.up { color: var(--shutter-deep); }
.s-delta.down { color: var(--lavender-deep); }
.s-delta.flat { color: var(--ink-soft); }
.s-delta.inline { display: inline; margin: 0; }
.s-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; }

.lists { display: grid; gap: 1.4rem; grid-template-columns: 1fr 1fr; margin-top: 18px; }
.lists h3, .q-weeks h3, .tips-h h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--shutter-deep); font-weight: 700; margin-bottom: 7px;
}
.lists > * { min-width: 0; }
.lists ul { list-style: none; }
.lists li {
  display: flex; justify-content: space-between; gap: .6rem; font-size: 14px;
  padding: 6px 0; border-bottom: 1px solid var(--hairline);
}
.l-name { color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.l-name a { color: var(--ink-soft); text-decoration: none; }
.l-name a:hover { color: var(--lavender-deep); text-decoration: underline; }
.l-val { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink); }
.l-sub { font-size: 12.5px; color: var(--ink-soft); }
.q-events summary { cursor: pointer; font-size: 14px; margin: 2px 0 8px; color: var(--lavender-deep); }

.note { font-size: 12.5px; color: var(--ink-soft); margin: 10px 0 0; max-width: 72ch; }

.highlight {
  background: var(--sun-tint); border-left: 4px solid var(--sun);
  border-radius: 0 var(--radius) var(--radius) 0; padding: 14px 18px; margin: 6px 0 24px;
}
.highlight .h { font-family: var(--display); font-size: 17px; color: var(--lavender-deep); margin-bottom: 4px; }
.highlight p { font-size: 14.5px; color: var(--ink); }

.empty { padding: 64px 32px; text-align: center; color: var(--ink-soft); }
.empty-h { font-family: var(--display); font-size: 24px; color: var(--lavender-deep); margin-bottom: 8px; }

.foot {
  padding: 16px 32px 28px; border-top: 3px double var(--shutter-tint);
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-soft);
}
.foot .b { font-family: var(--display); color: var(--lavender-deep); font-size: 14px; }

/* ---------- pill toggles: pure radio + CSS, no JS ---------- */
.pradio { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.period-tabs, .tr-scope { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tr-scope { margin-bottom: 8px; }
.ptab {
  font-size: 13px; font-weight: 700; color: var(--ink-soft); background: var(--paper);
  border: 2px solid var(--lavender-tint); border-radius: 999px; padding: 5px 15px;
  cursor: pointer; user-select: none; min-height: 34px; display: inline-flex; align-items: center;
}
.ptab:hover { border-color: var(--lavender); }
.ppanel { display: none; }
#sp-day:checked ~ .s-panels .ppanel[data-k="day"],
#sp-wtd:checked ~ .s-panels .ppanel[data-k="wtd"],
#sp-mtd:checked ~ .s-panels .ppanel[data-k="mtd"],
#sp-qtd:checked ~ .s-panels .ppanel[data-k="qtd"],
#sp-ytd:checked ~ .s-panels .ppanel[data-k="ytd"] { display: block; }
#sp-day:checked ~ .period-tabs label[for="sp-day"],
#sp-wtd:checked ~ .period-tabs label[for="sp-wtd"],
#sp-mtd:checked ~ .period-tabs label[for="sp-mtd"],
#sp-qtd:checked ~ .period-tabs label[for="sp-qtd"],
#sp-ytd:checked ~ .period-tabs label[for="sp-ytd"] {
  background: var(--lavender-deep); color: var(--paper); border-color: var(--lavender-deep);
}
#sp-day:focus-visible ~ .period-tabs label[for="sp-day"],
#sp-wtd:focus-visible ~ .period-tabs label[for="sp-wtd"],
#sp-mtd:focus-visible ~ .period-tabs label[for="sp-mtd"],
#sp-qtd:focus-visible ~ .period-tabs label[for="sp-qtd"],
#sp-ytd:focus-visible ~ .period-tabs label[for="sp-ytd"] { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------- revenue trend (inline SVG built in analytics.py) ---------- */
.tr-chart {
  border: 2px solid var(--lavender-tint); border-radius: var(--radius);
  background: var(--paper); padding: 10px 8px 4px;
}
.tr-chart svg {
  display: block; width: 100%; height: auto; font-family: var(--body);
  font-variant-numeric: tabular-nums;
}
.tr-narrow { display: none; }
.tr-legend {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  margin: 8px 4px 0; font-size: 12.5px; color: var(--ink-soft);
}
.tr-what { margin-left: auto; }
.tr-sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.tr-note { font-size: 12px; color: var(--ink-soft); margin: 4px 4px 0; }
.tr-table { margin: 8px 4px 0; font-size: 13px; }
.tr-table summary { cursor: pointer; color: var(--lavender-deep); font-weight: 700; }
.tr-table table { border-collapse: collapse; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tr-table th, .tr-table td { text-align: left; padding: 3px 18px 3px 0; border-bottom: 1px solid var(--hairline); }
.tr-table th:last-child, .tr-table td:last-child { text-align: right; padding-right: 0; }

/* ---------- tips (pearl#507) — inside the Sales section ---------- */
.tips { margin-top: 22px; }
.tips-h { display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap; margin-bottom: 8px; }
.tips-h h3 { margin-bottom: 0; }
.tips-asof { font-size: 12.5px; color: var(--ink-soft); margin-left: auto; }
.tips-win { margin-bottom: 14px; min-width: 0; }
/* One till: its two windows sit side by side, the way Brewing Tree's two
   tills do, rather than one card stretched across the page. */
.tips-wins.single { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.tips-wh { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.tips-mix { list-style: none; margin-top: 8px; border-top: 1px solid var(--hairline); padding-top: 5px; }
.tips-mix li { display: flex; justify-content: space-between; gap: .5rem; font-size: 12.5px; color: var(--ink-soft); padding: 1px 0; }
.tips-mix-v { font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- this quarter: weekly sales vs one and two years prior ---------- */
.q-weeks { margin-top: 18px; }
.q-weeks-scroll {
  overflow-x: auto; border: 2px solid var(--lavender-tint); border-radius: var(--radius);
  background: var(--paper);
}
.q-weeks table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.q-weeks th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft);
  font-weight: 700; text-align: right; padding: 9px 12px; border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.q-weeks th:first-child, .q-weeks td:first-child { text-align: left; }
.q-weeks td { padding: 7px 12px; border-bottom: 1px solid var(--hairline); text-align: right; white-space: nowrap; color: var(--ink); }
.q-weeks tr:last-child td { border-bottom: 0; }
.qw-mark { display: inline-block; font-size: 11.5px; color: var(--ink-soft); margin-left: 6px; }
.qw-delta { display: inline; margin: 0 0 0 5px; }
.qw-none { color: var(--ink-soft); }
.qw-foot { font-size: 12px; color: var(--ink-soft); margin: 6px 4px 0; }

/* ---------- sign-in ---------- */
body.signin {
  background: var(--footer-ink); min-height: 100vh; display: flex;
  align-items: center; justify-content: center; padding: 24px 16px;
}
.signin-card {
  background: var(--cream); border-radius: 16px; padding: 34px 32px; max-width: 380px;
  width: 100%; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.signin-card .brand-word { color: var(--ink); display: block; white-space: normal; }
.signin-card .brand-sub { display: block; color: var(--shutter-deep); }
.signin-card h1 { font-family: var(--display); font-weight: 400; font-size: 22px; color: var(--lavender-deep); margin-top: 22px; }
.signin-card p { font-size: 14px; color: var(--ink-soft); margin-top: 6px; }
.signin-card form { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; text-align: left; }
.signin-card label { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.signin-card input {
  padding: 12px 14px; border: 2px solid var(--lavender-tint); border-radius: var(--radius);
  font: inherit; font-size: 16px; background: var(--paper); color: var(--ink);
}
.signin-card input:focus { outline: none; border-color: var(--lavender); }
.signin-card button {
  padding: 12px; border: 0; border-radius: var(--radius); background: var(--shutter-deep);
  color: var(--paper); font: inherit; font-size: 15px; font-weight: 700; cursor: pointer;
}
.signin-card button:hover { background: var(--footer-ink); }
.signin-card .err { color: var(--lavender-deep); font-weight: 700; font-size: 13.5px; text-align: center; }

/* ---------- sample page (only when no snapshot can be read) ---------- */
.an-sample {
  border: 2px solid var(--lavender); border-radius: var(--radius); background: var(--lavender-wash);
  padding: 12px 16px; font-size: 14px; color: var(--ink); margin-bottom: 24px;
}
.an-sample strong { color: var(--lavender-deep); letter-spacing: .08em; }
.an-line { display: block; width: 100%; height: auto; }
.an-line-area { fill: var(--lavender); opacity: .12; }
.an-line-path { fill: none; stroke: var(--lavender); }
.an-line-dot { fill: var(--lavender); stroke: var(--paper); }
.an-line-value { fill: var(--ink); }
.an-line-label { fill: var(--ink-soft); }
.an-grid-2 { margin-top: 0; }
.an-wide { grid-column: 1 / -1; }
.an-hbar { display: grid; gap: 9px; margin-top: 10px; }
.an-hbar-row { display: grid; grid-template-columns: 11rem 1fr 2.8rem; align-items: center; gap: 10px; font-size: 14px; }
.an-hbar-track { background: var(--lavender-wash); border-radius: 3px; height: 14px; position: relative; }
.an-hbar-fill { position: absolute; inset: 0 auto 0 0; background: var(--lavender); border-radius: 3px 4px 4px 3px; min-width: 3px; }
.an-hbar-val { text-align: right; color: var(--ink); font-weight: 700; font-size: 13px; }
.an-hbar-label { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.an-preview .stat { border-style: dashed; }
.an-pending-badge { font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: 11px; color: var(--lavender-deep); }
.an-preview .highlight { margin-top: 16px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .head { padding: 20px 16px; }
  .head .doc { text-align: left; }
  .brand-word { font-size: 26px; }
  .body { padding: 18px 16px 4px; }
  .foot { padding: 16px 16px 24px; }
  .lists, .tips-wins.single { grid-template-columns: 1fr; }
  .lists li { flex-wrap: wrap; gap: 0 .6rem; }
  .l-name { white-space: normal; overflow-wrap: anywhere; }
  .l-val { margin-left: auto; }
  .sec-h .win { margin-left: 0; flex-basis: 100%; }
  .stats { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .an-hbar-row { grid-template-columns: 8rem 1fr 2.6rem; }
}
@media (max-width: 560px) {
  .tr-wide { display: none; }
  .tr-narrow { display: block; }
  .tr-what { margin-left: 0; }
}
