:root {
    --bg: #0b1020;
    --panel: #111830;
    --surface: rgba(255, 255, 255, 0.035);
    --border: rgba(255, 255, 255, 0.09);
    --text: #eef1f8;
    --muted: #9aa4bd;
    --accent: #22d3ee;
    --accent-2: #6366f1;
    --ok: #34d399;
    --warn: #fbbf24;
    --bad: #f87171;
    --radius: 12px;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0; font-weight: 600; }
h2 { font-size: 1.05rem; margin: 0 0 0.9rem; font-weight: 600; }
code { font-family: var(--mono); font-size: 0.85em; background: rgba(255, 255, 255, 0.06); padding: 0.1em 0.4em; border-radius: 5px; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; font-weight: 400; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* Layout */
body.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 1.4rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; flex-direction: column; gap: 0.4rem; color: var(--text); padding: 0 0.6rem; }
.brand img { width: 140px; }
.brand span { color: var(--muted); font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; }
.brand:hover { text-decoration: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.2rem; }
.sidebar nav a { color: var(--muted); padding: 0.55rem 0.7rem; border-radius: 8px; }
.sidebar nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: rgba(34, 211, 238, 0.1); color: var(--accent); }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 0.4rem; padding: 0 0.7rem; font-size: 0.9rem; }
.content { padding: 2rem 2.5rem; max-width: 1200px; width: 100%; }

body.auth { display: grid; place-items: center; min-height: 100vh; }
body.auth .content { max-width: 380px; padding: 1rem; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.login-logo { width: 150px; }
.login-card h1 { font-size: 1.3rem; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* Cards & tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem 1.5rem; margin-bottom: 1.2rem; }
.card.flush { padding: 0; overflow-x: auto; }
.card .pad { padding: 1.2rem 1.5rem 0; }
.card.notice { border-color: rgba(251, 191, 36, 0.4); }
.card.notice ol { margin: 0; padding-left: 1.2rem; display: grid; gap: 0.4rem; }
.card.danger { border-color: rgba(248, 113, 113, 0.35); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.2rem; }
.grid-2 .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 1.2rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.card:not(.flush) th:first-child, .card:not(.flush) td:first-child { padding-left: 0; }
table.dns code.wrap { white-space: pre-wrap; word-break: break-all; display: inline-block; max-width: 420px; }
code.copy { cursor: copy; }
code.copied { outline: 1px solid var(--ok); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.3rem; color: var(--muted); font-size: 0.85rem; }
.stat span { display: block; font-size: 1.8rem; font-weight: 600; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: var(--accent); }

dl.kv { display: grid; grid-template-columns: 200px 1fr; gap: 0.6rem 1rem; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }

.filters { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }
.filters a { padding: 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); font-size: 0.85rem; }
.filters a.active { border-color: var(--accent); color: var(--accent); }
.filters a:hover { text-decoration: none; color: var(--text); }

.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge.ok { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); }
.badge.bad { background: rgba(248, 113, 113, 0.12); color: var(--bad); }

.chips { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.chip { display: inline-block; padding: 0.15rem 0.6rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; color: var(--text); background: none; font-family: inherit; margin: 0 0.2rem 0.2rem 0; }
.chip.external { color: var(--muted); }
.chip.add { color: var(--accent); border-style: dashed; cursor: pointer; }

/* Forms */
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.form label, .login-card label { display: flex; flex-direction: column; gap: 0.35rem; color: var(--muted); font-size: 0.9rem; }
.form label.check { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--text); }
input, textarea, select {
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 0.6rem 0.75rem;
    font: inherit;
    width: 100%;
}
input[type="checkbox"] { width: auto; }
textarea { font-family: var(--mono); font-size: 0.9rem; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
.address { display: grid; grid-template-columns: 1fr auto 1.4fr; gap: 0.5rem; align-items: center; }
.address span { color: var(--muted); }
.with-button { display: flex; gap: 0.5rem; }
.with-button input { font-family: var(--mono); }
.hint { color: var(--muted); font-size: 0.82rem; margin: 0; }
.form-actions { display: flex; gap: 0.5rem; }
.inline-form { flex-direction: row; }
form.inline { display: inline; margin-left: 0.8rem; }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0.55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font: inherit; font-size: 0.9rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #061018; font-weight: 600; }
.btn.danger { background: rgba(248, 113, 113, 0.15); border-color: rgba(248, 113, 113, 0.5); color: var(--bad); }
.btn.wide { width: 100%; }
button.link { background: none; border: none; color: var(--accent); padding: 0; font: inherit; cursor: pointer; text-align: left; }
button.link.danger { color: var(--bad); }

.flash { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1.2rem; border: 1px solid; }
.flash.ok { background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.4); color: var(--ok); }
.flash.error { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.4); color: var(--bad); }

@media (max-width: 800px) {
    body.app { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; }
    .sidebar-footer { margin: 0; flex-direction: row; }
    .content { padding: 1.2rem; }
    dl.kv { grid-template-columns: 1fr; }
    .address { grid-template-columns: 1fr; }
}
