@font-face {
  font-family: "Archivo";
  src: url("assets/fonts/archivo-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}
@font-face {
  font-family: "Besley";
  src: url("assets/fonts/besley-latin.woff2") format("woff2");
  font-weight: 400 900;
  font-display: swap;
}

:root {
  --navy: #0A2035;
  --navy-raised: #12304B;
  --navy-line: #1D3A55;
  --navy-text: #B4C2D3;
  --gold: #C28C24;
  --gold-soft: #F7EEDB;
  --ink: #172B3D;
  --muted: #5E7084;
  --subtle: #8595A6;
  --canvas: #ECEFF3;
  --surface: #FFFFFF;
  --surface-alt: #F7F9FB;
  --line: #DDE4EA;
  --line-soft: #E9EDF2;
  --ok: #26754C;
  --warn: #A05A0B;
  --down: #B04141;
  --unknown: #8595A6;
  --ok-soft: #E3F1E9;
  --warn-soft: #F8EBD9;
  --down-soft: #F6E1E1;
  --unknown-soft: #EEF1F4;
  --bar: #356F9C;
  --bar-hover: #24557D;
  --text: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Besley", Georgia, serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E3E9F0;
    --muted: #A4B3C3;
    --subtle: #7F91A4;
    --canvas: #08172A;
    --surface: #0F2438;
    --surface-alt: #13293F;
    --line: #23405C;
    --line-soft: #1B3550;
    --ok: #5CC28A;
    --warn: #E5A048;
    --down: #EE7D7D;
    --unknown: #8EA0B3;
    --ok-soft: #12352A;
    --warn-soft: #3A2A12;
    --down-soft: #3D1C22;
    --unknown-soft: #1A2F45;
    --gold-soft: #3A2F18;
    --bar: #6FA6D2;
    --bar-hover: #A3C8E6;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 13.5px/1.45 var(--text);
  font-feature-settings: "tnum";
}
button, input, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; letter-spacing: -0.2px; }
a { color: var(--bar); }

/* Bar ---------------------------------------------------------------- */
.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 10px 24px;
  background: var(--navy); color: #fff;
  border-bottom: 1px solid var(--navy-line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand-name { font: 700 16px var(--display); }
.brand-sub { color: var(--navy-text); font-weight: 500; }
.env {
  padding: 2px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.7px;
  background: var(--navy-raised); color: var(--navy-text); border: 1px solid var(--navy-line);
}
.env[data-env="prod"] { background: var(--gold); color: var(--navy); border-color: var(--gold); }
.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 6px 12px; border-radius: 8px;
  color: var(--navy-text); text-decoration: none; font-weight: 600;
}
.tabs a:hover { color: #fff; background: var(--navy-raised); }
.tabs a[aria-current="page"] { color: #fff; background: var(--navy-raised); box-shadow: inset 0 -2px 0 var(--gold); }
.count {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 999px; background: var(--gold); color: var(--navy);
  font-size: 11px; font-weight: 700; text-align: center;
}
.session { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--navy-text); font-size: 12.5px; }
.who { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.overall { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: #fff; }

button.ghost {
  padding: 5px 10px; border-radius: 8px; cursor: pointer;
  background: transparent; color: #fff; border: 1px solid var(--navy-line);
}
button.ghost:hover { background: var(--navy-raised); }
button.primary {
  padding: 9px 18px; border-radius: 8px; cursor: pointer;
  background: var(--gold); color: var(--navy); border: 0; font-weight: 700;
}
button.primary:hover { filter: brightness(1.06); }
button.secondary {
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); font-weight: 600;
}
button.secondary:hover { background: var(--surface-alt); }
.link { font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
button.link { background: none; border: 0; padding: 0; color: var(--bar); cursor: pointer; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* Layout -------------------------------------------------------------- */
main { max-width: 1280px; margin: 0 auto; padding: 20px 24px 64px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 26px 0 10px; flex-wrap: wrap; }
.section-head:first-child { margin-top: 4px; }
.section-head h2 { font-size: 17px; font-weight: 700; }
.meta { margin: 0; color: var(--muted); font-size: 12.5px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 0; }
.panel-head h3 { font-size: 13.5px; font-weight: 700; }
.toggle { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.empty { padding: 18px 16px; color: var(--muted); }

/* Gate ---------------------------------------------------------------- */
.gate {
  max-width: 420px; margin: 12vh auto 0; padding: 36px 32px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
}
.gate h1 { font: 700 22px var(--display); margin: 14px 0 8px; }
.gate p { color: var(--muted); margin: 0 0 20px; }
.emulator-form { display: grid; gap: 8px; margin-top: 8px; }
.emulator-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-alt); }
.hint { font-size: 12px; }

/* Health -------------------------------------------------------------- */
.health { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; }
.check {
  display: grid; grid-template-columns: auto 1fr auto; gap: 2px 10px; align-items: start;
  padding: 11px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.check[data-status="down"] { border-color: var(--down); background: var(--down-soft); }
.check[data-status="warn"] { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.check-label { font-weight: 700; overflow-wrap: anywhere; }
.check-group { color: var(--subtle); font-size: 11px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.check-detail { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.check-latency { color: var(--subtle); font-size: 11.5px; white-space: nowrap; }

.status { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; font-size: 12px; white-space: nowrap; }
.status svg { width: 14px; height: 14px; flex: none; }
.status[data-status="ok"] { color: var(--ok); }
.status[data-status="warn"] { color: var(--warn); }
.status[data-status="down"] { color: var(--down); }
.status[data-status="unknown"] { color: var(--unknown); }
.overall .status { font-size: 12.5px; padding: 3px 9px; border-radius: 999px; background: var(--surface); }

/* Tiles --------------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.tile { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tile-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.tile-value { font-size: 26px; font-weight: 750; letter-spacing: -0.6px; margin-top: 2px; }
.tile-note { color: var(--subtle); font-size: 12px; }

/* Chart --------------------------------------------------------------- */
.chart-panel { margin-top: 10px; }
.chart { position: relative; padding: 8px 16px 14px; }
.chart svg { display: block; width: 100%; height: 160px; overflow: visible; }
.chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.chart .axis-label { fill: var(--subtle); font-size: 10.5px; }
.chart .bar { fill: var(--bar); pointer-events: none; }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit:hover + .bar, .chart .bar.active { fill: var(--bar-hover); }
.tooltip {
  position: absolute; pointer-events: none; z-index: 2;
  padding: 6px 9px; border-radius: 8px; white-space: nowrap;
  background: var(--navy); color: #fff; font-size: 12px;
  transform: translate(-50%, calc(-100% - 8px));
}
.tooltip strong { font-size: 13px; }
#signup-table { padding: 0 16px 14px; }

/* Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th { color: var(--muted); font-size: 11.5px; font-weight: 600; background: var(--surface-alt); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.sub { display: block; color: var(--subtle); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-alt); border: 1px solid var(--line); color: var(--muted);
  font-size: 11.5px; white-space: nowrap;
}
.chip[data-tone="gold"] { background: var(--gold-soft); border-color: var(--gold); color: var(--ink); }
.chip[data-tone="warn"] { background: var(--warn-soft); border-color: var(--warn); color: var(--ink); }
.chip[data-tone="down"] { background: var(--down-soft); border-color: var(--down); color: var(--ink); }
.chip[data-tone="ok"] { background: var(--ok-soft); border-color: var(--ok); color: var(--ink); }

.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 150px 140px 1fr; gap: 12px; padding: 9px 16px; border-bottom: 1px solid var(--line-soft); }
.log li:last-child { border-bottom: 0; }
.log time, .log .svc { color: var(--muted); font-size: 12px; }
.log .msg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* Inbox --------------------------------------------------------------- */
.inbox-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 14px; }
.segmented { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.segmented button { border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.segmented button[aria-pressed="true"] { background: var(--navy); color: #fff; }
#filter-text { flex: 1 1 220px; padding: 7px 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }

.inbox { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
.inbox-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; max-height: calc(100vh - 190px); overflow-y: auto; }
.inbox-list li + li { border-top: 1px solid var(--line-soft); }
.inbox-list button { display: block; width: 100%; text-align: left; padding: 11px 14px; background: none; border: 0; cursor: pointer; }
.inbox-list button:hover { background: var(--surface-alt); }
.inbox-list button[aria-current="true"] { background: var(--gold-soft); box-shadow: inset 3px 0 0 var(--gold); }
.item-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item-from { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-when { color: var(--subtle); font-size: 11.5px; white-space: nowrap; }
.item-snippet { color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 2px 0 5px; }
.item-new .item-from::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--gold); margin-right: 6px; vertical-align: 1px; }

.inbox-detail { padding: 18px 20px; min-height: 240px; position: sticky; top: 66px; }
.detail-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; flex-wrap: wrap; }
.detail-head h3 { font-size: 16px; }
.detail-from { color: var(--muted); margin-top: 3px; }
.detail-message { white-space: pre-wrap; overflow-wrap: anywhere; margin: 16px 0; padding: 14px 16px; background: var(--surface-alt); border: 1px solid var(--line-soft); border-radius: 10px; font-size: 14px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 16px; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.note label { display: block; font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.note textarea { width: 100%; min-height: 72px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); resize: vertical; }
.note .actions { margin-top: 8px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 10;
  padding: 10px 16px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 600;
  box-shadow: 0 6px 24px rgb(0 0 0 / 0.2);
}
.toast[data-tone="error"] { background: var(--down); }

@media (max-width: 820px) {
  .bar { padding: 10px 14px; gap: 10px; }
  .session { margin-left: 0; width: 100%; flex-wrap: wrap; }
  main { padding: 14px 14px 48px; }
  .inbox { grid-template-columns: 1fr; }
  .inbox-detail { position: static; }
  .log li { grid-template-columns: 1fr; gap: 2px; }
}
