:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #172033;
  --line: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #2563eb;
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #f87171;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.err { color: var(--err); min-height: 1.2em; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 12px; }
h1, h2, h3 { margin: 0 0 8px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
pre { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow: auto; max-height: 480px; white-space: pre-wrap; word-break: break-all; }

button, input, select { font: inherit; color: var(--text); }
button { background: var(--accent); border: 0; border-radius: 6px; padding: 6px 12px; cursor: pointer; }
button:hover { filter: brightness(1.1); }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 2px 8px; font-size: 12px; }
button.danger { background: #7f1d1d; }
button.secondary { background: #334155; }
input, select { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
label.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid label.check { flex-direction: row; align-self: end; padding: 8px 4px; font-size: 14px; color: var(--text); }
input[type='checkbox'] { width: 20px; height: 20px; padding: 0; accent-color: var(--accent); cursor: pointer; }

header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header nav { display: flex; gap: 4px; }
header nav button { background: transparent; color: var(--muted); }
header nav button.active { background: var(--accent); color: white; }
.badge { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.banner { padding: 8px 16px; background: #78350f; color: #fde68a; }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login .card { width: 320px; display: flex; flex-direction: column; gap: 10px; }

.account-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.account-head .name { font-weight: 600; font-size: 16px; }
.pill { white-space: nowrap; font-size: 11px; border-radius: 999px; padding: 1px 8px; background: #334155; color: var(--muted); }
.pill.ok { background: #064e3b; color: #a7f3d0; }
.pill.warn { background: #78350f; color: #fde68a; }
.pill.err { background: #7f1d1d; color: #fecaca; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--line); }
td { padding: 5px 6px; border-bottom: 1px solid #1f2a3d; vertical-align: top; }
td.mono { font-family: ui-monospace, monospace; font-size: 12px; }
.hosts td:last-child { white-space: nowrap; text-align: right; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; align-items: end; margin-top: 8px; }
.form-grid label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.settings label { display: grid; grid-template-columns: 220px 1fr; gap: 10px; align-items: center; margin-bottom: 10px; }
.settings label .help { grid-column: 2; font-size: 12px; color: var(--muted); margin-top: -6px; }
.settings .locked { font-size: 12px; color: var(--warn); }

.log td { font-size: 12px; }
.log tr.lvl-warn td { color: var(--warn); }
.log tr.lvl-error td { color: var(--err); }
.log tr.lvl-debug td { color: var(--muted); }
.log tr.has-detail { cursor: pointer; }
.log tr.detail td { background: var(--panel2); }
.filters { margin-bottom: 10px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; width: min(760px, 95vw); padding: 0; }
dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.dialog-body { padding: 16px; }
.copy { display: flex; gap: 6px; align-items: stretch; margin: 4px 0 10px; }
.copy code { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 4px 10px; }
.ns-table td { font-size: 12px; }

@media (max-width: 700px) {
  .settings label { grid-template-columns: 1fr; }
  .settings label .help { grid-column: 1; }
  .hosts th:nth-child(2), .hosts td:nth-child(2) { display: none; }
}

/* Tunnel */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #475569; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; width: 100%; min-height: 60px; }
.rule-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-top: 6px; }
.rule-form label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.rule-form label.check { flex-direction: row; align-items: center; font-size: 14px; color: var(--text); }
.tunnels td a { color: #93c5fd; text-decoration: none; }
.tunnels td a:hover { text-decoration: underline; }
pre.cmd { margin: 4px 0 10px; }
