/* Design tokens. Dark values are declared under both the media query (OS
   setting) and the data-theme scope (explicit toggle), so the toggle wins
   either way.

   Two kinds of colour live here and they are kept apart on purpose. The
   `--series-*` slots belong to the charts and never change meaning; the
   `--accent` family belongs to the interface (links, buttons, the active nav
   item, focus rings). An interface painted in a chart colour makes every
   button look like a data point. */
:root {
  color-scheme: light;
  --page: #f3f4f8;
  --surface-1: #ffffff;
  --surface-2: #f7f8fb;
  --text-primary: #0f1222;
  --text-secondary: #4b5063;
  --text-muted: #858a9c;
  --grid: #e6e8ef;
  --axis: #c9ccd8;
  --border: rgba(15, 18, 34, 0.09);
  --border-strong: rgba(15, 18, 34, 0.16);

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.10);
  --accent-ring: rgba(79, 70, 229, 0.28);
  --accent-ink: #ffffff;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 55%, #4338ca 100%);
  --brand-gradient: linear-gradient(135deg, #6366f1, #06b6d4);

  --rail-bg: #12172b;
  --rail-bg-2: #0d1123;
  --rail-text: #b8bdd0;
  --rail-muted: #6b7190;
  --rail-hover: rgba(255, 255, 255, 0.06);
  --rail-on: rgba(129, 140, 248, 0.18);
  --rail-on-text: #ffffff;
  --rail-border: rgba(255, 255, 255, 0.06);

  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;

  --diverge-pos: #2a78d6;
  --diverge-neg: #e34948;
  --diverge-mid: #eceef4;

  --good: #12924a;
  --good-soft: rgba(18, 146, 74, 0.11);
  --warning: #c27a00;
  --warning-soft: rgba(235, 160, 0, 0.14);
  --serious: #ec835a;
  --critical: #d03b3b;
  --critical-soft: rgba(208, 59, 59, 0.10);

  --shadow-sm: 0 1px 2px rgba(15, 18, 34, 0.05);
  --shadow-md: 0 1px 2px rgba(15, 18, 34, 0.04), 0 4px 14px rgba(15, 18, 34, 0.05);
  --shadow-lg: 0 10px 34px rgba(15, 18, 34, 0.14), 0 2px 6px rgba(15, 18, 34, 0.06);
  --shadow-accent: 0 6px 16px rgba(79, 70, 229, 0.28);

  --radius: 14px;
  --radius-sm: 9px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0b0e18;
    --surface-1: #141827;
    --surface-2: #1a1f30;
    --text-primary: #f3f4fa;
    --text-secondary: #b3b8cc;
    --text-muted: #7b8199;
    --grid: #252b3f;
    --axis: #333a52;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.14);
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: rgba(129, 140, 248, 0.16);
    --accent-ring: rgba(129, 140, 248, 0.38);
    --accent-ink: #0b0e18;
    --accent-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    --rail-bg: #0d1020;
    --rail-bg-2: #090b17;
    --rail-text: #aab0c6;
    --rail-muted: #5d637d;
    --rail-on: rgba(129, 140, 248, 0.2);
    --series-1: #4d92ea;
    --series-2: #ea6f3f;
    --series-3: #22b380;
    --series-4: #d99a1a;
    --diverge-pos: #4d92ea;
    --diverge-neg: #ee6b6b;
    --diverge-mid: #2b3147;
    --good: #34c46f;
    --good-soft: rgba(52, 196, 111, 0.14);
    --warning: #f0b429;
    --warning-soft: rgba(240, 180, 41, 0.14);
    --critical: #f06060;
    --critical-soft: rgba(240, 96, 96, 0.14);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.55);
    --shadow-accent: 0 6px 16px rgba(129, 140, 248, 0.22);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0b0e18;
  --surface-1: #141827;
  --surface-2: #1a1f30;
  --text-primary: #f3f4fa;
  --text-secondary: #b3b8cc;
  --text-muted: #7b8199;
  --grid: #252b3f;
  --axis: #333a52;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, 0.16);
  --accent-ring: rgba(129, 140, 248, 0.38);
  --accent-ink: #0b0e18;
  --accent-gradient: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  --rail-bg: #0d1020;
  --rail-bg-2: #090b17;
  --rail-text: #aab0c6;
  --rail-muted: #5d637d;
  --rail-on: rgba(129, 140, 248, 0.2);
  --series-1: #4d92ea;
  --series-2: #ea6f3f;
  --series-3: #22b380;
  --series-4: #d99a1a;
  --diverge-pos: #4d92ea;
  --diverge-neg: #ee6b6b;
  --diverge-mid: #2b3147;
  --good: #34c46f;
  --good-soft: rgba(52, 196, 111, 0.14);
  --warning: #f0b429;
  --warning-soft: rgba(240, 180, 41, 0.14);
  --critical: #f06060;
  --critical-soft: rgba(240, 96, 96, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.55);
  --shadow-accent: 0 6px 16px rgba(129, 140, 248, 0.22);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

/* Small inline icons. Every one is an inline SVG in the template -- no icon
   font, no sprite fetched from a CDN -- and sized to the text beside it. */
.ico {
  width: 17px; height: 17px; flex: none;
  stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
}

/* -- shell -----------------------------------------------------------------
   A fixed top bar for identity and preferences, a left rail for navigation.
   The rail is a list of pipeline stages -- it reads top to bottom because the
   pipeline runs top to bottom -- while the bar holds the three answers that
   are the same on every page: who am I, what does this look like, how do I
   leave. Putting those in the rail made the rail two things at once.

   The rail is dark in both themes. It is the one fixed thing on the screen,
   and a dark column beside light content reads as "chrome" at a glance, so
   the eye lands on the page rather than on the menu. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px;
  height: 58px; padding: 0 20px;
  background: color-mix(in srgb, var(--surface-1) 96%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text-primary);
         min-width: 0; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: var(--brand-gradient);
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
  color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; stroke: #fff; fill: none;
                  stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 700; letter-spacing: -0.015em; line-height: 1.15; min-width: 0;
              font-size: 14.5px; }
.brand-name span {
  display: block; color: var(--text-muted); font-weight: 500; font-size: 11px;
  letter-spacing: 0.02em; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* Account menu. <details> so it opens with the keyboard and without script. */
.menu { position: relative; }
.menu > summary {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 9px 4px 4px; border-radius: 999px; cursor: pointer;
  list-style: none; border: 1px solid transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary:hover { background: var(--surface-2); border-color: var(--border); }
.menu[open] > summary { background: var(--surface-2); border-color: var(--border); }
.menu > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--accent-gradient);
  color: #fff; font-size: 12.5px; font-weight: 700;
  box-shadow: 0 0 0 2px var(--surface-1), 0 0 0 3px var(--accent-soft);
}
.menu-who { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.menu-name { font-size: 13px; font-weight: 600; }
.menu-role { font-size: 10px; color: var(--text-muted); text-transform: uppercase;
             letter-spacing: 0.08em; font-weight: 600; }
.chev {
  width: 7px; height: 7px; flex: none; margin-left: 2px;
  border-right: 1.6px solid var(--text-muted); border-bottom: 1.6px solid var(--text-muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform .15s var(--ease);
}
.menu[open] .chev { transform: rotate(-135deg) translate(-3px, -3px); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  min-width: 232px; padding: 6px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: pop .14s var(--ease);
}
@keyframes pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.menu-head { padding: 9px 11px 11px; border-bottom: 1px solid var(--border);
             margin-bottom: 6px; }
.menu-head-name { font-weight: 650; }
.menu-head-sub { color: var(--text-muted); font-size: 11.5px; }
.menu-panel a, .menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px; border: 0; background: none;
  color: var(--text-secondary); font: inherit; font-size: 13px; cursor: pointer;
  font-weight: 500;
}
.menu-panel a:hover, .menu-item:hover {
  background: var(--surface-2); color: var(--text-primary); text-decoration: none;
}
.menu-panel .ico { width: 15px; height: 15px; color: var(--text-muted); }

.topic-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.topic-chip {
  display: flex; flex-direction: column; gap: 1px; min-width: 150px;
  padding: 9px 13px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-primary); background: var(--surface-1);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.topic-chip:hover { text-decoration: none; border-color: var(--text-muted); box-shadow: var(--shadow-md); }
.topic-chip.on { border-color: var(--accent); background: var(--accent-soft);
                 box-shadow: 0 0 0 3px var(--accent-ring); }

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - 58px); }

.rail {
  flex: none; width: 232px;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, var(--rail-bg), var(--rail-bg-2));
  border-right: 1px solid var(--rail-border);
  position: sticky; top: 58px; height: calc(100vh - 58px);
  /* The navigation scrolls; the rail itself does not, so the topic list can
     float over the nav instead of being clipped by it. */
  overflow: visible;
}

/* The product, in the bar. */
/* Two rows, one name: the first line carries the weight, the second completes
   it in the same size so it reads as a title rather than a tagline. */
.app-name { font-weight: 700; font-size: 14px; letter-spacing: -0.015em; line-height: 1.15;
            color: var(--text-primary); min-width: 0; white-space: nowrap; }
.app-name span { display: block; font-weight: 500; color: var(--text-secondary); }

/* The topic switcher, at the head of the rail. It expands in place. */
.rail-topic { position: relative; border-bottom: 1px solid var(--rail-border); }
.rail-topic > summary {
  display: flex; align-items: center; gap: 9px; cursor: pointer; list-style: none;
  padding: 10px 14px; color: #fff;
  transition: background .15s var(--ease);
}
.rail-topic > summary::-webkit-details-marker { display: none; }
.rail-topic > summary:hover, .rail-topic[open] > summary { background: var(--rail-hover); }
.rail-topic > summary:focus-visible { outline: 2px solid #818cf8; outline-offset: -2px; }
.rail-topic .brand-name { color: #fff; font-size: 12.5px; font-weight: 600; line-height: 1.2;
                          white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-topic .brand-kicker { color: var(--rail-muted); font-size: 9px; }
.rail-topic .chev { border-color: var(--rail-muted); margin-left: auto; }
.rail-topic[open] .chev { transform: rotate(-135deg) translate(-3px, -3px); }
.rail-topic .topic-mark { width: 26px; height: 26px; border-radius: 8px; font-size: 12px; }
/* The list floats over the navigation rather than pushing it down: the rail
   keeps its shape whether or not the list is open. Closed by a click outside
   or Escape, like the account menu. */
.rail-topic-list {
  position: absolute; top: calc(100% + 4px); left: 8px; right: 8px; z-index: 40;
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--rail-bg); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: pop .14s var(--ease);
}
.rail-topic-list a {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 8px;
  color: var(--rail-text); font-size: 13px; font-weight: 500;
}
.rail-topic-list a:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail-topic-list a.on { background: var(--rail-on); color: #fff; }
.rail-topic-list a.on .topic-dot { background: #a5b4fc; }
.rail-topic-name { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.rail-topic-name .menu-item-sub { margin: 0; }
.rail-topic-add { color: #a5b4fc; }
.rail-topic-add .ico { width: 15px; height: 15px; }
.rail-foot { padding: 10px 16px 14px; color: var(--rail-muted); font-size: 10.5px;
             font-family: var(--mono); border-top: 1px solid var(--rail-border);
             display: flex; align-items: center; gap: 6px; flex-wrap: wrap; cursor: default; }
.db-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; background: var(--rail-muted); }
.db-dot.ok { background: var(--good); box-shadow: 0 0 0 3px rgba(52, 196, 111, 0.18); }
.db-dot.down { background: var(--critical); box-shadow: 0 0 0 3px rgba(240, 96, 96, 0.18); }
.rail-foot .db-state { color: var(--rail-text); }

/* The topic's tile: its initial, in the accent, so it does not share a
   symbol with the product mark in the bar. */
.topic-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  background: rgba(129, 140, 248, 0.18); color: #c7d2fe;
  border: 1px solid rgba(129, 140, 248, 0.35);
  font-weight: 800; font-size: 14px;
}
.brand-kicker { display: block; color: var(--text-muted); font-size: 9.5px; font-weight: 700;
                text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 1px; }
.topic-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rail-muted); flex: none; }
.menu-item-sub { display: block; font-size: 11px; color: var(--rail-muted);
                 font-family: var(--mono); }

.rail-nav { display: flex; flex-direction: column; gap: 2px; padding: 14px 12px 18px; flex: 1;
            min-height: 0; overflow-y: auto;
            scrollbar-width: thin; scrollbar-color: var(--rail-muted) transparent; }
.rail-nav a {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: 9px;
  color: var(--rail-text); font-weight: 500; font-size: 13.5px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.rail-nav a .ico { color: var(--rail-muted); transition: color .15s var(--ease); }
.rail-nav a:hover { background: var(--rail-hover); text-decoration: none; color: #fff; }
.rail-nav a:hover .ico { color: #fff; }
.rail-nav a.on { background: var(--rail-on); color: var(--rail-on-text); font-weight: 600; }
.rail-nav a.on .ico { color: #a5b4fc; }
/* The active item carries a short bar on its left edge, so it still reads as
   selected for anyone who cannot see the tint. */
.rail-nav a.on::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: #818cf8;
}
.rail-group {
  color: var(--rail-muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em;
  padding: 18px 11px 6px;
}
.rail-group:first-child { padding-top: 6px; }

/* A segmented control: the current choice is visible, and "Auto" is a real
   option rather than the absence of one. Icons, not words: sun, moon and
   screen say the same thing in every language the team works in. */
.theme-control {
  display: flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
}
.theme-control button {
  display: grid; place-items: center;
  width: 30px; height: 26px; padding: 0;
  border: none; background: none; color: var(--text-muted); border-radius: 999px;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.theme-control button .ico { width: 15px; height: 15px; }
.theme-control button:hover { background: var(--surface-1); color: var(--text-primary); }
.theme-control button.on {
  background: var(--surface-1); color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.main { flex: 1; min-width: 0; padding: 30px 32px 80px; }

/* The menu handle and the drawer's close control exist only on a phone. */
.menu-toggle, .rail-close { display: none; }

/* On a phone the rail becomes a drawer: off the left edge until the handle
   in the bar is pressed, then over the page behind a backdrop, and gone
   again once a destination is chosen. A strip of tabs along the top was the
   alternative; it hid the topic switcher and turned five stages into a
   horizontal scroll nobody discovers. The drawer needs a line of script to
   open, so the handle is a real button and the links inside are ordinary
   links: without script the rail is simply off-screen and the page still
   reads. */
@media (max-width: 860px) {
  .menu-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0; flex: none; margin-left: -4px;
    background: transparent; border-color: transparent; box-shadow: none;
    color: var(--text-primary);
  }
  .menu-toggle .ico { width: 21px; height: 21px; }
  .rail {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 60;
    width: min(300px, 84vw); height: 100dvh;
    border-right: none; overflow-y: auto;
    transform: translateX(-102%);
    transition: transform .28s var(--ease), box-shadow .28s var(--ease), visibility 0s .28s;
    visibility: hidden;
  }
  .rail.open { transform: none; visibility: visible; transition-delay: 0s;
               box-shadow: 0 0 60px rgba(0, 0, 0, 0.45); }
  .rail-close {
    display: inline-flex; align-items: center; justify-content: center;
    position: absolute; top: 10px; right: 10px; z-index: 2; width: 36px; height: 36px; padding: 0;
    background: transparent; border-color: transparent; box-shadow: none;
    color: var(--rail-text);
  }
  .rail-close:hover { background: var(--rail-hover); color: #fff; }
  .rail-topic > summary { padding-right: 52px; }
  .rail-nav a { padding-top: 11px; padding-bottom: 11px; }
  .drawer-backdrop {
    position: fixed; inset: 0; z-index: 55;
    background: rgba(9, 12, 24, 0.5); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    opacity: 0; transition: opacity .28s var(--ease);
  }
  .drawer-backdrop.on { opacity: 1; }
  body.drawer-open { overflow: hidden; }
  .main { padding: 18px 16px 56px; }
  /* On a phone the bar keeps the handle, the brand and the account; the
     theme control is three more targets in a 44px-high row and loses the
     fight. It is still on the change-password page and in the OS. */
  .theme-control { display: none; }
  .menu-who { display: none; }
  .topbar { padding: 0 12px; gap: 8px; }
  .app-name { font-size: 13px; }
}

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }

/* -- tabs: sections of one page, linkable and script-free --
   A tab strip, not a button group: every tab stands on one shared baseline
   and the open one is marked by an accent bar that sits on that line, so the
   content under it reads as that tab's page. The strip runs the width of the
   content and its tabs share it; a narrow screen wraps them onto more rows. */
.tabs {
  display: flex; flex-wrap: wrap; width: 100%; gap: 0 4px;
  margin-bottom: 22px; border-bottom: 1px solid var(--border-strong);
}
.tabs a {
  position: relative; flex: 1 1 0; min-width: max-content; text-align: center;
  padding: 11px 16px 12px; color: var(--text-secondary); font-weight: 500;
  font-size: 13.5px; border-radius: 8px 8px 0 0;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.tabs a::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px;
  height: 3px; border-radius: 3px 3px 0 0; background: transparent;
  transition: background .15s var(--ease), left .2s var(--ease), right .2s var(--ease);
}
.tabs a:hover { color: var(--text-primary); background: var(--surface-2); text-decoration: none; }
.tabs a:hover::after { background: var(--border-strong); }
.tabs a.on { color: var(--accent); font-weight: 650; background: transparent; }
.tabs a.on::after { left: 0; right: 0; background: var(--accent); }
.tabs a:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
/* Wrapped onto rows, one baseline under the whole strip would leave the
   open tab's bar floating between rows; each tab carries its own line. */
@media (max-width: 860px) {
  .tabs { border-bottom: none; gap: 0; }
  .tabs a { border-bottom: 1px solid var(--border-strong); padding: 10px 12px 11px; }
}

/* One page per phase: the phase's name and blurb, then the tabs for its views.
   The view's own title sits under the tabs as an h2 so the page reads phase >
   view rather than two competing headlines. */
.phase-head { margin-bottom: 14px; }
.phase-head .page-sub { margin-bottom: 0; }
.page-tabs { margin-bottom: 26px; }
.view-title { font-size: 19px; font-weight: 700; letter-spacing: -0.015em;
              margin: 0 0 4px; line-height: 1.3; }
.view-title + .page-sub { margin-bottom: 20px; }

.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.row-3 > * { min-width: 0; }
.inline-form { display: inline-flex; gap: 5px; align-items: center; margin: 0 0 4px; }

h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; letter-spacing: -0.02em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 650; margin: 0 0 14px; letter-spacing: -0.01em; }
.page-sub { color: var(--text-secondary); margin: 0 0 24px; }

/* -- cards -- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-md);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.card-note { color: var(--text-muted); font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
.grid-2 > .span-2 { grid-column: 1 / -1; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; }

/* -- stat tiles: the number IS the chart when there is one number -- */
.tile {
  position: relative; overflow: hidden;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px 15px;
  box-shadow: var(--shadow-md);
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.tile::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: var(--accent-gradient); opacity: 0.85;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile-label { color: var(--text-secondary); font-size: 11px; font-weight: 600;
              text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px;
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
              font-variant-numeric: tabular-nums; }
.tile-note { color: var(--text-muted); font-size: 11.5px; margin-top: 6px; }
.tile-value.neg { color: var(--critical); }
.tile-value.pos { color: var(--good); }

/* -- charts -- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .reference { stroke: var(--axis); stroke-width: 1.5; }
.chart .tick { fill: var(--text-muted); font-size: 11px; font-family: var(--font);
                font-variant-numeric: tabular-nums; }
.chart .bar-label { fill: var(--text-secondary); font-size: 12.5px; font-family: var(--font); }
.chart .bar-value { fill: var(--text-primary); font-size: 12px; font-family: var(--font);
                    font-variant-numeric: tabular-nums; }
.chart .series-label { fill: var(--text-secondary); font-size: 12px; font-weight: 600;
                       font-family: var(--font); }
/* The crosshair: one hairline the script snaps to the nearest period while
   a pointer is over a line chart, with one tooltip for every series there. */
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; opacity: 0;
                    transition: opacity .12s; pointer-events: none; }
.chart.hover .crosshair { opacity: 0.7; }
.chart .dot.lit { stroke-width: 3; }
.chart .peak-label { fill: var(--text-primary); font-size: 11.5px; font-weight: 600;
                     font-family: var(--font); font-variant-numeric: tabular-nums; }
/* A live chart: the server's SVG and its numbers, laid out as if the wrapper
   were not there, until charts.js puts an ECharts host in the SVG's place.
   Height is the chart's business (set per kind); width is the card's. */
.live-chart { display: contents; }
.echart { width: 100%; height: 340px; }
.echart-donut { flex: none; }
/* The moment something was done. Dashed, because unlike the grid it really is
   a threshold: everything left of it is what the fit was judged on. */
.chart .event-rule { stroke: var(--text-muted); stroke-width: 1.5;
                     stroke-dasharray: 4 3; }
.chart .event-label { fill: var(--text-muted); font-size: 11px; font-weight: 600;
                      font-family: var(--font); }
/* The peta percakapan: graph in the middle, callouts in the corners, the node
   insight panel beside it. Neutral actors take a grey of their own -- the
   diverging midpoint is too close to the surface to read as a dot. */
:root { --sna-neutral: #9aa0b4; }
.sna { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: 18px; align-items: start; }
@media (max-width: 900px) { .sna { grid-template-columns: minmax(0, 1fr); } }
.sna-graph { display: block; margin: 0 auto; }
.sna-graph .sna-name { fill: var(--text-primary); font-size: 10.5px; font-weight: 600;
  font-family: var(--font); }
.sna-graph .sna-callout { fill: var(--text-secondary); font-size: 10.5px; font-family: var(--font); }
.sna-graph .sna-callout-title { font-size: 10.5px; font-weight: 800; letter-spacing: 0.05em; }
.sna-graph .sna-arrow { stroke: var(--text-primary); stroke-width: 1.4; }
.sna-graph .sna-note { fill: var(--text-muted); font-size: 11px; font-style: italic;
  font-family: var(--font); }
.sna-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0;
  color: var(--text-muted); font-size: 11.5px; }
.sna-legend .swatch { display: inline-block; vertical-align: -1px; margin-right: 5px;
  border-radius: 50%; }
.sna-panel { border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 12px 14px; font-size: 12px; }
.sna-panel h3 { margin: 0 0 8px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted); }
.sna-panel h3 + h3, .sna-panel .sna-profile + h3, .sna-panel .sna-sent + h3 { margin-top: 14px; }
.sna-profile { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sna-profile div { background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; }
.sna-profile small { display: block; color: var(--text-muted); font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.05em; }
.sna-profile b { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.sna-sent div { display: grid; grid-template-columns: 62px 1fr 34px; align-items: center;
  gap: 8px; margin: 4px 0; }
.sna-sent .bar { height: 5px; border-radius: 3px; background: var(--grid); overflow: hidden; }
.sna-sent .bar i { display: block; height: 100%; }
.sna-sent .num { text-align: right; color: var(--text-secondary); }
.sna-top { list-style: none; margin: 0; padding: 0; }
.sna-top li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 3px 0;
  border-top: 1px solid var(--border); }
.sna-top li:first-child { border-top: 0; }
.sna-top .who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sna-top .who small { color: var(--text-muted); margin-left: 5px; }
.sna-top .deg { color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.sna-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  vertical-align: -1px; margin-right: 6px; }
.sna-dot.positive { background: var(--diverge-pos); }
.sna-dot.negative { background: var(--diverge-neg); }
.sna-dot.neutral { background: var(--sna-neutral); }

.chart .dot, .chart .bar { cursor: pointer; transition: opacity .12s; }
.chart .dot { stroke: var(--surface-1); stroke-width: 2; }
.chart .dot:hover { stroke-width: 3; }
.chart .bar:hover { opacity: 0.8; }
.spark { vertical-align: middle; }

.chart-empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm); font-size: 13px; text-align: center; padding: 0 16px;
  background: var(--surface-2);
}

.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px;
               color: var(--text-secondary); font-size: 12px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

#tooltip {
  position: fixed; z-index: 60; pointer-events: none; opacity: 0;
  background: var(--text-primary); color: var(--page);
  border-radius: 8px;
  padding: 7px 10px; font-size: 12px; line-height: 1.45;
  box-shadow: var(--shadow-lg); transition: opacity .1s;
  max-width: 280px;
}
#tooltip strong { font-weight: 600; }
#tooltip .t-val { font-variant-numeric: tabular-nums; }
#tooltip .t-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
#tooltip .t-swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
#tooltip .t-name { color: var(--text-secondary); }
#tooltip .t-row .t-val { margin-left: auto; font-weight: 600; }

/* -- tables: the relief for sub-3:1 series colours, and always available -- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
th {
  text-align: left; font-weight: 600; color: var(--text-muted);
  padding: 9px 12px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
}
th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--accent-soft); }

/* -- data tables. The toolbar above (page length, search) and the line and
   pager below are the DataTables furniture, drawn in the interface palette:
   the current page is an accent button, never a series colour. The sort
   arrow lives on the header itself so a column says whether it is sorted
   without a legend. */
.dt { min-width: 0; }
.dt-top, .dt-bottom { display: flex; align-items: center; justify-content: space-between;
                      gap: 12px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-secondary); }
.dt-top { margin-bottom: 10px; }
.dt-bottom { margin-top: 10px; }
.dt-len, .dt-search { display: inline-flex; align-items: center; gap: 6px; margin: 0;
                      font-size: 12.5px; font-weight: 500; color: var(--text-secondary); }
.dt-len select { width: auto; padding: 5px 26px 5px 9px; font-size: 12.5px; box-shadow: none; }
.dt-search input { width: 220px; max-width: 60vw; padding: 6px 10px; font-size: 12.5px;
                   box-shadow: none; }
.dt-info { font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.dt-pager { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dt-pager .dt-page { padding: 4px 9px; min-width: 30px; justify-content: center;
                     font-size: 12px; font-weight: 500; box-shadow: none;
                     border-color: var(--border); background: transparent;
                     color: var(--text-secondary); }
.dt-pager .dt-page:hover { background: var(--surface-2); border-color: var(--border-strong);
                           color: var(--text-primary); }
.dt-pager .dt-page.on { background: var(--accent); border-color: transparent;
                        color: var(--accent-ink); }
.dt-pager .dt-page:disabled { background: transparent; }
.dt-pager .gap { padding: 0 3px; color: var(--text-muted); }
th.dt-sort { cursor: pointer; user-select: none; padding-right: 22px; position: relative;
             white-space: nowrap; }
th.dt-sort:hover { color: var(--text-secondary); }
th.dt-sort:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--accent-ring); }
th.dt-sort::after { content: "\2195"; position: absolute; right: 8px; top: 50%;
                    transform: translateY(-50%); font-size: 11px; opacity: 0.45; }
th.dt-sort[aria-sort="ascending"]::after { content: "\2191"; opacity: 1; color: var(--accent); }
th.dt-sort[aria-sort="descending"]::after { content: "\2193"; opacity: 1; color: var(--accent); }
tr.dt-empty td { text-align: center; padding: 18px 12px; }
/* The server-paged table (_pager.html): the same look, made of links and GET
   forms. A header's link fills it so the whole cell sorts. */
.dt-form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
a.dt-page { text-decoration: none; }
.dt-pager .dt-page[aria-disabled="true"] { opacity: .45; pointer-events: none; }
th.dt-sort .dt-sort-link { color: inherit; text-decoration: none; display: block; }
/* Hidden rows leave the visible last one with its rule; the footer sits
   under it, so the row keeps the rule and the last row of the table drops it. */
.dt tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.dt tbody tr:last-child td:first-child { border-bottom-left-radius: 0; }
@media (max-width: 640px) {
  .dt-search input { width: 100%; max-width: none; }
  .dt-search { flex: 1 1 100%; }
}

details.table-view { margin-top: 12px; }
details.table-view summary {
  cursor: pointer; color: var(--text-secondary); font-size: 12px; font-weight: 500;
  padding: 4px 0; user-select: none;
}
details.table-view summary:hover { color: var(--text-primary); }

/* -- pills & chips -- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-secondary);
  white-space: nowrap;
}
.pill.good { color: var(--good); background: var(--good-soft); border-color: transparent; }
.pill.warn { color: var(--warning); background: var(--warning-soft); border-color: transparent; }
.pill.crit { color: var(--critical); background: var(--critical-soft); border-color: transparent; }
.pill.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%;
                    background: currentColor; flex: none; }
a.pill:hover { text-decoration: none; border-color: var(--border-strong); }

.terms { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.term {
  font-family: var(--mono); font-size: 11.5px; padding: 1px 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; color: var(--text-secondary);
}

/* -- forms & buttons -- */
label { display: block; font-size: 12.5px; font-weight: 500; color: var(--text-secondary);
        margin-bottom: 5px; }
input[type="text"], input[type="number"], input[type="password"],
input[type="email"], input[type="url"], input[type="date"], input[type="datetime-local"],
input:not([type]), textarea, select {
  width: 100%; padding: 9px 11px; font-size: 13.5px; font-family: var(--font);
  color: var(--text-primary); background: var(--surface-1);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { font-family: var(--mono); font-size: 12.5px; min-height: 76px; resize: vertical; }
/* iOS Safari zooms the page into any field under 16px when it takes focus
   and does not zoom back out, leaving a sign-in or Settings form cropped
   and drifted. On a phone every field is 16px; the desktop sizes stay. */
@media (max-width: 860px) {
  /* The same selectors as the rule above, or its attribute selectors outrank
     a bare `input` and the password field on the sign-in page stays small. */
  input[type="text"], input[type="number"], input[type="password"],
  input[type="email"], input[type="url"], input[type="date"], input[type="datetime-local"],
  input[type="search"], input:not([type]), textarea, select,
  .dt-len select, .dt-search input { font-size: 16px; }
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field { margin-bottom: 15px; }
/* A checkbox and its words on one line, sized like the text beside a field. */
label.check { display: inline-flex; align-items: center; gap: 7px; margin: 0;
              font-size: 13px; color: var(--text-primary); cursor: pointer; }
label.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.field-hint { color: var(--text-muted); font-size: 11.5px; margin-top: 5px; line-height: 1.5; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 15px; font-size: 13px; font-weight: 600; font-family: var(--font);
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-1); color: var(--text-primary); cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background .15s var(--ease), box-shadow .15s var(--ease),
              transform .15s var(--ease), border-color .15s var(--ease);
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none;
                           border-color: var(--text-muted); }
button:active, .btn:active { transform: translateY(1px); }
button:focus-visible, .btn:focus-visible { outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring); }
button.primary {
  background: var(--accent-gradient); border-color: transparent; color: #fff;
  box-shadow: var(--shadow-accent);
}
button.primary:hover { filter: brightness(1.06); background: var(--accent-gradient); }
/* Something that cannot be undone. Outlined, not filled: it should never be
   the loudest thing on a page, only the most clearly marked. */
button.danger, .btn.danger { color: var(--critical); border-color: var(--critical); }
button.danger:hover, .btn.danger:hover { background: var(--critical-soft); border-color: var(--critical); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* -- the stage strip: which pipeline stage feeds this page, whether it has
   run, and the button to run it from here. */
.stage-strip { display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
               padding: 9px 14px; margin: -6px 0 16px; border-radius: var(--radius-sm);
               border: 1px dashed var(--border-strong); background: var(--surface-1); }
.stage-what { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.stage-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
               color: var(--text-muted); }
.stage-state { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 220px; flex-wrap: wrap; }
/* The run's last line takes whatever the strip has left and is cut with an
   ellipsis there, not at a fixed width; the full line is its title. */
.stage-line { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.stage-strip[data-stage-running] { border-style: solid; border-color: var(--accent); }
@media (max-width: 720px) { .stage-actions { margin-left: 0; } }

.btn.small, button.small { padding: 5px 10px; font-size: 12px; box-shadow: none; }

/* -- the monitoring timeline: three steps, the current one lit. */
.timeline { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.tl-step { padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border);
           background: var(--surface-2); position: relative; }
.tl-step.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.tl-step.done { opacity: .78; }
.tl-step.done .tl-label::after { content: " ✓"; color: var(--good); }
.tl-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
            color: var(--text-muted); margin-bottom: 4px; }
.tl-step.on .tl-label { color: var(--accent); }
.tl-value { font-size: 13px; line-height: 1.45; }
@media (max-width: 720px) { .timeline { grid-template-columns: 1fr; } }

/* -- modal forms. The native <dialog>, opened with showModal() so focus is
   trapped, Escape closes and the page behind is inert -- none of which a
   div with a backdrop gets for free. Rendered with `data-open` when the
   server wants it open on load (a ?edit= link, a rejected submission), so
   it works as a page even before app.js runs. */
dialog.modal {
  width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  padding: 0; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1); color: var(--text-primary);
  box-shadow: var(--shadow-lg); overflow: auto;
}
dialog.modal::backdrop { background: rgba(15, 18, 34, 0.45); backdrop-filter: blur(2px); }
dialog.modal[open] { animation: pop .16s var(--ease); }
.modal-body { padding: 22px 24px 20px; margin: 0; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between;
              gap: 12px; margin-bottom: 14px; }
.modal-head h2 { margin: 0 0 2px; }
.modal-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
                 color: var(--text-muted); margin: 18px 0 10px; }
.modal-close {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0; border-radius: 50%; font-size: 20px; line-height: 1;
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  box-shadow: none; cursor: pointer; text-decoration: none;
}
.modal-close:hover { background: var(--surface-2); color: var(--text-primary); text-decoration: none; }
.modal-foot { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
dialog.modal.modal-wide { width: min(980px, calc(100vw - 32px)); }

/* -- a run's log in the Recent runs table: the last lines and the error,
   each clipped to two lines so one long gateway error does not make the
   table a wall. "Full log" opens the whole of it (the server shows it when
   it knows the row is clipped; app.js when the text overflows). */
/* Which topic a run covered, under its name: the topic's name, then its id. */
.run-topic { margin-top: 2px; line-height: 1.35; }
.run-topic .mono { font-size: 11px; }
.run-log, .run-error {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow: hidden; overflow-wrap: anywhere; white-space: normal;
}
.pill.run-error { margin-top: 5px; border-radius: 8px; text-align: left; line-height: 1.45;
                  padding: 3px 9px; font-weight: 500; }
.run-more { display: inline-block; margin-top: 5px; font-family: var(--font); font-size: 12px;
            font-weight: 600; }
.run-more[hidden] { display: none; }
.run-full-log {
  margin: 14px 0 0; max-height: 58vh; overflow: auto; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere;
  color: var(--text-secondary);
}
.run-full-log .bad { color: var(--critical); }
.run-full-log .head { color: var(--text-primary); font-weight: 700; }
@media (max-width: 720px) {
  dialog.modal { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .modal-body .grid-2 { grid-template-columns: 1fr; }
}

.banner {
  position: relative;
  padding: 11px 14px 11px 18px; border-radius: var(--radius-sm); margin-bottom: 16px;
  border: 1px solid var(--border); background: var(--surface-1); font-size: 13px;
  box-shadow: var(--shadow-sm);
}
.banner::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--accent);
}
.banner.err { border-color: transparent; background: var(--critical-soft); color: var(--critical); }
.banner.err::before { background: var(--critical); }
.banner.warn { border-color: transparent; background: var(--warning-soft); }
.banner.warn::before { background: var(--warning); }
.banner.ok { border-color: transparent; background: var(--good-soft); color: var(--good); }
.banner.ok::before { background: var(--good); }
.banner a { font-weight: 600; }

/* -- toasts: what an action just did, over the top-right corner (app.js,
   "toasts"). The same .banner, lifted out of the flow and given a shadow,
   so an ok toast and an error toast read exactly as their banners do. */
.toasts {
  position: fixed; top: 68px; right: 20px; z-index: 60;
  display: flex; flex-direction: column; gap: 10px;
  width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.banner.toast {
  pointer-events: auto; margin: 0; padding-right: 40px;
  border: 1px solid var(--border); box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.18));
  background-clip: padding-box; animation: toast-in .28s var(--ease) both;
}
.banner.toast.ok { background: var(--surface-1); border-color: var(--border); color: var(--text-primary); }
.banner.toast.err { background: var(--surface-1); border-color: var(--critical); color: var(--text-primary); }
.banner.toast.leaving { animation: toast-out .22s var(--ease) both; }
.toast-close {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px;
  padding: 0; justify-content: center; font-size: 18px; line-height: 1;
  border: none; background: transparent; box-shadow: none; color: var(--text-muted);
}
.toast-close:hover { background: var(--surface-2); color: var(--text-primary); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }
@media (max-width: 860px) {
  .toasts { top: auto; bottom: 16px; right: 16px; left: 16px; width: auto; }
}

/* -- show-password toggle (password.js): an eye inside the field's right edge */
.pw-field { position: relative; display: block; }
.pw-field input { padding-right: 42px; }
.pw-toggle {
  position: absolute; top: 50%; right: 5px; transform: translateY(-50%);
  width: 32px; height: 32px; padding: 0; justify-content: center;
  border: none; background: transparent; box-shadow: none; color: var(--text-muted);
}
.pw-toggle:hover { background: var(--surface-2); color: var(--text-primary); }
.pw-toggle:active { transform: translateY(-50%); }
.pw-toggle[aria-pressed="true"] { color: var(--accent); }
.pw-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor;
                 stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* -- review -- */
.review-item { font-size: 16px; line-height: 1.6; margin: 10px 0 18px; }
.review-meta { color: var(--text-muted); font-size: 12px; }
.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice { flex: 1; min-width: 140px; justify-content: center; }
.kbd {
  font-family: var(--mono); font-size: 11px; padding: 1px 5px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 4px;
  color: var(--text-muted); background: var(--surface-2);
}

.quote {
  border-left: 3px solid var(--accent-soft); padding: 4px 0 4px 14px;
  margin: 10px 0; color: var(--text-secondary);
}
.quote:hover { border-left-color: var(--accent); }

/* -- variants: the alternatives an approver picks between -- */
.variants { margin-top: 14px; }
.variant {
  display: block; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-top: 8px; cursor: pointer;
  background: var(--surface-1);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.variant:hover { border-color: var(--text-muted); box-shadow: var(--shadow-md); }
.variant.chosen { border-color: var(--accent); background: var(--accent-soft);
                  box-shadow: 0 0 0 3px var(--accent-ring); }
.variant-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.variant-head input { margin: 0; accent-color: var(--accent); }
.variant-body {
  margin-top: 6px; white-space: pre-wrap; font-size: 13px;
  color: var(--text-secondary); line-height: 1.55;
}
.muted { color: var(--text-muted); }
.crit { color: var(--critical); }
/* A collection in progress: the pill and the card note pulse so "running"
   reads as now, not as a state that was true once. */
.live { animation: live-pulse 1.6s ease-in-out infinite; }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
/* A source's name is two words at most ("Berita online (GDELT)"); at the
   table's auto widths it broke onto three lines beside a wide Access cell. */
.src-name { min-width: 210px; }
.src-last { min-width: 180px; }
/* The attribute is the mechanism for "rendered, shown for one choice": a
   display rule on the element's class must not win over it. */
[hidden] { display: none !important; }
.small { font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }
.stack > * + * { margin-top: 14px; }

/* -- login and the other standalone pages ---------------------------------
   No rail, no bar: one card on a washed gradient. The gradient is the brand
   colours at low opacity, so the page is recognisably the same product before
   anyone has signed in. */
body.auth {
  min-height: 100vh;
  background:
    radial-gradient(60% 50% at 8% 0%, rgba(99, 102, 241, 0.18), transparent 60%),
    radial-gradient(50% 45% at 100% 100%, rgba(6, 182, 212, 0.14), transparent 60%),
    var(--page);
}
.login { max-width: 400px; margin: 10vh auto; padding: 0 16px; }
.login .card { padding: 30px 28px; box-shadow: var(--shadow-lg); }
.login h1 { font-size: 21px; margin-bottom: 6px; }
.login .brand-mark { margin-bottom: 18px; width: 40px; height: 40px; border-radius: 12px; }
.login .brand-mark svg { width: 22px; height: 22px; }
.login-mark {
  width: 40px; height: 40px; border-radius: 12px; margin-bottom: 18px;
  background: var(--brand-gradient);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}
.login button.primary { width: 100%; justify-content: center; padding: 10px 16px;
                        font-size: 14px; }

@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  main { padding: 16px 14px 48px; }
}

/* -- the diagnosis report -------------------------------------------------
   A narrative of framed cards rather than a dashboard grid: the reader is
   walked from volume to sentiment to who is driving it, and each card is
   sandwiched between the sentence that sets it up and the finding it produced.
   This is the shape Indonesian social-listening reports are read in, so it is
   the shape this page is written in. */
.report { }

.report-scope {
  background: linear-gradient(135deg, #f2743f, #e05a2b);
  color: #fff;
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 28px;
  box-shadow: 0 8px 24px rgba(235, 104, 52, 0.28);
}
.report-scope .scope-sources { font-weight: 650; font-size: 14.5px; }
.report-scope .scope-window { font-size: 12.5px; opacity: 0.92; margin-top: 3px; }

/* The bridge: prose that says what the last card showed, then the question the
   next one answers. Without it a report is a pile of charts. It runs the width
   of the cards around it: a paragraph held to a reading measure beside
   full-width cards read as a layout that had not finished loading. */
.bridge { margin: 28px 0 18px; }
.bridge p { margin: 0 0 10px; color: var(--text-secondary); line-height: 1.6;
            font-size: 14.5px; }
.bridge .ask { color: var(--text-primary); font-weight: 600; margin-bottom: 0; }

.rcard {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); border-bottom: 3px solid var(--series-2);
  padding: 18px 20px 20px; margin-bottom: 4px;
  box-shadow: var(--shadow-md);
}
.rcard-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.rcard-head h2 {
  margin: 0; color: var(--series-2); font-size: 14px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.rcard-head .rcard-note { color: var(--text-muted); font-size: 11.5px; }

/* The stat strip that opens every card: four numbers, labelled above, with the
   comparison below so a value is never shown without its context. */
.stat-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  margin-bottom: 14px;
}
.stat-strip .stat {
  padding: 12px 14px; border-right: 1px solid var(--border); background: var(--surface-2);
}
.stat-strip .stat:last-child { border-right: none; }
.stat-strip .stat-label {
  color: var(--text-muted); font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 3px;
}
.stat-strip .stat-value {
  font-size: 24px; font-weight: 700; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; line-height: 1.15;
}
.stat-strip .stat-value.neg { color: var(--diverge-neg); }
.stat-strip .stat-value.pos { color: var(--diverge-pos); }
.stat-strip .stat-note { color: var(--text-muted); font-size: 11px; margin-top: 2px; }

/* Three panes inside one card: the split, the breakdown, the vocabulary. */
.panes { display: grid; gap: 14px; }
.panes-3 { grid-template-columns: 250px minmax(0, 1fr) 210px; }
.panes-2 { grid-template-columns: 250px minmax(0, 1fr); }
.pane { min-width: 0; }
.pane-title {
  color: var(--text-secondary); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em; margin-bottom: 8px;
}
.chart .donut-total {
  fill: var(--text-primary); font-size: 26px; font-weight: 700;
  font-family: var(--font); font-variant-numeric: tabular-nums;
}
.chart .seg-label {
  fill: #fff; font-size: 10.5px; font-weight: 600; font-family: var(--font);
  font-variant-numeric: tabular-nums; pointer-events: none;
}
/* The neutral band is a surface colour in both themes, so its label takes ink
   that flips with the theme instead of the white that works on the other two. */
.chart .seg-label.on-neutral { fill: var(--text-secondary); }

/* The split under the ring: percentage and count, directly labelled, so the
   ring never has to be read by colour alone. */
.split-legend { display: flex; gap: 14px; justify-content: center; margin-top: 6px; }
.split-legend div { text-align: center; }
.split-legend .pct { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.split-legend .cnt { color: var(--text-muted); font-size: 11px;
                     font-variant-numeric: tabular-nums; }
.split-legend .nm { color: var(--text-secondary); font-size: 10.5px;
                    text-transform: uppercase; letter-spacing: 0.05em; }

.term-list { margin: 0 0 12px; }
.term-list .term-head { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
                        text-transform: uppercase; margin-bottom: 5px; }
.term-list .term-head.pos { color: var(--diverge-pos); }
.term-list .term-head.neg { color: var(--diverge-neg); }
.term-list .terms { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.term-list .terms span {
  font-size: 11.5px; color: var(--text-secondary);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; padding: 1px 6px;
}
.term-list .terms span b { color: var(--text-primary); font-weight: 600;
                           font-variant-numeric: tabular-nums; }

/* The findings under the card: what the reader should take away, each tied to
   the number it came from. */
.findings { list-style: none; margin: 14px 0 0; padding: 0; }
.findings li {
  display: flex; gap: 9px; align-items: flex-start;
  font-size: 13.5px; line-height: 1.55; color: var(--text-secondary);
  margin-bottom: 8px;
}
.findings li:last-child { margin-bottom: 0; }
.findings .dot-mark { width: 10px; height: 10px; border-radius: 999px;
                      flex: none; margin-top: 5px; }
.findings b { color: var(--text-primary); }

@media (max-width: 900px) {
  .panes-3, .panes-2 { grid-template-columns: 1fr; }
}

/* -- the three periods on the measure page: gathering, counter-sentiment,
   after. Three columns that read left to right in time, the middle one
   framed because it is the thing being judged. */
.periods { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.period { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px;
          background: var(--surface-2); }
.period-during { border-color: var(--accent); background: var(--surface-1);
                 box-shadow: 0 0 0 3px var(--accent-ring); }
.period-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.period-big { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
              font-variant-numeric: tabular-nums; }
.period-big.neg { color: var(--critical); }
.period-big.pos { color: var(--good); }
.share-bar { display: flex; height: 8px; border-radius: 999px; overflow: hidden;
             margin: 12px 0 6px; background: var(--diverge-mid); }
.share-bar span { display: block; height: 100%; }
.share-legend { display: flex; gap: 12px; color: var(--text-secondary); margin-bottom: 8px; }
.period-table { font-size: 12.5px; }
.period-table td { padding: 4px 6px 4px 0; border-bottom: 1px solid var(--border); }
.period-table tr:last-child td { border-bottom: none; }

/* A decision and an approval are attributed to the signed-in account, so the
   name is shown rather than asked for. It reads as a field so the form still
   scans as a form, but there is nothing to type: a name you can type is a name
   you can borrow, and the two-approver rule depends on you not being able to. */
.decider {
  padding: 8px 11px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-secondary); font-weight: 600; background: var(--surface-2);
}

/* -- motion. Three things move, and each says something: a page arrives
   (the view transition's crossfade, then the content rises into place in
   reading order), a request is in flight (the bar along the top and the
   button that was pressed spinning until the next page lands), and a
   chart is looked at (bars grow, lines draw, points and nodes pop in the
   first time it scrolls into view). Nothing loops, nothing bounces, and
   the reduced-motion rule below switches all of it off at once. */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: 120ms var(--ease) both vt-out; }
::view-transition-new(root) { animation: 200ms var(--ease) both vt-in; }
@keyframes vt-out { to { opacity: 0; } }
@keyframes vt-in { from { opacity: 0; } }

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* A page arrives dozens of times a day -- every tab is one -- so the rise is
   short and small and only the head of the page is staggered: settled in
   under 300ms, never a wait. It used to take 450ms over 10px with a stagger
   reaching 280ms, about 730ms before the last card stood still. */
.main > * { animation: rise .2s var(--ease) both; }
.main > :nth-child(2) { animation-delay: 40ms; }
.main > :nth-child(n+3) { animation-delay: 80ms; }
/* Table rows do not animate. The table script re-appends its rows on every
   sort, page and search keystroke, and an entrance there replayed on each
   one: the most frequent interaction in the app is not the place for one. */

/* The bar along the top: starts on any navigation or submit, creeps toward
   the right while the server thinks, and finishes when the next page lands. */
.nav-progress {
  position: fixed; top: 0; left: 0; z-index: 1000; height: 3px; width: 0;
  background: var(--accent-gradient); box-shadow: 0 0 10px var(--accent-ring);
  opacity: 0; pointer-events: none;
  transition: width .3s var(--ease), opacity .25s var(--ease);
}
.nav-progress.on { opacity: 1; width: 78%; transition: width 8s cubic-bezier(0.05, 0.6, 0.1, 1), opacity .1s; }
.nav-progress.done { opacity: 0; width: 100%; transition: width .25s var(--ease), opacity .3s .2s; }

/* The button that was pressed: a spinner where its icon would be, and the
   form goes quiet so a second press cannot send the same thing twice. */
button.busy, .btn.busy { pointer-events: none; opacity: 0.8; }
button.busy::before {
  content: ""; width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
form[aria-busy="true"] { transition: opacity .2s; opacity: 0.92; }
/* A model draft being waited on: the same spinner, beside its banner. */
.banner.drafting { display: flex; align-items: center; gap: 10px; }
.banner.drafting .spinner {
  width: 12px; height: 12px; flex: none; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}

/* Charts. `chart-anim` is put on by the script (so the picture is complete
   when there is no script), and `chart-in` when the chart is first seen.
   Keyframe animations rather than transitions, so a chart already in view
   at first paint animates too, and a class (`drawn`) rather than
   `path[pathLength]`: Chromium does not restyle descendants matched by a
   camel-case SVG attribute when an ancestor's class changes. */
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-ring { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes draw { from { stroke-dashoffset: 1px; } to { stroke-dashoffset: 0px; } }
@keyframes pop-dot { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes edge-in { from { opacity: 0; } to { opacity: 0.6; } }

.chart-anim .bar { transform-box: fill-box; transform-origin: left center; transform: scaleX(0); }
.chart-anim .bar[data-origin="right"] { transform-origin: right center; }
.chart-anim.chart-in .bar {
  animation: grow-x .7s var(--ease) both;
  animation-delay: min(calc(var(--i, 0) * 35ms), 600ms);
}
.chart-anim.donut .bar { transform-box: view-box; transform-origin: 50% 50%; transform: scale(0.6); opacity: 0; }
.chart-anim.donut.chart-in .bar {
  animation: grow-ring .6s var(--ease) both;
  animation-delay: min(calc(var(--i, 0) * 70ms), 600ms);
}
.chart-anim path.drawn { stroke-dasharray: 1px; stroke-dashoffset: 1px; }
.chart-anim.chart-in path.drawn {
  animation: draw 1.1s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 120ms);
}
.chart-anim .dot { transform-box: fill-box; transform-origin: center; transform: scale(0); }
.chart-anim.chart-in .dot {
  animation: pop-dot .35s var(--ease) both;
  animation-delay: min(calc(.45s + var(--i, 0) * 16ms), 1.3s);
}
.chart-anim text, .chart-anim .bar-value, .chart-anim .wash { opacity: 0; }
.chart-anim.chart-in text, .chart-anim.chart-in .bar-value, .chart-anim.chart-in .wash {
  animation: fade-in .5s var(--ease) .35s both; }
.chart-anim.sna-graph line[opacity] { opacity: 0; }
.chart-anim.sna-graph.chart-in line[opacity] { animation: edge-in .9s var(--ease) .5s both; }
.chart-anim.sna-graph .sna-callout, .chart-anim.sna-graph .sna-arrow { opacity: 0; }
.chart-anim.sna-graph.chart-in .sna-callout, .chart-anim.sna-graph.chart-in .sna-arrow {
  animation: fade-in .5s var(--ease) 1.1s both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* -- topics: the list and one topic's management page. */
.topic-name { display: flex; flex-direction: column; gap: 2px; }
.topic-name strong a { color: inherit; }
.topic-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.lifecycle { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.lifecycle .card { margin: 0; display: flex; flex-direction: column; }
.lifecycle .card > form:last-child, .lifecycle .card > .btn-row:last-child { margin-top: auto; }
.danger-zone { border-color: var(--critical); }
.danger-zone h2 { color: var(--critical); }
.confirm-id { font-family: var(--mono); }
.report-list { list-style: none; margin: 0 0 12px; padding: 0; }
.report-list li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between;
                  padding: 8px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.report-list li:last-child { border-bottom: none; }
.topics-table { overflow-x: auto; }
@media (max-width: 640px) {
  .topics-table .hide-sm { display: none; }
  .topic-actions { flex-direction: column; align-items: flex-end; }
}

/* -- hashtags and keywords: the action stays one line. */
.keyword-table button { white-space: nowrap; }

/* -- the topic assistant, at the top of the add-topic dialog. */
.assist { padding: 12px 14px; margin: 0 0 14px; border-radius: var(--radius-sm);
          background: var(--surface-2); border: 1px dashed var(--border-strong); }
.assist .field { margin-bottom: 8px; }

/* -- refining a topic's query: one change per line, its reason beside it. */
label.check.refine-change { display: flex; width: 100%; gap: 8px; align-items: flex-start; padding: 6px 0;
                 border-bottom: 1px solid var(--border); }
.refine-change input { margin-top: 3px; }
