/* Nginx Manager: hand-written styles. Light theme only, one indigo accent, soft neutral surfaces. */

:root {
  color-scheme: light;
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-2: #f6f7fb;
  --surface-3: #eef0f6;
  --border: #e5e7ef;
  --border-strong: #d3d7e2;
  --text: #121826;
  --muted: #566074;
  --faint: #8b94a7;
  --accent: #4a3fe0;
  --accent-hover: #3d33c7;
  --accent-weak: #eeedff;
  --accent-ring: rgba(74, 63, 224, .22);
  --on-accent: #ffffff;
  --ok: #0c8a57;
  --ok-weak: #e3f6ec;
  --warn: #a15c00;
  --warn-weak: #fff1d6;
  --danger: #c2301f;
  --danger-weak: #fde9e6;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(18, 24, 38, .05);
  --shadow: 0 1px 2px rgba(18, 24, 38, .04), 0 4px 16px rgba(18, 24, 38, .05);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; letter-spacing: -.02em; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 12px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ---- layout ---- */

.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 20px 14px 14px;
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 20px; font-weight: 700; font-size: 15.5px; letter-spacing: -.01em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 30px; height: 30px; border-radius: 8px; box-shadow: 0 2px 8px rgba(74, 63, 224, .28); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label { padding: 16px 12px 6px; font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.nav-label:first-child { padding-top: 0; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 12px; border-radius: 9px;
  color: var(--muted); font-weight: 550;
  transition: background .12s, color .12s;
}
.nav a .icon { color: var(--faint); transition: color .12s; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a:hover .icon { color: var(--muted); }
.nav a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--accent); }
.nav a[aria-current="page"]::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.sidebar-foot { margin-top: auto; padding: 14px 6px 0; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.sidebar-foot .who { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; color: var(--text); font-weight: 600; }
.sidebar-foot .who > span:not(.avatar) { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-weak); color: var(--accent); font-size: 12.5px; font-weight: 700; text-transform: uppercase; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .meta { padding-left: 2px; color: var(--faint); font-size: 12px; }

.main { padding: 32px 40px 80px; max-width: 1200px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.subtle { color: var(--muted); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); } /* a plain 1fr would grow to the widest table */
  .sidebar { position: static; height: auto; overflow: visible; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding: 2px 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-label { display: none; }
  .nav a { padding: 7px 9px; }
  .nav a[aria-current="page"]::before { display: none; }
  .nav a span { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; border: 0; }
  .sidebar-foot .meta, .sidebar-foot .who > span { display: none; }
  .sidebar-foot .who { margin: 0; }
  .main { padding: 22px 16px 56px; }
  h1 { font-size: 21px; }
}

/* ---- surfaces ---- */

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.card-head { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 20px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 20px 15px; box-shadow: var(--shadow-sm); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 6px; line-height: 1.2; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .note { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.stat a { color: inherit; }
.stat a:hover { color: var(--accent); text-decoration: none; }

/* ---- buttons & forms ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--faint); text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 1px 2px rgba(74, 63, 224, .35), inset 0 1px 0 rgba(255, 255, 255, .14); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-weak); border-color: var(--danger); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn-quiet:hover { background: var(--surface-3); border-color: transparent; color: var(--text); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; }
.btn.htmx-request { opacity: .7; pointer-events: none; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field > label, .label { font-weight: 600; font-size: 13px; }
.hint { color: var(--muted); font-size: 12.5px; }
.error-text { color: var(--danger); font-size: 12.5px; }
.field.has-error input, .field.has-error textarea, .field.has-error select { border-color: var(--danger); }

input[type="text"], input[type="password"], input[type="email"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
textarea.mono, input.mono { font-family: var(--mono); font-size: 12.5px; }
select { padding-right: 30px; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
input::placeholder, textarea::placeholder { color: var(--faint); }

.check { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 12px; cursor: pointer; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.check .text { display: flex; flex-direction: column; }
.check .text .hint { margin-top: 1px; }

.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.upstream { display: grid; grid-template-columns: 108px minmax(0, 1fr) 96px auto; gap: 8px; align-items: start; }
@media (max-width: 640px) { .upstream { grid-template-columns: 1fr 1fr; } }

.form-section { padding: 22px 0; border-top: 1px solid var(--border); }
.form-section:first-of-type { border-top: 0; padding-top: 0; }
.form-section > h2 { margin-bottom: 14px; font-size: 16px; }
.form-actions { display: flex; gap: 8px; align-items: center; padding-top: 20px; border-top: 1px solid var(--border); }

details.more { border-top: 1px solid var(--border); padding: 16px 0 0; }
details.more > summary { cursor: pointer; font-weight: 600; margin-bottom: 16px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .12s; }
details.more[open] > summary::before { transform: rotate(45deg); }

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

.table-wrap { overflow-x: auto; position: relative; } /* positioned, so the screen-reader-only labels inside cannot widen the page */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 20px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); white-space: nowrap; padding-top: 10px; padding-bottom: 10px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions .btn + .btn, td.actions form + .btn { margin-left: 4px; }
.domains { font-weight: 600; }
.domains .more { color: var(--muted); font-weight: 400; }
.cell-sub { color: var(--muted); font-size: 12.5px; }
.mono-cell { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.trunc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- badges ---- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 1px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; line-height: 20px;
  background: var(--surface-3); color: var(--muted); border: 1px solid transparent;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-weak); color: var(--ok); }
.badge.warn { background: var(--warn-weak); color: var(--warn); }
.badge.danger { background: var(--danger-weak); color: var(--danger); }
.badge.accent { background: var(--accent-weak); color: var(--accent); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }

.status { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); }
.status.s2xx { color: var(--ok); background: var(--ok-weak); }
.status.s3xx { color: var(--accent); background: var(--accent-weak); }
.status.s4xx { color: var(--warn); background: var(--warn-weak); }
.status.s5xx { color: var(--danger); background: var(--danger-weak); }

/* ---- alerts, banners ---- */

.alert { padding: 12px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); margin-bottom: 18px; }
.alert.warn { background: var(--warn-weak); border-color: #f4dba6; color: var(--warn); }
.alert.error { background: var(--danger-weak); border-color: #f6cbc5; color: var(--danger); }
.alert.info { background: var(--accent-weak); border-color: #d9d6fb; color: var(--accent); }
.alert strong { font-weight: 650; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.banner form { margin: 0; }
.alert pre { margin: 8px 0 0; padding: 10px 12px; background: var(--surface); color: var(--text); border-radius: 6px; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

pre.code { margin: 0; padding: 14px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; overflow: auto; max-height: 520px; line-height: 1.55; }

/* ---- tabs ---- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current="page"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- empty states ---- */

.empty { padding: 56px 24px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--text); margin-bottom: 6px; font-size: 16px; }
.empty p { max-width: 440px; margin: 0 auto 16px; }

/* ---- toasts & dialogs ---- */

#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 50; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  padding: 12px 16px; border-radius: 10px;
  background: #1c2233; color: #fff; font-weight: 500;
  box-shadow: 0 8px 28px rgba(18, 24, 38, .22);
  animation: toast-in .16s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: #0f7a4f; color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--text);
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 24px 64px rgba(18, 24, 38, .28);
}
dialog::backdrop { background: rgba(18, 24, 38, .42); backdrop-filter: blur(2px); }
dialog .dialog-body { padding: 22px 24px; font-size: 14.5px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface-2); }
dialog.wide { width: min(560px, calc(100vw - 32px)); }

/* ---- auth pages ---- */

.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 420px at 50% -120px, #e4e2ff 0%, rgba(228, 226, 255, 0) 70%), var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card .brand { padding: 0 0 20px; justify-content: center; font-size: 18px; }
.auth-card .brand img { width: 34px; height: 34px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .card { box-shadow: var(--shadow); }
.auth-card .card-body { padding: 28px; }

/* ---- chart ---- */

.chart { width: 100%; height: auto; display: block; margin-bottom: 10px; }
.chart .bar-ok { fill: var(--accent); }
.chart .bar-redirect { fill: #b9bfd0; }
.chart .bar-client { fill: #f0a52a; }
.chart .bar-server { fill: var(--danger); }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--sans); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; vertical-align: baseline; }
.legend .l-ok { background: var(--accent); } .legend .l-redirect { background: #b9bfd0; }
.legend .l-client { background: #f0a52a; } .legend .l-server { background: var(--danger); }

/* ---- logs ---- */

.log-table td, .log-table th { padding: 6px 12px; font-size: 12.5px; }
.log-table td { font-family: var(--mono); border-bottom-color: transparent; white-space: nowrap; }
.log-table td.uri { white-space: normal; word-break: break-all; min-width: 220px; }
.raw-log { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; word-break: break-all; padding: 14px 16px; margin: 0; max-height: 640px; overflow: auto; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; margin-right: 6px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ---- setup progress ---- */

.progress { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; max-height: 320px; overflow: auto; white-space: pre-wrap; }

.choice { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 18px; }
.choice label { display: flex; gap: 10px; padding: 14px 16px; border: 1px solid var(--border-strong); border-radius: 10px; cursor: pointer; background: var(--surface); transition: border-color .12s, background .12s; }
.choice label:hover { border-color: var(--faint); }
.choice label:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); box-shadow: 0 0 0 3px var(--accent-ring); }
.choice label:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.choice input { margin-top: 3px; accent-color: var(--accent); }
.choice .title { font-weight: 600; display: block; }

.flush { margin: 0 !important; }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.cell-sub.warn { color: var(--warn); }
.cell-sub.danger { color: var(--danger); }
.form-preview { margin-top: 18px; }
.form-preview:empty { display: none; }
#check-result { min-height: 0; }
#check-result:not(:empty) { margin-top: 6px; }

.section-title { margin-bottom: 12px; }
.inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.inline-form .field { margin-bottom: 0; flex: 1 1 180px; }
.inline-form .field:last-child { flex: 0 0 auto; }
.trunc-inline { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filters .field { margin-bottom: 0; }
.filters .field.grow { flex: 1 1 220px; }
.more-row td { text-align: center; padding: 14px; }
.toggle-line { display: flex; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 8px 16px; margin: 0 0 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.settings-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }

pre.code.flat { border: 0; border-radius: 0; max-height: 420px; }

.inline-form .field:first-child { flex: 2 1 260px; }

.section-title { margin-bottom: 10px; }
.inline-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.inline-form .field { margin-bottom: 0; flex: 1 1 180px; }
.inline-form .field:last-child { flex: 0 0 auto; }
.trunc-inline { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.filters .field { margin-bottom: 0; }
.filters .field.grow { flex: 1 1 220px; }
.more-row td { text-align: center; padding: 12px; }
.toggle-line { display: flex; align-items: center; gap: 8px; }
.kv { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 16px; margin: 0 0 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.settings-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

pre.code.flat { border: 0; border-radius: 0 0 var(--radius) var(--radius); max-height: 420px; }

.inline-form .field:first-child { flex: 2 1 260px; }

/* ---- path rows ---- */
.path-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; background: var(--surface); }
.path-main { display: grid; grid-template-columns: minmax(110px, 1fr) 112px minmax(130px, 1.4fr) 90px auto auto; gap: 8px; align-items: center; }
.path-options { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; }
.path-options .check { margin-bottom: 0; }
.path-row .error-text { display: block; margin-top: 6px; }
#paths:empty { display: none; }
@media (max-width: 640px) { .path-main { grid-template-columns: 1fr 1fr; } }
.path-health-field { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; }
.path-health-field .hint { white-space: nowrap; }
.path-health { flex: 1 1 auto; min-width: 160px; height: 30px; }
.path-options { align-items: center; }
.path-check:not(:empty) { margin-top: 8px; }

/* ---- health ---- */
.danger-text { color: var(--danger); }
.health-up a, .health-up { color: var(--ok); }
.health-down a, .health-down { color: var(--danger); font-weight: 600; }
.health-unknown a, .health-unknown { color: var(--muted); }
.health-up a, .health-down a, .health-unknown a { text-decoration: none; }
.health-stats { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.spark { display: block; }
.spark .bar-ok { fill: var(--ok); opacity: .75; }
.spark .bar-server { fill: var(--danger); }
.alert.warn a { color: inherit; text-decoration: underline; }

/* ---- balancing and header rules ---- */
.pool { margin: 10px 0 14px; }
.pool-first, .server-options, .balancer-options { display: none; }
.pool:has(.server-row) .pool-first { display: flex; }
.pool:has(.server-row) .balancer-options { display: block; }
.pool-first { align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; padding: 8px 12px; background: var(--surface-2); border-radius: var(--radius); }
.pool-first .check, .server-options .check { margin-bottom: 0; }
.balancer-options { margin-top: 12px; padding: 12px 14px 2px; border: 1px solid var(--border); border-radius: var(--radius); }
.balancer-options .hint { margin-bottom: 10px; }
.server-row { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; background: var(--surface); }
.server-main { display: grid; grid-template-columns: minmax(120px, 1.5fr) 96px auto auto auto; gap: 8px; align-items: center; }
.server-options { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 8px; }
.inline-num { display: inline-flex; align-items: center; gap: 8px; }
.inline-num input { width: 72px; height: 30px; }
.server-check { min-width: 0; }
.server-check .badge, .server-check .error-text { white-space: nowrap; }
.server-list:empty { display: none; }
.server-list { margin-bottom: 8px; }
.server-row .server-options { display: flex; }
.sub-h { margin: 14px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.path-more { margin-top: 10px; border-top: 1px dashed var(--border); padding-top: 8px; }
.path-more > summary { cursor: pointer; font-weight: 550; color: var(--muted); }
.path-more[open] > summary { margin-bottom: 4px; }
.header-row { margin-bottom: 8px; }
.header-main { display: grid; grid-template-columns: 150px minmax(120px, 1fr) minmax(140px, 1.6fr) auto; gap: 8px; align-items: center; }
.header-row:has(select option[value="remove"]:checked) .hdr-value { visibility: hidden; }
.header-list:empty { display: none; }
.header-list { margin-bottom: 8px; }
@media (max-width: 640px) { .server-main { grid-template-columns: 1fr 1fr; } .header-main { grid-template-columns: 1fr 1fr; } }

/* ---- traffic ---- */

.stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.traffic-controls { justify-content: space-between; align-items: center; }
.traffic-controls .field { min-width: 220px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.segmented a { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; background: var(--surface); color: var(--muted); font-weight: 550; white-space: nowrap; }
.segmented a + a { border-left: 1px solid var(--border-strong); }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current="page"] { background: var(--accent-weak); color: var(--accent); }
.top-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr)); margin: 16px 0; }
.top-grid > .card { min-width: 0; }
.top-grid .card + .card { margin-top: 0; }
.top-table td { padding-top: 7px; padding-bottom: 7px; }
.top-table .meter-cell { width: 84px; padding-left: 0; }
.meter { display: block; width: 72px; height: 6px; }
.meter-bg { fill: var(--surface-2); }
.meter-fill { fill: var(--accent); }
.tone-danger .meter-fill { fill: var(--danger); }
.tone-warn .meter-fill { fill: var(--warn); }
@media (max-width: 640px) {
  .top-table .trunc-inline { max-width: 150px; }
  .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- protection: limits, access, response headers ---- */

.limit-fields { display: flex; flex-direction: column; gap: 8px; }
.limit-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.limit-line select { width: auto; min-width: 100px; }
.inline-num input[type="number"] { width: 92px; }
.preset-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.label-like { display: block; margin-bottom: 6px; font-weight: 550; }
.user-row { margin-bottom: 8px; }
.user-main { display: grid; grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) auto; gap: 8px; align-items: center; }
.access-fields .field { margin-bottom: 14px; }
.access-fields .field > .btn { align-self: flex-start; }
.own-block .own-fields { display: none; }
.own-block:has(.own-toggle input:checked) .own-fields { display: block; margin-top: 10px; }
@media (max-width: 640px) { .user-main { grid-template-columns: 1fr 1fr; } }

.maint-fields { margin-top: 10px; }

/* ---- route tester ---- */


#tester-result { margin-top: 16px; }
#tester-result > .card + .card, #tester-result > .alert + .card { margin-top: 16px; }
.trace-outcome { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.trace-outcome.stopped .trace-headline { color: var(--text); }
.trace-steps { list-style: none; margin: 0 0 8px; padding: 0; }
.step { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 8px; padding: 6px 0; position: relative; }
.step + .step::before { content: ""; position: absolute; left: 7px; top: -10px; height: 18px; width: 2px; background: var(--border); }
.step-mark { width: 16px; height: 16px; border-radius: 50%; margin-top: 3px; border: 2px solid var(--faint); background: var(--surface); }
.step-pass .step-mark { border-color: var(--ok); background: var(--ok); }
.step-info .step-mark { border-color: var(--faint); }
.step-warn .step-mark { border-color: var(--warn); background: var(--surface); }
.step-stop .step-mark { border-color: var(--danger); background: var(--danger); border-radius: 3px; }
.step-title { font-weight: 600; }
.step-tag { margin-left: 6px; font-size: 12px; font-weight: 500; color: var(--warn); }
.step-body p { margin: 2px 0 0; color: var(--muted); }
.not-sent td { color: var(--muted); }
td.wrap { word-break: break-all; }
.card-head { flex-wrap: wrap; }
.card-head code { max-width: 100%; overflow-wrap: anywhere; }
.trace-headline { overflow-wrap: anywhere; min-width: 0; }
.step-body { min-width: 0; overflow-wrap: anywhere; }
.upstream select { padding-left: 10px; padding-right: 22px; }

.btn + .hint, .btn + .hint-block { margin-top: 10px; }
.card .form-actions { padding: 16px 20px; }
.card-body .form-actions { padding-left: 0; padding-right: 0; padding-bottom: 0; }
