/* ==========================================================================
   region·latency — "calibration" design system

   One idea: the page is a measuring instrument, not a dashboard.
   - one signal colour (vermilion) for measured overhead; everything else is ink
   - providers are NAMED, never tinted (brand blues are indistinguishable under
     colour-vision deficiency, and identity by text beats identity by hue)
   - three faces: Martian Mono engraves labels, DM Mono carries every figure,
     Barlow Semi Condensed does the talking
   ========================================================================== */

:root {
  /* --- day calibration --- */
  --paper:  #E7E9E6;
  --card:   #FBFBFA;
  --sunk:   #F1F2F0;
  --ink:    #14171A;
  --ink-2:  #5C646A;
  --ink-3:  #6E767C;
  --rule:   #D2D6D3;
  --rule-2: #C2C7C3;
  --signal: #C9331B;
  --signal-soft: rgba(201, 51, 27, .10);
  --physics: rgba(20, 23, 26, .13);
  --dot:    #14171A;

  --shadow: 0 1px 0 var(--rule), 0 12px 28px -22px rgba(20,23,26,.5);

  --display: "Martian Mono", ui-monospace, monospace;
  --data:    "DM Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ui:      "Barlow Semi Condensed", "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --gap: 22px;
  --maxw: 1400px;
}

:root[data-theme="dark"] {
  --paper:  #17181A;
  --card:   #1E2124;
  --sunk:   #191C1E;
  --ink:    #E9EBE8;
  --ink-2:  #98A0A6;
  --ink-3:  #868E94;
  --rule:   #2C3034;
  --rule-2: #3A3F44;
  --signal: #FF5A3C;
  --signal-soft: rgba(255, 90, 60, .13);
  --physics: rgba(233, 235, 232, .15);
  --dot:    #E9EBE8;
  --shadow: 0 1px 0 var(--rule), 0 12px 28px -22px #000;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.sheet { max-width: var(--maxw); margin: 0 auto; padding: 0 22px 90px; }

/* --------------------------------------------------------------- primitives */

.eyebrow {
  font-family: var(--display);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 0; }

.num { font-family: var(--data); font-variant-numeric: tabular-nums; }

.panel {
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: 3px;
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------------- header */

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 22px 28px;
  align-items: start;
  padding: 34px 0 20px;
}

.wordmark {
  margin: 0;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 9px;
}
.wordmark .mark {
  width: 11px; height: 11px; flex: 0 0 auto;
  border-radius: 50%;
  border: 2.5px solid var(--signal);
}
.wordmark .sep { color: var(--signal); }

.thesis {
  margin: 15px 0 0;
  font-size: 19px;
  line-height: 1.32;
  letter-spacing: -.005em;
  max-width: 42ch;
  font-weight: 400;
}
.thesis b { font-weight: 600; }
.thesis .lede { display: block; color: var(--ink-2); font-size: 14.5px; line-height: 1.5; margin-top: 9px; max-width: 52ch; }

/* probe-origin readout: a stamped label plate */
.origin {
  display: grid;
  grid-template-columns: auto auto;
  gap: 2px 18px;
  align-items: baseline;
  padding: 13px 16px 14px;
  background: var(--sunk);
  border: 1px solid var(--rule);
  border-radius: 3px;
  min-width: 280px;
}
.origin .hd { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.origin .hd .rule { flex: 1; }
.origin dt { font-family: var(--ui); font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; }
.origin dd { margin: 0; font-family: var(--data); font-size: 12.5px; color: var(--ink); text-align: right; }
.origin dd.wait { color: var(--ink-3); }

.tools { display: flex; gap: 6px; align-self: start; }
.tool {
  appearance: none; cursor: pointer;
  width: 32px; height: 32px; border-radius: 2px;
  border: 1px solid var(--rule); background: var(--card); color: var(--ink-2);
  display: grid; place-items: center; padding: 0;
}
.tool:hover { color: var(--ink); border-color: var(--rule-2); }
.tool svg { width: 15px; height: 15px; }
.tool:focus-visible, .chip:focus-visible, .seg button:focus-visible, .go:focus-visible,
.ghost:focus-visible, input:focus-visible, select:focus-visible, .th:focus-visible {
  outline: 2px solid var(--signal); outline-offset: 2px;
}

/* -------------------------------------------------------------- the console */

.console { margin-top: 6px; }

.bay { padding: 15px 18px 17px; }
.bay + .bay { border-top: 1px solid var(--rule); }

.bay-hd { display: flex; align-items: baseline; gap: 12px; margin-bottom: 11px; flex-wrap: wrap; }
.bay-hd .note { font-size: 13px; color: var(--ink-3); }
.bay-hd .acts { margin-left: auto; display: flex; gap: 4px; }

.act {
  appearance: none; border: 0; background: none; cursor: pointer;
  font-family: var(--ui); font-size: 13px; color: var(--signal);
  padding: 2px 7px; border-radius: 2px;
}
.act:hover { background: var(--signal-soft); }
.act[disabled] { color: var(--ink-3); cursor: default; background: none; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 5px 10px; border-radius: 2px;
  border: 1px solid var(--rule-2); background: var(--card);
  font-family: var(--ui); font-size: 14px; color: var(--ink-2);
  white-space: nowrap;
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip .k { font-family: var(--data); font-size: 11px; color: var(--ink-3); }
.chip[aria-pressed="true"] {
  background: var(--ink); border-color: var(--ink); color: var(--card);
}
.chip[aria-pressed="true"] .k { color: rgba(255,255,255,.62); }
:root[data-theme="dark"] .chip[aria-pressed="true"] .k { color: rgba(0,0,0,.55); }
.chip.wide { font-family: var(--display); font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; padding: 7px 12px; }
.chip[disabled] { opacity: .4; cursor: not-allowed; }

.regionbay { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }

.finder { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.input {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 10px;
  border: 1px solid var(--rule-2); background: var(--card); border-radius: 2px;
  flex: 1 1 230px; max-width: 340px;
}
.input:focus-within { border-color: var(--ink); }
.input svg { width: 14px; height: 14px; color: var(--ink-3); flex: 0 0 auto; }
.input input {
  border: 0; background: none; outline: 0; width: 100%; min-width: 0;
  font-family: var(--ui); font-size: 14px; color: var(--ink);
}
.input input::placeholder { color: var(--ink-3); }
.input.mini { flex: 0 0 150px; max-width: 150px; }
.input.mini .lab { font-family: var(--data); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

select.pick {
  appearance: none; height: 32px; padding: 0 26px 0 10px; border-radius: 2px;
  border: 1px solid var(--rule-2); background: var(--card); color: var(--ink);
  font-family: var(--ui); font-size: 14px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236E767C' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
}

.tally { font-family: var(--data); font-size: 12.5px; color: var(--ink-3); margin-left: auto; white-space: nowrap; }
.tally b { color: var(--ink); }

.regionwell {
  max-height: 246px; overflow-y: auto;
  border: 1px solid var(--rule); background: var(--sunk);
  border-radius: 2px; padding: 9px;
}
.regionwell .grouphd {
  flex: 0 0 100%;
  font-family: var(--display); font-size: 9px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3);
  margin: 8px 0 3px; display: flex; align-items: center; gap: 8px;
}
.regionwell .grouphd:first-child { margin-top: 0; }
.regionwell .grouphd .rule { flex: 1; }

.seg { display: inline-flex; border: 1px solid var(--rule-2); border-radius: 2px; overflow: hidden; }
.seg button {
  appearance: none; border: 0; border-left: 1px solid var(--rule-2); cursor: pointer;
  background: var(--card); color: var(--ink-2);
  font-family: var(--data); font-size: 12.5px; padding: 7px 12px;
}
.seg button:first-child { border-left: 0; }
.seg button:hover { color: var(--ink); background: var(--sunk); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--card); }

/* ----------------------------------------------------------------- the sweep */

.sweepbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px; border-top: 1px solid var(--rule); background: var(--sunk);
}

.go {
  appearance: none; cursor: pointer; border: 1px solid var(--signal);
  background: var(--signal); color: #fff;
  font-family: var(--display); font-size: 11px; font-weight: 700;
  letter-spacing: .11em; text-transform: uppercase;
  height: 38px; padding: 0 20px; border-radius: 2px;
  display: inline-flex; align-items: center; gap: 9px;
}
.go:hover:not(:disabled) { filter: brightness(1.08); }
.go:disabled { opacity: .4; cursor: not-allowed; }
.go svg { width: 12px; height: 12px; }

.ghost {
  appearance: none; cursor: pointer; height: 38px; padding: 0 14px; border-radius: 2px;
  border: 1px solid var(--rule-2); background: var(--card); color: var(--ink-2);
  font-family: var(--ui); font-size: 14px;
}
.ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--ink-3); }
.ghost:disabled { opacity: .4; cursor: not-allowed; }

.meter { flex: 1 1 160px; min-width: 120px; display: flex; align-items: center; gap: 10px; }
.meter .track { flex: 1; height: 3px; background: var(--rule-2); position: relative; overflow: hidden; }
.meter .track > i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--signal); transition: width .3s; }
.meter .read { font-family: var(--data); font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* confirm strip — never a browser dialog */
.confirm {
  display: none; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-top: 1px solid var(--signal);
  background: var(--signal-soft); font-size: 14px;
}
.confirm.on { display: flex; }
.confirm .msg { flex: 1 1 320px; color: var(--ink); }
.confirm .msg b { font-family: var(--data); }

/* ---------------------------------------------------------------- read-out */

.readout { margin-top: var(--gap); }

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr));
  border-bottom: 1px solid var(--rule);
}
.tile { padding: 15px 18px 16px; border-left: 1px solid var(--rule); }
.tile:first-child { border-left: 0; }
.tile .fig {
  font-family: var(--data); font-size: 34px; font-weight: 500;
  letter-spacing: -.03em; line-height: 1.05; margin-top: 8px;
  font-variant-numeric: tabular-nums;
}
.tile .fig .u { font-size: 14px; color: var(--ink-3); letter-spacing: 0; margin-left: 3px; }
.tile.lead .fig { color: var(--signal); }
.tile .cap { margin-top: 5px; font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cap .code { font-family: var(--data); font-size: 12px; }

.legend {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 11px 18px; border-bottom: 1px solid var(--rule); background: var(--sunk);
}
.legend .item { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.legend .sw { width: 16px; height: 8px; border-radius: 1px; flex: 0 0 auto; }
.legend .sw.phys { background: var(--physics); }
.legend .sw.over { background: var(--signal); }
.legend .sw.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px var(--sunk); }
.legend .grow { flex: 1; }
.legend .disclaim { font-size: 12.5px; color: var(--ink-3); }

.scroller { overflow-x: auto; }

table.grid { width: 100%; min-width: 900px; border-collapse: collapse; }

table.grid thead th {
  position: sticky; top: 0; z-index: 3; background: var(--card);
  font-family: var(--display); font-size: 9px; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3);
  text-align: left; padding: 10px 12px 9px; white-space: nowrap;
  border-bottom: 1px solid var(--rule-2);
}
table.grid thead th.sortable { cursor: pointer; user-select: none; }
table.grid thead th.sortable:hover { color: var(--ink); }
table.grid thead th.r { text-align: right; }
table.grid thead th[aria-sort] { color: var(--ink); }
table.grid thead th .dir { color: var(--signal); }

/* the ruler row: the shared axis every measurement is drawn on */
tr.ruler th { position: sticky; top: 34px; z-index: 2; background: var(--card); padding: 0; border-bottom: 1px solid var(--rule); }
.axis { position: relative; height: 21px; margin: 0 12px; }
.axis .t { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--rule-2); }
.axis .t span {
  position: absolute; top: 4px; left: 4px;
  font-family: var(--data); font-size: 10px; color: var(--ink-3); white-space: nowrap;
}
.axis .t.zero span { left: 2px; }

tbody tr.row { border-bottom: 1px solid var(--rule); }
tbody tr.row:hover { background: var(--sunk); }
tbody td { padding: 8px 12px; vertical-align: middle; }
tbody td.r { text-align: right; }

.pos { font-family: var(--data); font-size: 11px; color: var(--ink-3); width: 30px; text-align: right; }
tr.row.lead .pos { color: var(--signal); }

.place { min-width: 0; }
.place .city { font-size: 14.5px; font-weight: 500; letter-spacing: -.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place .code { font-family: var(--data); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.place .code .flag { font-family: var(--ui); }

.cloud {
  font-family: var(--display); font-size: 9.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2);
  border: 1px solid var(--rule-2); border-radius: 2px; padding: 3px 6px; white-space: nowrap;
}

.rtt { font-family: var(--data); font-size: 17px; font-weight: 500; letter-spacing: -.02em; white-space: nowrap; }
.rtt .u { font-size: 10.5px; color: var(--ink-3); margin-left: 2px; }
.rtt.out { font-size: 12.5px; color: var(--ink-3); font-weight: 400; }

/* ------ the signature: one shared scale, physics vs overhead, per row ------ */

td.plot { width: 34%; min-width: 190px; padding: 8px 12px; }
.track { position: relative; height: 16px; }
.track::after {                       /* baseline the marks sit on */
  content: ''; position: absolute; left: 0; right: 0; bottom: 3px;
  border-bottom: 1px solid var(--rule);
}
.track .phys, .track .over {
  position: absolute; bottom: 4px; height: 8px; border-radius: 1px;
  transition: width .45s cubic-bezier(.22,1,.36,1), left .45s cubic-bezier(.22,1,.36,1);
}
.track .phys { left: 0; background: var(--physics); border-radius: 1px 0 0 1px; }
.track .over { background: var(--signal); border-radius: 0 1px 1px 0; }
.track .ping {
  position: absolute; bottom: 4px; width: 7px; height: 7px; margin-left: -3.5px;
  border-radius: 50%; background: var(--dot);
  box-shadow: 0 0 0 2px var(--card);
  animation: land .22s cubic-bezier(.3,1.6,.5,1);
}
tbody tr.row:hover .track .ping { box-shadow: 0 0 0 2px var(--sunk); }
@keyframes land { from { transform: scale(.2); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.ratio { font-family: var(--data); font-size: 13px; white-space: nowrap; }
.ratio .x { color: var(--ink-3); font-size: 11px; }
.ratio.tight { color: var(--ink); }
.ratio.loose { color: var(--signal); }

.est { font-family: var(--data); font-size: 13px; white-space: nowrap; }
.est .tag { font-size: 9.5px; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; margin-left: 4px; }

/* region-to-region plate: figures in the data face, verdicts in the ui face */
.pairsep { color: var(--ink-3); font-size: 14px; }
.pairout {
  display: flex; flex-wrap: wrap; gap: 4px 20px; align-items: baseline;
  font-family: var(--data); font-size: 12.5px; color: var(--ink-2);
}
.pairout .lab { font-family: var(--ui); font-size: 12.5px; color: var(--ink-3); margin-right: 5px; }
.pairout b { color: var(--ink); font-weight: 500; }
.pairout .hint { font-family: var(--ui); font-size: 13px; color: var(--ink-3); }

.km { font-family: var(--data); font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }

.more {
  appearance: none; border: 0; background: none; cursor: pointer; color: var(--ink-3);
  padding: 3px; display: grid; place-items: center; border-radius: 2px;
}
.more:hover { color: var(--ink); background: var(--rule); }
.more svg { width: 13px; height: 13px; transition: transform .16s; }
.more[aria-expanded="true"] svg { transform: rotate(90deg); }

tr.sheet-detail > td { background: var(--sunk); padding: 4px 12px 16px 42px; border-bottom: 1px solid var(--rule); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 11px 26px; }
.facts dt { font-family: var(--display); font-size: 8.5px; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); }
.facts dd { margin: 3px 0 0; font-family: var(--data); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.facts .wide { grid-column: 1 / -1; }
.cidrs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.cidrs code { font-family: var(--data); font-size: 11px; background: var(--card); border: 1px solid var(--rule); padding: 1px 5px; border-radius: 2px; color: var(--ink-2); }

.blank { padding: 58px 20px; text-align: center; color: var(--ink-3); font-size: 14px; }
.blank .big { font-family: var(--display); font-size: 11px; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 8px; }

.spin { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .25; transform: scale(.7); } 50% { opacity: 1; transform: scale(1); } }

/* --------------------------------------------------------------- colophon */

.colophon { margin-top: var(--gap); padding: 20px 22px 22px; }
.colophon .cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 22px 36px; }
.colophon h3 { margin: 0 0 7px; font-family: var(--display); font-size: 9px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.colophon p { margin: 0 0 9px; font-size: 13.5px; color: var(--ink-2); line-height: 1.55; }
.colophon p b { color: var(--ink); font-weight: 600; }
.colophon code { font-family: var(--data); font-size: 11.5px; color: var(--ink); }
.colophon a { color: var(--signal); text-decoration: none; border-bottom: 1px solid transparent; }
.colophon a:hover { border-bottom-color: var(--signal); }
.feeds { display: flex; flex-direction: column; gap: 4px; margin-top: 2px; }
.feeds a { font-family: var(--data); font-size: 11.5px; color: var(--ink-2); }
.feeds a .st { color: var(--signal); }

.flash {
  position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 70px);
  background: var(--ink); color: var(--paper); padding: 9px 15px; border-radius: 2px;
  font-size: 13.5px; opacity: 0; transition: .22s; pointer-events: none; z-index: 60;
  max-width: 88vw; font-family: var(--ui);
}
.flash.on { transform: translate(-50%, 0); opacity: 1; }

/* -------------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .masthead { grid-template-columns: 1fr; }
  .thesis { font-size: 17px; max-width: none; }
  .origin { min-width: 0; }
  .tools { position: absolute; top: 34px; right: 22px; }
  .sheet { position: relative; }
  table.grid { min-width: 620px; }
  .drop { display: none !important; }
  .tile .fig { font-size: 27px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

/* theme control shows the state you'll get, not the one you're in */
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* provider glyphs — identity by shape, so it holds up in one colour */
.glyph {
  width: 13px; height: 13px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 1.9;
  stroke-linecap: round; stroke-linejoin: round;
}
.glyph rect { fill: currentColor; stroke: none; }
.chip { align-items: center; }
.chip .k { line-height: 1.1; }
.cloud { display: inline-flex; align-items: center; gap: 5px; }
.cloud .glyph { width: 12px; height: 12px; stroke-width: 2.1; }
.legend .item .glyph, .regionwell .chip .glyph { opacity: .75; }

/* a figure inflated by the endpoint's own server time, not by distance */
.warnmark {
  font-family: var(--ui); font-size: 12px; color: var(--signal);
  text-decoration: none; cursor: help; margin-left: 3px; vertical-align: top;
}
