/* WonderNotes admin portal - design system (Brief 42).
   Token names are kept stable across the restyle so every template built
   against the old palette keeps working; only the values (and the nav/
   layout markup in base.html) changed. */

@font-face {
  font-family: "Inter";
  src: url("fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Palette */
  --ink: #171321;
  --muted: #6b6577;
  --paper: #f7f5f9;
  --card: #ffffff;
  --line: #e5e1ea;
  --accent: #e72b7a;        /* magenta - primary actions only */
  --accent-ink: #c21f67;
  --ok: #0e7c5a;   --ok-bg: #e3f6ef;
  --warn: #93650a; --warn-bg: #fbf0d9; --warn-border: #eeddba;
  --bad: #c1403a;  --bad-bg: #fbeae8;
  --white: #ffffff;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  /* New (Brief 42) */
  --nav: #211b27;
  --nav-text: rgba(255,255,255,0.68);
  --radius-card: 14px;
  --radius-btn: 8px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 20px;
  --space-xl: 28px;
  --space-2xl: 40px;
  --container: 1400px;

  /* Chart.js secondary series (Brief 42 item 2) - the primary series reads
     --accent directly; these are the short tinted set for every series
     after it (e.g. the jobs-per-day bar chart's per-team bars). Not
     resolved through var(--accent) chaining on purpose - a custom
     property's computed value is returned as the literal var(...) string,
     not the resolved colour, so JS reading these via getComputedStyle
     needs plain hex here to get a usable colour back. */
  --chart-2: #7c5cbf;
  --chart-3: #2f8fd1;
  --chart-4: #1fa394;
  --chart-5: #d98a2b;
  --chart-6: #9c4f8f;

  /* Health tiles (Brief 42 item 1) - sit on the dark --nav background, so
     need their own on-dark values rather than the light-card --ok/--warn/
     --bad tokens above. */
  --health-bg: rgba(255,255,255,0.08);
  --health-border: rgba(255,255,255,0.14);
  --health-text: rgba(255,255,255,0.72);
  --health-dot: rgba(255,255,255,0.35);
  --health-ok-bg: rgba(74,222,154,0.16);     --health-ok-text: #7cedb8;   --health-ok-dot: #4ade9a;
  --health-warn-bg: rgba(242,179,61,0.16);   --health-warn-text: #f6c976; --health-warn-dot: #f2b33d;
  --health-bad-bg: rgba(242,114,107,0.16);   --health-bad-text: #f6a29c; --health-bad-dot: #f2726b;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body, h1, h2, p, dl, dd { margin: 0; }

body {
  background: var(--paper); color: var(--ink);
  font-family: Inter, -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 16px; line-height: 1.55;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── Top nav ─── */
.topnav { background: var(--nav); }
.topnav__inner {
  max-width: var(--container); margin: 0 auto; padding: 0 var(--space-lg);
  display: flex; align-items: center; gap: var(--space-xl); height: 64px;
}
.topnav__brand { font-size: 20px; font-weight: 700; color: var(--white); letter-spacing: -0.01em; white-space: nowrap; }
.topnav__brand span { color: var(--accent); }
.topnav__links { display: flex; align-items: center; gap: var(--space-lg); flex-wrap: wrap; }
.topnav__link {
  color: var(--nav-text); font-size: 14px; font-weight: 600;
  padding: 22px 2px; border-bottom: 2px solid transparent;
}
.topnav__link:hover { color: var(--white); text-decoration: none; }
.topnav__link.is-active { color: var(--white); border-bottom-color: var(--accent); }
.topnav__right { margin-left: auto; display: flex; align-items: center; gap: var(--space-md); }
.topnav__account { color: var(--nav-text); font-size: 13px; white-space: nowrap; }
.topnav__account a { color: var(--nav-text); text-decoration: underline; }
.topnav__account a:hover { color: var(--white); }

@media (max-width: 900px) {
  .topnav__inner { flex-wrap: wrap; height: auto; padding: var(--space-md) var(--space-lg); gap: var(--space-sm); }
  .topnav__links { gap: var(--space-md); }
  .topnav__link { padding: 6px 2px; }
  .topnav__right { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* ─── Banner / flash ─── */
.banner {
  background: var(--warn-bg); color: var(--warn);
  border-bottom: 1px solid var(--warn-border); padding: var(--space-sm) var(--space-lg); font-size: 13px;
}
.flash {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--muted);
  padding: var(--space-sm) var(--space-md); margin: 0 0 var(--space-lg);
  border-radius: 0 8px 8px 0; font-size: 14px;
}

/* ─── Layout ─── */
.container { max-width: var(--container); margin: 0 auto; padding: var(--space-xl) var(--space-lg) 64px; }
/* Vertical rhythm between top-level sections (a .grid of cards followed by
   a lone .card, two .grid rows back to back, etc.) - .card + .card alone
   only covers literal adjacent cards, not every shape a page's top-level
   sections actually take. */
.container > * + * { margin-top: var(--space-lg); }
h1 { font-size: 28px; font-weight: 700; margin: 0 0 var(--space-lg); letter-spacing: -0.01em; }
h2 {
  font-size: 14px; font-weight: 650; color: var(--muted);
  text-transform: none; margin: 0 0 var(--space-md);
}

/* ─── Team page header (Brief 43) ─── */
.breadcrumb { font-size: 13px; color: var(--muted); }
.breadcrumb a { color: var(--muted); text-decoration: underline; }
.breadcrumb a:hover { color: var(--ink); }
.page-header > * + * { margin-top: var(--space-sm); }
.page-header h1 { margin-bottom: 0; }

/* ─── Tabs (Brief 43) ─── */
/* Scrolls horizontally rather than wrapping - on a narrow screen a
   wrapped second row would push every panel down and still not fit
   "Team details"/"Danger zone" on one line anyway. */
.tabs { display: flex; gap: var(--space-xl); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab {
  display: inline-block; flex: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 0 0 var(--space-sm); border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.panel--empty { text-align: center; padding: var(--space-2xl) var(--space-xl); }
.panel--empty .row { justify-content: center; }
.icon-chart { stroke: var(--muted); flex: none; }

.grid { display: grid; gap: var(--space-lg); }
/* Same min-width:auto issue as dl.kv dd below - a grid item won't shrink
   past its content's own min-content width by default, so a canvas with
   no CSS width of its own (status-chart, people-chart) settles at its
   HTML-attribute default (300) and drags the whole track/card wide with
   it at narrow viewports, regardless of what Chart.js's own responsive
   resize later computes from that same, now-too-wide, parent. */
.grid > * { min-width: 0; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: 3fr 2fr; }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.row { display: flex; align-items: center; gap: var(--space-sm); flex-wrap: wrap; }
.stack { display: grid; gap: var(--space-md); max-width: 460px; }

/* ─── Cards ─── */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-card); padding: var(--space-xl);
}
.card + .card { margin-top: var(--space-lg); }
.card > * + * { margin-top: var(--space-md); }
.card--narrow { max-width: 480px; margin: 48px auto; text-align: center; }
.card--form { max-width: 560px; }
.card--danger { border-color: var(--bad); }
.panel--reference summary { cursor: pointer; font-weight: 650; color: var(--muted); font-size: 14px; }
.panel--reference pre {
  white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius-btn); padding: var(--space-md); max-height: 360px; overflow: auto;
}

.stat .n { font-size: 36px; font-weight: 700; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 13px; }

/* ─── Tables ─── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { text-align: left; color: var(--muted); font-size: 12px; padding-bottom: var(--space-sm); caption-side: top; }
th {
  text-align: left; color: var(--muted); font-weight: 650; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.02em;
  border-bottom: 1px solid var(--line); padding: var(--space-sm) var(--space-md);
}
td { border-bottom: 1px solid var(--line); padding: var(--space-md); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
.table-scroll { overflow-x: auto; }

.mono, code { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--paper); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; }

/* ─── Pills / badges ─── */
.pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 650;
}
.pill.ACTIVE { background: var(--ok-bg); color: var(--ok); }
.pill.PROVISIONING { background: var(--warn-bg); color: var(--warn); }
.pill.DELETING { background: var(--warn-bg); color: var(--warn); }
.pill.FAILED { background: var(--bad-bg); color: var(--bad); }
.pill.DELETE_FAILED { background: var(--bad-bg); color: var(--bad); }

/* Brief 37 item 4 - the three-tile health card, every page's header.
   Lives on the dark top nav now (Brief 42), so its colours are its own,
   not the light-card --ok/--warn/--bad tokens above - those are tuned
   for white cards, these need to read on var(--nav). */
.health-card { display: flex; gap: var(--space-sm); }
.health-tile {
  display: flex; align-items: center; gap: 5px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--health-bg); border: 1px solid var(--health-border);
  color: var(--health-text); cursor: pointer;
}
.health-tile:hover { text-decoration: none; border-color: var(--accent); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--health-dot); flex: none; }
.health-tile.ok { background: var(--health-ok-bg); color: var(--health-ok-text); border-color: transparent; }
.health-tile.ok .health-dot { background: var(--health-ok-dot); }
.health-tile.warn { background: var(--health-warn-bg); color: var(--health-warn-text); border-color: transparent; }
.health-tile.warn .health-dot { background: var(--health-warn-dot); }
.health-tile.bad { background: var(--health-bad-bg); color: var(--health-bad-text); border-color: transparent; }
.health-tile.bad .health-dot { background: var(--health-bad-dot); }
@media (max-width: 900px) { .health-card .health-label { display: none; } }

/* ─── Forms ─── */
label { font-size: 13px; font-weight: 600; display: grid; gap: 5px; }
label.checkbox { display: flex; align-items: center; gap: var(--space-sm); font-weight: 500; }
label.checkbox input { margin: 0; }
.hint { display: block; color: var(--muted); font-weight: 400; font-size: 13px; margin-top: var(--space-xs); }

input:not([type=checkbox]):not([type=hidden]), select, textarea {
  font: inherit; font-size: 14px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius-btn); background: var(--card); width: 100%;
}
input.mono { font-family: var(--mono); font-size: 13px; }
textarea.editor { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

fieldset { border: 1px solid var(--line); border-radius: var(--radius-btn); padding: var(--space-md); }
legend { font-size: 13px; font-weight: 600; padding: 0 4px; }

/* ─── Buttons ─── */
.btn {
  display: inline-block; border: 1px solid transparent; border-radius: var(--radius-btn);
  cursor: pointer; font: 600 14px/1 inherit; padding: 11px 20px;
}
.btn.primary { background: var(--accent); color: var(--white); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.quiet { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.quiet:hover { border-color: var(--accent); }
.btn.quiet.danger { color: var(--bad); padding: 6px 14px; font-size: 13px; }
.btn.quiet.danger:hover { background: var(--bad-bg); border-color: transparent; }

/* ─── Utilities ─── */
.text-muted { color: var(--muted); font-size: 13px; }
.text-small { font-size: 13px; }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.muted-sub { color: var(--muted); font-weight: 500; }
.back-link { margin: -10px 0 var(--space-md); font-size: 13px; }

dl.kv { display: grid; grid-template-columns: 190px 1fr; gap: var(--space-sm) var(--space-md); margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
/* min-width: 0 overrides a grid item's default min-width:auto, which
   otherwise sizes to its content's intrinsic (unwrapped) width - on a
   narrow screen, a .truncate+button .row (see below) would force the
   1fr column, then the whole dl.kv/card/page, wider than the
   viewport instead of actually truncating. */
dl.kv dd { word-break: break-all; min-width: 0; }

.truncate {
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; display: inline-block; vertical-align: bottom;
  /* Same min-width:auto issue as dl.kv dd above, one layer down - a flex
     item (inside .row) also defaults to its content's intrinsic width
     unless told otherwise, which would silently defeat max-width/
     overflow/ellipsis here and overflow the row instead of truncating. */
  min-width: 0;
}

.empty { color: var(--muted); font-size: 13px; padding: var(--space-xl) 0; text-align: center; }
.reason {
  background: var(--bad-bg); color: var(--bad); border-radius: var(--radius-btn);
  padding: 10px 12px; font-family: var(--mono); font-size: 12px;
  word-break: break-all; margin-top: var(--space-md);
}

/* ─── Usage dashboards (Brief 46) ─── */
/* A true 50/50 split, unlike .grid.cols-2's own 3fr/2fr sidebar ratio -
   the four usage panels are peers, not a main+sidebar pair. */
.grid.cols-2-even { grid-template-columns: 1fr 1fr; }
@media (max-width: 900px) { .grid.cols-2-even { grid-template-columns: 1fr; } }

.usage-period-note { margin-top: var(--space-xs); }

/* Segmented control - one bordered strip, not .tab's underline style,
   since this is a set of equally-weighted choices (a period), not a
   page's own section navigation. */
.period-selector { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-btn); overflow: hidden; }
.period-selector a {
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted);
  border-right: 1px solid var(--line);
}
.period-selector a:last-child { border-right: none; }
.period-selector a:hover { background: var(--paper); text-decoration: none; }
.period-selector a.is-active { background: var(--accent); color: var(--white); }
.period-selector a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.chart-card__header { display: flex; align-items: center; gap: var(--space-md); flex-wrap: wrap; justify-content: space-between; }
.chart-card__header h2 { margin: 0; }
.chart-switcher { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-btn); overflow: hidden; }
.chart-switcher button {
  background: var(--card); border: none; border-right: 1px solid var(--line);
  color: var(--muted); font: 600 13px/1 inherit; padding: 8px 12px; cursor: pointer;
}
.chart-switcher button:last-child { border-right: none; }
.chart-switcher button:hover { background: var(--paper); }
.chart-switcher button.is-active { background: var(--accent); color: var(--white); }
.chart-switcher button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-lg); }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi-tile__label { color: var(--muted); font-size: 13px; font-weight: 650; }
.kpi-tile__value { font-size: 28px; font-weight: 700; line-height: 1.1; margin-top: 4px; }
.kpi-tile__delta { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-top: 4px; }
.kpi-tile__delta.is-up { color: var(--ok); }
.kpi-tile__delta.is-down { color: var(--bad); }

.usage-directorate-row td { background: var(--paper); font-weight: 650; }
