:root {
  color-scheme: dark;
  --bg: #0a0b0f;
  --bg2: #101219;
  --card: #13151d;
  --card2: #171a24;
  --line: #222634;
  --line2: #2c3142;
  --text: #e6e8ee;
  --muted: #8a90a2;
  --dim: #5d6375;
  --accent: #6366f1;
  --accent2: #818cf8;
  --ok: #10b981;
  --ok-bg: #062e24;
  --warn: #f59e0b;
  --warn-bg: #3a2606;
  --bad: #ef4444;
  --bad-bg: #3b1013;
  --radius: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- controls ---------- */
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line2); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font: inherit; font-size: 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.18); }
textarea { resize: vertical; min-height: 70px; width: 100%; }
button {
  font: inherit; font-size: 13px; font-weight: 500; border: 0; border-radius: 8px; padding: 8px 14px;
  cursor: pointer; background: var(--accent); color: #fff; transition: background .15s, opacity .15s, transform .05s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
button:hover { background: #5458e8; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--line2); color: var(--text); }
button.ghost:hover { background: var(--card2); }
button.danger { background: #b91c1c; }
button.danger:hover { background: #dc2626; }
button.ok { background: #047857; }
button.ok:hover { background: #059669; }
button.sm { padding: 5px 10px; font-size: 12px; }
button.link { background: none; padding: 0; color: var(--accent2); }

.toggle {
  width: 38px; height: 22px; border-radius: 11px; background: var(--line2); position: relative;
  cursor: pointer; display: inline-block; flex: none; transition: background .15s; border: 0; padding: 0;
}
.toggle::after {
  content: ""; position: absolute; width: 16px; height: 16px; background: #fff; border-radius: 50%;
  top: 3px; left: 3px; transition: left .15s;
}
.toggle.on { background: var(--ok); }
.toggle.on::after { left: 19px; }
.toggle:hover { background: #3a4057; }
.toggle.on:hover { background: #0ea371; }
.toggle.disabled { opacity: .35; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 500; background: var(--card2); color: var(--muted); border: 1px solid var(--line);
}
.pill.ok { background: var(--ok-bg); color: #6ee7b7; border-color: #0b4a3a; }
.pill.warn { background: var(--warn-bg); color: #fcd34d; border-color: #5a3b08; }
.pill.bad { background: var(--bad-bg); color: #fca5a5; border-color: #5c1a1e; }
.pill.acc { background: #1e1f45; color: #a5b4fc; border-color: #2e3170; }

/* ---------- login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(99,102,241,.22), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(16,185,129,.14), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: rgba(19,21,29,.85); backdrop-filter: blur(12px);
  border: 1px solid var(--line); border-radius: 18px; padding: 36px 32px 28px;
  box-shadow: 0 30px 80px rgba(0,0,0,.55);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #10b981); box-shadow: 0 6px 20px rgba(99,102,241,.35);
}
.brand-logo svg { width: 24px; height: 24px; }
.brand h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input { padding: 11px 12px; font-size: 14px; width: 100%; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; padding: 6px;
  color: var(--dim);
}
.pw-eye:hover { background: none; color: var(--text); }
.pw-eye svg { width: 18px; height: 18px; display: block; }
.login-card button[type=submit] { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 6px; }
.alert {
  border-radius: 10px; padding: 10px 12px; font-size: 13px; margin-bottom: 16px;
  background: var(--bad-bg); border: 1px solid #5c1a1e; color: #fecaca;
}
.alert b { display: block; margin-bottom: 2px; color: #fca5a5; }
.login-foot { margin-top: 20px; text-align: center; color: var(--dim); font-size: 12px; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(10,11,15,.85); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1280px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 18px; }
.topbar .brand { margin: 0; }
.topbar .brand-logo { width: 32px; height: 32px; border-radius: 9px; }
.topbar .brand-logo svg { width: 18px; height: 18px; }
.topbar .brand h1 { font-size: 16px; }
.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tab {
  background: none; color: var(--muted); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.tab:hover { background: var(--card2); color: var(--text); }
.tab.active { background: var(--card2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line2); }
.tab .cnt { background: var(--line2); color: var(--text); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.tab .cnt.bad { background: #7f1d1d; }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.me .who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.me .who b { font-size: 13px; }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.section-head .grow { flex: 1; }
.search { width: 240px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; }
.card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .f { display: flex; flex-direction: column; gap: 5px; }
.form-row .f label { font-size: 12px; color: var(--muted); }
.w-domain { width: 220px; } .w-origin { width: 300px; } .w-user { width: 180px; }

/* ---------- domain cards ---------- */
.domains { display: grid; gap: 16px; }
.dom {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: opacity .2s, transform .2s;
}
.dom.removing { opacity: 0; transform: scale(.98); }
.dom.banned { border-color: #5c1a1e; }
.dom-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line);
  background: var(--bg2); flex-wrap: wrap;
}
.dom-head .name { font-size: 15px; font-weight: 600; }
.dom-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.ban-note {
  padding: 10px 18px; background: var(--bad-bg); color: #fecaca; font-size: 13px; border-bottom: 1px solid #5c1a1e;
}
.dom-body { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.dom-sec { padding: 14px 18px; border-right: 1px solid var(--line); min-width: 0; }
.dom-sec:last-child { border-right: 0; }
.dom-sec h4 { margin: 0 0 10px; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .07em; }
.line { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 13px; color: var(--muted); }
.line .lbl { flex: 1; }
.line input.num { width: 78px; padding: 5px 8px; }
.line select { padding: 5px 8px; flex: 1; min-width: 0; }
.origin-row { display: flex; gap: 6px; }
.origin-row input { flex: 1; min-width: 0; }
.origin-row input.dirty { border-color: var(--warn); }
.dom-locked .dom-body { opacity: .55; pointer-events: none; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.dchip {
  background: var(--card2); border: 1px solid var(--line2); border-radius: 6px; padding: 2px 8px; font-size: 12px;
  color: var(--text); cursor: pointer;
}
.dchip:hover { background: #20243a; }
.dchip.banned { border-color: #7f1d1d; color: #fca5a5; text-decoration: line-through; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* ---------- modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(3px); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s;
}
.modal {
  background: var(--card); border: 1px solid var(--line2); border-radius: 16px; width: 100%; max-width: 440px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6); animation: pop .15s;
}
.modal.wide { max-width: 980px; }
.modal-h { padding: 18px 20px 6px; font-size: 16px; font-weight: 600; display: flex; align-items: center; }
.modal-h .x { margin-left: auto; background: none; color: var(--muted); padding: 4px 8px; font-size: 18px; }
.modal-b { padding: 8px 20px 4px; }
.modal-b p { margin: 6px 0 12px; color: var(--muted); }
.modal-b .field input, .modal-b .field select { width: 100%; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 6px 0 12px; cursor: pointer; }
.check input { width: auto; }
.modal-f { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-err { color: #fca5a5; font-size: 13px; min-height: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--card2); border: 1px solid var(--line2); border-left: 3px solid var(--ok); color: var(--text);
  padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
  max-width: 360px; animation: pop .15s;
}
.toast.bad { border-left-color: var(--bad); }

/* ---------- stats ---------- */
.stat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.chip {
  display: flex; align-items: center; gap: 7px; padding: 6px 11px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; user-select: none; font-size: 12px; color: var(--text);
}
.chip:hover { background: var(--bg2); }
.chip.off { opacity: .35; }
.chip b { font-size: 14px; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.tip {
  position: absolute; pointer-events: none; background: var(--bg); border: 1px solid var(--line2); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; z-index: 5; min-width: 160px; box-shadow: 0 4px 14px rgba(0,0,0,.5);
}
.tip div { display: flex; justify-content: space-between; gap: 14px; }
.tip .d { color: var(--muted); margin-bottom: 4px; }

pre.log {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 12px;
  white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; margin: 0;
}

@media (max-width: 1100px) {
  .dom-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dom-sec:nth-child(2) { border-right: 0; }
  .dom-sec:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 720px) {
  .topbar-in { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .tabs { order: 3; margin-left: 0; width: 100%; overflow-x: auto; }
  .me .who { display: none; }
  main { padding: 16px; }
  .dom-body { grid-template-columns: 1fr; }
  .dom-sec { border-right: 0; border-bottom: 1px solid var(--line); }
  .w-domain, .w-origin, .w-user, .search { width: 100%; }
  .form-row .f { width: 100%; }
}
.modal .line select { flex: none; width: auto; }

/* ---------- DNS ---------- */
.dns-head { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; flex-wrap: wrap; }
.dns-head .grow, .f.grow { flex: 1; }
.rr-form { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.rr-form .f.grow input { width: 100%; min-width: 200px; }
.w-rrname { width: 150px; } .w-num { width: 84px; }
.rr-table td { padding: 8px 10px; font-size: 13px; }
.rr-table td.val { max-width: 380px; word-break: break-all; }
.rr-table tr.sys td { background: rgba(99,102,241,.05); }
.rr-table tr.editing td { background: rgba(245,158,11,.08); }
.modal.wide .tbl-wrap { max-height: 50vh; overflow: auto; }
pre.log.tall { max-height: 60vh; min-height: 300px; }

/* ---------- серверы ---------- */
.nodes { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.node { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.node-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.node-head .name { font-size: 15px; font-weight: 600; }
.node-head .pills { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.metrics > div { display: flex; flex-direction: column; min-width: 0; }
.metrics span { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .05em; }
.metrics b { font-size: 14px; font-weight: 600; margin-top: 2px; overflow-wrap: anywhere; }
.metrics small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { margin-top: 5px; height: 6px; }
.bar svg { width: 100%; height: 6px; display: block; }
.bar .bg { fill: var(--line2); }
.bar .fg { fill: var(--ok); }
.bar.warn .fg { fill: var(--warn); }
.bar.bad .fg { fill: var(--bad); }
.node-err { background: var(--bad-bg); border: 1px solid #5c1a1e; color: #fecaca; border-radius: 8px; padding: 8px 10px; font-size: 12px; word-break: break-word; }
.node-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.node-foot .line { margin: 0; gap: 10px; cursor: pointer; }
.node-foot .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.node-meta { margin-top: -4px; }
@media (max-width: 720px) {
  .nodes { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
