:root {
  --bg: #0a0b0d;
  --bg-1: #0f1013;
  --bg-2: #15171b;
  --bg-3: #1b1e23;
  --line: #1f2228;
  --line-2: #2b2f37;
  --fg: #e6e8eb;
  --fg-2: #a4aab4;
  --fg-3: #6c727c;
  --accent: #8ab4ff;
  --accent-bg: rgba(138, 180, 255, 0.1);
  --good: #63d39c;
  --warn: #e6b65c;
  --bad: #f07a7a;
  --bar: rgba(138, 180, 255, 0.55);
  --radius: 10px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 var(--sans);
  font-feature-settings: "tnum" 1;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: var(--bg-3); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--fg-3); }
.small { font-size: 12px; }
.good { color: var(--good); }
.warn { color: var(--warn); }

.wrap { max-width: 1440px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 24px; padding-bottom: 64px; }

/* ---------------------------------------------------------------- header: same grid on every page, so nothing moves */

.top { position: sticky; top: 0; z-index: 20; background: rgba(10, 11, 13, 0.88); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px) minmax(0, 1fr); align-items: center; gap: 20px; height: 56px; }
.brand { justify-self: start; display: flex; align-items: center; gap: 9px; color: var(--fg); font: 600 14px var(--mono); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 10px; height: 10px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 12px rgba(138, 180, 255, 0.5); }
.top-mid { display: flex; align-items: center; gap: 12px; min-width: 0; }
.top-mid input[type="search"] { height: 34px; }
.top-nav { justify-self: end; display: flex; gap: 20px; font-size: 13px; white-space: nowrap; }
.top-nav a { color: var(--fg-2); padding: 4px 0; }
.top-nav a:hover, .top-nav a.on { color: var(--fg); text-decoration: none; }
.top-nav a.on { box-shadow: 0 2px 0 var(--accent); }
@media (max-width: 760px) {
  .top-in { grid-template-columns: minmax(0, 1fr) auto; height: auto; padding-top: 12px; padding-bottom: 12px; row-gap: 10px; }
  .top-mid { grid-column: 1 / -1; grid-row: 2; }
  .top-mid:empty { display: none; }
  .top-nav { gap: 14px; }
}

/* ---------------------------------------------------------------- page structure */

.crumbs { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--fg-3); margin-bottom: 10px; }
.ph { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 20px; }
.ph h1 { font-size: 24px; line-height: 1.25; }
.ph .pre { color: var(--fg-3); font-weight: 500; }
.ph-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin-top: 8px; color: var(--fg-2); font-size: 13px; }
.ph-a { display: flex; gap: 8px; flex-wrap: wrap; }

.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span2 { grid-column: 1 / -1; }
.side-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 1100px) {
  .grid2, .side-grid { grid-template-columns: minmax(0, 1fr); }
}

.panel { background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.panel.danger { border-color: rgba(240, 122, 122, 0.25); }
.panel-h { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px 0; }
.panel-h h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-2); font-weight: 600; }
.panel-at { margin-left: auto; font: 12px var(--mono); color: var(--fg-3); }
.panel-b { padding: 14px 18px 18px; display: grid; gap: 16px; min-width: 0; }
.panel-b > * { min-width: 0; }

/* stat strip: each tile draws its right and bottom divider; the outer edge clips them,
   so any column count (and a lone last tile) looks right */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.stat { padding: 10px 14px; min-width: 0; box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.stat-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-3); white-space: nowrap; }
.stat-v { font: 500 18px/1.3 var(--mono); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-s { font-size: 12px; color: var(--fg-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats.big { margin-bottom: 16px; border-radius: var(--radius); background: var(--bg-1); }
.stats.big .stat { padding: 14px 18px; }
.stats.big .stat-v { font-size: 22px; }
@media (max-width: 640px) {
  .stats.big { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats.big .stat { padding: 12px 14px; }
  .stats.big .stat-v, .stat-v { font-size: 16px; }
  .panel-h { padding: 12px 14px 0; }
  .panel-b { padding: 12px 14px 14px; }
  .wrap { padding: 0 12px; }
  .ph h1 { font-size: 21px; }
}

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px 28px; align-items: start; }

/* ---------------------------------------------------------------- controls */

input, select, textarea {
  font: inherit; color: var(--fg); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: 6px;
  padding: 7px 10px; width: 100%; min-width: 0;
}
input, select { height: 36px; }
input[type="checkbox"] { width: auto; height: auto; accent-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
::placeholder { color: var(--fg-3); }
.check { display: inline-flex; gap: 7px; align-items: center; color: var(--fg-2); font-size: 13px; cursor: pointer; user-select: none; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px;
  font: 500 13px var(--sans); color: var(--fg); background: var(--bg-3);
  border: 1px solid var(--line-2); border-radius: 6px; padding: 0 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--fg-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #0a0f1a; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { border-color: var(--line-2); color: var(--fg); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { border-color: var(--bad); }

.badge { display: inline-block; font-size: 11px; line-height: 1; padding: 4px 7px; border-radius: 999px; background: var(--bg-3); color: var(--fg-2); border: 1px solid var(--line-2); white-space: nowrap; vertical-align: 1px; }
.badge.good { color: var(--good); border-color: rgba(99, 211, 156, 0.3); background: rgba(99, 211, 156, 0.07); }
.badge.warn { color: var(--warn); border-color: rgba(230, 182, 92, 0.3); background: rgba(230, 182, 92, 0.07); }
.badge.accent { color: var(--accent); border-color: rgba(138, 180, 255, 0.3); background: var(--accent-bg); }
.badge.dim { color: var(--fg-3); }
td .badge { margin-left: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 5px; background: var(--bg-2); border: 1px solid var(--line); color: var(--fg); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
a.chip:hover { border-color: var(--line-2); text-decoration: none; }
.flag { font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; }

.flash { background: rgba(99, 211, 156, 0.08); border: 1px solid rgba(99, 211, 156, 0.25); color: var(--good); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px; }
.flash.err { background: rgba(240, 122, 122, 0.08); border-color: rgba(240, 122, 122, 0.3); color: var(--bad); }

/* ---------------------------------------------------------------- server list */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-1); }
.grid { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.grid th {
  position: sticky; top: 0; text-align: left; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--fg-3); background: var(--bg-1); padding: 11px 12px; border-bottom: 1px solid var(--line); cursor: pointer; user-select: none;
}
.grid th:hover { color: var(--fg-2); }
.grid th[aria-sort="ascending"]::after { content: " ↑"; color: var(--accent); }
.grid th[aria-sort="descending"]::after { content: " ↓"; color: var(--accent); }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr[data-href] { cursor: pointer; }
.grid tbody tr[data-href]:hover td { background: var(--bg-2); }
.grid td.name a { color: var(--fg); display: inline-flex; gap: 6px; align-items: baseline; }
.grid td.name a:hover { text-decoration: none; }
.grid td.name a:hover .plan { color: var(--accent); }
.grid .prov { color: var(--fg-2); }
.grid .plan { font-weight: 500; }
.grid .clip { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.grid tr.retired { display: none; }
.grid.show-retired tr.retired { display: table-row; }
.grid tr.retired td { color: var(--fg-3); }
.grid tr[hidden] { display: none !important; }
.grid td.empty { text-align: center; color: var(--fg-3); padding: 36px 12px; }
.grid .n, .t .n { text-align: right; font-family: var(--mono); font-size: 12.5px; }
.grid th.n, .t th.n { font-family: var(--sans); font-size: 11px; }
@media (max-width: 900px) {
  .grid td.name, .grid th:first-child { position: sticky; left: 0; z-index: 1; background: var(--bg-1); box-shadow: inset -1px 0 0 var(--line), inset 0 -1px 0 var(--line); }
  .grid th:first-child { z-index: 2; }
  .grid td.name a { flex-direction: column; gap: 0; }
  .grid td.name .prov { font-size: 11.5px; }
  .grid td.name .badge { display: none; }
}

/* thin magnitude bar under a number, relative to the column max */
.bar { display: block; padding-bottom: 4px; background: linear-gradient(90deg, var(--bar) var(--p), var(--line) var(--p)) left bottom / 100% 2px no-repeat; }

/* ---------------------------------------------------------------- detail tables */

.t-wrap { overflow-x: auto; }
.t { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.t th { text-align: left; font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3); padding: 0 12px 8px 0; border-bottom: 1px solid var(--line); }
.t td { padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th:last-child, .t td:last-child { padding-right: 0; }
.t .u { color: var(--fg-3); font-size: 11px; }
.t tr.sel td { color: var(--accent); }
.t tr.dim td { color: var(--fg-3); }
.t td.actions { padding-top: 3px; padding-bottom: 3px; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions form { display: inline; }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; font-size: 13px; }
.kv dt { color: var(--fg-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.kv.tight { gap: 5px 14px; font-size: 12.5px; }

.lat-v { font-family: var(--mono); font-size: 12.5px; }
.lat-v.l1 { color: var(--good); }
.lat-v.l3 { color: var(--warn); }
.lat-v.l4 { color: var(--bad); }
.region td { padding-top: 16px; color: var(--fg-3); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; border-bottom-color: var(--line-2); }
.path { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; white-space: normal; }
.path .chip { font-size: 11.5px; padding: 1px 6px; }
.path .sep { color: var(--fg-3); font-size: 11px; }
.t tr.toggle { cursor: pointer; }
.t tr.toggle:hover td { color: var(--fg); }
.t tr.toggle.open .lat-more { transform: rotate(90deg); }
.lat-more { display: inline-block; width: 10px; color: var(--fg-3); transition: transform 0.15s; }
.t tr.hops > td { padding: 0 0 10px 18px; background: var(--bg); }
.hop-t { margin-top: 8px; }
.hop-t td, .hop-t th { padding-top: 4px; padding-bottom: 4px; font-size: 12px; }

.run-note { background: var(--accent-bg); border: 1px solid rgba(138, 180, 255, 0.25); border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 16px; }

.plist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.pcard { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 18px; background: var(--bg-1); border: 1px solid var(--line); border-radius: var(--radius); color: var(--fg); }
.pcard:hover { border-color: var(--line-2); text-decoration: none; }
.pcard-n { font-weight: 500; }

/* ---------------------------------------------------------------- admin */

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 16px; }
.field { display: grid; gap: 6px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field-l { font-size: 12px; color: var(--fg-2); font-weight: 500; }
.field-h { font-size: 11.5px; color: var(--fg-3); }
.field .check { height: 36px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline input, .inline select { width: auto; flex: 1 1 200px; max-width: 320px; }

.cmd { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 6px 6px 6px 12px; min-width: 0; }
.cmd code { background: none; padding: 0; flex: 1; overflow-x: auto; white-space: nowrap; font-size: 12px; color: var(--fg); scrollbar-width: none; }
.opts { display: flex; gap: 8px 18px; flex-wrap: wrap; }
.opts .check { font-size: 12.5px; }
.code { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 11.5px/1.5 var(--mono); overflow-x: auto; color: var(--fg-2); margin: 8px 0 0; }
details.more { font-size: 12.5px; color: var(--fg-2); }
details.more summary { cursor: pointer; }

.login { max-width: 380px; margin: 12vh auto 0; }
.login .btn { width: 100%; }
