/* Totalis GTM, in the app's own look (hip4-frontend and the HIP-4 admin):
   Smoke neutrals on a dot-matrix ground, Open Sauce One, Rich Orange for the
   brand and primary actions. Charts use the admin's categorical palette;
   orange is the accent, so no series wears it. */
@font-face { font-family: "Open Sauce One"; src: url("/fonts/open-sauce-one-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; size-adjust: 95%; }
@font-face { font-family: "Open Sauce One"; src: url("/fonts/open-sauce-one-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; size-adjust: 95%; }
@font-face { font-family: "Open Sauce One"; src: url("/fonts/open-sauce-one-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; size-adjust: 95%; }
:root {
  color-scheme: dark;
  --ground: #191718;
  --paper: #242223;
  --raised: #2c292a;
  --ink: #f2f0f0;
  --muted: #9c9798;
  --faint: #7a7576;
  --rule: #322f30;
  --line: #3a3637;
  --input: #444041;
  --soft: #2c292a;
  --page-dot: #242122;
  --accent: #ff5f01;
  --accent-soft: color-mix(in oklab, #ff5f01 18%, #242223);
  --good: #30d158;
  --lost: #f43f5e;
  --lost-soft: color-mix(in oklab, #f43f5e 14%, #242223);
  --warn: #f5c518;
  --warn-soft: color-mix(in oklab, #f5c518 12%, #242223);
  --link: #8ab4ff;
  /* Chart series, in order. --series-dim is the earlier days behind the last week. */
  --series-1: #7e72ff;
  --series-dim: #3b2fb8;
  --series-2: #3987e5;
  --series-3: #e2a336;
  --series-4: #199e70;
  --series-other: #6f6a6b;
  --series-rest: #4a4546;
  /* Older names the pages still use. */
  --blue: var(--series-2);
  --kept: var(--series-2);
  --in: var(--series-1);
  --login: var(--lost);
  --invite: var(--series-3);
  --other: var(--series-other);
  --sans: "Open Sauce One", ui-sans-serif, system-ui, sans-serif;
  --cond: var(--sans);
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { background: var(--ground); }
body {
  margin: 0; color: var(--ink); font: 13.5px/1.5 var(--sans); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
  background-image: radial-gradient(circle at 4px 6px, var(--page-dot) 0.75px, transparent 1.25px); background-size: 8px 12px;
}
::selection { background: color-mix(in oklab, var(--accent) 22%, var(--ground)); }
::-webkit-scrollbar { height: 8px; width: 8px; }
::-webkit-scrollbar-thumb { background: var(--input); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* Header menu */
.topbar { background: color-mix(in oklab, var(--ground) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--rule); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1480px; margin: 0 auto; padding: 0 20px; display: flex; align-items: center; gap: 0 22px; min-height: 52px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; margin: 0; }
.brand:hover { text-decoration: none; }
.brand img { display: block; height: 18px; width: auto; }
.brand-tag { border-radius: 6px; background: var(--raised); padding: 1px 6px; font-size: 11px; font-weight: 500; color: var(--muted); }
.menu { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; font-size: 13px; }
.menu a { color: var(--muted); text-decoration: none; padding: 6px 11px; border-radius: 8px; }
.menu a:hover { color: var(--ink); background: var(--raised); text-decoration: none; }
.menu a[aria-current="page"] { color: var(--ink); background: var(--raised); font-weight: 500; }
.menu .external::after { content: " ↗"; font-size: 11px; }
.menu .signout { margin-left: auto; }
.menu .who { color: var(--faint); font-size: 12px; align-self: center; padding: 0 4px 0 12px; }
.subbar { border-top: 1px solid var(--rule); }
.subbar .topbar-inner { min-height: 38px; gap: 0 4px; padding-left: 20px; }
.subbar a { color: var(--muted); text-decoration: none; font-size: 12.5px; padding: 9px 10px 8px; border-bottom: 2px solid transparent; }
.subbar a:hover { color: var(--ink); text-decoration: none; }
.subbar a[aria-current="page"] { color: var(--ink); border-color: var(--accent); font-weight: 500; }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn); color: #191718; font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; margin-left: 2px; }
.badge.critical { background: var(--lost); color: #fff; }

main { max-width: 1480px; margin: 0 auto; padding: 22px 20px 56px; }
header.page { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; justify-content: space-between; margin-bottom: 14px; }
h1 { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 13.5px; font-weight: 600; margin: 0 0 2px; }
h3 { font-size: 13px; font-weight: 600; margin: 0 0 2px; }
.note { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; max-width: 90ch; }
.meta { color: var(--muted); font-size: 12.5px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

button, .button {
  font: inherit; font-size: 12.5px; font-weight: 500; color: var(--ink); background: var(--raised); text-decoration: none;
  border: 1px solid var(--input); border-radius: 8px; padding: 5px 11px; cursor: pointer; display: inline-block; transition: filter .12s, background .12s;
}
button:hover, .button:hover { background: var(--line); border-color: #5a5556; text-decoration: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }
button.primary:hover, .button.primary:hover { background: var(--accent); filter: brightness(1.06); }
button.quiet { border-color: transparent; background: none; color: var(--muted); padding-left: 4px; padding-right: 4px; }
button.quiet:hover { color: var(--ink); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: .5; cursor: progress; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
input, textarea, select { font: inherit; font-size: 12.5px; color: var(--ink); background: var(--ground); border: 1px solid var(--input); border-radius: 8px; padding: 5px 9px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
input::placeholder, textarea::placeholder { color: var(--faint); }
textarea { width: 100%; resize: vertical; line-height: 1.45; }

/* Every section is a panel. */
section { background: var(--paper); border: 0; border-radius: var(--radius); padding: 16px 18px; margin: 0 0 12px; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 24px; }
.half { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2 > section { margin: 0; }
@media (max-width: 960px) { .split, .half, .grid2 { grid-template-columns: 1fr; } }

.answer { font-size: 17px; line-height: 1.35; font-weight: 500; margin: 4px 0 2px; max-width: 70ch; }
.answer-sub { color: var(--muted); font-size: 13px; margin: 0 0 10px; max-width: 80ch; }
.verdict { font-size: 13.5px; margin: 10px 0 0; max-width: 80ch; }
.verdict b { font-weight: 600; }
.setup { border: 0; background: var(--warn-soft); color: var(--ink); border-radius: 8px; padding: 8px 12px; margin: 0 0 12px; font-size: 12.5px; }

/* KPI tiles */
.cards, .numbers, .kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; }
.cards > div, .numbers > div, .kpis > div { background: var(--paper); padding: 11px 13px; }
.cards div b, .numbers div b, .kpis div b { display: block; font-family: var(--cond); font-size: 22px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.cards div .what, .numbers div span, .kpis div span { display: block; font-size: 12px; color: var(--muted); }
.cards div small, .kpis div small { display: block; font-size: 11.5px; color: var(--faint); margin-top: 1px; }
section > .kpis, section > .cards { margin-top: 6px; }
.up { color: var(--good); font-weight: 500; } .down { color: var(--lost); font-weight: 500; }

/* Alerts */
.alerts, .alert-plain { list-style: none; margin: 0; padding: 0; }
.alerts li, .alert-plain li { padding: 6px 0 6px 10px; border-left: 3px solid var(--warn); margin-bottom: 6px; }
.alerts li.critical, .alert-plain li.critical { border-color: var(--lost); }
.alerts li.info, .alert-plain li.info { border-color: var(--good); }
.alerts .title { font-weight: 500; }
.alerts .ctx, .alert-plain small { display: block; color: var(--muted); font-size: 12px; }
.quiet-ok { color: var(--good); }

/* Funnel bars */
.funnel { display: grid; gap: 6px; }
.fstep { display: grid; grid-template-columns: 180px minmax(0, 1fr) 128px; gap: 12px; align-items: center; }
.fstep .label { font-size: 12.5px; line-height: 1.25; }
.fstep .label small { display: block; color: var(--muted); font-size: 11.5px; }
.fstep .loss { color: var(--lost); font-size: 12px; text-align: right; }
.fstep.worst .loss { font-weight: 600; }
.track { position: relative; height: 24px; display: flex; background: var(--raised); border-radius: 4px; overflow: hidden; }
.kept { background: var(--blue); height: 100%; min-width: 2px; color: #fff; font-family: var(--cond); font-size: 12.5px; display: flex; align-items: center; padding-left: 7px; white-space: nowrap; }
.gone { height: 100%; background: repeating-linear-gradient(135deg, rgba(244,63,94,.22) 0 6px, rgba(244,63,94,.07) 6px 12px); }
.fstep.worst .gone { background: repeating-linear-gradient(135deg, rgba(244,63,94,.40) 0 6px, rgba(244,63,94,.15) 6px 12px); }
@media (max-width: 560px) { .fstep { grid-template-columns: 1fr; gap: 2px; } .fstep .loss { text-align: left; } }
.findings { margin: 0; padding-left: 18px; }
.findings li { margin-bottom: 6px; }

.stack { display: flex; height: 28px; width: 100%; margin: 6px 0 10px; border-radius: 4px; overflow: hidden; }
.stack span { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--cond); font-size: 12.5px; font-weight: 500; overflow: hidden; white-space: nowrap; min-width: 2px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.legend li { display: grid; grid-template-columns: 12px 36px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.legend i { width: 10px; height: 10px; display: inline-block; border-radius: 2px; }
.legend b { font-family: var(--cond); font-size: 14px; font-weight: 500; text-align: right; }
.legend small { display: block; color: var(--muted); font-size: 12px; }
.compare { display: grid; gap: 8px; margin-top: 6px; max-width: 640px; }
.compare-row { display: grid; grid-template-columns: 180px minmax(0, 1fr) 52px; gap: 10px; align-items: center; font-size: 12.5px; }
.compare-row .bar { height: 16px; background: var(--raised); border-radius: 3px; overflow: hidden; }
.compare-row .bar i { display: block; height: 100%; background: var(--series-1); }
.compare-row b { font-family: var(--cond); font-size: 15px; font-weight: 500; text-align: right; }
.compare-row small { display: block; color: var(--muted); font-size: 11.5px; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 6px 10px 6px 0; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--paper); position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th[aria-sort="ascending"]::after { content: " ▲"; font-size: 9px; }
th[aria-sort="descending"]::after { content: " ▼"; font-size: 9px; }
td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
tbody tr:hover td { background: color-mix(in oklab, var(--raised) 60%, var(--paper)); }
td.n, th.n { text-align: right; font-family: var(--cond); }
td.what { word-break: break-word; }
td small, .dim { color: var(--faint); }
.when { white-space: nowrap; }
.rate { display: inline-flex; gap: 8px; align-items: center; justify-content: flex-end; }
.rate i { display: inline-block; height: 6px; border-radius: 3px; background: var(--series-1); }
.low { color: var(--lost); font-weight: 600; }
.scroll { overflow: auto; }
.tall { max-height: 70vh; }
tr.flagged td { color: var(--lost); }
tr.flagged td:first-child::after { content: "  much lower than average"; font-size: 11px; font-weight: 500; }
tr.team td { color: var(--faint); }
tr.clickable, tr[data-href] { cursor: pointer; }
a[data-person] { color: var(--ink); text-decoration: underline; text-decoration-color: var(--input); text-underline-offset: 3px; }
a[data-person]:hover { text-decoration-color: var(--ink); }

/* Person panel */
.drawer[hidden] { display: none; }
.drawer-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; }
.drawer-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: var(--paper); border-left: 1px solid var(--rule); z-index: 41; overflow-y: auto; padding: 18px 20px 40px; box-shadow: -12px 0 32px rgba(0, 0, 0, .4); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-head h2 { font-size: 17px; }
a.button { text-decoration: none; }
a.button.primary { color: #000; }
.facts { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 3px 12px; margin: 0; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin: 0 0 12px; border-bottom: 1px solid var(--rule); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 6px 10px; margin-bottom: -1px; color: var(--muted); background: none; font-size: 13px; }
.tabs button:hover { background: none; color: var(--ink); }
.tabs button[aria-selected="true"] { color: var(--ink); border-color: var(--accent); background: none; }
.tabs .count { color: var(--faint); font-weight: 400; margin-left: 4px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; font-size: 12.5px; color: var(--muted); }
.toolbar input[type="search"] { width: 240px; }
.toolbar label { display: inline-flex; gap: 5px; align-items: center; }

/* Small words that carry meaning: tags and levels, as coloured text. */
.tag { font-size: 11.5px; white-space: nowrap; margin-right: 8px; color: var(--muted); }
.tag.bad { color: var(--lost); }
.tag.good { color: var(--good); }
.tag.warn { color: var(--warn); }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.chart { background: var(--paper); border: 0; border-radius: var(--radius); padding: 12px 14px 8px; }
.chart h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 0; }
.chart .now { font-family: var(--cond); font-size: 20px; font-weight: 600; line-height: 1.2; }
.chart .now small { font-family: var(--sans); font-size: 11.5px; font-weight: 400; color: var(--faint); margin-left: 6px; }
.chart svg { display: block; width: 100%; height: 84px; margin-top: 4px; }
.chart .axis { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--faint); }

.chart.wide svg { height: 110px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; color: var(--muted); margin: 6px 0 2px; }
.legend-row i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; transform: translateY(1px); }
.legend-row b { color: var(--ink); font-weight: 500; font-family: var(--cond); }
.charts.two { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); }
.hbars { display: grid; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(120px, 34%) minmax(0, 1fr) 64px; gap: 10px; align-items: center; font-size: 12.5px; }
.hbar span small { display: block; color: var(--faint); font-size: 11px; }
.hbar div { height: 14px; background: var(--raised); border-radius: 3px; overflow: hidden; }
.hbar i { display: block; height: 100%; }
.hbar b { font-family: var(--cond); font-weight: 500; text-align: right; }

/* AI findings */
.finding { display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-top: 1px solid var(--rule); }
.finding:first-child { border-top: 0; }
.finding > i { border-radius: 2px; background: var(--warn); }
.finding.problem > i { background: var(--lost); }
.finding.good > i { background: var(--good); }
.finding h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 2px; }
.finding .evidence { font-family: var(--cond); font-size: 13px; margin: 0 0 3px; }
.finding .fix { font-size: 12.5px; margin: 0; }
.finding .fix b { font-weight: 600; }
.finding .who { font-size: 12px; color: var(--muted); margin: 3px 0 0; }

/* AI reports */
.report { border-left: 3px solid var(--series-1); padding: 2px 0 2px 14px; }
.report h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 0; }
.report .headline { font-size: 15px; line-height: 1.35; font-weight: 600; margin: 4px 0 10px; max-width: 70ch; }
.report .sec { margin: 0 0 10px; white-space: pre-line; line-height: 1.5; font-size: 13px; max-width: 80ch; }
.report .sec b:first-child { display: block; font-size: 12.5px; margin-bottom: 1px; }
.report-actions { display: flex; gap: 10px; align-items: center; margin-top: 10px; }

/* Daily bars on Reports */
.days { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; align-items: end; height: 120px; margin: 8px 0 4px; border-bottom: 1px solid var(--rule); }
.days div { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.days i { display: block; background: var(--series-1); min-height: 1px; border-radius: 2px 2px 0 0; }
.days i.zero { background: var(--line); }
.days b { font-family: var(--cond); font-size: 11px; font-weight: 500; text-align: center; margin-bottom: 3px; }
.days-axis { display: grid; grid-template-columns: repeat(15, minmax(0, 1fr)); gap: 4px; font-family: var(--cond); font-size: 10.5px; color: var(--faint); text-align: center; margin-bottom: 14px; }
.big { font-family: var(--cond); font-size: 30px; font-weight: 500; line-height: 1.1; margin: 2px 0; }
.missing { padding-left: 18px; margin: 0; }
.missing li { margin-bottom: 4px; }
.empty { color: var(--muted); padding: 14px 0; }
.runs { font-size: 12px; color: var(--muted); }
.runs .bad { color: var(--lost); }
svg.spark { width: 100%; height: 70px; display: block; }
details.engineering { margin-top: 10px; border-top: 1px solid var(--rule); padding-top: 12px; }
details.engineering > summary { cursor: pointer; font-weight: 600; font-size: 13.5px; color: var(--muted); }

/* Sign in */
body.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-form { width: 100%; max-width: 360px; background: var(--paper); border-radius: 18px; padding: 24px; display: grid; gap: 14px; }
.signin-form .brand { margin-bottom: 4px; }
.signin-form .note { margin: 0; font-size: 13.5px; }
.signin-form .big-button { display: flex; align-items: center; justify-content: center; height: 44px; border-radius: 10px; font-size: 15px; }
.signin-error { background: var(--lost-soft); color: var(--lost); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin: 0; }
