:root {
  --bg: #0c0f14;
  --bg-2: #11151c;
  --card: #151a23;
  --card-2: #1a2029;
  --line: #242c38;
  --line-2: #2f3947;
  --text: #e7ebf1;
  --muted: #8a95a6;
  --faint: #5d6877;
  --accent: #5eead4;
  --accent-ink: #04201c;
  --accent-dim: rgba(94, 234, 212, 0.12);
  --ok: #4ade80;
  --warn: #fbbf24;
  --bad: #f87171;
  --bad-dim: rgba(248, 113, 113, 0.12);
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.hidden { display: none !important; }

svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--bg-2); border-right: 1px solid var(--line);
  padding: 18px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 15px; }
.brand .logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent-dim); color: var(--accent); display: grid; place-items: center; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-dim); color: var(--accent); }
.sidebar .spacer { flex: 1; }
.sidebar .who { padding: 10px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 8px; display: flex; align-items: center; justify-content: space-between; }
.main { padding: 28px 34px 60px; max-width: 1180px; width: 100%; min-width: 0; }
.banner { background: rgba(251, 191, 36, 0.1); color: var(--warn); border-bottom: 1px solid rgba(251, 191, 36, 0.25); padding: 6px 14px; font-size: 12.5px; text-align: center; grid-column: 1 / -1; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }

@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; padding: 8px 10px; gap: 6px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 8px 0 2px; }
  .nav { display: flex; gap: 2px; }
  .sidebar .spacer { flex: 1; }
  .sidebar .who span { display: none; }
  .sidebar .who { border: 0; margin: 0; padding: 0; }
  .main { padding: 20px 14px 50px; }
}
@media (max-width: 520px) {
  .nav a span { display: none; }
  .nav a { padding: 8px 11px; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 13px;
  background: var(--card-2); border: 1px solid var(--line-2); border-radius: 8px;
  cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #212a36; border-color: #3b4757; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: #7bf0de; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-dim); border-color: rgba(248,113,113,.4); }
.btn.solid-danger { background: var(--bad); color: #2a0707; border-color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { background: var(--card-2); color: var(--text); }
.btn.sm { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.icon { width: 28px; height: 28px; padding: 0; justify-content: center; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 8px 11px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
textarea { resize: vertical; min-height: 80px; }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 550; margin-bottom: 5px; }
label.field > small { display: block; color: var(--muted); margin-top: 5px; font-size: 12.5px; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.check { display: flex; align-items: center; gap: 8px; margin: 8px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-pad { padding: 18px; }
.grid { display: grid; gap: 14px; }
.grid.stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); margin-bottom: 22px; }
.grid.sites { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.stat { padding: 16px 18px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 550; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 24px; font-weight: 650; margin: 4px 0 8px; letter-spacing: -0.02em; }
.stat .value small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.bar { height: 6px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar > i.warn { background: var(--warn); }
.bar > i.bad { background: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--card-2); color: var(--muted); border: 1px solid var(--line-2); }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.badge.on { color: var(--ok); border-color: rgba(74,222,128,.3); background: rgba(74,222,128,.08); }
.badge.on .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(74,222,128,.18); }
.badge.off .dot { background: var(--faint); }
.badge.bad { color: var(--bad); border-color: rgba(248,113,113,.3); }
.badge.bad .dot { background: var(--bad); }
.badge.type { color: var(--accent); background: var(--accent-dim); border-color: transparent; }

.site-card { padding: 16px 18px; display: block; color: inherit; transition: border-color .12s, transform .12s; }
.site-card:hover { border-color: var(--line-2); background: var(--card-2); text-decoration: none; }
.site-card .top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.site-card .name { font-size: 16px; font-weight: 650; }
.site-card .domains { color: var(--muted); font-size: 13px; word-break: break-all; }

.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; font-size: 16px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 18px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- file manager ---------- */
.fm { position: relative; overflow: hidden; }
.fm-bar { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; flex: 1; min-width: 160px; font-family: var(--mono); font-size: 13px; }
.crumbs a, .crumbs span.cur { padding: 3px 6px; border-radius: 6px; color: var(--muted); }
.crumbs a:hover { background: var(--card-2); color: var(--text); text-decoration: none; }
.crumbs span.cur { color: var(--text); }
.crumbs .sep { color: var(--faint); }
table.files { width: 100%; border-collapse: collapse; }
table.files th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
table.files td { padding: 7px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.files tr:last-child td { border-bottom: 0; }
table.files tbody tr:hover { background: var(--card-2); }
table.files tr.sel { background: var(--accent-dim); }
table.files td.chk, table.files th.chk { width: 36px; padding-right: 0; }
table.files input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.fname { display: flex; align-items: center; gap: 10px; cursor: pointer; min-width: 0; }
.fname:hover .n { color: var(--accent); }
.fname .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fname svg { color: var(--muted); }
.fname.dir svg { color: var(--accent); }
.col-size, .col-date { color: var(--muted); white-space: nowrap; }
.col-act { text-align: right; white-space: nowrap; }
.col-act .btn { opacity: 0; }
tr:hover .col-act .btn, tr.sel .col-act .btn { opacity: 1; }
@media (hover: none) { .col-act .btn { opacity: 1; } }
#fm-list { overflow-x: auto; }
@media (max-width: 700px) {
  .col-date, .col-size { display: none; }
  table.files td, table.files th { padding-left: 8px; padding-right: 8px; }
  table.files td.chk, table.files th.chk { padding-left: 12px; }
  .fm-bar { padding: 10px; }
}
.dropzone { position: absolute; inset: 0; background: rgba(12, 15, 20, .88); border: 2px dashed var(--accent); border-radius: var(--radius); display: grid; place-items: center; text-align: center; z-index: 5; color: var(--accent); font-weight: 600; pointer-events: none; }
.fm-empty { padding: 50px 20px; text-align: center; color: var(--muted); }

/* ---------- modal / toasts ---------- */
.overlay { position: fixed; inset: 0; background: rgba(4, 6, 9, .66); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 50; padding: 20px; }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: 12px; width: 100%; max-width: 480px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal.wide { max-width: 980px; height: 86vh; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px; overflow: auto; flex: 1; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.editor { width: 100%; height: 100%; min-height: 300px; font-family: var(--mono); font-size: 13px; line-height: 1.55; tab-size: 2; white-space: pre; overflow: auto; resize: none; background: var(--bg); }
.preview { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; background: repeating-conic-gradient(#1b212b 0% 25%, #151a23 0% 50%) 50% / 18px 18px; border-radius: 8px; }

/* top-right and click-through, so a toast can never block a button underneath it */
#toasts { position: fixed; right: 16px; top: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: 360px; pointer-events: none; }
.toast { background: var(--card-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); border-radius: 8px; padding: 10px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: pop .18s ease-out; }
.toast.err { border-left-color: var(--bad); }
.toast .bar { margin-top: 8px; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }

pre.out { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 14px; overflow: auto; margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 62vh; line-height: 1.5; }
.kv { display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.kv input { font-family: var(--mono); font-size: 13px; }
.danger-zone { border-color: rgba(248,113,113,.3); }
.section { margin-bottom: 18px; }
.section > h2 { margin-bottom: 4px; }
.section > .muted { margin-bottom: 14px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(700px 360px at 50% -10%, rgba(94,234,212,.09), transparent 70%), var(--bg); }
.login { width: 100%; max-width: 360px; padding: 28px; }
.login .brand { padding: 0 0 20px; font-size: 17px; }
.err-text { color: var(--bad); margin: 0 0 12px; min-height: 18px; font-size: 13px; }

/* ---------- overview: live checks, DNS records ---------- */
.badge.warn { color: var(--warn); border-color: rgba(251,191,36,.3); background: rgba(251,191,36,.08); }
.badge.warn .dot { background: var(--warn); }
.ov-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.ov-top .spacer, .con-bar .spacer { flex: 1; }
.grid.checks { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.check-card { padding: 14px 16px; }
.check-card .ch-head { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.chk-item { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.chk-item + .chk-item { border-top: 1px solid var(--line); }
.chk-item .t { font-weight: 600; }
.chk-item .d { color: var(--muted); font-size: 13px; margin-top: 1px; word-break: break-word; }
.dom { color: var(--faint); font-size: 12px; font-family: var(--mono); margin-top: 2px; word-break: break-all; }
.lv { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex: none; background: var(--faint); display: inline-block; }
.lv.ok { background: var(--ok); box-shadow: 0 0 0 3px rgba(74,222,128,.16); }
.lv.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(251,191,36,.14); }
.lv.bad { background: var(--bad); box-shadow: 0 0 0 3px rgba(248,113,113,.14); }
.lvtxt { display: inline-flex; align-items: center; gap: 8px; }
.lvtxt .lv { margin-top: 0; }
.ipbox { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px 14px; margin: 12px 0 14px; }
.ipbox .ip { font-family: var(--mono); font-size: 20px; font-weight: 650; }
table.dnsrec { width: 100%; border-collapse: collapse; min-width: 560px; }
table.dnsrec th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 550; text-transform: uppercase; letter-spacing: .05em; padding: 6px 10px; }
table.dnsrec td { padding: 10px; border-top: 1px solid var(--line); vertical-align: middle; }
.cp { display: inline-flex; align-items: center; font-family: var(--mono); background: var(--bg); border: 1px solid var(--line-2); border-radius: 7px; padding: 3px 9px; cursor: pointer; }
.cp:hover { border-color: var(--accent); color: var(--accent); }
.notes { margin: 14px 0 0; padding-left: 18px; color: var(--muted); }
.notes li { margin: 5px 0; }
.notes code, .chk-item code { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; }
.notes .warnli { color: var(--warn); }

/* ---------- console ---------- */
.con-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--muted); padding: 5px 12px; cursor: pointer; font-weight: 550; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--accent-dim); color: var(--accent); }
.con { background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); padding: 8px 0; height: 60vh; overflow: auto; font-family: var(--mono); font-size: 12.5px; line-height: 1.6; }
.con.compact { height: 220px; }
.cl { display: flex; gap: 10px; padding: 1px 14px; }
.cl:hover { background: var(--card-2); }
.cl .ct { color: var(--faint); flex: none; }
.cl .cs { flex: none; width: 50px; font-weight: 650; font-size: 11px; padding-top: 1px; letter-spacing: .04em; }
.cl .cx { white-space: pre-wrap; word-break: break-word; min-width: 0; }
.cs.app { color: var(--accent); } .cs.visit { color: #93c5fd; } .cs.caddy { color: #c4b5fd; } .cs.panel { color: var(--warn); }
.cl.lv-err .cx { color: var(--bad); }
.cl.lv-warn .cx { color: var(--warn); }
.cl.kind-access:not(.lv-err):not(.lv-warn) .cx { color: var(--muted); }
.con-empty { padding: 18px; color: var(--muted); font-family: var(--sans); font-size: 14px; white-space: normal; }
@media (max-width: 700px) { .cl { flex-wrap: wrap; gap: 2px 8px; } .cl .cx { flex-basis: 100%; } }

/* let grid children shrink below their content width (wide tables then scroll inside their own box) */
.grid > * { min-width: 0; }

/* ---------- system files ---------- */
.sys-card { max-width: 560px; }
.sys-card h2 { margin: 6px 0 8px; }
.sys-card p { margin: 0 0 12px; }
.sys-ic { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-dim); color: var(--accent); display: grid; place-items: center; }
.sys-ic svg { width: 22px; height: 22px; }
.sys-warn { margin-top: 18px; padding: 10px 12px; border-radius: 8px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.25); color: var(--warn); font-size: 12.5px; }
.cmdbox { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; margin: 0 0 12px; flex-wrap: wrap; }
.cmdbox code { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.sys-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.sys-bar .spacer { flex: 1; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip-link { padding: 4px 11px; border-radius: 99px; border: 1px solid var(--line-2); color: var(--muted); font-size: 12.5px; background: var(--card); }
.chip-link:hover { color: var(--text); text-decoration: none; border-color: var(--accent); }
.chip-link.on { color: var(--accent); background: var(--accent-dim); border-color: transparent; }
.crit-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; background: rgba(248,113,113,.1); border-bottom: 1px solid rgba(248,113,113,.3); color: var(--bad); font-size: 12.5px; }
.crit-banner svg { flex: none; margin-top: 2px; }
.ed-wrap { height: 100%; display: flex; flex-direction: column; }
.ed-wrap .editor { flex: 1; }
.del-list { max-height: 160px; overflow: auto; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.del-list .mono { overflow-wrap: anywhere; padding: 1px 0; }
.lnk { color: var(--faint); font-family: var(--mono); font-size: 12px; margin-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.files.sys .col-perm { font-size: 12px; color: var(--muted); white-space: nowrap; }
table.files.sys .col-own { color: var(--muted); white-space: nowrap; }
.act { font-family: var(--mono); font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--card-2); }
.act.a-delete, .act.a-unlock-failed { color: var(--bad); }
.act.a-write, .act.a-upload, .act.a-rename { color: var(--warn); }
@media (max-width: 800px) {
  table.files.sys .col-perm, table.files.sys .col-own { display: none; }
}
table.nodev .col-act .btn { opacity: 1; }
