/* BlobIT console
   Design intent: an instrument face, not a dashboard. The technician is on the
   phone with a user and needs the broken segment to be visible before any
   number is read. Hence: dark base, hairline rules instead of cards, a faint
   measurement grid, and monospace for every value so digits do not shift as
   they update. */

:root {
  /* base */
  --bg:        #0B0E14;
  --panel:     #111721;
  --panel-2:   #161D29;
  --rule:      #1E2733;
  --rule-lit:  #2C3846;

  /* ink */
  --ink:       #E6EDF6;
  --ink-2:     #9AA9BC;
  --ink-3:     #5D6B7E;

  /* state — carries meaning, never decoration */
  --ok:        #00E5A0;
  --warn:      #FFB238;
  --fault:     #FF4D5E;
  --ref:       #5B8DEF;   /* gateway / local segment */
  --idle:      #3B4757;

  --ok-dim:    #00e5a01f;
  --warn-dim:  #ffb2381f;
  --fault-dim: #ff4d5e1f;

  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Chivo', system-ui, -apple-system, sans-serif;

  --rail-w: 300px;
  --gut: 22px;
}

* { box-sizing: border-box; }

/* `display` on a class beats the `hidden` attribute's UA rule, so state it
   explicitly. Without this, a hidden .empty-state still claims 100vh. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* The measurement grid: a barely-there reference field, like an instrument
   face. Kept at very low alpha so it reads as texture, not as content. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(to right, #ffffff06 1px, transparent 1px),
    linear-gradient(to bottom, #ffffff06 1px, transparent 1px);
  background-size: 64px 64px;
}

.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--rail-w) 1fr;
  min-height: 100vh;
}

/* ── typography ─────────────────────────────────────────────── */

h1 {
  font-size: 25px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

h2 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin: 0;
}

.micro {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.micro-dim { color: var(--ink-3); }

/* ── left rail ──────────────────────────────────────────────── */

.rail {
  border-right: 1px solid var(--rule);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-head {
  padding: 20px var(--gut) 16px;
  border-bottom: 1px solid var(--rule);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}

/* A signal-strength glyph rather than a generic logo: three rising bars,
   the thing this product actually measures. */
.brand-mark {
  width: 15px;
  height: 15px;
  background:
    linear-gradient(to top, var(--ok) 0 33%, transparent 33%) 0 100% / 3px 33% no-repeat,
    linear-gradient(to top, var(--ok) 0 66%, transparent 66%) 6px 100% / 3px 66% no-repeat,
    linear-gradient(to top, var(--ok) 0 100%, transparent 100%) 12px 100% / 3px 100% no-repeat;
}

.brand-text {
  font-weight: 900;
  font-size: 17px;
  letter-spacing: -0.03em;
}

.tenant-pick { display: block; }
.tenant-pick .micro { display: block; margin-bottom: 5px; }

select, input[type=text], input[type=number] {
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--rule-lit);
  border-radius: 0;
  padding: 7px 9px;
  font-family: var(--mono);
  font-size: 12px;
}

/* Native spinner arrows read as a foreign widget against this theme. */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { appearance: textfield; }

select:focus-visible, input:focus-visible, button:focus-visible {
  outline: 2px solid var(--ref);
  outline-offset: 1px;
}

/* fleet counters */
.fleet-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--rule);
}

.fstat {
  padding: 12px var(--gut);
  border-right: 1px solid var(--rule);
}
.fstat:last-child { border-right: 0; }

.fstat-n {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  display: block;
}
.fstat-l {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: 4px;
  display: block;
}
.fstat.is-bad .fstat-n  { color: var(--fault); }
.fstat.is-warn .fstat-n { color: var(--warn); }

.rail-section {
  padding: 14px var(--gut) 8px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.fleet {
  list-style: none;
  margin: 0;
  padding: 0 0 12px;
  overflow-y: auto;
  flex: 1;
}

.fleet-item {
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  color: var(--ink);
  padding: 10px var(--gut);
  cursor: pointer;
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: center;
  font-family: var(--sans);
}

.fleet-item:hover { background: var(--panel-2); }

.fleet-item.is-on {
  background: var(--panel-2);
  border-left-color: var(--ok);
}

/* status dot doubles as the health readout */
.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--idle);
}
.dot.s-ok    { background: var(--ok);    box-shadow: 0 0 7px var(--ok); }
.dot.s-warn  { background: var(--warn);  box-shadow: 0 0 7px var(--warn); }
.dot.s-fault { background: var(--fault); box-shadow: 0 0 7px var(--fault); }
.dot.s-stale { background: var(--idle); }

.fleet-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fleet-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fleet-val {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  text-align: right;
  white-space: nowrap;
}

.rail-foot {
  border-top: 1px solid var(--rule);
  padding: 12px var(--gut);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* ── buttons ────────────────────────────────────────────────── */

.btn {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 0;
  padding: 7px 12px;
  cursor: pointer;
  border: 1px solid var(--rule-lit);
  background: var(--panel-2);
  color: var(--ink-2);
}
.btn:hover { color: var(--ink); border-color: var(--ink-3); }

.btn-go {
  background: var(--ok);
  border-color: var(--ok);
  color: #04150E;
  font-weight: 700;
}
.btn-go:hover { background: #4DFFC0; border-color: #4DFFC0; color: #04150E; }

/* ── main ───────────────────────────────────────────────────── */

.main { min-width: 0; }

.empty-state {
  min-height: 60vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--ink-3);
}
.empty-state h1 { color: var(--ink-2); font-weight: 400; }
.empty-state p { font-family: var(--mono); font-size: 12px; }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  padding: 22px var(--gut) 18px;
  border-bottom: 1px solid var(--rule);
  flex-wrap: wrap;
}

.id-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 6px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}
.id-meta .tag {
  color: var(--ink-2);
  border: 1px solid var(--rule-lit);
  padding: 1px 6px;
}

.probe-form { display: flex; gap: 7px; align-items: stretch; }
.probe-form select { width: auto; }
.probe-form input { width: 210px; }

/* warnings: clone detection, reinstall merges */
.warn-strip {
  margin: 0;
  padding: 10px var(--gut);
  background: var(--warn-dim);
  border-bottom: 1px solid var(--warn);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--warn);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* ── SIGNATURE: path spine ──────────────────────────────────── */

.spine-wrap { padding: 22px var(--gut); border-bottom: 1px solid var(--rule); }

.spine {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
}

.hop {
  flex: 1 1 0;
  min-width: 132px;
  border: 1px solid var(--rule);
  border-right: 0;
  padding: 13px 14px 15px;
  position: relative;
  background: var(--panel);
}
.hop:last-child { border-right: 1px solid var(--rule); }

/* the connective tissue: a bar whose colour is the segment verdict */
.hop::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--seg, var(--idle));
}

.hop-label {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: block;
}

.hop-name {
  font-size: 13px;
  font-weight: 600;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hop-val {
  font-family: var(--mono);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
  margin-top: 9px;
  color: var(--seg, var(--ink-2));
}
.hop-unit { font-size: 11px; font-weight: 400; color: var(--ink-3); }

.hop-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 5px;
  min-height: 13px;
}

.hop.is-idle .hop-val { color: var(--ink-3); }

/* A blocked media path has no latency to show, but it is the most important
   finding on the page -- it must not render as absent data. */
.hop.is-blocked .hop-val {
  color: var(--fault);
  font-size: 17px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.hop.is-blocked .hop-sub { color: var(--fault); }

/* ── traceroute panel ───────────────────────────────────────── */

.trace-panel {
  padding: 20px var(--gut);
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
}

.trace-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.trace-hops { display: grid; gap: 1px; }

.trace-hop {
  display: grid;
  grid-template-columns: 32px 1fr auto;
  gap: 14px;
  padding: 5px 0;
  font-family: var(--mono);
  font-size: 12px;
  border-bottom: 1px solid var(--rule);
}

.trace-ttl { color: var(--ink-3); }
.trace-addr { color: var(--ink); overflow-wrap: anywhere; }
.trace-rtt { color: var(--ok); text-align: right; }

/* A hop that did not answer is a gap in knowledge, not a fault. */
.trace-hop.is-silent .trace-addr,
.trace-hop.is-silent .trace-rtt { color: var(--ink-3); }

.trace-hop.is-dest .trace-addr { color: var(--ok); font-weight: 700; }

.trace-foot {
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ── charts ─────────────────────────────────────────────────── */

.charts { padding: 22px var(--gut); border-bottom: 1px solid var(--rule); }

.range-pick { display: flex; }
.range {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  background: var(--panel);
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-right: 0;
  padding: 5px 10px;
  cursor: pointer;
}
.range:last-child { border-right: 1px solid var(--rule); }
.range.is-on { background: var(--panel-2); color: var(--ok); border-color: var(--rule-lit); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
}

.chart {
  background: var(--panel);
  padding: 14px 16px 10px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-t {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-now {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
}

.chart svg { display: block; width: 100%; height: 78px; overflow: visible; }

.chart-foot {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--ink-3);
  margin-top: 4px;
}

/* ── panels / tables ────────────────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1px;
  background: var(--rule);
  border-bottom: 1px solid var(--rule);
}

.panel { background: var(--bg); padding: 22px var(--gut); min-width: 0; }

.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  text-align: left;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0 10px 7px 0;
  border-bottom: 1px solid var(--rule);
}
.tbl td {
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--rule);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-2);
  vertical-align: top;
}
.tbl td.p-kind { color: var(--ok); }
.tbl .from { color: var(--ink-3); }

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; }
.kv dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.kv dd.v-on   { color: var(--ok); }
.kv dd.v-off  { color: var(--ink-3); }
.kv dd.v-warn { color: var(--warn); }

/* ── modal ──────────────────────────────────────────────────── */

.modal {
  border: 1px solid var(--rule-lit);
  background: var(--panel);
  color: var(--ink);
  border-radius: 0;
  padding: 0;
  max-width: 540px;
  width: calc(100% - 40px);
}
.modal::backdrop { background: #050709cc; }
.modal form { padding: 22px; }
.modal h2 { margin-bottom: 8px; }
.modal-lede { font-family: var(--mono); font-size: 11px; color: var(--ink-3); margin: 0 0 18px; }

.field { display: block; margin-bottom: 16px; }
.field .micro { display: block; margin-bottom: 5px; }

.field-check { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; }
.field-check input { margin: 0; }

.probe-form-add { display: flex; gap: 7px; align-items: stretch; margin-top: 12px; }
.probe-form-add select { width: auto; }
.probe-form-add input[type="text"] { width: 160px; }
.probe-form-add input[type="number"] { width: 70px; }

.token-out { display: grid; gap: 5px; margin-bottom: 18px; }
.token-out code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--rule-lit);
  padding: 9px 10px;
  color: var(--ok);
  overflow-wrap: anywhere;
  display: block;
}
.token-out code.cmd { color: var(--ink-2); }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 0;
  padding: 0;
}

/* ── toasts ─────────────────────────────────────────────────── */

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  z-index: 50;
}
.toast {
  background: var(--panel-2);
  border: 1px solid var(--rule-lit);
  border-left: 2px solid var(--ok);
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink);
  max-width: 420px;
  animation: rise .18s ease-out;
}
.toast.is-bad { border-left-color: var(--fault); color: var(--fault); }
.toast.is-warn { border-left-color: var(--warn); }

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ── responsive ─────────────────────────────────────────────── */

@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--rule); }
  .fleet { max-height: 250px; }
  .detail-head { align-items: flex-start; }
  .probe-form { flex-wrap: wrap; }
  .probe-form input { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
  .dot { box-shadow: none; }
}
