/*
 * Themes.
 *
 * Every colour in the panel comes from one of these names, so a theme is a
 * block of values and nothing else — no rules are duplicated per theme. The
 * default block is Unhinged, which is what loads when nothing has been chosen.
 *
 * Two of these names are worth explaining. --on-brand is text that sits on top
 * of a solid brand-coloured fill, and is not always white: the lighter accents
 * need dark text to stay readable. --stripe is the diagonal hairline texture
 * on the page background.
 */
:root {
  /* Legends Unhinged — black + signature red (#e8201a) */
  --bg: #0a0a0b;
  --bg-panel: #08080a;
  --bg-card: #141416;
  --bg-tile: #101012;
  --border: #2a2a2e;
  --border-hi: #3a3a40;
  --text: #ffffff;
  --text-dim: #a0a0a8;
  --text-faint: #6b6b73;
  --brand: #e8201a;
  --brand-hi: #ff3b34;
  --brand-bg: rgba(232, 32, 26, 0.13);
  --on-brand: #ffffff;
  --green: #3fb950;
  --green-bg: rgba(63, 185, 80, 0.13);
  --blue: #e8201a;
  --blue-bg: rgba(232, 32, 26, 0.13);
  --purple: #bc8cff;
  --purple-bg: rgba(188, 140, 255, 0.12);
  --cyan: #39d2c0;
  --cyan-bg: rgba(57, 210, 192, 0.12);
  --yellow: #d9a441;
  --yellow-bg: rgba(217, 164, 65, 0.14);
  --yellow-border: rgba(217, 164, 65, 0.3);
  --red: #f85149;
  --red-bg: rgba(248, 81, 73, 0.1);
  --console-bg: #05070a;
  --console-fg: #b9c3ce;
  --overlay: rgba(4, 6, 9, 0.9);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.5);
  --stripe: rgba(232, 32, 26, 0.035);
  --radius: 12px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-head: "Arial Black", "Segoe UI", Inter, system-ui, sans-serif;
}

/* Midnight — deep navy, sky accent. Quieter than the red at 3am. */
[data-theme="midnight"] {
  --bg: #0a0f1a;
  --bg-panel: #070b14;
  --bg-card: #121a2b;
  --bg-tile: #0e1626;
  --border: #22304a;
  --border-hi: #334564;
  --text: #eef3fb;
  --text-dim: #93a4c0;
  --text-faint: #61728e;
  --brand: #38bdf8;
  --brand-hi: #7dd3fc;
  --brand-bg: rgba(56, 189, 248, 0.15);
  --on-brand: #04121c;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.14);
  --blue: #38bdf8;
  --blue-bg: rgba(56, 189, 248, 0.15);
  --purple: #a78bfa;
  --purple-bg: rgba(167, 139, 250, 0.14);
  --cyan: #22d3ee;
  --cyan-bg: rgba(34, 211, 238, 0.13);
  --yellow: #fbbf24;
  --yellow-bg: rgba(251, 191, 36, 0.14);
  --yellow-border: rgba(251, 191, 36, 0.32);
  --red: #fb7185;
  --red-bg: rgba(251, 113, 133, 0.12);
  --console-bg: #050a14;
  --console-fg: #b6c7de;
  --overlay: rgba(4, 8, 16, 0.9);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.55);
  --stripe: rgba(56, 189, 248, 0.035);
}

/* Graphite — neutral dark with an amber accent, for when red is too loud. */
[data-theme="graphite"] {
  --bg: #121212;
  --bg-panel: #0d0d0d;
  --bg-card: #1c1c1c;
  --bg-tile: #181818;
  --border: #2e2e2e;
  --border-hi: #414141;
  --text: #f2f0ed;
  --text-dim: #a8a29b;
  --text-faint: #75706a;
  --brand: #f59e0b;
  --brand-hi: #fbbf24;
  --brand-bg: rgba(245, 158, 11, 0.15);
  --on-brand: #1a1200;
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.13);
  --blue: #f59e0b;
  --blue-bg: rgba(245, 158, 11, 0.15);
  --purple: #c4b5fd;
  --purple-bg: rgba(196, 181, 253, 0.13);
  --cyan: #2dd4bf;
  --cyan-bg: rgba(45, 212, 191, 0.12);
  --yellow: #facc15;
  --yellow-bg: rgba(250, 204, 21, 0.14);
  --yellow-border: rgba(250, 204, 21, 0.3);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --console-bg: #0a0a0a;
  --console-fg: #c9c5be;
  --overlay: rgba(8, 8, 8, 0.9);
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: rgba(0, 0, 0, 0.5);
  --stripe: rgba(245, 158, 11, 0.03);
}

/*
 * Daylight — the same red identity on a light ground.
 *
 * The accents are darkened rather than reused: #e8201a on white is too low a
 * contrast to read small text in. The console keeps its dark ground, because a
 * washed-out log is harder to scan than a dark panel on a light page.
 */
[data-theme="daylight"] {
  --bg: #f7f5f5;
  --bg-panel: #ffffff;
  --bg-card: #ffffff;
  --bg-tile: #f1eded;
  --border: #e3dbdb;
  --border-hi: #cbc0c0;
  --text: #17131a;
  --text-dim: #5d555f;
  --text-faint: #8b838f;
  --brand: #c4130e;
  --brand-hi: #e8201a;
  --brand-bg: rgba(196, 19, 14, 0.1);
  --on-brand: #ffffff;
  --green: #1a7f37;
  --green-bg: rgba(26, 127, 55, 0.11);
  --blue: #c4130e;
  --blue-bg: rgba(196, 19, 14, 0.1);
  --purple: #6d34c4;
  --purple-bg: rgba(109, 52, 196, 0.1);
  --cyan: #0f7f73;
  --cyan-bg: rgba(15, 127, 115, 0.1);
  --yellow: #8a5d00;
  --yellow-bg: rgba(138, 93, 0, 0.11);
  --yellow-border: rgba(138, 93, 0, 0.28);
  --red: #c0271f;
  --red-bg: rgba(192, 39, 31, 0.09);
  --console-bg: #16131a;
  --console-fg: #ccd4de;
  --overlay: rgba(35, 28, 32, 0.55);
  --scrim: rgba(0, 0, 0, 0.35);
  --shadow: rgba(60, 45, 50, 0.18);
  --stripe: rgba(196, 19, 14, 0.04);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  background-image:
    repeating-linear-gradient(-45deg, var(--stripe) 0 1px, transparent 1px 140px);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
}

.hidden { display: none !important; }

.layout { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 230px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand {
  font-family: var(--font-head);
  font-weight: 900;
  letter-spacing: 1px;
  font-size: 17px;
  line-height: 1.05;
  margin-bottom: 26px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand .brand-txt { display: flex; flex-direction: column; }
.brand .brand-txt .l1 { color: var(--text); }
.brand .brand-txt .l2 { color: var(--brand); }
.brand span { color: var(--text-dim); font-weight: 400; }
.brand-logo { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }
.brand-icon { font-size: 18px; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
  margin: 16px 8px 6px;
}
.nav-link {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13.5px;
}
.nav-link:hover { background: var(--bg-card); color: var(--text); }
.nav-link.active { background: var(--brand-bg); color: var(--text); box-shadow: inset 3px 0 0 var(--brand); }
/* Theme swatches, sitting just above the account row at the foot of the
   sidebar. This takes the auto margin so the pair is pushed down together. */
.theme-row {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 8px 10px;
}
.theme-dot {
  width: 19px; height: 19px;
  border-radius: 50%;
  border: 1px solid var(--border-hi);
  padding: 0;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--bg-panel), 0 0 0 3.5px var(--brand);
}
.theme-dot:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 0;
  border-top: 1px solid var(--border);
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--blue-bg);
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.user-name { font-size: 13px; color: var(--text); font-weight: 600; line-height: 1.2; }
.user-role {
  font-size: 11px;
  color: var(--text-faint);
  text-decoration: none;
}
.user-role:hover { color: var(--brand); }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 26px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
  position: sticky;
  top: 0;
  z-index: 5;
}
.crumb { font-weight: 600; }
.view { padding: 24px 26px; }

/* ---------- pills / chips ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-bg); color: var(--green); }
.pill-red { background: var(--red-bg); color: var(--red); }
.pill-dim { background: var(--bg-card); color: var(--text-dim); }
.pill-blue { background: var(--blue-bg); color: var(--blue); }
.pill-purple { background: var(--purple-bg); color: var(--purple); }
.pill-yellow { background: var(--yellow-bg); color: var(--yellow); }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.chip-blue { background: var(--blue-bg); color: var(--blue); border-color: transparent; }
.chip-purple { background: var(--purple-bg); color: var(--purple); border-color: transparent; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; }

/* ---------- buttons ---------- */
.btn {
  border: 1px solid var(--border-hi);
  background: var(--bg-card);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { border-color: var(--brand); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.btn-primary:hover { background: var(--brand-hi); border-color: var(--brand-hi); }
.btn-green { color: var(--green); }
.btn-red { color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ---------- cards & grids ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.card h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 14px;
  text-transform: none;
}
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.server-card { cursor: pointer; transition: border-color 0.15s; margin-bottom: 0; }
.server-card:hover { border-color: var(--border-hi); }
.server-card .head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.server-card .name { font-weight: 700; font-size: 15px; }
.server-card .meta { color: var(--text-faint); font-size: 12px; margin-bottom: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-card .actions { display: flex; gap: 8px; margin-top: 14px; }

/* ---------- server detail ---------- */
.detail-layout { display: grid; grid-template-columns: 400px 1fr; gap: 20px; align-items: start; }
.detail-layout > * { min-width: 0; }
@media (max-width: 1100px) { .detail-layout { grid-template-columns: 1fr; } }
.tile-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 10px 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
}
.tile:hover { border-color: var(--border-hi); }
.tile.active { border-color: var(--text-dim); }
.tile .ico {
  width: 40px; height: 40px;
  margin: 0 auto 10px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.tile .t { font-weight: 600; font-size: 13px; }
.tile .s { font-size: 11.5px; color: var(--text-faint); margin-top: 3px; }
.ico-green { background: var(--green-bg); }
.ico-blue { background: var(--blue-bg); }
.ico-purple { background: var(--purple-bg); }
.ico-cyan { background: var(--cyan-bg); }
.ico-yellow { background: var(--yellow-bg); }
.ico-red { background: var(--red-bg); }
.tile-danger .t { color: var(--red); }

/* ---------- wizard ---------- */
.wiz-card { max-width: 760px; }
.stepper {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  max-width: 760px;
  flex-wrap: wrap;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-card);
  font-size: 13px;
  color: var(--text-faint);
  flex: 1;
  min-width: 0;
}
.step.done { cursor: pointer; color: var(--text-dim); }
.step.done:hover { border-color: var(--brand); }
.step.active { border-color: var(--brand); background: var(--brand-bg); color: var(--text); }
.step-n {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--bg-tile);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}
.step.active .step-n { background: var(--brand); color: var(--on-brand); }
.step.done .step-n { background: var(--green-bg); color: var(--green); }
.step-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiz-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.hint {
  font-size: 12px;
  color: var(--text-faint);
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.hint-warn { color: var(--yellow); border-color: var(--yellow-border); }

/* port + key-value editors */
.port-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.port-label {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 78px;
}
.port-in { width: 100px; }
.port-in-sm { width: 92px; }
.port-proto { width: 78px; }
.port-arrow { color: var(--text-faint); font-size: 12px; }
.port-warn { flex-basis: 100%; font-size: 12px; color: var(--red); padding-left: 78px; }
.port-warn:empty { display: none; }

.port-summary {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 11px 13px;
  margin-bottom: 12px;
}
.port-summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-family: Consolas, monospace;
  font-size: 13px;
}
.port-summary-note { font-size: 12px; color: var(--text-faint); margin-top: 7px; }

.kv-edit { display: flex; gap: 8px; margin-bottom: 8px; }
.kv-edit .kv-k { flex: 0 0 40%; font-family: Consolas, monospace; font-size: 12.5px; }
.kv-edit .kv-v, .kv-edit .vol-p { flex: 1; font-family: Consolas, monospace; font-size: 12.5px; }
.kv-edit .vol-n { flex: 0 0 40%; font-family: Consolas, monospace; font-size: 12.5px; }

/* ---------- game picker ---------- */
.select-wrap { position: relative; }
.select-wrap::after {
  content: "";
  position: absolute;
  right: 15px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -6px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: rotate(45deg);
  pointer-events: none;
}
.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  cursor: pointer;
}
.select-lg {
  font-size: 15px;
  padding: 13px 15px;
  background: var(--bg-tile);
}
.select-lg:hover { border-color: var(--border-hi); }
.select-wrap select option { background: var(--bg-card); color: var(--text); padding: 8px; }
.select-wrap select optgroup { background: var(--bg-panel); color: var(--text-faint); font-style: normal; }

.game-preview {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-top: 14px;
}
.gp-head { display: flex; align-items: center; gap: 10px; }
.gp-ico { font-size: 26px; line-height: 1; }
.gp-name { font-weight: 700; font-size: 15px; }
.gp-facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.gp-ports {
  margin-top: 12px;
  font-family: Consolas, monospace;
  font-size: 12.5px;
  color: var(--text-dim);
}

/* ---------- info rows ---------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.info-box { background: var(--bg-tile); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.info-box .k { font-size: 11px; color: var(--text-faint); margin-bottom: 4px; }
.info-box .v { font-size: 14px; font-weight: 600; font-family: Consolas, monospace; }
.kv-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.kv-row:last-child { border-bottom: none; }
.kv-row .k { color: var(--text-dim); }
.kv-row .v { font-family: Consolas, monospace; word-break: break-all; text-align: right; }

/* ---------- console / logs ---------- */
.console {
  background: var(--console-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  line-height: 1.55;
  height: 480px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--console-fg);
}
.console-sm { height: 300px; }
.console-bar { display: flex; gap: 8px; margin-top: 10px; }
.console-bar input { flex: 1; }

/* ---------- forms ---------- */
input, select, textarea {
  background: var(--bg-tile);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); }
textarea { font-family: Consolas, monospace; resize: vertical; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-cols-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }

/* ---------- charts ---------- */
.chart-wrap { position: relative; }
.chart-wrap canvas { width: 100%; height: 120px; display: block; }
.chart-val { font-size: 20px; font-weight: 700; margin-bottom: 6px; font-family: Consolas, monospace; }
.chart-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .chart-cards { grid-template-columns: 1fr; } }

/* ---------- tables / lists ---------- */
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-tile);
}
.list-row .main-txt { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.list-row .sub-txt { color: var(--text-faint); font-size: 12px; }
.list-row .row-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* file browser */
.file-entry { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; font-family: Consolas, monospace; }
.file-entry:hover { background: var(--bg-tile); }
.path-bar { display: flex; gap: 8px; margin-bottom: 12px; }
.path-bar input { font-family: Consolas, monospace; }

/* ---------- login / toast ---------- */
#login-overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 34px;
  width: 340px;
  text-align: center;
}
.login-card p { color: var(--text-dim); font-size: 13px; margin: 10px 0 18px; }
.login-card input { margin-bottom: 12px; }
.login-card .btn { width: 100%; }
.login-logo { width: 92px; height: 92px; object-fit: contain; margin-bottom: 14px; }
.brand-mark { font-family: var(--font-head); font-weight: 900; letter-spacing: 1px; font-size: 20px; }
.brand-mark .l1 { color: var(--text); }
.brand-mark .l2 { color: var(--brand); }
.brand-mark span { color: var(--text-dim); font-weight: 400; }
.login-error { color: var(--red); font-size: 12px; margin-top: 10px; min-height: 16px; }

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  z-index: 90;
  max-width: 380px;
  box-shadow: 0 8px 30px var(--shadow);
}
.toast.err { border-color: var(--red); color: var(--red); }

.page-title { font-family: var(--font-head); font-weight: 900; font-size: 22px; letter-spacing: 0.5px; margin-bottom: 4px; text-transform: uppercase; }

/* ---------- mods ---------- */
.modtabs {
  display: flex;
  gap: 4px;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.modtab {
  flex: 1;
  min-width: 92px;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-dim);
  padding: 9px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.modtab:hover { color: var(--text); }
.modtab.active { background: var(--bg-card); border-color: var(--brand); color: var(--text); }

.mod-card {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-tile);
  margin-bottom: 10px;
}
.mod-logo {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-card);
}
.mod-logo-blank { display: flex; align-items: center; justify-content: center; font-size: 22px; }
.mod-body { flex: 1; min-width: 0; }
.mod-name { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.mod-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.mod-author, .mod-dl { color: var(--text-faint); }
.mod-link { color: var(--text-dim); text-decoration: none; }
.mod-link:hover { color: var(--brand); }
.mod-actions { flex-shrink: 0; }
.chip-green { background: var(--green-bg); color: var(--green); border-color: transparent; }

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

.mod-savebar {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand-bg);
  font-size: 13px;
}

.order-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-tile);
  margin-bottom: 8px;
  cursor: grab;
}
.order-row.dragging { opacity: 0.4; border-color: var(--brand); }
.order-grip { color: var(--text-faint); cursor: grab; }
.order-arrows { display: flex; flex-direction: column; gap: 2px; }
.order-arrows .btn { padding: 1px 7px; font-size: 10px; line-height: 1.4; }
.order-logo { width: 38px; height: 38px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.order-name { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; }
.order-num {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-dim);
  flex-shrink: 0;
}

/* ---------- toolbar & groups ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.tb-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-faint); }
.tb-select { width: auto; min-width: 130px; padding: 7px 11px; font-size: 12.5px; }

.group-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0 12px;
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
}
.group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.group-count {
  font-family: var(--font);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-faint);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
  order: 3;
}
.group-chip { cursor: pointer; }
.group-chip:hover { border-color: var(--brand); color: var(--text); }

/* ---------- dashboard ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  display: block;
}
a.stat:hover { border-color: var(--brand); }
.stat-k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-faint); }
.stat-v {
  font-family: var(--font-head);
  font-weight: 900;
  font-size: 30px;
  line-height: 1.15;
  margin-top: 8px;
}
.stat-of { font-size: 16px; color: var(--text-faint); font-weight: 400; }
.stat-s { font-size: 12px; color: var(--text-dim); margin-top: 5px; }

.attn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: var(--bg-tile);
  font-size: 13px;
  text-decoration: none;
  color: var(--text);
}
.attn:last-child { margin-bottom: 0; }
.attn.warn { border-left-color: var(--yellow); }
.attn.info { border-left-color: var(--blue); }
.attn:hover { border-color: var(--border-hi); border-left-color: var(--brand); }
.attn-go { color: var(--text-faint); }

.dash-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
/* grid children default to min-width:auto, which lets a wide table push the
   whole page sideways instead of scrolling inside its own container */
.dash-cols > * { min-width: 0; }
@media (max-width: 1100px) { .dash-cols { grid-template-columns: 1fr; } }
.row-link { cursor: pointer; }

/* ---------- cluster matrix ---------- */
.matrix-wrap { overflow-x: auto; }
.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.matrix th,
.matrix td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.matrix th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  font-weight: 600;
}
.matrix tbody tr:hover { background: var(--bg-tile); }
.matrix tbody tr:last-child td { border-bottom: none; }
.matrix .col-map {
  text-align: center;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.matrix .cell { text-align: center; font-size: 15px; }
.matrix .cell.yes { color: var(--green); }
.matrix .cell.no { color: var(--text-faint); }
.matrix .mono { font-family: Consolas, monospace; }
.matrix input[type="checkbox"] { width: auto; }
.m-name { font-weight: 600; }
.m-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.map-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 10px 12px;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.map-pick {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.map-pick input { width: auto; }

input[type="file"] {
  padding: 9px 12px;
  font-size: 12.5px;
  cursor: pointer;
}

/* ---------- mobile ---------- */
.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-hi);
  color: var(--text);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  padding: 7px 11px;
  cursor: pointer;
  margin-right: 12px;
}
.topbar-left { display: flex; align-items: center; min-width: 0; }
.scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--scrim);
  z-index: 18;
}
.scrim.show { display: block; }

@media (max-width: 860px) {
  .menu-btn { display: block; }

  /* sidebar becomes a drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 20;
    width: 250px;
    height: 100dvh;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }

  .view { padding: 16px 14px 40px; }
  .topbar { padding: 12px 14px; }
  .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* one column everywhere */
  .form-cols, .form-cols-3, .chart-cards, .detail-layout { grid-template-columns: 1fr; }
  .server-grid { grid-template-columns: 1fr; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: repeat(2, 1fr); }
  .select-lg { font-size: 16px; } /* 16px stops iOS zooming the page on focus */

  .card { padding: 14px; }
  .console { height: 320px; font-size: 12px; }
  .console-sm { height: 220px; }

  /* comfortable tap targets */
  .btn { padding: 9px 15px; }
  .nav-link { padding: 11px 12px; }
  .file-entry { padding: 11px 10px; }

  /* stacking rows that would otherwise squeeze */
  .list-row { flex-wrap: wrap; }
  .list-row .row-actions { width: 100%; justify-content: flex-end; }
  .kv-edit { flex-wrap: wrap; }
  .kv-edit .kv-k, .kv-edit .vol-n { flex: 1 1 100%; }
  .kv-edit .kv-v, .kv-edit .vol-p { flex: 1 1 calc(100% - 52px); }

  /* port rows: label on its own line, the fields share the next one */
  .port-row {
    gap: 6px;
    padding-bottom: 10px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--border);
  }
  .port-label { flex: 1 1 100%; min-width: 0; font-weight: 600; color: var(--text); }
  .port-in { flex: 1 1 0; width: auto; min-width: 0; }
  .port-in-sm { flex: 1 1 0; width: auto; min-width: 0; }
  .port-proto { flex: 0 0 72px; width: auto; }
  .port-warn { padding-left: 0; }
  .kv-row { flex-direction: column; gap: 2px; }
  .kv-row .v { text-align: left; }

  /* drop secondary table columns so action buttons stay reachable */
  .matrix .hide-sm { display: none; }
  .matrix th, .matrix td { padding: 9px 8px; }
  .matrix td .btn { margin-bottom: 3px; }

  /* the stepper collapses to numbers only */
  .stepper { gap: 6px; }
  .step { padding: 7px 10px; flex: 0 0 auto; }
  .step .step-l { display: none; }
  .step.active .step-l { display: inline; }

  .wiz-nav { position: sticky; bottom: 0; background: var(--bg-card); padding-bottom: 4px; }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 420px) {
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr; }
  .page-title { font-size: 19px; }
}
.page-sub { color: var(--text-dim); font-size: 13px; margin-bottom: 22px; }
.empty { color: var(--text-faint); text-align: center; padding: 40px 0; font-size: 13px; }
.mt { margin-top: 14px; }
code.inline { background: var(--bg-tile); border: 1px solid var(--border); padding: 1px 6px; border-radius: 5px; font-size: 12px; }

/* The two-factor QR. It keeps its white ground in every theme — a scanner
   needs the contrast, and an inverted code is a common reason a camera
   refuses to read one. */
.qr-frame {
  display: inline-block;
  background: #ffffff;
  /* the border is what separates a white code from a light page background */
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin: 14px 0;
  line-height: 0;
}
.qr-frame svg { width: 208px; height: 208px; display: block; }

/* Setup keys and recovery codes: monospaced and selectable, since they are
   meant to be read off the screen and typed in somewhere else. */
.code-block {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 12px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  letter-spacing: 0.06em;
  color: var(--text);
  user-select: all;
  overflow-x: auto;
  white-space: pre;
}

.chip-warn { background: var(--yellow-bg); color: var(--yellow); border-color: transparent; }

/* ---------- My Servers: summary, search and filter chips ---------- */
.filter-summary {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.filter-search {
  position: relative;
  flex: 1 1 240px;
  max-width: 340px;
}
.filter-search-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 15px;
  pointer-events: none;
}
.filter-search input {
  width: 100%;
  padding-left: 30px;
  border-radius: 999px;
}

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

.fchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.fchip:hover { background: var(--bg-tile); color: var(--text); }
.fchip:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* the count sits in its own well, so the number reads as data not decoration */
.fchip-n {
  background: var(--bg-tile);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.fchip.active {
  background: var(--bg-card);
  border-color: var(--border-hi);
  color: var(--text);
}
.fchip.active .fchip-n { background: var(--brand-bg); color: var(--brand); }

/* filters that mean "look at this" carry their colour on the count only,
   so the row stays calm until something is actually wrong */
.fchip-warn .fchip-n { background: var(--yellow-bg); color: var(--yellow); }
.fchip-blue .fchip-n { background: var(--blue-bg); color: var(--blue); }
.fchip-warn.active { border-color: var(--yellow-border); }

@media (max-width: 600px) {
  .filter-search { max-width: none; flex-basis: 100%; }
  .fchip { padding: 6px 11px; font-size: 12.5px; }
}

/* ---------- My Servers: view modes ---------- */
/* The card grid gives every card the same height so the action row lines up
   across a row — a ragged bottom edge is what made this hard to scan. */
/* Scoped to the grid on purpose: .server-card is also on the <tr> of the list
   view and the tile of the compact one, and turning a table row into a flex
   column stacks every cell on top of the next. */
.server-grid { grid-auto-rows: 1fr; }
.server-grid > .server-card { display: flex; flex-direction: column; }
.server-grid > .server-card .name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.server-grid > .server-card .head { gap: 10px; }
.server-grid > .server-card .actions { margin-top: auto; padding-top: 14px; }

.sv-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.sv-chips .chip { font-size: 11px; }
.sv-badge { font-size: 12px; line-height: 1; }

/* the three facts every view shows, in the same order everywhere */
.sv-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 0 0;
  border-top: 1px solid var(--border);
}
.sv-facts dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-faint);
  margin-bottom: 3px;
}
.sv-facts dd {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- list view ---- */
.sv-list-card { padding: 0; overflow: hidden; }
.sv-table { min-width: 720px; }
.sv-table th, .sv-table td { padding: 10px 14px; }
.sv-row { cursor: pointer; }
.sv-row:hover { background: var(--bg-tile); }
.sv-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sv-ports { font-family: Consolas, monospace; font-size: 11.5px; }
.sv-actions { text-align: right; white-space: nowrap; }
.sv-actions .btn { margin-left: 6px; }

/* ---- compact view ---- */
.sv-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 8px;
}
.sv-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  min-width: 0;
}
.sv-tile:hover { border-color: var(--border-hi); }
.sv-tile-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sv-tile-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
/* the status is a dot here; the pill colours carry over as backgrounds */
.sv-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.sv-dot.pill-green { background: var(--green); }
.sv-dot.pill-red { background: var(--red); }
.sv-dot.pill-yellow { background: var(--yellow); }
.sv-dot.pill-dim { background: var(--text-faint); }

/* ---- the view switcher ---- */
.view-switch {
  display: inline-flex;
  gap: 2px;
  margin-left: auto;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 2px;
}
.vbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.vbtn:hover { color: var(--text); }
.vbtn.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 2px var(--shadow); }
.vbtn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.vbtn-ico { font-size: 12px; line-height: 1; }

@media (max-width: 760px) {
  .view-switch { margin-left: 0; }
  .vbtn-txt { display: none; }
  .vbtn { padding: 7px 10px; }
}

/* the container's real name under a display name — present but quiet */
.sv-realname {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--text-faint);
  margin: -6px 0 8px;
}
.rn-input { width: 100%; min-width: 180px; }
