/* BAPC DNS and Edge Network - operations console. One idea carries the look: every item wears its state as a
   coloured edge, so a phone screen of changes, checks and incidents reads at a glance. */
:root {
  --paper: #f3f6fa;
  --surface: #ffffff;
  --ink: #17212e;
  --ink-soft: #4d5b6c;
  --line: #d6dee8;
  --route: #1d3557;      /* brand: deep route blue */
  --route-soft: #e3ecf7;
  --link: #2a5c9e;
  --ok: #2e7d5b;
  --warn: #a8670f;
  --bad: #b42318;
  --unknown: #6b7684;
  --focus: #f0a202;
  --radius-s: 6px;
  --radius-l: 12px;
  --tab-h: 60px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f1722;
    --surface: #172231;
    --ink: #e7edf5;
    --ink-soft: #a4b1c2;
    --line: #2a3a4f;
    --route: #9cc3ef;
    --route-soft: #1c2d44;
    --link: #9cc3ef;
    --ok: #5cc196;
    --warn: #e0a64a;
    --bad: #f07a6e;
    --unknown: #8a96a6;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
  -webkit-text-size-adjust: 100%;
}
a { color: var(--link); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px; z-index: 10; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--route); color: #fff;
}
@media (prefers-color-scheme: dark) { .top { background: #13243a; } }
.brand { color: inherit; text-decoration: none; font-weight: 650; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.mark { width: 18px; height: 18px; border-radius: 50%; border: 3px solid #7fb3e6; box-shadow: 8px -6px 0 -3px #fff; }
.env-flag, .stop-flag { margin-left: auto; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.16); }
.stop-flag { background: var(--bad); color: #fff; }
.stop-flag:not([hidden]) ~ .env-flag { margin-left: 8px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; outline: none; }
.pad { padding: 16px 0; }
h1 { font-size: 1.6rem; line-height: 1.2; letter-spacing: -0.02em; margin: 8px 0 4px; font-weight: 700; }
h2 { font-size: 1.1rem; margin: 28px 0 8px; font-weight: 650; }
h3 { font-size: 1rem; margin: 16px 0 6px; }
p { margin: 6px 0 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.875rem; }
.num { font-variant-numeric: tabular-nums; }
code, .code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
pre { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; overflow-x: auto; font-size: 0.8rem; }

/* The signature: state edges */
.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 5px solid var(--unknown);
  border-radius: var(--radius-s);
  padding: 12px 14px;
}
a.item { display: block; color: inherit; text-decoration: none; }
a.item:hover { border-color: var(--route); border-left-color: inherit; }
.item .row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.item .title { font-weight: 600; overflow-wrap: anywhere; }
.item .sub { color: var(--ink-soft); font-size: 0.875rem; margin-top: 2px; overflow-wrap: anywhere; }
.s-ok { border-left-color: var(--ok); }
.s-warn { border-left-color: var(--warn); }
.s-bad { border-left-color: var(--bad); }
.s-unknown { border-left-color: var(--unknown); }
.s-route { border-left-color: var(--route); }

.state { font-size: 0.8rem; font-weight: 600; white-space: nowrap; }
.t-ok { color: var(--ok); } .t-warn { color: var(--warn); } .t-bad { color: var(--bad); } .t-unknown { color: var(--unknown); } .t-route { color: var(--link); }

/* Today: the one-line pulse under the heading */
.pulse { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 18px; color: var(--ink-soft); font-size: 0.9rem; }
.pulse b { color: var(--ink); font-variant-numeric: tabular-nums; }
.empty { border: 1px dashed var(--line); border-radius: var(--radius-s); padding: 18px; color: var(--ink-soft); text-align: center; }

/* Key/value detail lists */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 8px 0 16px; }
dl.kv dt { color: var(--ink-soft); font-size: 0.875rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }

/* Tables scroll inside themselves on phones */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 0.875rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: none; }

/* Controls */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
button, .btn {
  font: inherit; font-weight: 600; font-size: 0.95rem;
  min-height: 44px; padding: 8px 16px; border-radius: var(--radius-s);
  border: 1px solid var(--route); background: var(--route); color: #fff; cursor: pointer;
  text-decoration: none; display: inline-flex; align-items: center;
}
@media (prefers-color-scheme: dark) { button, .btn { color: #0f1722; } }
button.quiet, .btn.quiet { background: transparent; color: var(--link); border-color: var(--line); }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: 0.9rem; margin: 12px 0 4px; }
.hint { font-weight: 400; color: var(--ink-soft); font-size: 0.85rem; }
input, select, textarea {
  font: inherit; width: 100%; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); color: var(--ink);
}
textarea { min-height: 120px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
.check input { width: auto; min-height: 0; }
form.card, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-l); padding: 16px; margin: 12px 0; }
.error { color: var(--bad); font-weight: 600; }
.seg { display: flex; gap: 4px; overflow-x: auto; margin: 8px 0 12px; }
.seg a { padding: 8px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-soft); white-space: nowrap; border: 1px solid transparent; }
.seg a[aria-current='page'] { background: var(--route-soft); color: var(--ink); border-color: var(--line); font-weight: 600; }

/* Bottom tab bar: thumb reach on phones */
.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line);
}
.tabs a { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--ink-soft); font-size: 0.85rem; font-weight: 600; }
.tabs a[aria-current='page'] { color: var(--ink); box-shadow: inset 0 3px 0 var(--route); }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 200px; }
  .tabs { top: 0; right: auto; width: 200px; height: 100vh; grid-template-columns: 1fr; grid-auto-rows: 52px; align-content: start; padding-top: 72px; border-top: none; border-right: 1px solid var(--line); }
  .tabs a { justify-content: flex-start; padding-left: 24px; }
  .tabs a[aria-current='page'] { box-shadow: inset 3px 0 0 var(--route); }
  .top { margin-left: -200px; padding-left: 24px; z-index: 6; }
}

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  max-width: 520px; margin: 0 auto; padding: 12px 16px; border-radius: var(--radius-s);
  background: var(--ink); color: var(--paper); z-index: 20;
}
.toast.err { background: var(--bad); color: #fff; }
@media (prefers-reduced-motion: no-preference) { .toast:not([hidden]) { animation: rise .18s ease-out; } }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Shared BAPC language button (speakers.bapc.app): start it above the phone tab bar.
   Only its starting spot is moved; once dragged, it goes wherever the person put it. */
@media (max-width: 899px) {
  body > div.notranslate[style*="bottom: 14px"] { bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom)) !important; }
}
