/* Executive dashboard -- phone first, widens to tablet and desktop.
   Colors are the validated three-slot categorical palette plus chrome ink.
   Every value is a token so light/dark swap in one place. */

:root {
  color-scheme: light;
  --plane:          #f9f9f7;
  --surface:        #fcfcfb;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --ink-muted:      #898781;
  --grid:           #e1e0d9;
  --axis:           #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --shadow:         0 1px 2px rgba(11, 11, 11, .05), 0 1px 12px rgba(11, 11, 11, .04);

  /* categorical slots 1-3: booked / AR / demand */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;

  --good:     #006300;
  --bad:      #d03b3b;
  --warning:  #fab219;

  --radius: 14px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --plane:     #0d0d0d;
    --surface:   #1a1a19;
    --ink:       #ffffff;
    --ink-2:     #c3c2b7;
    --ink-muted: #898781;
    --grid:      #2c2c2a;
    --axis:      #383835;
    --border:    rgba(255, 255, 255, 0.10);
    --shadow:    none;
    --s1: #3987e5;
    --s2: #d95926;
    --s3: #199e70;
    --good: #0ca30c;
    --bad:  #e66767;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:     #0d0d0d;
  --surface:   #1a1a19;
  --ink:       #ffffff;
  --ink-2:     #c3c2b7;
  --ink-muted: #898781;
  --grid:      #2c2c2a;
  --axis:      #383835;
  --border:    rgba(255, 255, 255, 0.10);
  --shadow:    none;
  --s1: #3987e5;
  --s2: #d95926;
  --s3: #199e70;
  --good: #0ca30c;
  --bad:  #e66767;
}

* { box-sizing: border-box; }

/* Direction colors, global -- used by tiles, YoY headlines and table cells
   alike. Never the only cue: every one of them sits beside a signed number. */
.up   { color: var(--good); font-weight: 550; }
.down { color: var(--bad);  font-weight: 550; }

body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font: 400 15px/1.45 ui-sans-serif, -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 48px;
}

/* -- header --------------------------------------------------------------- */

header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--plane);
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
}

.titlebar { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
h1 { margin: 0; font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }

.asof { color: var(--ink-muted); font-size: 12.5px; }
.asof strong { color: var(--ink-2); font-weight: 550; }

.spacer { flex: 1 1 auto; }

button.ghost {
  appearance: none;
  background: var(--surface);
  color: var(--ink-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  min-height: 32px;
}
button.ghost:hover { color: var(--ink); }

.banner {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--warning) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--ink-2);
  font-size: 12.5px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.banner .icon { flex: none; }

/* -- sections ------------------------------------------------------------- */

section { margin-top: 26px; }

h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* -- hero ----------------------------------------------------------------- */

.hero { padding: 20px; display: flex; flex-direction: column; }
.hero .label { color: var(--ink-2); font-size: 13px; }
.hero .figure {
  font-size: 46px;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.05;
  margin: 4px 0 2px;
}
.hero .sub { color: var(--ink-muted); font-size: 12.5px; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px; }

.arbox {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--ink-2);
}
.arbox .t { display: flex; justify-content: space-between; margin-bottom: 8px; }
.arbox .t .n { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.agebar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; gap: 2px; }
.agebar span { display: block; }
.agekeys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 7px; font-size: 11.5px; color: var(--ink-muted); }
.agekeys b { color: var(--ink-2); font-weight: 550; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend-item .amt { color: var(--ink); font-weight: 550; }

/* -- tiles ---------------------------------------------------------------- */

.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; }

.tile { padding: 16px; cursor: pointer; }
.tile:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }
.tile .label { color: var(--ink-2); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.tile .value { font-size: 27px; font-weight: 650; letter-spacing: -0.02em; margin: 5px 0 3px; }
.tile .delta { font-size: 12.5px; color: var(--ink-muted); }
.tile .delta .up { color: var(--good); font-weight: 550; }
.tile .delta .down { color: var(--bad); font-weight: 550; }

.chev { margin-left: auto; color: var(--ink-muted); font-size: 11px; transition: transform .15s; }
.tile[aria-expanded="true"] .chev { transform: rotate(90deg); }

.breakdown { display: none; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.tile[aria-expanded="true"] .breakdown { display: block; }

.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 4px 0;
  font-size: 13px;
  color: var(--ink-2);
}
.row .n { font-variant-numeric: tabular-nums; color: var(--ink); }
.row .bar-track { grid-column: 1 / -1; height: 4px; border-radius: 2px; background: var(--grid); overflow: hidden; }
.row .bar-fill { height: 100%; border-radius: 2px; background: var(--s1); }
.row .sub { color: var(--ink-muted); font-size: 11.5px; }

.bdhead {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 10px 0 2px;
}
.bdhead:first-child { margin-top: 0; }

/* -- chart ---------------------------------------------------------------- */

.chart-card { padding: 16px 12px 12px; }
.chart-head { display: flex; align-items: baseline; gap: 10px; padding: 0 4px 10px; flex-wrap: wrap; }
.chart-head .t { font-size: 13.5px; font-weight: 600; }
.chart-head .s { font-size: 12px; color: var(--ink-muted); }

.chart { width: 100%; height: 230px; display: block; touch-action: pan-y; }
.chart .grid-line { stroke: var(--grid); stroke-width: 1; }
.chart .axis-line { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--ink-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.chart .daylabel { fill: var(--ink-muted); font-size: 10px; }
.chart .weekend { fill: color-mix(in srgb, var(--ink-muted) 8%, transparent); }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover + .col rect, .chart .col.active rect { filter: brightness(1.06); }

.tip {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.14);
  padding: 9px 11px;
  font-size: 12.5px;
  min-width: 168px;
  opacity: 0;
  transition: opacity .1s;
}
.tip.on { opacity: 1; }
.tip .d { font-weight: 600; margin-bottom: 5px; }
.tip .line { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.tip .line .n { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--ink); }
.tip .tot { border-top: 1px solid var(--border); margin-top: 5px; padding-top: 5px; font-weight: 600; }

/* -- table view (the relief for the low-contrast slot) -------------------- */

.tablewrap { display: none; overflow-x: auto; margin-top: 10px; }
.tablewrap.on { display: block; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { padding: 6px 10px; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--ink-muted); font-weight: 600; border-bottom: 1px solid var(--border); }
tbody td { font-variant-numeric: tabular-nums; border-bottom: 1px solid var(--grid); }
tbody tr:last-child td { border-bottom: none; }
tfoot td { font-weight: 650; border-top: 1px solid var(--axis); }

/* -- YoY comparison ------------------------------------------------------- */

.yoy { padding: 16px; }
.yoy .head { display: flex; align-items: baseline; gap: 8px; }
.yoy .head .k { font-size: 13px; color: var(--ink-2); }
.yoy .head .p { margin-left: auto; font-size: 12px; color: var(--ink-muted); }
.yoy .value { font-size: 27px; font-weight: 650; letter-spacing: -0.02em; margin: 5px 0 2px; }
.yoy .vs { font-size: 12.5px; color: var(--ink-muted); }
.yoy .vs .up { color: var(--good); font-weight: 550; }
.yoy .vs .down { color: var(--bad); font-weight: 550; }
.yoy table { margin-top: 12px; }

footer {
  margin-top: 30px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  color: var(--ink-muted);
  font-size: 11.5px;
  line-height: 1.6;
}

.skeleton {
  background: linear-gradient(90deg, var(--grid) 25%, var(--surface) 50%, var(--grid) 75%);
  background-size: 200% 100%;
  animation: sweep 1.3s infinite;
  border-radius: 6px;
  color: transparent;
}
@keyframes sweep { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* -- responsive ----------------------------------------------------------- */

@media (min-width: 620px) {
  /* Four tiles: two up on a tablet, one row of four on a desktop. */
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .chart { height: 270px; }
  .hero .figure { font-size: 54px; }
  .split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

@media (min-width: 960px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .wrap { padding-top: 0; }
  .topgrid { display: grid; grid-template-columns: 1.1fr 2fr; gap: 12px; align-items: start; }
  .chart { height: 300px; }
}

/* The hidden attribute must win over any display rule below (.login is
   display:grid, which otherwise keeps the sign-in form on screen after login). */
[hidden] { display: none !important; }

/* -- sign-in gate --------------------------------------------------------- */

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}

.loginbox {
  width: 100%;
  max-width: 360px;
  padding: 26px 24px 22px;
  display: flex;
  flex-direction: column;
}
.loginbox h1 { margin: 0; font-size: 22px; font-weight: 650; letter-spacing: -0.02em; }
.loginbox .sub { margin: 4px 0 18px; color: var(--ink-muted); font-size: 13px; }

.loginbox label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
}

.loginbox input {
  appearance: none;
  background: var(--plane);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--ink);
  font: inherit;
  font-size: 16px;          /* 16px stops iOS zooming the page on focus */
  padding: 10px 12px;
  margin-bottom: 14px;
  min-height: 44px;         /* comfortable touch target */
}
.loginbox input:focus-visible { outline: 2px solid var(--s1); outline-offset: 1px; }

.loginbox button {
  appearance: none;
  background: var(--s1);
  color: #fff;
  border: 0;
  border-radius: 9px;
  font: inherit;
  font-weight: 600;
  padding: 11px 14px;
  min-height: 44px;
  cursor: pointer;
  margin-top: 2px;
}
.loginbox button:disabled { opacity: .6; cursor: default; }

.loginerr {
  margin: 12px 0 0;
  min-height: 1em;
  color: var(--bad);
  font-size: 12.5px;
  font-weight: 550;
}

/* -- Management Dashboard additions -------------------------------------- */

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.tab {
  appearance: none; font: inherit; font-size: 13px; font-weight: 600;
  background: transparent; color: var(--ink-2);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; min-height: 34px; cursor: pointer;
}
.tab[aria-current="page"] { background: var(--s1); border-color: var(--s1); color: #fff; }
.tab:focus-visible { outline: 2px solid var(--s1); outline-offset: 2px; }

.empty { padding: 28px 24px; margin-top: 14px; }
.empty h2 { margin: 0 0 6px; font-size: 18px; }
.empty p { margin: 0; color: var(--ink-muted); }

#qr { width: 180px; height: 180px; align-self: center; margin: 4px 0 10px; background: #fff; border-radius: 8px; padding: 6px; }
#secret { word-break: break-all; font-size: 12px; }
.loginbox .linkbtn {
  appearance: none; background: none; border: 0; color: var(--ink-muted);
  font: inherit; font-size: 12.5px; margin-top: 10px; cursor: pointer; text-decoration: underline;
}
