/*
 * WHISP client portal.
 *
 * A sibling of the creator catalog (creator.whisplab.io): the same white brand line, the
 * same dark ground and raised surfaces, the same serif for headings and sans for
 * everything else, the same token names. What differs is the job: this page is read,
 * not swiped, so it is panels of numbers in a calm grid.
 *
 * Colour has one meaning each:
 *   green      live, and a change for the better (always with an arrow and a word)
 *   warm red   an error, a change for the worse, a person flagged (always with a word)
 *   blue       the one chart series, and links
 * Status is never colour alone: every pill has its word.
 *
 * Type never goes below 12px, and body copy is 15px or more.
 */

:root {
  --ground: #080c14;
  --surface: #111827;
  --surface-raised: #1a2437;
  --line: #263248;
  --text: #f4f6fa;
  --text-soft: #cdd4e0;
  --muted: #98a3b6;
  --good: #3ddc97;
  --good-ink: #04271a;
  --bad: #ff9d8f;
  --link: #9cc5ff;
  --series: #3987e5;
  --paper: #ffffff;
  --ink: #111827;
  --ink-soft: #566074;
  --paper-line: #dfe4ec;
  --radius: 22px;
  --bar-height: 64px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: radial-gradient(1200px 700px at 50% 0%, #132037 0%, var(--ground) 62%) fixed var(--ground);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, summary:focus-visible, .chart-svg:focus-visible { outline: 3px solid var(--link); outline-offset: 3px; }
h1, h2, h3, p, ul, figure { margin: 0; }
img { display: block; }
a { color: var(--link); }
code, pre { font-family: var(--mono); font-size: 13.5px; }

/* ---------- the brand line ---------- */

.bar {
  position: sticky; top: 0; z-index: 10;
  height: var(--bar-height);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px;
  padding: 0 28px;
  background: var(--paper); color: var(--ink);
}
.bar :focus-visible { outline-color: #1d4ed8; }
.bar-home { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.bar-whisp { height: 30px; width: auto; }
.bar-title { font: 400 19px/1 var(--serif); color: var(--ink-soft); padding-left: 14px; border-left: 1px solid var(--paper-line); }
.bar-clients { display: flex; justify-content: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.bar-clients a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--ink-soft); text-decoration: none; font-size: 15px; font-weight: 600; white-space: nowrap;
}
.bar-clients a:hover { color: var(--ink); background: #f2f4f8; }
.bar-clients a[aria-current="page"] { color: var(--paper); background: var(--ink); }
.bar-right { justify-self: end; display: flex; align-items: center; gap: 12px; }
.bar-who { font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); }
.bar-button {
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--paper-line);
  background: var(--paper); color: var(--ink); font-size: 14.5px; font-weight: 600;
}
.bar-button:hover { border-color: #b8c1d1; }

/* ---------- the page ---------- */

.page { width: min(1240px, 100%); margin: 0 auto; padding: 36px 28px 72px; }

.client-head { display: grid; gap: 8px; margin-bottom: 28px; }
.client-name { font: 400 40px/1.1 var(--serif); letter-spacing: -0.01em; }
.client-summary { max-width: 46em; color: var(--text-soft); font-size: 16.5px; }

.client-list { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.client-card {
  display: block; padding: 26px 24px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
  color: var(--text); text-decoration: none; font: 400 26px/1.2 var(--serif);
}
.client-card:hover { border-color: #3b4c6b; }

/* Panels sit two to a row; the wide ones take the row. */
.panels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.panel {
  min-width: 0; display: grid; gap: 18px; padding: 24px 26px 26px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.panel.is-wide { grid-column: 1 / -1; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.panel-title { font: 400 24px/1.2 var(--serif); margin-right: auto; }
.panel-asof { color: var(--muted); font-size: 13px; }
.panel-body { display: grid; gap: 18px; min-width: 0; transition: opacity 150ms ease; }
.panel-body.is-refreshing { opacity: 0.45; }
.panel-loading { color: var(--muted); font-size: 15px; }
.panel-reason { color: var(--text-soft); font-size: 15px; }
.panel-empty { padding: 22px; border-radius: 14px; border: 1px dashed var(--line); color: var(--text-soft); text-align: center; }
.panel-since { color: var(--muted); font-size: 14.5px; }
.panel-notes { padding: 14px 0 0 18px; border-top: 1px solid var(--line); display: grid; gap: 6px; color: var(--muted); font-size: 13.5px; }

/* status: a dot and its word */
.pill {
  display: inline-flex; align-items: center; gap: 7px; min-height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-raised);
  font: 650 12px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-soft);
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.pill.is-live .pill-dot { background: var(--good); }
.pill.is-error { border-color: #6b3a35; }
.pill.is-error .pill-dot { background: var(--bad); }
.pill.is-loading .pill-dot { animation: pulse 1s ease-in-out infinite alternate; }
@keyframes pulse { to { opacity: 0.25; } }

/* ---------- figures ---------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { display: grid; gap: 4px; align-content: start; padding: 14px 16px; border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--line); min-width: 0; }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font: 650 28px/1.15 var(--sans); letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tile-note { color: var(--muted); font-size: 13px; font-weight: 400; }
.tile-note.is-flag { color: var(--bad); font-weight: 600; }
.tile-delta { font-size: 13.5px; font-weight: 650; }
.tile-delta.is-up { color: var(--good); }
.tile-delta.is-down { color: var(--bad); }

.figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.figure { display: grid; gap: 8px; min-width: 0; }
.figure-title { font-size: 14.5px; font-weight: 650; color: var(--text-soft); }
.chart { min-height: 220px; min-width: 0; }
.chart-svg { display: block; max-width: 100%; height: auto; border-radius: 6px; }
.chart-tick { fill: var(--muted); font: 12px var(--sans); font-variant-numeric: tabular-nums; }
.chart-value { fill: var(--text); font: 650 12.5px var(--sans); }

.tooltip {
  position: absolute; z-index: 30; pointer-events: none;
  display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(17, 24, 39, 0.97); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  font-size: 13px; white-space: nowrap;
}
.tooltip[hidden] { display: none; }
.tooltip strong { font-size: 15px; color: var(--text); }
.tooltip span { color: var(--muted); }

/* the App Store ranges, as App Store Connect's Trends screen offers them */
.segments { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface-raised); border: 1px solid var(--line); justify-self: start; }
.segment { min-height: 36px; min-width: 52px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--text-soft); font-size: 14px; font-weight: 650; }
.segment:hover { color: var(--text); }
.segment[aria-pressed="true"] { background: var(--text); color: var(--ink); }

/* ---------- tables ---------- */

.table-wrap { overflow-x: auto; min-width: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th, .table td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
.table thead th { font: 650 12px/1.2 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table tbody th { font-weight: 650; white-space: nowrap; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tbody tr:last-child td, .table tbody tr:last-child th { border-bottom: 0; }
.cell-soft { color: var(--muted); }
.cell-when { white-space: nowrap; }
.cell-phone { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.cell-action { text-align: right; }

.table-view summary { cursor: pointer; color: var(--link); font-size: 14.5px; font-weight: 600; padding: 4px 0; }
.table-view[open] summary { margin-bottom: 8px; }
.table-view .table-wrap { max-height: 420px; overflow-y: auto; }

/* employees: one body per person, so a person's choices open right under them */
.employees > tbody { border-bottom: 1px solid var(--line); }
.employees > tbody > tr > th, .employees > tbody > tr > td { border-bottom: 0; }
.employees > tbody.is-inactive > tr > th { color: var(--text-soft); }
.employees .detail > td { padding: 0 12px 16px; }
.employees .detail .table { font-size: 14px; background: var(--ground); border-radius: 12px; }
.row-toggle { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.row-toggle:hover { border-color: #4a5b7c; }
.flag { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--bad); color: var(--bad); font: 650 11.5px/1.5 var(--sans); letter-spacing: 0.04em; text-transform: uppercase; vertical-align: 1px; }
.flag.is-soft { border-color: var(--line); color: var(--muted); }
.choice { font-size: 12.5px; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; }
.choice.is-save { color: var(--good); }
.choice.is-pass { color: var(--muted); }

/* contracts: the stage in words, never colour alone */
.stage { white-space: nowrap; font-weight: 650; }
.stage-words { text-transform: capitalize; }
.stage.is-live { color: var(--good); }
.stage.is-declined { color: var(--bad); }
.stage-history { display: block; margin-top: 4px; color: var(--muted); font-size: 13px; }

/* HGV's timeline, with today among the dates */
.timeline { list-style: none; padding: 0; display: grid; gap: 0; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline-item { display: grid; grid-template-columns: minmax(150px, max-content) 1fr auto; gap: 4px 16px; align-items: baseline; padding: 9px 0 9px 18px; position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -7px; top: 15px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.timeline-item.is-past { color: var(--muted); }
.timeline-item.is-past::before { background: var(--muted); }
.timeline-item.is-now::before, .timeline-item.is-next::before { border-color: var(--text); }
.timeline-item.is-today::before { background: var(--good); border-color: var(--good); }
.timeline-item.is-today { font-weight: 650; }
.timeline-day { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--text-soft); }
.timeline-state { font: 650 11.5px/1.5 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
@media (max-width: 640px) { .timeline-item { grid-template-columns: 1fr auto; } .timeline-label { grid-column: 1 / -1; } }

.section-title { margin-top: 10px; font: 650 12px/1.2 var(--sans); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.feed { list-style: none; padding: 0; display: grid; gap: 10px; }
.feed-item { padding: 14px 16px; border-radius: 14px; background: var(--surface-raised); border: 1px solid var(--line); display: grid; gap: 4px; }
.feed-meta { color: var(--muted); font-size: 13.5px; }
.feed-meta b { color: var(--text); }
.feed-text { color: var(--text-soft); overflow-wrap: anywhere; }

/* ---------- not connected, and errors ---------- */

.needs { display: grid; gap: 10px; padding: 16px 18px; border-radius: 14px; border: 1px dashed var(--line); color: var(--text-soft); font-size: 15px; }
.needs-secret { justify-self: start; padding: 6px 10px; border-radius: 8px; background: var(--ground); color: var(--text); }
.needs-fields { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.needs-fields code { display: inline-block; padding: 3px 9px; border-radius: 999px; background: var(--surface-raised); border: 1px solid var(--line); color: var(--text); }
.needs-example { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--ground); color: var(--text-soft); overflow-x: auto; }
.error-label { display: block; padding: 10px 12px; border-radius: 8px; background: var(--ground); border: 1px solid #6b3a35; color: #ffb4a8; overflow-wrap: anywhere; white-space: pre-wrap; }

/* ---------- states that are not a client ---------- */

.notice {
  max-width: 480px; margin: 8vh auto 0; text-align: center; display: grid; gap: 14px; justify-items: center;
  padding: 44px 36px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface);
}
.notice h1 { font: 400 30px/1.2 var(--serif); }
.notice p { color: var(--text-soft); }
.notice button { min-height: 48px; padding: 0 26px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface-raised); font-weight: 600; }
.notice button.is-primary { background: var(--text); color: var(--ink); border-color: var(--text); }
.notice-link { font-weight: 600; }

.skeleton {
  height: min(60dvh, 560px); border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(100deg, var(--surface) 30%, #172135 50%, var(--surface) 70%); background-size: 200% 100%;
  animation: shimmer 1.3s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- narrow screens ---------- */

@media (max-width: 860px) {
  :root { --bar-height: 56px; }
  .bar { grid-template-columns: auto 1fr; gap: 10px; padding: 0 14px; height: auto; min-height: var(--bar-height); padding-block: 8px; }
  .bar-whisp { height: 22px; }
  .bar-title { font-size: 16px; padding-left: 10px; }
  .bar-clients { grid-column: 1 / -1; grid-row: 2; justify-content: flex-start; }
  .bar-who { display: none; }
  .page { padding: 22px 12px 48px; }
  .client-name { font-size: 32px; }
  .panels, .figures { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 18px 16px 20px; border-radius: 18px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-value { font-size: 24px; }
}

/* On a phone a table is a stack of rows, each a list of labelled values: no sideways scrolling to find a column. */
@media (max-width: 640px) {
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table, .table tbody, .table tr, .table th, .table td { display: block; width: 100%; }
  .table tbody tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table tbody tr:last-child { border-bottom: 0; }
  .table th, .table td { padding: 3px 0; border-bottom: 0; }
  .table td[data-label] { display: flex; justify-content: space-between; gap: 16px; text-align: right; }
  .table td[data-label]::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 13px; text-align: left; }
  .table td:not([data-label]) { text-align: left; }
  .table .num { text-align: right; }
  .employees > tbody > tr > th { font-size: 16px; padding-bottom: 6px; }
  .employees .cell-action { text-align: left; padding-top: 8px; }
  .employees .detail > td { padding: 0 0 12px; }
  .employees .detail .table { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton, .pill.is-loading .pill-dot { animation: none; }
  .panel-body { transition: none; }
}
