/* publicsite portal — visual system.
 *
 * The tokens, the type scale and the component vocabulary are signavision's,
 * lifted from /opt/www_signavision_ca/static/css/main.css so the two products
 * read as one house. What changes here is density: that stylesheet dresses a
 * marketing page with 120px blur orbs and 5rem display headings, and this one
 * has to carry tables, forms and a file listing without tiring anyone out.
 *
 * Hand-written rather than Tailwind on purpose. signavision needs a node build
 * step (`npm run build:css`) before a class exists in the output; adding one
 * here would mean a template edit could ship a page with no styling until
 * someone remembered to rebuild. This file is served as it is written.
 *
 * No @import: every nested import is a serial round trip the browser cannot
 * begin until this file has parsed. Fonts are a <link> in base.html.
 */

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root {
  /* Surfaces, darkest first.
   *
   * signavision's ramp, lifted. Its values were chosen for a marketing page
   * that is mostly full-bleed dark with occasional cards; this is a dense app
   * where nearly everything sits inside a card, and at the original --surf-1
   * (#1c1838) the cards barely separated from the page behind them.
   *
   * The page ground stays at --void so the lift actually reads. Checked
   * before changing: --txt-3, the dimmest text, still clears 4.5:1 on
   * --surf-1 (4.91), and the two chart series still pass all six palette
   * checks against it -- the card surface IS the chart surface. */
  --void:    #14112a;
  --surf-1:  #26204d;   /* cards, sidebar, stat tiles, sticky table headers */
  --surf-2:  #322a63;   /* inputs' chrome, row hover, tags, muted badges */
  --surf-3:  #3b3273;   /* pressed / hovered controls */
  --border:  #332c5e;
  --border-2:#40376f;

  /* signavision ships two accent pairs: the Tailwind config says #00c9a7 /
     #3b8ef3, main.css says #4f7fff / #8b5cf6. main.css is what actually paints
     the live site, so that is the pair used here. */
  --accent:  #4f7fff;
  --accent2: #8b5cf6;

  --txt-1: #e8e8f4;
  --txt-2: #a5a5cf;
  --txt-3: #8e8ec8;

  --ok:      #34d399;
  --warn:    #fbbf24;
  --danger:  #f87171;
  --pending: #60a5fa;

  --radius:    12px;
  --radius-sm: 8px;
  --radius-lg: 16px;

  --shadow: 0 16px 48px rgba(79, 127, 255, 0.08);

  --sidebar: 248px;
  --max:     1400px;

  color-scheme: dark;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--void);
  color: var(--txt-1);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; letter-spacing: -0.02em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }

p { margin: 0 0 .75rem; }

code, pre, .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85em;
}

pre {
  background: #16132e;
  background: color-mix(in srgb, var(--void) 88%, var(--surf-1));
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem .9rem;
  overflow-x: auto;
  margin: 0;
}

hr { border: 0; height: 1px; background: var(--border); margin: 1.25rem 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--void); }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--txt-3); }

/* Keyboard focus must stay obvious: this is an admin tool operated fast. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ── Shell ──────────────────────────────────────────────────────────────── */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: var(--surf-1);
  border-right: 1px solid var(--border);
  padding: 1.1rem .85rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .25rem .5rem .9rem;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--txt-1);
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: grid; place-items: center;
  font-size: .8rem; font-weight: 800; color: #fff;
  flex: 0 0 auto;
}

.nav-group { display: flex; flex-direction: column; gap: 1px; }

.nav-label {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--txt-3);
  padding: 0 .5rem .35rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .48rem .55rem;
  border-radius: var(--radius-sm);
  color: var(--txt-2);
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surf-2); color: var(--txt-1); text-decoration: none; }
.nav-link.active { background: var(--surf-2); color: var(--txt-1); box-shadow: inset 2px 0 0 var(--accent); }
.nav-link .count { margin-left: auto; font-size: .72rem; color: var(--txt-3); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 17, 42, .85);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }

.content { padding: 1.5rem; max-width: var(--max); width: 100%; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.page-head .grow { flex: 1; min-width: 240px; }
.page-head .sub { color: var(--txt-2); margin: 0; }

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surf-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  /* A card is a raised surface, so it catches a little light along its top
     edge and casts a shadow. Cheaper and steadier than a gradient. */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 1px 2px rgba(0, 0, 0, .25);
}

/* Boxes that hold nothing should not compete with boxes that hold something.
   An empty card drops back toward the page ground and loses its highlight, so
   a screen of mostly-empty cards reads as quiet rather than busy.

   :has() is unsupported in older browsers, where every card simply stays at
   full brightness -- the same as before this rule existed. */
.card:has(.empty),
.stat:has(.value.is-zero) {
  background: #1d193c;
  background: color-mix(in srgb, var(--surf-1) 55%, var(--void));
  box-shadow: none;
}
.card + .card { margin-top: 1rem; }
.card-head {
  display: flex; align-items: center; gap: .75rem;
  margin: -.15rem 0 .9rem;
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .spacer { flex: 1; }
.card-tight { padding: 0; overflow: hidden; }
.card-tight .card-head { padding: 1rem 1.2rem 0; margin-bottom: .75rem; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* ── Stats ──────────────────────────────────────────────────────────────── */

.stat {
  background: var(--surf-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .05),
    0 1px 2px rgba(0, 0, 0, .25);
}
.stat .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--txt-3); font-weight: 650; }
.stat .value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.04em; margin-top: .15rem; }
.stat .value.ok { color: var(--ok); }
.stat .value.danger { color: var(--danger); }
.stat .value.pending { color: var(--pending); }
.stat .foot { font-size: .78rem; color: var(--txt-3); }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .15rem .55rem;
  border-radius: 100px;
  font-size: .73rem; font-weight: 650;
  letter-spacing: .02em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.badge.ok      { color: var(--ok);      background: rgba(52,211,153,.10); border-color: rgba(52,211,153,.25); }
.badge.danger  { color: var(--danger);  background: rgba(248,113,113,.10); border-color: rgba(248,113,113,.25); }
.badge.pending { color: var(--pending); background: rgba(96,165,250,.10); border-color: rgba(96,165,250,.25); }
.badge.warn    { color: var(--warn);    background: rgba(251,191,36,.10); border-color: rgba(251,191,36,.25); }
/* --txt-2, not --txt-3: on the lifted --surf-2 the dimmer ink falls to
   4.16:1, under the 4.5 floor. This is 5.39. */
.badge.muted   { color: var(--txt-2);   background: var(--surf-2); border-color: var(--border-2); }
.badge.plain::before { display: none; }

.tag {
  display: inline-block;
  padding: .1rem .45rem;
  background: var(--surf-2);
  border: 1px solid var(--border-2);
  border-radius: 5px;
  font-size: .74rem;
  color: var(--txt-2);
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  padding: .5rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surf-2);
  color: var(--txt-1);
  font: inherit; font-weight: 600; font-size: .84rem;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s, opacity .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surf-3); border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.disabled { opacity: .45; pointer-events: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent; color: #fff;
}
.btn-primary:hover { opacity: .9; box-shadow: 0 8px 24px rgba(79,127,255,.28); }

.btn-danger { color: var(--danger); border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.08); }
.btn-danger:hover { background: rgba(248,113,113,.16); border-color: var(--danger); }

.btn-sm { padding: .3rem .6rem; font-size: .78rem; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--txt-2); }
.btn-ghost:hover { background: var(--surf-2); color: var(--txt-1); }

.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

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

table.data { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.data th {
  text-align: left;
  font-size: .7rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--txt-3); font-weight: 700;
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surf-1);
  position: sticky; top: 0;
}
table.data td { padding: .6rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surf-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data td.shrink { width: 1%; white-space: nowrap; }

.empty { padding: 2.25rem 1rem; text-align: center; color: var(--txt-3); opacity: .85; }
.empty .big { font-size: 1rem; color: var(--txt-2); margin-bottom: .35rem; }

/* ── Forms ──────────────────────────────────────────────────────────────── */

.field { margin-bottom: 1rem; }
.field > label {
  display: block; margin-bottom: .3rem;
  font-weight: 600; font-size: .82rem; color: var(--txt-2);
}
.field .help { font-size: .78rem; color: var(--txt-3); margin-top: .3rem; }
.field .errors { font-size: .8rem; color: var(--danger); margin-top: .3rem; }

input[type=text], input[type=password], input[type=email], input[type=number],
input[type=search], input[type=url], select, textarea {
  width: 100%;
  padding: .5rem .7rem;
  /* Recessed relative to the card it sits in, which is what makes a field
     look like a field. Kept off --void so it does not read as a hole now that
     the cards are brighter. */
  background: #191634;
  background: color-mix(in srgb, var(--void) 70%, var(--surf-1));
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  color: var(--txt-1);
  font: inherit; font-size: .86rem;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
/* Lifted with the surfaces. A placeholder is exempt from the text floor, but
   at 2.7:1 it was genuinely hard to read; this is 4.1:1 and still clearly
   subordinate to typed text at 14:1. */
input::placeholder, textarea::placeholder { color: #7d79ab; }
textarea { resize: vertical; line-height: 1.5; }
textarea.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .82rem; line-height: 1.55; tab-size: 2;
}
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--txt-3) 50%), linear-gradient(135deg, var(--txt-3) 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 2rem; }
input[type=file] { font-size: .82rem; color: var(--txt-2); }

.form-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 160px; margin-bottom: 0; }
.form-narrow { max-width: 560px; }

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; }
legend { padding: 0 .4rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--txt-3); }

/* ── Messages ───────────────────────────────────────────────────────────── */

.messages { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.15rem; }
.message {
  padding: .65rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--surf-1);
  font-size: .86rem;
  border-left-width: 3px;
}
.message.success { border-left-color: var(--ok);      background: rgba(52,211,153,.07); }
.message.error   { border-left-color: var(--danger);  background: rgba(248,113,113,.07); }
.message.warning { border-left-color: var(--warn);    background: rgba(251,191,36,.07); }
.message.info    { border-left-color: var(--pending); background: rgba(96,165,250,.07); }

.notice {
  padding: .8rem 1rem;
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--pending);
  border-radius: var(--radius-sm);
  background: var(--surf-1);
  font-size: .86rem;
  color: var(--txt-2);
  margin-bottom: 1rem;
}
.notice.danger { border-left-color: var(--danger); }
.notice.warn   { border-left-color: var(--warn); }
.notice strong { color: var(--txt-1); }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab {
  padding: .55rem .85rem;
  color: var(--txt-2); font-weight: 600; font-size: .85rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--txt-1); text-decoration: none; }
.tab.active { color: var(--txt-1); border-bottom-color: var(--accent); }

/* ── Definition lists ───────────────────────────────────────────────────── */

.facts { display: grid; grid-template-columns: max-content 1fr; gap: .45rem 1.1rem; font-size: .86rem; margin: 0; }
.facts dt { color: var(--txt-3); font-weight: 600; }
.facts dd { margin: 0; word-break: break-word; }

/* ── Checks (doctor / jail) ─────────────────────────────────────────────── */

.check { display: flex; gap: .65rem; padding: .55rem 0; border-bottom: 1px solid var(--border); align-items: flex-start; }
.check:last-child { border-bottom: 0; }
.check .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: .42rem; flex: 0 0 auto; }
.check .dot.ok { background: var(--ok); }
.check .dot.danger { background: var(--danger); }
.check .dot.pending { background: var(--warn); }
.check .body { min-width: 0; flex: 1; }
.check .title { font-weight: 600; font-size: .85rem; }
.check .detail { color: var(--txt-3); font-size: .8rem; word-break: break-word; }
.check .fix { color: var(--warn); font-size: .8rem; margin-top: .15rem; }

/* ── File manager ───────────────────────────────────────────────────────── */

.crumbs { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; font-size: .85rem; margin-bottom: .9rem; }
.crumbs a { color: var(--txt-2); }
.crumbs a:hover { color: var(--txt-1); }
.crumbs .sep { color: var(--txt-3); }
.crumbs .here { color: var(--txt-1); font-weight: 600; }

.file-icon {
  width: 22px; height: 22px; border-radius: 5px;
  display: inline-grid; place-items: center;
  font-size: .62rem; font-weight: 700; letter-spacing: -.02em;
  background: var(--surf-2); color: var(--txt-3);
  flex: 0 0 auto;
}
.file-icon.folder { background: rgba(79,127,255,.14); color: var(--accent); }
.file-icon.code   { background: rgba(139,92,246,.14); color: var(--accent2); }
.file-icon.image  { background: rgba(52,211,153,.12); color: var(--ok); }
.file-icon.doc    { background: rgba(251,191,36,.12); color: var(--warn); }

.file-name { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.file-name .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar form { display: flex; gap: .4rem; align-items: center; }
.toolbar input[type=text] { width: 170px; }

/* ── Utility ────────────────────────────────────────────────────────────── */

.muted { color: var(--txt-3); }
.dim   { color: var(--txt-2); }
.small { font-size: .8rem; }
.tiny  { font-size: .74rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt1 { margin-top: .5rem; } .mb1 { margin-bottom: .5rem; }
.mt2 { margin-top: 1rem; }  .mb2 { margin-bottom: 1rem; }
.mt3 { margin-top: 1.5rem; }
.flex { display: flex; gap: .5rem; align-items: center; }
.flex-between { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.wrap-anywhere { overflow-wrap: anywhere; }
.divider { height: 1px; background: linear-gradient(90deg, transparent, var(--border), transparent); margin: 1.25rem 0; }

/* An inline form that should not introduce layout. */
form.inline { display: inline; }

/* ── Auth ───────────────────────────────────────────────────────────────── */

.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surf-1); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.75rem; box-shadow: var(--shadow); }
.auth-card .brand { justify-content: center; border-bottom: 0; padding-bottom: .35rem; font-size: 1.2rem; }
.auth-card .lede { text-align: center; color: var(--txt-3); font-size: .85rem; margin-bottom: 1.4rem; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: .5rem; padding: .7rem .9rem;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .brand { border-bottom: 0; padding: 0 .5rem 0 0; }
  .nav-group { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .nav-link.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .content { padding: 1rem; }
}

@media print {
  .sidebar, .topbar, .toolbar, .btn { display: none !important; }
  body { background: #fff; color: #000; }
}

/* ── Charts ─────────────────────────────────────────────────────────────── */
/*
 * The two series colours are NOT the portal's own accent pair.
 *
 * --accent (#4f7fff) and --accent2 (#8b5cf6) are blue and violet, and against
 * each other they fail as a categorical palette: CVD ΔE 2.2 for deuteranopia
 * and 10.3 for normal vision, where the floor is 15. They look distinct to a
 * full-colour reader and are the same bar to a red-green colourblind one.
 *
 * Slot 2 is therefore orange. Validated on the portal's dark surface
 * (#1c1838): CVD ΔE 30.3 protan, 34.2 normal, both series ≥3:1 contrast, all
 * six checks pass. The brand blue is kept as slot 1, so the chart still reads
 * as part of this product.
 *
 * Do not "fix" these back to the accent pair without re-running the validator.
 */
:root {
  --series-1: #4f7fff;   /* pageviews — the portal's own blue */
  --series-2: #d95926;   /* visitors  — validated against slot 1 */
  /* Recessive against the card it is drawn on; lifted with the surfaces so it
     does not disappear. */
  --grid: #3a3269;
}

.chart-card { overflow: hidden; }

.chart-figure { margin: 0; }
.chart-svg { display: block; width: 100%; height: auto; }

/* Recessive: the data is the subject, the scaffolding is not. */
.chart-grid line { stroke: var(--grid); stroke-width: 1; }
.chart-grid text,
.chart-axis text { fill: var(--txt-3); font-size: 10px; }
.chart-baseline { stroke: var(--border-2); stroke-width: 1; }

.bar-pageviews { fill: var(--series-1); }
.bar-visitors  { fill: var(--series-2); }

/* One transparent target per day, wider than the bars it covers, so the
   tooltip is reachable without pixel-hunting a 2px mark. */
.chart-hit { fill: transparent; }
.chart-hit:hover { fill: rgba(255, 255, 255, 0.04); }

.chart-legend {
  display: flex; gap: 1.1rem; flex-wrap: wrap;
  margin: .35rem 0 0 var(--chart-pad-left, 44px);
  font-size: .78rem; color: var(--txt-2);
}
.chart-legend .key { display: inline-flex; align-items: center; gap: .4rem; }
/* The swatch carries identity; the label stays in text ink, never the series
   colour. */
.chart-legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.chart-legend .swatch.s1 { background: var(--series-1); }
.chart-legend .swatch.s2 { background: var(--series-2); }

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 30;
  min-width: 148px;
  padding: .5rem .65rem;
  background: var(--surf-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  font-size: .78rem;
  opacity: 0;
  transition: opacity .12s;
}
.chart-tooltip[data-open="1"] { opacity: 1; }
.chart-tooltip .t-day { font-weight: 700; margin-bottom: .3rem; }
.chart-tooltip .t-row { display: flex; align-items: center; gap: .4rem; justify-content: space-between; }
.chart-tooltip .t-row .n { font-variant-numeric: tabular-nums; color: var(--txt-1); }
.chart-tooltip .t-label { display: inline-flex; align-items: center; gap: .35rem; color: var(--txt-2); }

.chart-wrap { position: relative; }

/* Inline magnitude bar behind a table label — sequential, one hue. */
.share-cell { position: relative; }
.share-bar {
  position: absolute; inset: 0 auto 0 0;
  background: rgba(79, 127, 255, .16);
  border-radius: 3px;
  pointer-events: none;
}
.share-cell > span { position: relative; }

/* Reduced motion: the tooltip fade is the only animation here. */
@media (prefers-reduced-motion: reduce) {
  .chart-tooltip { transition: none; }
}

/* Selective direct labels: the peak of each series.
   Text wears text ink, never the series colour -- the bar beneath it already
   carries identity, and a coloured numeral is harder to read against the
   surface than it looks. */
.peak-label {
  fill: var(--txt-1);
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── View-as banner ─────────────────────────────────────────────────────── */
/*
 * Deliberately loud and deliberately sticky. An operator who forgets they are
 * inside a member's view will misread every page after it, so this must be
 * impossible to miss and impossible to scroll away from.
 */
.viewas-bar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-wrap: wrap;
  padding: .55rem 1.5rem;
  background: rgba(251, 191, 36, .12);
  border-bottom: 1px solid rgba(251, 191, 36, .4);
  color: var(--txt-1);
  font-size: .85rem;
}
.viewas-bar .spacer { flex: 1; }
.viewas-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn);
  flex: 0 0 auto;
}
@media (prefers-reduced-motion: no-preference) {
  .viewas-dot { animation: pulse-dot 2s ease-in-out infinite; }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}
