/* haproxy.tools.midgard.com.hr — light / dark via tokens.
   Theme: system by default; [data-theme] on <html> forces light or dark. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #16181d;
  --text-2: #4b5260;
  --muted: #7a8190;
  --accent: #2563eb;
  --accent-hover: #1d4fd7;
  --accent-soft: #e8efff;
  --on-accent: #ffffff;
  --bit-net: #2563eb;
  --bit-sub: #c2410c;
  --bit-host: #0f8a5f;
  --danger: #c4312b;
  --danger-soft: #fdecea;
  --toolbar-bg: rgba(255, 255, 255, 0.82);
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --surface-2: #1e222a;
    --border: #2a2f39;
    --border-strong: #3a404c;
    --text: #e8eaef;
    --text-2: #b3b9c5;
    --muted: #858c99;
    --accent: #6c9bff;
    --accent-hover: #8bb0ff;
    --accent-soft: #1c2742;
    --on-accent: #0b1020;
    --bit-net: #7aa5ff;
    --bit-sub: #f0a45b;
    --bit-host: #4fd1a1;
    --danger: #ff7b72;
    --danger-soft: #3a1d1d;
    --toolbar-bg: rgba(15, 17, 21, 0.8);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --surface-2: #1e222a;
  --border: #2a2f39;
  --border-strong: #3a404c;
  --text: #e8eaef;
  --text-2: #b3b9c5;
  --muted: #858c99;
  --accent: #6c9bff;
  --accent-hover: #8bb0ff;
  --accent-soft: #1c2742;
  --on-accent: #0b1020;
  --bit-net: #7aa5ff;
  --bit-sub: #f0a45b;
  --bit-host: #4fd1a1;
  --danger: #ff7b72;
  --danger-soft: #3a1d1d;
  --toolbar-bg: rgba(15, 17, 21, 0.8);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code { font-family: var(--mono); font-size: 0.95em; }

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.875rem; }

/* ---------- Toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--toolbar-bg);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.toolbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 650;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  font: 700 12px/1 var(--mono);
}

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.nav-link {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 0.93rem;
  white-space: nowrap;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.nav-api { font-family: var(--mono); font-size: 0.85rem; }

.nav-sep {
  width: 1px;
  height: 20px;
  margin: 0 8px;
  background: var(--border-strong);
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--border-strong); }
.theme-toggle svg { display: none; }
.theme-toggle .fill { fill: currentColor; stroke: none; }
.theme-toggle:not([data-mode]) .i-auto,
.theme-toggle[data-mode="system"] .i-auto,
.theme-toggle[data-mode="light"] .i-light,
.theme-toggle[data-mode="dark"] .i-dark { display: block; }

/* ---------- Layout ---------- */
.main {
  flex: 1;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.page-title {
  margin: 0 0 20px;
  font-size: 1.6rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 24px 16px;
  color: var(--muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.footer a { color: var(--muted); font-family: var(--mono); }
.footer a:hover { color: var(--text); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font: 500 0.93rem/1 var(--sans);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--border-strong); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 0.83rem; }
.btn.copied { color: var(--bit-host); border-color: var(--bit-host); }
.btn.copied span, .btn-sm.copied { font-size: 0; }
.btn.copied span::after, .btn-sm.copied::after { content: "Copied"; font-size: 0.93rem; }
.btn-sm.copied::after { font-size: 0.83rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-left: 6px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
}
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.copied { color: var(--bit-host); opacity: 1; }
.r-row:hover .icon-btn, .kv-v:hover .icon-btn, .icon-btn:focus-visible { opacity: 1; }
@media (hover: none) { .icon-btn { opacity: 1; } }

/* ---------- Landing ---------- */
.hero {
  padding: 40px 0 36px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-ip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px 16px;
}

.hero-ip code {
  font-size: clamp(2rem, 7vw, 3.4rem);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
  overflow-wrap: anywhere;
}
.hero-ip code.is-v6 { font-size: clamp(1.3rem, 4.4vw, 2.4rem); }

.chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 0;
}

.chip {
  padding: 3px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.83rem;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.chip-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip-mono { font-family: var(--mono); font-size: 0.8rem; }

.hero-actions { margin: 28px 0 0; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.tile {
  display: block;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text-2);
  transition: border-color 0.12s, transform 0.12s;
}
.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile h2 { margin: 0 0 6px; color: var(--text); font-size: 1rem; font-weight: 600; }
.tile h2::after { content: " →"; color: var(--accent); }
.tile p { margin: 0; font-size: 0.9rem; }

.cli { display: grid; gap: 8px; }
.cli-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  border-radius: 9px;
  background: var(--surface-2);
}
.cli-row code { overflow-wrap: anywhere; }
.cli + p { margin: 12px 0 0; }

/* ---------- Calculator form ---------- */
.calc-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); }
.field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 1rem var(--mono);
}
.field input::placeholder { color: var(--muted); opacity: 0.7; }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.hint { font-size: 0.8rem; color: var(--muted); }
.hint code { font-size: 0.78rem; }

.form-actions { grid-column: 1 / -1; display: flex; gap: 8px; }

.form-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.9rem;
}

/* ---------- Results ---------- */
.legend { display: flex; gap: 14px; justify-content: flex-end; margin: -4px 0 8px; font-size: 0.78rem; }
.lg::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 2px; background: currentColor; vertical-align: 0; }

.r-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.r-row:last-child { border-bottom: 0; }

.r-label { color: var(--muted); font-size: 0.88rem; }

.r-value {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}
.r-value code { font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.r-note { margin-left: 10px; color: var(--muted); font-size: 0.85rem; font-family: var(--mono); overflow-wrap: anywhere; }

.r-bin {
  font: 0.86rem/1.6 var(--mono);
  letter-spacing: 0.02em;
  text-align: right;
}

.r-sep {
  padding: 6px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.b-net { color: var(--bit-net); }
.b-sub { color: var(--bit-sub); }
.b-host { color: var(--bit-host); }
.b-dot { color: var(--muted); }
.b-grp { display: inline-block; }

/* IPv6 binary is 128 bits: give it a full-width line under the value. */
.r-row:has(.b-grp) { grid-template-columns: 110px minmax(0, 1fr); }
.r-row:has(.b-grp) .r-bin { grid-column: 2; text-align: left; font-size: 0.8rem; }

.summary { margin: 0 0 12px; color: var(--text-2); }
.summary code { font-size: 0.9em; }
.card .summary + .r-row { border-top: 1px solid var(--border); }

.kv {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 0 16px;
}
.kv-k, .kv-v { padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv-k { color: var(--muted); font-size: 0.88rem; }
.kv-v { display: flex; align-items: center; flex-wrap: wrap; gap: 0 6px; min-width: 0; }
.kv-v code { overflow-wrap: anywhere; }
.kv-v .icon-btn { margin-left: 0; }
.kv > :nth-last-child(-n + 2) { border-bottom: 0; }

.table-wrap { overflow-x: auto; margin: 0 -20px -20px; border-top: 1px solid var(--border); }
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { padding: 7px 20px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .num { color: var(--muted); text-align: right; width: 1%; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .r-row { grid-template-columns: 96px minmax(0, 1fr); }
  .r-bin, .r-row:has(.b-grp) .r-bin { grid-column: 1 / -1; text-align: left; font-size: 0.78rem; }
  .calc-form { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .main { padding-top: 20px; }
  .toolbar-inner { gap: 8px; }
  .brand-name { display: none; }
  .nav-link { padding: 6px 8px; }
  .nav-sep { margin: 0 4px; }
  .grid-2 { grid-template-columns: 1fr; }
  .calc-form { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px -16px; }
  .tbl th, .tbl td { padding: 7px 16px; }
  .r-row, .r-row:has(.b-grp) { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .r-row .r-bin { grid-column: 1; }
  .r-label { font-size: 0.8rem; }
  .r-value { flex-wrap: nowrap; }
  .r-value code { min-width: 0; }
  .r-note { flex-shrink: 0; max-width: 45%; }
  .kv { grid-template-columns: 1fr; }
  .kv-k { padding-bottom: 0; border-bottom: 0; font-size: 0.8rem; }
  .kv > :nth-last-child(2) { border-bottom: 0; }
}


/* ================= haproxy ================= */
.brand-mark svg { width: 18px; height: 18px; stroke-width: 2.2; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-note { margin: -8px 0 20px; max-width: 760px; }
.grid-2 > * { min-width: 0; }
.page-note code, .hint code { overflow-wrap: anywhere; }

/* Option forms */
.opts { display: flex; flex-wrap: wrap; align-items: end; gap: 14px 16px; }
.opts .field { flex: 1 1 180px; }
.opts .field-num { flex: 0 1 130px; }
.opts .field-wide, .opts > .hint { flex: 1 1 100%; }
.opts > .hint { margin: 0; }
.opt-checks { display: flex; flex-wrap: wrap; align-items: center; gap: 0 18px; min-height: 42px; margin: 0; padding: 0; border: 0; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; font-size: 0.9rem; color: var(--text-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.check code { font-size: 0.85rem; }
.field select, .tbl select {
  width: 100%;
  height: 42px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a8190' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 10l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  color: var(--text);
  font: 0.95rem var(--sans);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.field textarea, .big-text {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  font: 0.9rem/1.5 var(--mono);
  resize: vertical;
}
.field select:focus, .field textarea:focus, .tbl select:focus, .tbl input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field input:disabled, .field select:disabled, .tbl input:disabled { opacity: 0.55; cursor: not-allowed; }
.field input[type="range"] { height: 42px; padding: 0; border: 0; background: none; box-shadow: none; accent-color: var(--accent); cursor: pointer; }
.field label output { margin-left: 6px; color: var(--accent); font: 700 0.95rem var(--mono); }
.field .check { margin-top: 2px; }

/* Segmented control */
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; border-radius: 7px; color: var(--text-2); font-size: 0.88rem; font-weight: 500; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Card header with actions */
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.card-head .card-title { margin: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }

/* Generated code */
.code-out {
  max-height: 70vh;
  overflow: auto;
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  font: 0.82rem/1.55 var(--mono);
  white-space: pre;
  tab-size: 4;
}
.code-out:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.msgs { margin: 0 0 12px; padding: 10px 12px 10px 30px; border-radius: 9px; font-size: 0.88rem; }
.msgs li + li { margin-top: 4px; }
.msgs-err { background: var(--danger-soft); color: var(--danger); }
.msgs-warn { background: var(--surface-2); color: var(--bit-sub); border: 1px solid var(--border); }
.out-mods { margin: 10px 0 0; }
.out-mods code { font-size: 0.78rem; }

/* .htaccess page: options left, output right */
.ht-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 16px; align-items: start; }
.ht-form .card { margin-bottom: 12px; padding: 14px 18px; }
.ht-form .card-title { margin-bottom: 10px; }
.ht-out { position: sticky; top: 72px; }
.ht-out .card { margin-bottom: 0; }
.ht-out .code-out { max-height: calc(100vh - 220px); min-height: 240px; }
.ht-toggle { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.ht-toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }
.ht-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.ht-sec:not(.is-on) .ht-body { display: none; }
.ht-sec:not(.is-on) .ht-toggle { color: var(--text-2); font-weight: 500; }

/* Row tables (redirects, users, aliases) */
.redir-wrap { margin: 0 -18px; border-top: 0; }
.tbl td .icon-btn { opacity: 1; margin: 0; }
.redir-tbl th, .redir-tbl td { padding: 6px 4px; white-space: normal; }
.redir-tbl th:first-child, .redir-tbl td:first-child { padding-left: 18px; }
.redir-tbl th:last-child, .redir-tbl td:last-child { padding-right: 14px; width: 1%; }
.redir-tbl tbody tr:hover { background: transparent; }
.redir-tbl select { width: auto; height: 36px; padding-right: 28px; background-position: right 6px center; font-size: 0.85rem; }
.redir-tbl input {
  width: 100%;
  min-width: 90px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: 0.85rem var(--mono);
}
.redir-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; }
.redir-foot .hint { flex: 1 1 200px; }

@media (max-width: 900px) {
  .ht-layout { grid-template-columns: minmax(0, 1fr); }
  .ht-out { position: static; }
  .ht-out .code-out { max-height: 70vh; }
}

@media (max-width: 560px) {
  .card-actions { width: 100%; margin-left: 0; }
  .card-actions .btn { flex: 1; justify-content: center; }
  .opts .field-num { flex: 1 1 110px; }
  .ht-form .card { padding: 14px 16px; }
  .redir-wrap { margin: 0 -16px; }
  .redir-tbl thead { display: none; }
  .redir-tbl tr { display: grid; grid-template-columns: auto auto 1fr; gap: 6px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
  .redir-tbl td, .redir-tbl td:first-child, .redir-tbl td:last-child { padding: 0; border: 0; width: auto; }
  .redir-tbl td:nth-child(3), .redir-tbl td:nth-child(4) { grid-column: 1 / -1; }
  .redir-tbl td:nth-child(5) { grid-column: 3; grid-row: 1; justify-self: end; }
}

@media (max-width: 420px) {
  .toolbar-inner { padding: 0 12px; gap: 6px; }
  .nav { gap: 0; }
  .nav-link { padding: 6px 4px; font-size: 0.8rem; }
}

/* vhost page */
.cmd-card { margin-top: 16px; }
.steps { display: grid; gap: 10px; margin: 0; padding-left: 22px; }
.steps li::marker { color: var(--muted); font: 0.85rem var(--mono); }
.steps .cli-row code { font-size: 0.85rem; }
.steps p { margin: 4px 0 0 2px; }

/* Log formats page */
.fmt-wrap { margin-top: 16px; }
.fmt-tbl td:last-child { white-space: normal; min-width: 240px; color: var(--text-2); }
.fmt-tbl td code { font-weight: 600; white-space: pre; }
.fmt-tbl tr.is-lit td { color: var(--muted); }
.fmt-tbl tr.is-lit code { font-weight: 400; }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile-stat { display: grid; gap: 2px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.tile-stat strong { font: 650 1.15rem/1.3 var(--mono); overflow-wrap: anywhere; }
.tile-long strong { font-size: 0.85rem; font-weight: 600; }
.stat-cards { align-items: start; }
.stat-cards .card { margin-bottom: 0; min-width: 0; }
.bars { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.bars li { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(40px, 1fr) auto; align-items: center; gap: 10px; font-size: 0.85rem; }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: 0.8rem; }
.bar-track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar-n { font: 0.8rem var(--mono); text-align: right; white-space: nowrap; }
.bar-n .muted { font-size: 0.75rem; }
.bars-sub { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.bar.s2 { background: var(--bit-host); }
.bar.s3 { background: var(--accent); }
.bar.s4 { background: var(--bit-sub); }
.bar.s5 { background: var(--danger); }
.bar-label.s2 { color: var(--bit-host); }
.bar-label.s4 { color: var(--bit-sub); }
.bar-label.s5 { color: var(--danger); }
.log-wrap { max-height: 70vh; overflow: auto; }
.log-tbl { font: 0.8rem var(--mono); }
.log-tbl th, .log-tbl td { padding: 5px 10px; }
.log-tbl th:first-child, .log-tbl td:first-child { padding-left: 20px; }
.log-tbl td.wide { white-space: normal; min-width: 220px; overflow-wrap: anywhere; }
.log-tbl td code { white-space: pre; }
.log-tbl tr td.st { font-weight: 700; }
.log-tbl tr.s2 td.st { color: var(--bit-host); }
.log-tbl tr.s3 td.st { color: var(--accent); }
.log-tbl tr.s4 td.st { color: var(--bit-sub); }
.log-tbl tr.s5 td.st { color: var(--danger); }
.log-tbl tr.s4 td:first-child { box-shadow: inset 3px 0 0 var(--bit-sub); }
.log-tbl tr.s5 td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
#lines { white-space: pre; overflow-x: auto; }

@media (max-width: 560px) {
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .log-tbl th:first-child, .log-tbl td:first-child { padding-left: 16px; }
}

.strong { font-weight: 700; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font: 600 0.75rem/1.5 var(--sans); white-space: nowrap; }
.tag-ok { background: var(--accent-soft); color: var(--bit-host); }
.tag-no { background: var(--danger-soft); color: var(--danger); }
.tag-r { background: var(--accent-soft); color: var(--accent); }

/* Config generator */
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; }
.preset-row .btn { white-space: normal; height: auto; min-height: 30px; padding-top: 5px; padding-bottom: 5px; text-align: left; line-height: 1.3; }
.be-list { display: grid; gap: 12px; margin-bottom: 10px; }
.be-card { padding: 12px 14px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); min-width: 0; }
.be-card .field input, .be-card .field select, .be-card .field textarea { background-color: var(--surface); }
.be-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-size: 0.9rem; }
.be-head .icon-btn { opacity: 1; margin: 0; }
.sub-title { margin: 4px 0 8px; font-size: 0.9rem; font-weight: 600; color: var(--text-2); }
.sub-title + .table-wrap { margin-top: 0; }
.redir-foot + .sub-title { margin-top: 18px; }
.route-def { margin-top: 16px; }
.route-tbl select, .path-tbl select, .tcp-tbl select { width: 100%; min-width: 90px; }
.tcp-tbl .in-port { min-width: 56px; width: 64px; }
.tcp-tbl .check { min-height: 36px; }
.tcp-tbl .check input { width: 16px; height: 16px; min-width: 0; padding: 0; }
.notes { margin: 0; padding-left: 20px; color: var(--text-2); font-size: 0.9rem; }
.notes li + li { margin-top: 6px; }
.notes code, .page-note code, .hint code, .cmd-card code, .about-cols code, .muted code, .tr-info code { overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .route-tbl tr { grid-template-columns: minmax(0, 1fr) auto; }
  .route-tbl td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .route-tbl td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .route-tbl td:nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  .path-tbl tr { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .path-tbl td:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .path-tbl td:nth-child(2) { grid-column: 1; grid-row: 2; }
  .path-tbl td:nth-child(3) { grid-column: 2 / -1; grid-row: 2; }
  .path-tbl td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  .path-tbl td:nth-child(5) { grid-column: 3; grid-row: 1; justify-self: end; }
  .tcp-tbl tr { grid-template-columns: minmax(0, 1fr) auto auto auto; }
  .tcp-tbl td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .tcp-tbl td:nth-child(2) { grid-column: 2 / 4; grid-row: 1; }
  .tcp-tbl td:nth-child(3) { grid-column: 1 / -1; grid-row: 2; }
  .tcp-tbl td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; }
  .tcp-tbl td:nth-child(5) { grid-column: 1; grid-row: 4; }
  .tcp-tbl td:nth-child(6) { grid-column: 2 / -1; grid-row: 4; }
  .tcp-tbl td:nth-child(7) { grid-column: 4; grid-row: 1; justify-self: end; }
  .tcp-tbl .in-port { width: 70px; }
  .tcp-tbl td:nth-child(5) .check::after { content: "Health check"; }
  .tcp-tbl td:nth-child(6) select { width: 100%; }
}

/* ACL explainer and tester */
.rw-grid { align-items: start; }
.rw-grid .card { margin-bottom: 0; }
.rw-grid .card-title label { cursor: default; }
.rw-result { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 14px; font-size: 0.95rem; }
.rw-result code { font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }
.rw-result p { flex-basis: 100%; margin: 4px 0 0; }
.rw-result .form-error { flex-basis: 100%; }
.pass + .pass { margin-top: 16px; }
.pass-title { margin: 0 0 8px; font-size: 0.9rem; font-weight: 600; }
.pass-title code { font-size: 0.88rem; overflow-wrap: anywhere; }
.steps-trace { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.steps-trace > li { padding: 8px 12px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 9px; background: var(--surface-2); min-width: 0; }
.steps-trace > li.is-hit { border-left-color: var(--bit-host); }
.steps-trace > li.is-miss { border-left-color: var(--border-strong); }
.steps-trace > li.is-skip { opacity: 0.65; }
.tr-line, .tr-cond { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.tr-line code, .tr-cond code { font-size: 0.82rem; overflow-wrap: anywhere; min-width: 0; }
.tr-cond { margin: 4px 0 0 0; flex-wrap: wrap; }
.ln { flex-shrink: 0; min-width: 1.8em; color: var(--muted); font: 0.75rem var(--mono); text-align: right; }
.tr-info { margin: 4px 0 0 calc(1.8em + 8px); font-size: 0.85rem; overflow-wrap: anywhere; }
.tr-info code { font-size: 0.82rem; }
.about-cols p { margin: 0 0 10px; color: var(--text-2); font-size: 0.9rem; }
.about-cols p:last-child { margin-bottom: 0; }
.cfg-in { min-height: 220px; white-space: pre; overflow-x: auto; }
.explain { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.explain > li { padding: 6px 10px; border-radius: 8px; background: var(--surface-2); min-width: 0; }
.explain > li.ex-acl { box-shadow: inset 3px 0 0 var(--accent); }
.explain > li.ex-use, .explain > li.ex-default { box-shadow: inset 3px 0 0 var(--bit-host); }
.explain > li.ex-rule { box-shadow: inset 3px 0 0 var(--bit-sub); }
.explain > li.ex-other { opacity: 0.7; }
.acl-tbl td.why { white-space: normal; min-width: 200px; color: var(--text-2); font-size: 0.85rem; overflow-wrap: anywhere; }
.tr-cond span { display: inline-flex; align-items: center; gap: 4px; }

/* Log parser */
.log-in { min-height: 140px; white-space: pre; overflow-x: auto; }
.tbl th.r, .tbl td.r { text-align: right; }
.ph-TR { background: var(--muted); }
.ph-Tw { background: var(--bit-sub); }
.ph-Tc { background: var(--danger); }
.ph-Tr { background: var(--accent); }
.ph-Td { background: var(--bit-host); }
.tbar { display: flex; width: 120px; height: 10px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.tbar i { display: block; height: 100%; }
.tbar-empty { opacity: 0.5; }
.timer-bars li { grid-template-columns: minmax(0, 150px) minmax(40px, 1fr) auto; }
.timer-bars .bar { min-width: 0; }
.tl-k { font-size: 0.85rem; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-k code { font-weight: 600; color: var(--text); }
.tl-total { padding-top: 6px; border-top: 1px solid var(--border); }
.timer-chart { max-width: 640px; margin-bottom: 12px; }
.timer-notes { margin: 0 0 12px; }
.term-box { margin-bottom: 4px; }
.term-head { margin: 0 0 8px; font-size: 0.92rem; }
.term-code { padding: 1px 6px; border-radius: 6px; background: var(--surface-2); font-weight: 700; }
.term-parts { display: grid; gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; font-size: 0.88rem; color: var(--text-2); }
.term-parts li { display: grid; grid-template-columns: 1.6em minmax(0, 1fr); gap: 6px; }
.term-parts code { font-weight: 700; color: var(--text); }
.term-ref { margin-bottom: 4px; }
.term-ref .sub-title { margin-top: 0; }
.term-tbl td:last-child { white-space: normal; min-width: 240px; color: var(--text-2); }
.fmt-tbl td.v { white-space: normal; min-width: 180px; }
.fmt-tbl td.v code { white-space: normal; overflow-wrap: anywhere; font-weight: 500; }
.fmt-tbl td:first-child { white-space: nowrap; }
.log-tbl tr[data-n] { cursor: pointer; }
.log-tbl code.term-bad { color: var(--bit-sub); font-weight: 700; }
.timer-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; font-size: 0.85rem; color: var(--text-2); }
.timer-legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 2px; vertical-align: -1px; }
@media (max-width: 560px) {
  .timer-bars li { grid-template-columns: minmax(0, 110px) minmax(30px, 1fr) auto; }
}

/* Timeouts page */
.to-tbl td:nth-child(3), .to-tbl td:nth-child(4) { white-space: normal; min-width: 170px; color: var(--text-2); font-size: 0.86rem; }
.to-tbl td:first-child code { font-weight: 600; }
.to-cards { align-items: start; }
.to-cards .card { margin-bottom: 0; min-width: 0; }
.to-cards .muted.small { margin: 10px 0 0; }
