:root {
  --bg: #f4f5f7; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2554c7; --accent-text: #fff;
  --ok: #157a3c; --ok-bg: #e3f4e9; --warn: #9a5b00; --warn-bg: #fdf0d9; --bad: #b42318; --bad-bg: #fde7e5;
  --off: #4b5563; --off-bg: #eceef1;
  --radius: 8px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --panel: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --line: #2c323d;
    --accent: #6b8ef5; --accent-text: #0b0d12;
    --ok: #57c785; --ok-bg: #173323; --warn: #f0b350; --warn-bg: #3a2c12; --bad: #f2786d; --bad-bg: #3d1916;
    --off: #b6bdc9; --off-bg: #2a303b;
  }
}
[x-cloak] { display: none !important; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--accent); }
h1, h2, h3 { margin: 0 0 .6em; font-weight: 600; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.wrap { word-break: break-all; white-space: normal; }
.ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); }
.error { color: var(--bad); margin: .4em 0; }

.login { min-height: 100vh; display: grid; place-items: center; }
.login-card { width: 340px; display: flex; flex-direction: column; gap: 12px; }

.layout { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 1.1rem; padding: 4px 10px 16px; }
.sidebar a { display: block; padding: 8px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.sidebar a:hover { background: var(--bg); }
.sidebar a.active { background: var(--accent); color: var(--accent-text); }
.sidebar-foot { margin-top: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.content { padding: 24px 28px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.page-head h2, .page-head h3 { margin: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.row.space { justify-content: space-between; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; overflow-x: auto; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.tile span { color: var(--muted); font-size: 12px; } .tile strong { font-size: 1.6rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; }
td.actions { white-space: nowrap; text-align: right; }
tbody tr:hover { background: color-mix(in srgb, var(--bg) 60%, transparent); }

.btn { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 6px; padding: 7px 12px; cursor: pointer; font: inherit; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0 2px; font: inherit; }

input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select {
  font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; width: 100%;
}
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
.form { display: flex; flex-direction: column; gap: 12px; }
form.card.form { max-width: 560px; }
fieldset { border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; }
legend { font-size: 13px; padding: 0 4px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; max-height: 220px; overflow: auto; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; align-items: end; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: var(--off-bg); color: var(--off); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.chip { display: inline-block; padding: 1px 7px; margin: 1px 3px 1px 0; border-radius: 4px; background: var(--off-bg); font-size: 12px; }

.chart { display: flex; align-items: flex-end; gap: 2px; height: 160px; border-bottom: 1px solid var(--line); }
.bar { flex: 1; display: flex; flex-direction: column-reverse; height: 100%; min-width: 3px; }
.seg.ok { background: var(--ok); } .seg.warn { background: var(--warn); } .seg.bad { background: var(--bad); }
.legend { margin-top: 8px; font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }

.selection-bar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 10px; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: grid; place-items: center; z-index: 10; padding: 20px; }
.modal { background: var(--panel); border-radius: var(--radius); padding: 20px; width: min(760px, 100%); max-height: 90vh; overflow: auto; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; min-width: 0; }
.copybox { display: flex; gap: 8px; align-items: flex-start; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; margin: 4px 0; }
.copybox code { flex: 1; word-break: break-all; }
.dnsrec { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin-bottom: 10px; display: flex; flex-direction: column; gap: 4px; }
.loglines { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 12px; white-space: pre-wrap; word-break: break-all; max-height: 50vh; overflow: auto; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.toast { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 14px; box-shadow: 0 4px 14px rgba(0,0,0,.15); max-width: 420px; }
.toast.error { border-left-color: var(--bad); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin: 0; flex-direction: row; }
  .grid2 { grid-template-columns: 1fr; }
}
