:root {
    --bg: #f6f8fb;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --accent: #2563eb;
    --accent-hov: #1d4ed8;
    --ok: #10b981;
    --warn: #f59e0b;
    --err: #ef4444;
    --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 12px rgba(0,0,0,.04);
    --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hov); }
code { font: 12px/1.4 "JetBrains Mono", Consolas, Menlo, monospace; background: #f1f5f9; padding: 1px 5px; border-radius: 4px; }
em { color: var(--err); font-style: normal; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 600; }
.brand small { color: var(--muted); font-size: 12px; }
.logo {
    width: 34px; height: 34px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: #fff; font-weight: 700; display: grid; place-items: center;
    font-size: 16px;
}
.topbar nav { display: flex; gap: 8px; }

.container { max-width: 1180px; margin: 24px auto; padding: 0 24px; display: flex; flex-direction: column; gap: 18px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

.btn {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s ease;
}
.btn:hover { background: #f3f4f6; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hov); border-color: var(--accent-hov); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #fecaca; background: #fef2f2; }
.btn.danger:hover { background: #fee2e2; }
.btn.xs { padding: 3px 9px; font-size: 12px; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
table.grid th { background: #f9fafb; font-weight: 600; color: #374151; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
table.grid.compact td, table.grid.compact th { padding: 6px 10px; }
table.grid tr:hover td { background: #fafbfc; }
.actions { text-align: right; white-space: nowrap; }
.actions form { margin-left: 4px; }
.ralign { text-align: right; }
.trunc { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot-on { background: var(--ok); box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.dot-off { background: #d1d5db; }

.badge { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 500; }
.badge.ok { background: #d1fae5; color: #047857; }
.badge.off { background: #f3f4f6; color: #6b7280; }

.pill { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #eef2ff; color: #4338ca; font-weight: 500; }
.pill-proxy   { background: #fef3c7; color: #92400e; }
.pill-redirect{ background: #fee2e2; color: #991b1b; }
.pill-static  { background: #e0e7ff; color: #3730a3; }
.pill-local   { background: #d1fae5; color: #065f46; }

.flash {
    padding: 11px 16px;
    border-radius: 8px;
    border: 1px solid;
    font-size: 13px;
}
.flash-ok   { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.flash-err  { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Form */
.vform { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 200px; }
.field.small { flex: 0 0 140px; min-width: 120px; }
.field.grow  { flex: 2; }
.field > span { font-size: 12px; color: #374151; font-weight: 500; }
.field input[type=text], .field input[type=url], .field input[type=number], .field select, .field textarea {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font: inherit;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.field textarea { font-family: "JetBrains Mono", Consolas, monospace; font-size: 12px; resize: vertical; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; flex: 0 0 auto; }
.field.inline > span { font-size: 13px; font-weight: 400; }
.hint { color: var(--muted); font-size: 11px; }

.group {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 0;
    display: flex; flex-direction: column; gap: 10px;
}
.group legend { font-size: 12px; color: #4b5563; font-weight: 600; padding: 0 6px; }

.actions-row { display: flex; gap: 10px; margin-top: 6px; }

pre.code {
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: 8px;
    overflow-x: auto;
    font: 12px/1.55 "JetBrains Mono", Consolas, monospace;
}

.footer { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 12px; }
.footer code { background: transparent; color: var(--muted); }

@media (max-width: 720px) {
    .topbar { flex-direction: column; gap: 10px; align-items: flex-start; }
    .field.small { flex: 1; }
    .actions { text-align: left; }
}

/* Login page */
body.login-bg {
    min-height: 100vh;
    display: grid; place-items: center;
    background: linear-gradient(135deg, #f0f4ff 0%, #fdf2f8 100%);
}
.login-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,.08);
    padding: 28px 32px;
    width: 360px;
    max-width: 92vw;
}
.login-head { text-align: center; margin-bottom: 22px; }
.login-head .logo { margin: 0 auto 12px; display: grid; }
.login-head h1 { margin: 0 0 4px; font-size: 18px; }
.login-head small { color: var(--muted); }
.btn.block { width: 100%; padding: 10px; }
.hint.center { text-align: center; color: var(--muted); margin-top: 14px; }
