/* Embedded and served as-is. No build step and no external fonts. */

:root {
  color-scheme: light dark;

  --page: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --ink: #16181d;
  --ink-2: #5b6270;
  --line: #e4e6eb;
  --line-2: #cdd1d9;

  --accent: #2370cd;
  --accent-ink: #ffffff;
  --series: #257de0;
  --grid: #e7e7e7;
  --axis: #c2c2c2;

  /* Status colours carry a dot or fill. Text beside them uses the -ink step. */
  --good: #0aac23;
  --good-ink: #006c10;
  --warning: #fbb315;
  --warning-ink: #8a5d00;
  --critical: #dc3c3d;
  --critical-ink: #b3262a;

  --radius: 14px;
  --radius-s: 9px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05), 0 4px 16px rgb(16 24 40 / 0.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0b0b0b;
    --surface: #191919;
    --surface-2: #212225;
    --ink: #eeeff1;
    --ink-2: #9ea3ad;
    --line: #2b2d31;
    --line-2: #3d4046;
    --accent: #338ced;
    --accent-ink: #08111d;
    --series: #338ced;
    --grid: #303030;
    --axis: #474747;
    --good-ink: #53c556;
    --warning-ink: #fbb315;
    --critical-ink: #ff7b7c;
    --shadow: none;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, dl, dd, figure, ul { margin: 0; padding: 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: 1rem; letter-spacing: -0.01em; }
h3 { font-size: 1.05rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace; }
code { color: var(--ink-2); font-size: 0.82rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.eyebrow { display: block; color: var(--ink-2); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; }
.lede, .age, .crumbs { color: var(--ink-2); }
.lede { max-width: 62ch; margin-top: 0.25rem; }
.age { font-size: 0.82rem; }
.crumbs { font-size: 0.85rem; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar__inner { display: flex; align-items: center; gap: 1.75rem; max-width: 82rem; margin: 0 auto; padding: 0 1.5rem; min-height: 3.75rem; }
.brand { display: flex; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 700; font-size: 1.1rem; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand svg { width: 1.9rem; height: 1.9rem; padding: 0.35rem; border-radius: var(--radius-s); background: var(--accent); fill: var(--accent-ink); }
.nav { display: flex; gap: 0.25rem; flex: 1; }
.nav a { padding: 0.45rem 0.8rem; border-radius: var(--radius-s); color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.account { display: flex; align-items: center; gap: 0.75rem; }
.account__name { color: var(--ink-2); font-size: 0.9rem; }

.page { max-width: 82rem; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; display: flex; flex-direction: column; gap: 1.25rem; }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel__head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: 1rem 1.25rem 0.5rem; }
.empty { padding: 2.5rem 1.5rem; color: var(--ink-2); text-align: center; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.3rem; padding: 0.4rem 0.85rem;
  border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 0.88rem; font-weight: 550; text-align: center; cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { background: var(--accent); filter: brightness(1.07); }
.btn--quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn--danger { border-color: color-mix(in srgb, var(--critical) 45%, var(--line)); color: var(--critical-ink); }
.btn--danger:hover { background: color-mix(in srgb, var(--critical) 10%, var(--surface)); }
.btn--danger-solid { background: #c62f31; border-color: #c62f31; color: #fff; }
.btn--danger-solid:hover { background: #b02a2c; }
.btn--block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 0.3rem; color: var(--ink-2); font-size: 0.82rem; font-weight: 600; }
input, select {
  min-height: 2.4rem; padding: 0.4rem 0.7rem; min-width: 0;
  border: 1px solid var(--line-2); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 400;
}
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem; padding: 1rem 1.25rem; }
.filters .field { flex: 1 1 11rem; max-width: 18rem; }

/* Messages */
.banner { padding: 0.8rem 1rem; border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-s); background: var(--surface); }
.banner--error { border-color: color-mix(in srgb, var(--critical) 40%, var(--line)); border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 9%, var(--surface)); }
#connection { position: sticky; top: 3.75rem; z-index: 4; border-radius: 0; }

.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 30; display: flex; flex-direction: column; gap: 0.5rem; width: min(26rem, calc(100vw - 2.5rem)); }
.toasts:empty { display: none; }
.toast { padding: 0.85rem 1rem; border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-s); background: var(--surface); box-shadow: 0 8px 30px rgb(0 0 0 / 0.18); cursor: pointer; overflow-wrap: anywhere; }
.toast.flash--ok { border-left-color: var(--good); animation: leave 0.4s ease 6s forwards; }
.toast.flash--error { border-left-color: var(--critical); }
@keyframes leave { to { opacity: 0; visibility: hidden; transform: translateY(0.5rem); } }

/* Status: always a word, with a coloured dot */
.state, .switch, .pill { display: inline-flex; align-items: center; gap: 0.4rem; border-radius: 999px; font-weight: 600; white-space: nowrap; }
.state, .pill { padding: 0.12rem 0.65rem; font-size: 0.78rem; background: var(--surface-2); color: var(--ink-2); }
.state::before, .switch::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.state--good, .state--observed { background: color-mix(in srgb, var(--good) 13%, transparent); color: var(--good-ink); text-transform: capitalize; }
.state--critical, .state--rejected, .pill--critical { background: color-mix(in srgb, var(--critical) 13%, transparent); color: var(--critical-ink); }
.state--no-effect, .pill--confirm { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning-ink); }
.state--sent { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.pill--sealed { background: color-mix(in srgb, var(--critical) 13%, transparent); color: var(--critical-ink); }

.switch { padding: 0.35rem 0.9rem; font-size: 0.9rem; letter-spacing: 0.05em; background: var(--surface-2); color: var(--ink-2); }
.switch--ON { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-ink); }
.switch--OFF { background: color-mix(in srgb, var(--critical) 15%, transparent); color: var(--critical-ink); }

/* Headline figures */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.85rem; }
.stat { padding: 0.9rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat dt, .figures dt { color: var(--ink-2); font-size: 0.8rem; font-weight: 600; }
.stat dd { font-size: 1.65rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.35; }
.stat dd small, .figures small { margin-left: 0.3rem; color: var(--ink-2); font-size: 0.85rem; font-weight: 500; letter-spacing: 0; }
.stat .state { font-size: 0.9rem; }
.stat dd.stat__note { color: var(--ink-2); font-size: 0.78rem; font-weight: 400; letter-spacing: 0; }

/* Gateways */
.gateway-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 21rem), 1fr)); gap: 1rem; list-style: none; }
.gateway-card { display: flex; flex-direction: column; gap: 1rem; padding: 1.15rem 1.25rem; color: var(--ink); transition: border-color 0.12s, transform 0.12s; }
.gateway-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-1px); }
.gateway-card__head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; font-size: 1.05rem; }
.gateway-card__figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; font-size: 1.15rem; font-weight: 600; }

/* Gateway page */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 18rem; gap: 1.25rem; align-items: start; }
.live-area { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.breakers { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 24rem), 1fr)); gap: 1rem; }
.side { position: sticky; top: 5rem; display: flex; flex-direction: column; gap: 1.1rem; padding: 1.15rem 1.25rem; }
.controls__stack { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.4rem; }
.mount { display: flex; flex-direction: column; gap: 0.55rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }

.breaker { display: flex; flex-direction: column; gap: 1rem; padding: 1.15rem 1.25rem; border-top: 3px solid var(--line-2); }
.breaker--ON { border-top-color: var(--good); }
.breaker--OFF { border-top-color: var(--critical); }
.breaker--busy { border-color: var(--accent); }
.breaker--stale { border-style: dashed; }
.breaker__head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.figures div { padding: 0.65rem 0.85rem; border-radius: var(--radius-s); background: var(--surface-2); }
.figures dd { font-size: 1.75rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.3; }

.scroll { overflow-x: auto; }
.scroll--tall { max-height: 24rem; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { color: var(--ink-2); font-size: 0.75rem; font-weight: 600; }
.phases { font-size: 0.86rem; }
.phases th, .phases td { padding: 0.32rem 0.3rem; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.phases th:first-child { text-align: left; }
.phases tbody td { color: var(--ink-2); }
.phases tr.live td, .phases tr.live th { color: var(--ink); font-weight: 600; }
.phases tbody tr:last-child > * { border-bottom: 0; }

.pending { display: flex; align-items: center; gap: 0.65rem; padding: 0.65rem 0.8rem; border-radius: var(--radius-s); background: color-mix(in srgb, var(--accent) 12%, transparent); font-size: 0.86rem; }
.spinner { flex: none; width: 1rem; height: 1rem; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

.controls { display: flex; flex-direction: column; gap: 0.8rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.controls__buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.45rem; margin-top: 0.35rem; }
.controls__group--1 .btn { min-height: 2.9rem; font-size: 0.95rem; }
.controls__group--1 .btn:not(.btn--danger) { background: #0a7d1c; border-color: #0a7d1c; color: #fff; }
.controls__group--1 .btn:not(.btn--danger):hover { background: #086617; }
.controls__group--1 .btn--danger { background: #c62f31; border-color: #c62f31; color: #fff; }
.controls__group--1 .btn--danger:hover { background: #b02a2c; }
.controls__group--3 .btn { font-size: 0.8rem; font-weight: 500; }

/* Tables */
.data { font-size: 0.88rem; }
.data th, .data td { padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
.data thead th { position: sticky; top: 0; background: var(--surface-2); }
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr:last-child td { border-bottom: 0; }
.data .num { text-align: right; }
.data .mono { font-size: 0.92em; }
.data td.wrap { min-width: 18rem; white-space: normal; }
.panel > .scroll:first-child { border-radius: var(--radius); }

/* Chart */
.chart { padding: 1.1rem 1.25rem 0.75rem; }
.chart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.75rem; }
.chart__readout { color: var(--ink-2); font-size: 0.85rem; font-variant-numeric: tabular-nums; white-space: pre; }
/* A narrow screen scrolls the chart, starting at the newest end. */
.chart .scroll { direction: rtl; }
.chart svg { direction: ltr; display: block; width: 100%; min-width: 40rem; height: auto; touch-action: pan-x; }
.chart__grid { stroke: var(--grid); stroke-width: 1; }
.chart__axis { stroke: var(--axis); stroke-width: 1; }
.chart__tick { fill: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart__line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__dot { fill: var(--series); }
.chart__cursor { stroke: var(--axis); stroke-width: 1; }
.chart__marker { fill: var(--series); stroke: var(--surface); stroke-width: 2; }

/* Confirmation gate */
.gate { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 1.25rem; background: rgb(6 8 12 / 0.55); backdrop-filter: blur(3px); }
.gate__box { width: min(100%, 27rem); padding: 1.5rem; border-top: 4px solid var(--critical); box-shadow: 0 24px 70px rgb(0 0 0 / 0.35); }
.gate__box h2 { margin-top: 0.3rem; font-size: 1.35rem; }
.gate__target { margin-top: 0.25rem; color: var(--ink-2); }
.gate__warning { margin: 1rem 0 1.25rem; padding: 0.8rem 0.9rem; border-radius: var(--radius-s); background: color-mix(in srgb, var(--critical) 10%, transparent); }
.gate__buttons { display: flex; flex-direction: row-reverse; gap: 0.6rem; }
.gate__buttons .btn { flex: 1; min-height: 2.8rem; }

/* Sign in */
.login { display: grid; place-items: center; min-height: 100vh; padding: 1.25rem; }
.login__box { width: min(100%, 24rem); padding: 2rem; }
.login__box .brand { margin-bottom: 1.5rem; }
.login__box form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }
.login__box .banner { margin-top: 1rem; }

@media (max-width: 62rem) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
}
@media (max-width: 40rem) {
  .topbar { position: static; }
  .topbar__inner { flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.65rem 1rem; }
  .nav { order: 3; flex-basis: 100%; }
  .brand { flex: 1; }
  .account__name { display: none; }
  #connection { top: 0; }
  .page { padding: 1.25rem 1rem 6rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat dd { font-size: 1.35rem; }
  .breaker { padding: 1rem; }
  .btn { min-height: 2.75rem; }
  .data th, .data td { padding: 0.6rem 0.8rem; }
  .chart__tick { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-delay: 0s !important; transition: none !important; }
  .toast.flash--ok { animation: none; }
}
