/* DartNode status — no framework, dark/light via [data-theme] + system pref */
:root {
  --bg: #f5f7fa; --card: #ffffff; --text: #16202b; --muted: #66788c;
  --border: #e2e8f0; --accent: #2563eb;
  --up: #22b866; --degraded: #f59e0b; --down: #e5484d; --unknown: #8b98a9; --paused: #8b98a9;
  --banner-op: #16a34a; --banner-deg: #d97706; --banner-out: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1219; --card: #151d28; --text: #e6edf5; --muted: #8598ad;
    --border: #24303f; --accent: #4d8dff;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1219; --card: #151d28; --text: #e6edf5; --muted: #8598ad;
  --border: #24303f; --accent: #4d8dff;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, pre { background: rgba(128,128,128,.12); border-radius: 6px; padding: 2px 6px; font-size: 13px; }
pre { padding: 12px; overflow-x: auto; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--border); background: var(--card); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; flex-direction: column; line-height: 1.2; }
.brand-mark { font-weight: 700; font-size: 19px; color: var(--text); }
.brand-mark span { color: var(--accent); }
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.site-header nav { display: flex; gap: 16px; align-items: center; }
#theme-toggle { background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 3px 9px; cursor: pointer; font-size: 15px; }
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 18px 0; color: var(--muted); font-size: 13px; }
.site-footer .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

main { padding-top: 22px; }
section { margin-bottom: 30px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
h3 { margin: 0 0 10px; font-size: 15px; }

/* 3D network globe hero (public index). Collapses via .is-off if WebGL fails. */
.globe-hero {
  position: relative;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  margin-top: -22px; /* cancel main padding so the globe sits under the header */
  height: 430px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 42%, #1c2a44 0%, #0a1018 58%, #05070c 100%);
}
.globe-hero.theme-light {
  background:
    radial-gradient(ellipse at 50% 42%, #d5e6f6 0%, #a9c2da 62%, #8aa6c2 100%);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .globe-hero:not(.theme-dark) {
    background:
      radial-gradient(ellipse at 50% 42%, #d5e6f6 0%, #a9c2da 62%, #8aa6c2 100%);
  }
}
@media (max-width: 720px) {
  .globe-hero { height: 300px; }
}
@media (min-width: 1200px) {
  .globe-hero { height: 460px; }
}
.globe-hero.is-off {
  display: none !important;
  height: 0;
  margin: 0;
}
.globe-hero:not(.is-on):not(.is-off)::after {
  content: "Loading network map…";
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.5); font-size: 12px;
  letter-spacing: .1em; text-transform: uppercase;
  pointer-events: none;
}
.globe-hero.theme-light:not(.is-on):not(.is-off)::after { color: rgba(16,28,44,.45); }
.globe-canvas {
  position: absolute;
  inset: 0;
  z-index: 0;
  touch-action: none;
}
.globe-vignette {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 46%, transparent 40%, color-mix(in srgb, var(--bg) 28%, transparent) 78%, var(--bg) 100%);
}
.globe-chrome {
  position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 2;
  display: flex; justify-content: space-between; align-items: flex-end;
  pointer-events: none; gap: 12px;
}
.globe-kicker {
  margin: 0; font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  color: rgba(255,255,255,.72); text-shadow: 0 1px 8px rgba(0,0,0,.45);
}
.globe-hero.theme-light .globe-kicker,
.globe-hero.theme-light .globe-hint { color: rgba(16,28,44,.7); text-shadow: none; }
.globe-hint {
  margin: 0; font-size: 11px; color: rgba(255,255,255,.55);
  transition: opacity .4s ease;
}
.globe-hero.is-interacting .globe-hint { opacity: 0; }
/* globe.gl tooltip (appended inside the canvas container) */
.scene-tooltip {
  z-index: 5 !important;
  pointer-events: none;
}
.globe-tip {
  font: 13px/1.4 -apple-system, "Segoe UI", Roboto, sans-serif;
  background: rgba(12, 18, 28, .92);
  color: #e6edf5;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  padding: 8px 11px;
  min-width: 140px;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
  backdrop-filter: blur(8px);
}
.globe-tip-title { font-weight: 650; }
.globe-tip-code { letter-spacing: .04em; }
.globe-tip-sub { color: #9aabc0; font-size: 12px; margin-top: 1px; }
.globe-tip-meta { display: flex; align-items: center; gap: 6px; margin-top: 5px; font-size: 12px; color: #c5d0dc; text-transform: capitalize; }
.globe-tip-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; box-shadow: 0 0 6px currentColor; }
@keyframes globe-flash {
  0%, 100% { box-shadow: none; }
  35% { box-shadow: 0 0 0 3px var(--accent); }
}
.globe-flash { animation: globe-flash 1.2s ease; border-radius: 12px; }
tr.globe-flash td:first-child { border-radius: 8px 0 0 8px; }
tr.globe-flash td:last-child { border-radius: 0 8px 8px 0; }

/* Sit the overall-status banner on the globe's lower edge when the hero is live. */
.globe-hero.is-on + #banner {
  position: relative;
  z-index: 3;
  margin-top: -28px;
  box-shadow: 0 12px 32px rgba(0,0,0,.18);
}
@media (max-width: 720px) {
  .globe-hero.is-on + #banner { margin-top: -18px; }
}

/* banner */
.banner {
  display: flex; align-items: center; gap: 16px;
  border-radius: 14px; padding: 22px 24px; color: #fff; margin-top: 4px;
}
.banner.slim { padding: 12px 18px; }
.banner.operational { background: var(--banner-op); }
.banner.degraded { background: var(--banner-deg); }
.banner.outage { background: var(--banner-out); }
.banner-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; animation: pulse 2s infinite; flex: none; }
.banner-sub { margin: 4px 0 0; opacity: .9; font-size: 14px; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .45 } }

/* cards */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.table-card { padding: 4px 8px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }

/* status dots */
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.up { background: var(--up); box-shadow: 0 0 6px color-mix(in srgb, var(--up) 60%, transparent); }
.dot.degraded { background: var(--degraded); }
.dot.down { background: var(--down); }
.dot.unknown, .dot. { background: var(--unknown); }
.dot.paused { background: var(--paused); opacity: .5; }

/* pops */
.pop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 12px; }
.pop-card .pop-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pop-code { font-weight: 700; text-transform: uppercase; }
.pop-name { color: var(--muted); font-size: 13px; }
.pop-stats { display: flex; gap: 16px; font-size: 13px; }
.pop-stats .label { color: var(--muted); margin-right: 4px; font-size: 11px; text-transform: uppercase; }
.pop-stats .val { font-variant-numeric: tabular-nums; }
.pop-probe { margin-top: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.pop-probe.ok { color: var(--up); } .pop-probe.bad { color: var(--down); }

/* routes */
.routes td { font-variant-numeric: tabular-nums; }
.route-link { font-weight: 600; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 1.6; }
.spark-thresh { stroke: var(--degraded); stroke-width: 1; stroke-dasharray: 3 3; }
.spark-empty, .axis { fill: var(--muted); font-size: 11px; }
.axis { text-anchor: end; } .axis.mid { text-anchor: middle; }
.graph-line { fill: none; stroke: var(--accent); stroke-width: 1.8; }
.grid { stroke: var(--border); stroke-width: 1; }
.graph-wrap { overflow-x: auto; }
.graph-btn { font-size: 13px; }
.range-tabs { display: flex; gap: 8px; align-items: center; margin: 14px 0 6px; }
.range-tabs a { padding: 4px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 13px; }
.range-tabs a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.route-title { display: inline; font-size: 20px; }
.route-stats { margin: 12px 0; }

/* upstreams */
.upstream-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.upstream-card { display: flex; gap: 12px; align-items: center; }
.up-provider { font-weight: 600; }

/* services */
.group-card { margin-bottom: 14px; }
.svc-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.svc-row:last-child { border-bottom: 0; }
.svc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; }
.svc-name { font-weight: 600; }
.svc-msg { color: var(--degraded); font-size: 12px; }
.svc-uptime { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.bars { display: flex; gap: 2px; height: 26px; }
.bars i {
  flex: 1 1 0; border-radius: 2px; min-width: 2px;
  background: var(--up);
}
.bars i.warn { background: var(--degraded); }
.bars i.bad { background: var(--down); }
.bars i.nodata { background: var(--border); }

/* incidents */
.incident { margin-bottom: 12px; }
.inc-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inc-impact {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  border-radius: 6px; padding: 2px 8px; color: #fff; background: var(--unknown);
}
.inc-impact.minor { background: var(--degraded); }
.inc-impact.major { background: var(--down); }
.inc-impact.maintenance { background: var(--accent); }
.inc-update { margin-top: 8px; padding-left: 10px; border-left: 2px solid var(--border); font-size: 14px; }
.inc-status { font-weight: 600; text-transform: capitalize; margin-right: 6px; }
.maint-notice .maint-item { background: color-mix(in srgb, var(--accent) 12%, var(--card)); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; }

/* subscribe */
.subscribe-box { text-align: center; padding: 26px; }
.sub-form { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
button, .btn-primary {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 16px; font: inherit; cursor: pointer; display: inline-block;
}
button:hover, .btn-primary:hover { filter: brightness(1.08); text-decoration: none; }
button.danger { background: var(--down); }
.subscribe-result, .login-box { max-width: 460px; margin: 40px auto; text-align: center; }

/* admin */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.admin-nav a { padding: 5px 11px; border-radius: 8px; color: var(--text); font-size: 14px; }
.admin-nav a:hover { background: var(--card); text-decoration: none; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; align-items: end; }
.grid-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.grid-form label.wide { grid-column: 1 / -1; }
.grid-form label.check { flex-direction: row; align-items: center; }
.grid-form input, .grid-form select, .grid-form textarea { width: 100%; }
.actions { display: flex; gap: 6px; align-items: center; }
.actions form { display: inline; }
.actions button { padding: 3px 9px; font-size: 12px; background: var(--border); color: var(--text); }
.actions button.danger { background: var(--down); color: #fff; }
.admin-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.state-summary { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px; font-size: 12px; }
.pill.up { border-color: var(--up); color: var(--up); }
.pill.degraded { border-color: var(--degraded); color: var(--degraded); }
.pill.down { border-color: var(--down); color: var(--down); }
.pill.unknown { border-color: var(--unknown); color: var(--unknown); }
.ok-text { color: var(--up); } .bad-text { color: var(--down); }
.token-reveal .token { display: block; font-size: 15px; padding: 10px; margin: 8px 0; word-break: break-all; }
.draft-alert { border-color: var(--degraded); margin-bottom: 14px; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .admin-cols { grid-template-columns: 1fr; }
  .banner { padding: 16px; }
  h1 { font-size: 18px; }
}
