/* ==========================================================================
   Mesa — Restaurant Analytics Dashboard Template
   Design tokens. Change the values here and the whole dashboard follows.
   ========================================================================== */

:root {
  color-scheme: light;

  /* --- surfaces & ink --- */
  --surface:        #fcfcfb;   /* cards, chart surface */
  --plane:          #f4f4f1;   /* page background */
  --sidebar:        #14140f;
  --sidebar-ink:    #e8e8e2;
  --sidebar-muted:  #8d8d84;

  --ink:            #0b0b0b;   /* primary text */
  --ink-2:          #52514e;   /* secondary text */
  --muted:          #898781;   /* axis labels, captions */
  --grid:           #e1e0d9;   /* hairline gridlines */
  --axis:           #c3c2b7;   /* baseline */
  --line:           rgba(11, 11, 11, .10);
  --line-2:         rgba(11, 11, 11, .16);
  --wash:           rgba(11, 11, 11, .04);

  /* --- categorical series (validated: adjacent CVD ΔE ≥ 8) --- */
  --s1: #2a78d6;  /* blue    */
  --s2: #eb6834;  /* orange  */
  --s3: #1baf7a;  /* aqua    */
  --s4: #eda100;  /* yellow  */
  --s5: #e87ba4;  /* magenta */
  --s6: #008300;  /* green   */
  --s7: #4a3aa7;  /* violet  */
  --s8: #e34948;  /* red     */

  /* --- sequential (single hue, light → dark) --- */
  --q1: #cde2fb; --q2: #b7d3f6; --q3: #9ec5f4; --q4: #86b6ef;
  --q5: #5598e7; --q6: #2a78d6; --q7: #1c5cab; --q8: #104281;

  /* --- status: always paired with an icon + label, never colour alone --- */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --good-ink: #006300;

  /* --- type --- */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 6px 20px rgba(11, 11, 11, .04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface:        #1a1a19;
    --plane:          #0d0d0d;
    --sidebar:        #000000;
    --sidebar-ink:    #e8e8e2;
    --sidebar-muted:  #7d7d76;

    --ink:            #ffffff;
    --ink-2:          #c3c2b7;
    --muted:          #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --line:           rgba(255, 255, 255, .10);
    --line-2:         rgba(255, 255, 255, .16);
    --wash:           rgba(255, 255, 255, .05);

    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;

    --q1: #104281; --q2: #1c5cab; --q3: #256abf; --q4: #2a78d6;
    --q5: #3987e5; --q6: #5598e7; --q7: #86b6ef; --q8: #b7d3f6;

    --good-ink: #0ca30c;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface:        #1a1a19;
  --plane:          #0d0d0d;
  --sidebar:        #000000;
  --sidebar-ink:    #e8e8e2;
  --sidebar-muted:  #7d7d76;

  --ink:            #ffffff;
  --ink-2:          #c3c2b7;
  --muted:          #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --line:           rgba(255, 255, 255, .10);
  --line-2:         rgba(255, 255, 255, .16);
  --wash:           rgba(255, 255, 255, .05);

  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;

  --q1: #104281; --q2: #1c5cab; --q3: #256abf; --q4: #2a78d6;
  --q5: #3987e5; --q6: #5598e7; --q7: #86b6ef; --q8: #b7d3f6;

  --good-ink: #0ca30c;
  --shadow: none;
}

/* ==========================================================================
   Base
   ========================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--s1);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   Shell: sidebar + main
   ========================================================================== */

.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px; flex: none;
  background: var(--sidebar-ink); color: var(--sidebar);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: -.02em;
}
.brand-name { font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--sidebar-muted); letter-spacing: .08em; text-transform: uppercase; }

.nav-group + .nav-group { margin-top: 20px; }
.nav-label {
  font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 0 8px; margin-bottom: 8px;
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 8px;
  color: var(--sidebar-muted); font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-ink); }
.nav a.is-active { background: rgba(255, 255, 255, .11); color: #fff; font-weight: 600; }
.nav svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; }

/* Pages that live in the full template. They stay in the nav so the free
   version still shows the whole shape of the product — dimmed, badged, and
   pointing at where to get them rather than at a 404. */
.nav a.is-locked { opacity: .5; }
.nav a.is-locked:hover { opacity: 1; }
.nav-pro {
  margin-left: auto; font-size: 9.5px; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase;
  padding: 2px 6px; border-radius: 5px;
  border: 1px solid currentColor; line-height: 1.5;
}

.sidebar-foot { margin-top: auto; font-size: 11.5px; color: var(--sidebar-muted); padding: 0 8px; }
.sidebar-foot a { color: var(--sidebar-ink); text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   Topbar
   ========================================================================== */

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 19px; font-weight: 650; letter-spacing: -.015em; margin: 0; }
.topbar .sub { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* .btn sets display later in this file, so the hide has to match its weight —
   plain `.burger` loses the cascade and the button shows up on desktop */
.btn.burger { display: none; }

/* filter row — one row above the charts */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.seg { display: flex; background: var(--wash); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: transparent; cursor: pointer;
  padding: 6px 12px; border-radius: 6px;
  font-size: 12.5px; font-weight: 550; color: var(--ink-2);
  transition: background .15s, color .15s;
}
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* compact variant for card headers */
.seg-sm { padding: 2px; }
.seg-sm button { padding: 4px 10px; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 8px 13px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 550;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--wash); }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn-icon { padding: 8px; }

/* ==========================================================================
   Content grid
   ========================================================================== */

.content { padding: 22px 26px 40px; display: flex; flex-direction: column; gap: 18px; }

.row { display: grid; gap: 18px; }
.row-4 { grid-template-columns: repeat(4, 1fr); }
.row-3 { grid-template-columns: repeat(3, 1fr); }
.row-2 { grid-template-columns: repeat(2, 1fr); }
.row-2-1 { grid-template-columns: 2fr 1fr; }
.row-1-2 { grid-template-columns: 1fr 2fr; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; margin: 0; }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-head .right { margin-left: auto; }

/* ==========================================================================
   Stat tiles
   ========================================================================== */

.stat .k {
  font-size: 11.5px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 600;
}
.stat .v {
  font-size: 30px; font-weight: 680; letter-spacing: -.025em;
  margin-top: 6px; line-height: 1.05;
}
.stat .foot { display: flex; align-items: center; gap: 8px; margin-top: 10px; }

.delta { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.delta svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2.2; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--critical); }
.delta-note { font-size: 12px; color: var(--muted); }

.spark { margin-top: 12px; height: 38px; }

/* ==========================================================================
   Charts
   ========================================================================== */

.chart { width: 100%; display: block; overflow: visible; }
.chart text { font-family: var(--sans); }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .tick-y { text-anchor: end; }
.chart .tick-x { text-anchor: middle; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chart .bar { rx: 4; }
.chart .bar-seg { stroke: var(--surface); stroke-width: 2; }
.chart .dot { stroke: var(--surface); stroke-width: 2; }
.chart .crosshair { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 3 3; }
/* the thread that carries the running total from one waterfall bar to the next */
.chart .wf-link { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 2 3; }
/* "today" on a timeline — the one line everything else is read against */
.chart .tl-now { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .value-label { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
/* latest value printed at the end of a line — carries the series colour on purpose,
   so the number and its line are tied together without a legend lookup */
.chart .end-label { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* tooltip */
.tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 8px;
  padding: 9px 11px; font-size: 12.5px; line-height: 1.45;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .10), 0 10px 28px rgba(0, 0, 0, .14);
  opacity: 0; transform: translateY(3px); transition: opacity .12s, transform .12s;
  min-width: 128px;
}
.tip.on { opacity: 1; transform: none; }
.tip .t-head { font-weight: 650; margin-bottom: 5px; }
.tip .t-row { display: flex; align-items: center; gap: 7px; }
.tip .t-row + .t-row { margin-top: 3px; }
.tip .t-sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.tip .t-name { color: var(--ink-2); }
.tip .t-val { margin-left: auto; font-weight: 650; font-variant-numeric: tabular-nums; }

/* heatmap */
.heat-grid { display: grid; grid-template-columns: 34px repeat(12, 1fr); gap: 3px; align-items: center; }
.heat-cell { aspect-ratio: 1 / 1; border-radius: 3px; cursor: pointer; transition: outline-color .12s; outline: 2px solid transparent; }
.heat-cell:hover { outline-color: var(--ink); }
.heat-lab { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.heat-scale { display: flex; align-items: center; gap: 7px; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.heat-scale .steps { display: flex; gap: 2px; }
.heat-scale .steps i { width: 17px; height: 9px; border-radius: 2px; display: block; }

/* ==========================================================================
   Table
   ========================================================================== */

/* A wide table scrolls inside its card. The two shadows below appear only when
   there is something left to scroll to and fade out at the ends — pure CSS:
   the covers scroll with the content ("local"), the shadows stay put. */
.table-wrap {
  overflow-x: auto;
  margin: 0 -20px -16px;
  padding: 0 20px;
  background:
    linear-gradient(to right, var(--surface) 60%, transparent) left center / 28px 100% no-repeat local,
    linear-gradient(to left,  var(--surface) 60%, transparent) right center / 28px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--line-2), transparent) left center / 12px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--line-2), transparent) right center / 12px 100% no-repeat scroll;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); font-weight: 650; padding: 0 12px 9px 0; white-space: nowrap;
}
tbody td { padding: 11px 12px 11px 0; border-top: 1px solid var(--line); white-space: nowrap; }
tbody tr:hover td { background: var(--wash); }
/* Right-aligned figures need a gutter on BOTH sides: without it the last number
   of one column sits flush against the heading of the next. */
.num { text-align: right; font-variant-numeric: tabular-nums; padding-left: 12px; }
.wrap-cell { white-space: normal; min-width: 210px; }
th.num, td.num { padding-right: 12px; }
th.num:last-child, td.num:last-child { padding-right: 0; }
/* a long first column is what pushes a comparison table off a phone screen;
   let it wrap and tighten the figure gutters instead of hiding the change column */
.key-cell { white-space: normal; }
/* P&L statement: subtotal rows stand out, cost lines sit under the line they reduce */
.pl-total td { font-weight: 700; }
.pl-total td:first-child { color: var(--ink); }
tbody tr.pl-total td { border-top: 1px solid var(--line-2); }
.pl-indent { padding-left: 16px; color: var(--ink-2); display: inline-block; }
@media (max-width: 560px) {
  table { font-size: 12px; }
  .num { padding-left: 9px; }
  th.num, td.num { padding-right: 9px; }
  .key-cell { min-width: 74px; }
}

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px 3px 7px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; border: 1px solid var(--line-2);
}
.pill i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.pill.ok     i { background: var(--good); }
.pill.wait   i { background: var(--warning); }
.pill.cancel i { background: var(--critical); }
/* change shown next to a figure inside a pill */
.pill b { font-weight: 700; }
.pill b.up   { color: var(--good-ink); }
.pill b.down { color: var(--critical); }

/* --- trend rows: small multiples, one sparkline per series --------------- */
.trend { display: flex; flex-direction: column; gap: 2px; margin-top: 4px; }
/* The sparkline column is the one that gives way, so the row survives a narrow card. */
.trend-row {
  display: grid;
  grid-template-columns: minmax(0, max-content) max-content minmax(34px, 1fr) max-content;
  align-items: center; gap: 10px;
  padding: 13px 2px; border-bottom: 1px solid var(--line);
}
.trend-row:last-child { border-bottom: 0; }
.trend-row.is-derived { border-top: 1px solid var(--line-2); margin-top: 2px; }
.trend-row .t-key {
  display: inline-flex; align-items: center; gap: 8px; min-width: 0;
  font-size: 13.5px; font-weight: 600; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.trend-row .t-key i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.trend-row .t-now {
  font-size: 19px; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em;
}
.trend-row .t-spark { min-width: 0; }
.trend-row.is-derived .t-key,
.trend-row.is-derived .t-now { color: var(--ink-2); }

@media (max-width: 420px) {
  .trend-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .trend-row .t-spark { grid-column: 1 / -1; }
}

/* ranked list */
.ranked { display: flex; flex-direction: column; gap: 13px; }
.ranked .item { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: baseline; }
.ranked .name { font-weight: 550; }
.ranked .val { font-variant-numeric: tabular-nums; font-weight: 650; }
.ranked .meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--wash); overflow: hidden; }
.ranked .meter span { display: block; height: 100%; border-radius: 3px; }
/* the quiet second line of a ranked row — units, par level, where it is stored */
.ranked .name em { font-style: normal; font-weight: 400; color: var(--muted); margin-left: 8px; font-size: 12px; }

/* ==========================================================================
   Forms, switches (settings page)
   ========================================================================== */

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field input, .field select {
  width: 100%; padding: 10px 12px; font: inherit; font-size: 13.5px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: 8px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--s1); box-shadow: 0 0 0 3px rgba(42, 120, 214, .16); }

.toggles { display: grid; }
.toggle-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 0; border-top: 1px solid var(--line);
}
.toggle-row:first-child { border-top: 0; padding-top: 0; }
.toggle-row .t-name { font-weight: 600; }
.toggle-row .card-sub { margin-top: 1px; }
.toggle-row .switch { margin-left: auto; }

.switch {
  width: 42px; height: 24px; flex: none; padding: 3px; cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--wash);
  transition: background .18s, border-color .18s;
}
.switch span {
  display: block; width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform .18s, background .18s;
}
.switch.on { background: var(--ink); border-color: var(--ink); }
.switch.on span { background: var(--surface); transform: translateX(18px); }

/* ==========================================================================
   Centred pages (login, 404)
   ========================================================================== */

.center-page {
  min-height: 100vh; display: grid; place-items: center;
  padding: 28px; background: var(--plane);
}
.center-card {
  width: 100%; max-width: 392px; text-align: left;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 28px; box-shadow: var(--shadow);
}
.center-card .brand { padding: 0; margin-bottom: 22px; }
.center-card h1 { font-size: 21px; font-weight: 680; letter-spacing: -.02em; margin: 0 0 5px; }
.center-card .lead { color: var(--muted); font-size: 13.5px; margin: 0 0 22px; }
.center-card .btn-primary {
  width: 100%; justify-content: center; margin-top: 4px;
  background: var(--ink); color: var(--surface); border-color: var(--ink);
}
.center-card .btn-primary:hover { opacity: .88; background: var(--ink); }
.center-foot { margin-top: 18px; font-size: 12.5px; color: var(--muted); text-align: center; }
.code-404 { font-size: 64px; font-weight: 700; letter-spacing: -.045em; line-height: 1; margin: 0 0 10px; }

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 1180px) {
  .row-4 { grid-template-columns: repeat(2, 1fr); }
  .row-3, .row-2-1, .row-1-2 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 258px; z-index: 60;
    transform: translateX(-100%); transition: transform .22s ease;
  }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .42); z-index: 50;
  }
  .btn.burger { display: inline-flex; }
  .topbar { padding: 14px 18px; flex-wrap: wrap; }
  .content { padding: 18px 18px 36px; }
  .row-2 { grid-template-columns: 1fr; }
}

/* Topbar controls get their own full-width row once they stop fitting. */
@media (max-width: 680px) {
  .topbar { align-items: center; row-gap: 12px; }
  .topbar-actions { order: 3; width: 100%; margin-left: 0; }
  .filters { flex: 1; min-width: 0; }
  .seg { flex: 1; }
  .seg button { flex: 1; padding: 6px 4px; text-align: center; }
  .btn-label { display: none; }
  .btn { padding: 8px; }
}

@media (max-width: 560px) {
  .row-4 { grid-template-columns: 1fr; }
  .topbar h1 { font-size: 17px; }
  .stat .v { font-size: 26px; }
  .heat-grid { grid-template-columns: 28px repeat(12, 1fr); gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
