:root {
  --bg: #0b0b0d;
  --surface: #17171a;
  --surface-2: #1e1e22;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #a1a1aa;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;

  --chip-a:     #2563eb;
  --chip-aaaa:  #3b82f6;
  --chip-cname: #8b5cf6;
  --chip-mx:    #10b981;
  --chip-txt:   #6b7280;
  --chip-ns:    #f59e0b;
  --chip-caa:   #ec4899;
  --chip-srv:   #06b6d4;
  --chip-alias: #a855f7;
  --chip-ptr:   #94a3b8;
  --chip-add:   #22c55e;
  --chip-del:   #ef4444;
  --chip-upd:   #f59e0b;
}

html { color-scheme: dark; }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

code, .mono, pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* Sidebar */
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  padding: 0.25rem 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.sidebar .brand a { text-decoration: none; color: var(--text); display: block; }
.brand-name { font-weight: 700; font-size: 1.1rem; display: block; }
.brand-sub { color: var(--text-muted); font-weight: 400; font-size: 0.88em; margin-top: 0.15rem; display: block; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar nav a, .sidebar nav .linklike {
  display: flex; align-items: center; gap: 0.55rem;
  padding: 0.5rem 0.8rem; color: var(--text-muted); text-decoration: none;
  border-radius: 6px; font-weight: 500; font-size: 0.95em;
}
.sidebar nav a:hover, .sidebar nav .linklike:hover { color: var(--text); background: var(--bg); }
.sidebar nav a.active { background: color-mix(in srgb, var(--primary) 18%, transparent); color: var(--primary); }
.sidebar nav a .icon { font-size: 1em; opacity: 0.75; width: 1.1em; display: inline-block; text-align: center; }
.sidebar-sep { margin: 0.75rem 0 0.5rem; border-top: 1px solid var(--border); }
.sidebar-foot { margin-top: auto; padding: 0.75rem 0.8rem; color: var(--text-muted); font-size: 0.82em; line-height: 1.5; border-top: 1px solid var(--border); }

.linklike { background: none; border: none; color: inherit; cursor: pointer; padding: 0; font: inherit; width: 100%; text-align: left; }
.sidebar nav .linklike:hover { background: var(--bg); color: var(--primary); }
.inline { display: inline; }

/* Main */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.main-area.no-sidebar { max-width: 900px; margin: 0 auto; }
.content { flex: 1; padding: 1.5rem 2rem; max-width: 1400px; width: 100%; }

h1 { margin-top: 0; }
.muted { color: var(--text-muted); }
.ok, .success { color: var(--success); }
.err { color: var(--error); }
.warn { color: var(--warning); }
.center { text-align: center; }
.num { text-align: right; }
.ml-auto { margin-left: auto; }

/* Flash */
.flash-wrap { padding: 1rem 2rem 0; }
.flash { padding: 0.6rem 0.9rem; border-radius: 4px; margin-bottom: 0.5rem; border-left: 3px solid; background: var(--surface); }
.flash-success { border-color: var(--success); }
.flash-error   { border-color: var(--error); }
.flash-warning { border-color: var(--warning); }
.flash-info    { border-color: var(--primary); }

/* Card / row */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; margin-bottom: 1.25rem; }
.row { display: flex; padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.row:last-child { border-bottom: none; }
.row .label { min-width: 180px; color: var(--text-muted); font-weight: 500; }
.row .value { flex: 1; }

/* Chips */
.chip { display: inline-block; padding: 0.1rem 0.5rem; margin: 0 0.15rem; border-radius: 3px; color: #fff; font-size: 0.8em; font-weight: 600; letter-spacing: 0.02em; }
.chip-a { background: var(--chip-a); }
.chip-aaaa { background: var(--chip-aaaa); }
.chip-cname { background: var(--chip-cname); }
.chip-mx { background: var(--chip-mx); }
.chip-txt { background: var(--chip-txt); }
.chip-ns { background: var(--chip-ns); }
.chip-caa { background: var(--chip-caa); }
.chip-srv { background: var(--chip-srv); }
.chip-alias { background: var(--chip-alias); }
.chip-ptr { background: var(--chip-ptr); }
.chip-add { background: var(--chip-add); }
.chip-del { background: var(--chip-del); }
.chip-upd { background: var(--chip-upd); }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem; margin-top: 0.5rem; }
.tile { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-decoration: none; color: var(--text); transition: border-color 0.15s; }
.tile:hover { border-color: var(--primary); }
.tile-title { font-weight: 700; margin-bottom: 0.25rem; }
.tile-sub { color: var(--text-muted); font-size: 0.92em; }

/* Forms */
.filter-bar { display: flex; gap: 0.6rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.filter-bar input[type="search"] { min-width: 280px; }
.filter-bar .counts { color: var(--text-muted); margin-left: 0.75rem; }

input, select, textarea { padding: 0.42rem 0.6rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }

.record-form, .setup-form { max-width: 720px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem; }
.record-form .field, .setup-form .field { margin-bottom: 1rem; }
.record-form .field label, .setup-form .field label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.record-form .field small, .setup-form .field small { display: block; color: var(--text-muted); margin-top: 0.2rem; }
.record-form input[type="text"],
.record-form input[type="number"],
.record-form input[type="email"],
.record-form input[type="password"],
.record-form select,
.setup-form input[type="text"],
.setup-form input[type="number"],
.setup-form input[type="email"],
.setup-form input[type="password"],
.setup-form select { width: 100%; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; margin: 0 0 1rem; }
fieldset legend { padding: 0 0.4rem; color: var(--primary); font-weight: 700; }

.actions-row { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

.setup-wrap { max-width: 780px; margin: 2rem auto; padding: 0 1rem; }
.setup-wrap h1 { margin-top: 0; }
.verify-row { display: flex; align-items: center; gap: 0.7rem; margin-top: 0.25rem; }

/* Buttons */
.btn, button { display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--border); border-radius: 4px; background: var(--surface); color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.btn:hover, button:hover { border-color: var(--primary); }
.btn-primary, button.btn-primary { background: var(--primary); color: #0b0b0d; border-color: var(--primary); font-weight: 600; }
.btn-primary:hover, button.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn-danger:hover { background: var(--error); color: #fff; }
.btn-sm { padding: 0.25rem 0.55rem; font-size: 0.88em; }

button[disabled], .btn[aria-disabled="true"] { opacity: 0.7; cursor: progress; pointer-events: none; }

/* Tables */
table.records { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 1.5rem; }
table.records thead th { text-align: left; padding: 0.55rem 0.75rem; background: var(--bg); border-bottom: 1px solid var(--border); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); user-select: none; }
table.records thead th[data-sort] { cursor: pointer; }
table.records thead th[data-sort]:hover { color: var(--text); }
.sort-indicator { display: inline-block; margin-left: 0.3em; opacity: 0.4; font-size: 0.9em; }
.sort-indicator.active { opacity: 1; color: var(--primary); }
table.records thead th.num, table.records thead th.actions { text-align: right; }
table.records tbody td { padding: 0.45rem 0.75rem; border-top: 1px solid var(--border); }
table.records tbody tr:hover { background: var(--bg); }
table.records td.actions { text-align: right; white-space: nowrap; }
table.records td.data-cell { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-add { background: color-mix(in srgb, var(--success) 10%, transparent); }
.row-del { background: color-mix(in srgb, var(--error) 10%, transparent); }
.row-upd { background: color-mix(in srgb, var(--warning) 10%, transparent); }

/* Diff pre block */
pre.diff { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; max-height: 500px; overflow: auto; white-space: pre; }

/* Spinner + loading overlay */
.spinner { display: inline-block; width: 0.95em; height: 0.95em; margin-right: 0.45em; vertical-align: -0.15em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px); z-index: 1000; }
.loading-overlay.active { display: flex; }
.loading-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 1.5rem 2rem; min-width: 300px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.25); }
.loading-card .big-spinner { width: 2.4em; height: 2.4em; margin: 0 auto 0.8rem; border: 3px solid var(--primary); border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.loading-card .loading-msg { font-weight: 600; font-size: 1.05rem; margin-bottom: 0.3rem; }
.loading-card .loading-sub { color: var(--text-muted); font-size: 0.92em; }

/* Reusable dialog / modal */
.modal-backdrop {
  position: fixed; inset: 0;
  display: none;
  align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 900;
}
.modal-backdrop.active { display: flex; }
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  min-width: 420px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}
.modal-card h2 { margin-top: 0; }
.modal-card .field { margin-bottom: 0.9rem; }
.modal-card .field label { display: block; font-weight: 600; margin-bottom: 0.3rem; }
.modal-card .field input[type="text"],
.modal-card .field input[type="password"],
.modal-card .field input[type="email"] { width: 100%; }
.modal-card .field small { display: block; color: var(--text-muted); margin-top: 0.25rem; }
.modal-card .actions-row { margin-top: 0.75rem; }
.modal-card .err-inline {
  color: var(--error); font-size: 0.9em; min-height: 1em;
}
