:root {
  --bg: #f5f7fa; --surface: #ffffff; --surface-2: #f0f3f7; --border: #dfe4ea;
  --text: #17202b; --muted: #5d6b7c; --primary: #1f6feb; --primary-ink: #ffffff; --primary-hover: #185bc4;
  --danger: #c8312c; --danger-bg: #fdecec; --ok: #18794e; --ok-bg: #e3f5ec; --warn: #8a5a00; --warn-bg: #fff4d6;
  --bar: #111827; --bar-text: #e8edf3; --focus: #1f6feb55; --shadow: 0 1px 2px #0b16260d, 0 4px 16px #0b16260a;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b; --surface: #161d26; --surface-2: #1d2631; --border: #2a3542;
    --text: #e6ebf1; --muted: #93a1b2; --primary: #4c8dff; --primary-ink: #08111f; --primary-hover: #6ea2ff;
    --danger: #ff6b66; --danger-bg: #3a1a1b; --ok: #4cc38a; --ok-bg: #133024; --warn: #f0c25a; --warn-bg: #3a2f12;
    --bar: #0a0e13; --bar-text: #dfe6ee; --focus: #4c8dff66; --shadow: 0 1px 2px #0006, 0 4px 16px #0004;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 18px; margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 0.92em; }
.break { word-break: break-all; }
.sep { margin: 0 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* top bar */
.topbar { background: var(--bar); color: var(--bar-text); }
.topbar-inner { max-width: 1200px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 24px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--bar-text); font-weight: 650; font-size: 16px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; fill: none; stroke: #6ea2ff; stroke-width: 2; }
.topnav a { color: var(--bar-text); opacity: .75; padding: 17px 2px; border-bottom: 2px solid transparent; }
.topnav a[aria-current] { opacity: 1; border-color: #6ea2ff; }
.topnav a:hover { opacity: 1; text-decoration: none; }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: #2b3b52; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user .btn-ghost { color: var(--bar-text); border-color: #ffffff33; }
.user .btn-ghost:hover { background: #ffffff14; }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-title { margin-bottom: 12px; }
.table-card { padding: 0; overflow: hidden; }
.narrow { max-width: 520px; margin: 40px auto; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:focus-visible, .icon-btn:focus-visible, input:focus, select:focus, textarea:focus, .chip:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--focus); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--muted); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.icon-btn { width: 34px; height: 34px; display: inline-grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-danger:hover { color: var(--danger); background: var(--danger-bg); }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.actions { text-align: right; white-space: nowrap; }
.actions-col { width: 90px; }
.domain-link { font-weight: 600; font-size: 16px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.records .name-cell { font-family: var(--mono); font-size: 14px; white-space: nowrap; }
.records .data-cell { font-family: var(--mono); font-size: 14px; word-break: break-all; }
.prio { display: inline-block; font-size: 12px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; margin-right: 6px; }
.type-summary { margin-left: 10px; display: inline-flex; gap: 4px; flex-wrap: wrap; vertical-align: middle; }

/* tags & pills */
.tag { display: inline-block; min-width: 52px; text-align: center; font: 600 12px/20px var(--mono); padding: 0 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.type-summary .tag { min-width: 0; font-weight: 500; }
.tag-a, .tag-aaaa { background: #e6efff; color: #1d4fb8; }
.tag-cname { background: #f1e8ff; color: #6935c4; }
.tag-mx { background: #e3f5ec; color: #18794e; }
.tag-txt { background: #fff1dc; color: #92520a; }
.tag-ns { background: #e8eef4; color: #3d5266; }
.tag-srv { background: #e0f6f7; color: #0d6f78; }
.tag-caa { background: #fde8ef; color: #a42357; }
.tag-act-add { background: var(--ok-bg); color: var(--ok); }
.tag-act-edit { background: #e6efff; color: #1d4fb8; }
.tag-act-delete { background: var(--danger-bg); color: var(--danger); }
.tag-act-restore { background: var(--warn-bg); color: var(--warn); }
@media (prefers-color-scheme: dark) {
  .tag-a, .tag-aaaa, .tag-act-edit { background: #1a2a48; color: #8fb5ff; }
  .tag-cname { background: #2b2045; color: #c4a6ff; }
  .tag-mx { background: #133024; color: #6fd6a4; }
  .tag-txt { background: #3a2a12; color: #f3b965; }
  .tag-ns { background: #222d39; color: #a9bacb; }
  .tag-srv { background: #0f3236; color: #6fd3dc; }
  .tag-caa { background: #3a1626; color: #ff8fb7; }
}
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-ok { background: var(--ok-bg); color: var(--ok); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--danger-bg); color: var(--danger); }

/* toolbar */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; gap: 6px; align-items: center; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--text); font-size: 13px; font-weight: 500; }
.chip span { color: var(--muted); }
.chip:hover { text-decoration: none; border-color: var(--muted); }
.chip-on { background: var(--text); color: var(--surface); border-color: var(--text); }
.chip-on span { color: inherit; opacity: .7; }
.search input { width: 240px; max-width: 100%; height: 34px; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
input, select, textarea { font: inherit; font-weight: 400; font-size: 15px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 40px; width: 100%; }
textarea { resize: vertical; font-family: var(--mono); font-size: 14px; min-height: 40px; }
.hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.suffix-input { display: flex; align-items: stretch; }
.suffix-input input { border-radius: 8px 0 0 8px; font-family: var(--mono); font-size: 14px; }
.suffix-input span { display: flex; align-items: center; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; color: var(--muted); font-weight: 400; font-family: var(--mono); font-size: 13px; white-space: nowrap; max-width: 50%; overflow: hidden; text-overflow: ellipsis; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }

/* alerts & toasts */
.alert { border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: var(--danger-bg); color: var(--danger); }
.alert-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent); }
.toast { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.toast-success { background: var(--ok-bg); color: var(--ok); }
.toast-error { background: var(--danger-bg); color: var(--danger); }
.toast-x { background: none; border: 0; color: inherit; font-size: 20px; cursor: pointer; opacity: .7; }

/* dialogs */
.dialog { border: 0; padding: 0; border-radius: 14px; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px #0007; }
.dialog-sm { width: min(440px, calc(100vw - 32px)); }
.dialog::backdrop { background: #0b1220a6; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.dialog-body { padding: 20px 20px 6px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }

/* login */
.login-wrap { display: grid; place-items: center; min-height: calc(100vh - 160px); }
.login-card { width: min(400px, 100%); padding: 32px; }
.login-card h1 { margin-bottom: 4px; }
.login-card p { margin: 0 0 20px; }

/* history */
.history-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.timeline li:last-child { border: 0; }
.timeline .tag { min-width: 64px; flex-shrink: 0; height: 20px; }
.backups { list-style: none; margin: 0; padding: 0; }
.backups li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-family: var(--mono); font-size: 14px; }
.backups li:last-child { border: 0; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.zonefile { margin: 0; overflow: auto; font: 12.5px/1.6 var(--mono); background: var(--surface-2); padding: 12px; border-radius: 8px; max-height: 70vh; }

@media (max-width: 760px) {
  .hide-sm { display: none; }
  .history-grid, .compare { grid-template-columns: 1fr; }
  .username { display: none; }
  .topbar-inner { gap: 14px; }
  .table td, .table th { padding: 10px 10px; }
  .tag { min-width: 0; }
  .records .name-cell { white-space: normal; word-break: break-all; }
  .search, .search input { width: 100%; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 22px; }
}
