/* Design tokens - see references/palette.md in the dataviz skill for the
   source values. Dark mode follows the OS setting only (no in-app toggle). */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --status-good: #0ca30c;
  --status-warning: #fab219;
  --status-serious: #ec835a;
  --status-critical: #d03b3b;
  --zone-star: rgba(42, 120, 214, 0.06);
  --zone-plowhorse: rgba(235, 104, 52, 0.06);
  --zone-puzzle: rgba(27, 175, 122, 0.06);
  --zone-dog: rgba(137, 135, 129, 0.09);
  /* Sequential magnitude ramp (labor cost % heatmap) - one hue (--series-1),
     monotone alpha steps light -> dark. See the dataviz skill: a sequential
     ramp is judged on lightness monotonicity, not the categorical CVD
     checks, so this is validated by construction rather than the script. */
  --heat-1: rgba(42, 120, 214, 0.06);
  --heat-2: rgba(42, 120, 214, 0.16);
  --heat-3: rgba(42, 120, 214, 0.28);
  --heat-4: rgba(42, 120, 214, 0.42);
  --heat-5: rgba(42, 120, 214, 0.60);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0d0d0d;
    --surface: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #e66767;
    --zone-star: rgba(57, 135, 229, 0.10);
    --zone-plowhorse: rgba(217, 89, 38, 0.10);
    --zone-puzzle: rgba(25, 158, 112, 0.10);
    --zone-dog: rgba(137, 135, 129, 0.12);
    --heat-1: rgba(57, 135, 229, 0.12);
    --heat-2: rgba(57, 135, 229, 0.24);
    --heat-3: rgba(57, 135, 229, 0.38);
    --heat-4: rgba(57, 135, 229, 0.54);
    --heat-5: rgba(57, 135, 229, 0.72);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

a { color: var(--series-1); }

.page-shell {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}

section { margin-bottom: 32px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
}

.card + .card { margin-top: 16px; }

.grid-2 {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

h1, h2, h3 { font-weight: 650; margin: 0 0 8px; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }

.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gridline);
  font-variant-numeric: tabular-nums;
}

th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }

.table-scroll { overflow-x: auto; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.badge-flag {
  color: var(--status-critical);
  border-color: var(--status-critical);
}

.badge-good {
  color: var(--status-good);
  border-color: var(--status-good);
}

nav.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: relative;
  z-index: 100;
}

nav.topbar a { text-decoration: none; color: var(--text-secondary); font-size: 0.9rem; }
nav.topbar strong { color: var(--text-primary); }
nav.topbar .brand { flex: 0 0 auto; }

.nav-admin { flex: 0 0 auto; }
.nav-admin .link-btn {
  background: none; border: none; margin: 0; padding: 0; cursor: pointer;
  color: var(--text-secondary); font-size: 0.9rem; text-decoration: underline;
}
.inline-form { display: inline; }

/* Nested flyout menu: top level opens below the nav; each deeper level
   opens as a flyout to the right of its parent item. */
.menu {
  list-style: none;
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
}

.menu-item { position: relative; }

.menu-label {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}

.menu-item.disabled .menu-label { color: var(--text-muted); cursor: default; opacity: 0.65; }

.menu-item > .submenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 230px;
  margin: 4px 0 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16);
}

.menu-item .menu-item > .submenu { top: -7px; left: 100%; margin: 0 0 0 4px; }

.menu-item:hover > .submenu,
.menu-item:focus-within > .submenu,
.menu-item.open > .submenu {
  display: block;
}

.submenu .menu-item { width: 100%; }
.submenu .menu-label:hover,
.submenu > .menu-item:hover > .menu-label,
.submenu > .menu-item.open > .menu-label {
  background: var(--page);
  color: var(--text-primary);
}

@media (max-width: 860px) {
  nav.topbar { flex-wrap: wrap; }
  .menu { flex-wrap: wrap; }
}

.flash {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.flash-success { background: rgba(12, 163, 12, 0.12); color: var(--status-good); }
.flash-error { background: rgba(208, 59, 59, 0.12); color: var(--status-critical); }

form label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin: 12px 0 4px; }
form input[type=text], form input[type=password], form input[type=file], form select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--page);
  color: var(--text-primary);
  font-size: 0.95rem;
}
button, .btn {
  margin-top: 16px;
  padding: 9px 16px;
  border-radius: 6px;
  border: none;
  background: var(--series-1);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}
button.secondary-btn { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
button.danger-btn { background: transparent; color: var(--status-critical); border: 1px solid var(--status-critical); }

.glossary dt { font-weight: 650; margin-top: 10px; }
.glossary dd { margin: 2px 0 0; color: var(--text-secondary); }

/* Chart.js with maintainAspectRatio:false needs a parent with a fixed,
   non-content-derived height - otherwise the canvas (sized to fill the
   parent) and the parent (sized to fit the canvas) feed off each other and
   the chart grows without bound. */
.chart-box { position: relative; width: 100%; height: 360px; }
.chart-box-short { height: 240px; }

.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-tile { flex: 1; min-width: 160px; }
.stat-tile .value { font-size: 1.6rem; font-weight: 650; }
.stat-tile .label { font-size: 0.82rem; color: var(--text-muted); }

/* Placeholder content areas (home, about) - reserved slots for copy that
   hasn't been written yet. */
.placeholder-card {
  border-style: dashed;
  color: var(--text-muted);
}
.placeholder-card h3 { color: var(--text-secondary); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.card-grid .card { margin-top: 0; }
@media (max-width: 860px) {
  .card-grid { grid-template-columns: 1fr; }
}

/* Report status box (upper right of the Menu Profitability Report) */
.header-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.header-row #header-branding { flex: 1 1 320px; margin-bottom: 0; }
.header-row #report-status { flex: 0 0 220px; margin-bottom: 0; }
.status-box .btn {
  display: block;
  width: 100%;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}
.status-box .btn + .btn { margin-top: 8px; }

/* Labor cost % heatmap (day-of-week x daypart) - sequential fill (magnitude)
   plus a critical-colored value when a cell is over its daypart's target
   (status, kept in the text so it's never color-fill-alone - see the
   dataviz skill's "text wears text tokens" rule). */
.heatmap-table td.heat-cell { text-align: center; min-width: 92px; }
.heat-0 { background: var(--heat-1); }
.heat-1 { background: var(--heat-2); }
.heat-2 { background: var(--heat-3); }
.heat-3 { background: var(--heat-4); }
.heat-4 { background: var(--heat-5); }
.heat-cell .pct { font-weight: 650; }
.heat-cell .pct.over-target { color: var(--status-critical); }
.heat-cell .sub { display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 400; }
.heatmap-legend { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--text-muted); margin-top: 10px; flex-wrap: wrap; }
.heatmap-legend .swatch { width: 16px; height: 12px; border-radius: 3px; border: 1px solid var(--border); display: inline-block; }
