:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --border: #e2e4e9;
  --text: #1c1f26;
  --muted: #6b7280;
  --accent: #2f5bea;
  --accent-soft: #e8eeff;
  --green: #16803c;
  --green-soft: #e3f5e9;
  --amber: #a15c00;
  --amber-soft: #fff3dc;
  --red: #c0262d;
  --red-soft: #fde8e8;
  --sidebar: #161a23;
  --sidebar-text: #aab1c0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1218;
    --surface: #171b23;
    --surface-2: #1f242e;
    --border: #2a303b;
    --text: #e6e8ec;
    --muted: #9099a8;
    --accent: #6d8cff;
    --accent-soft: #1f2a4d;
    --green: #4cc27a;
    --green-soft: #15301f;
    --amber: #f0b44c;
    --amber-soft: #33270f;
    --red: #f07178;
    --red-soft: #3a1a1d;
    --sidebar: #0b0d12;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 12px; }
code, textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.error-text { color: var(--red); }

/* Layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 0 10px 18px; }
.nav a { display: block; color: var(--sidebar-text); padding: 8px 10px; border-radius: 7px; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar .spacer { flex: 1; }
.sidebar .user { padding: 8px 10px; font-size: 12.5px; }
.sidebar .user button { margin-top: 6px; }
.main { padding: 28px 32px 60px; min-width: 0; max-width: 1280px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 12px; }
  .brand { padding: 0 10px; }
  .nav { display: flex; flex-wrap: wrap; }
  .sidebar .spacer { display: none; }
  .sidebar .user { padding: 4px 10px; }
  .main { padding: 20px 16px 48px; }
}

/* Cards & grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid .card + .card { margin-top: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.stat .label { color: var(--muted); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; color: var(--muted); font-weight: 500; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.empty { text-align: center; padding: 28px 12px; color: var(--muted); }
.stack > * + * { margin-top: 12px; }

/* Buttons */
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 13px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 3px 9px; font-size: 12.5px; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0; }
.btn-link:hover { background: none; text-decoration: underline; }
.sidebar .btn-link { color: var(--sidebar-text); }

/* Forms */
label.field { display: block; }
label.field > span { display: block; font-weight: 550; font-size: 13px; margin-bottom: 4px; }
label.field .hint { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; font-weight: 400; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { width: auto; margin: 0; accent-color: var(--accent); }
textarea { resize: vertical; }
textarea.code { min-height: 420px; line-height: 1.45; tab-size: 2; white-space: pre; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.section-title { font-weight: 650; margin: 22px 0 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-title:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { max-width: 280px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); cursor: pointer; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { text-align: right; white-space: nowrap; }
td.actions button + button { margin-left: 4px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; gap: 8px; }

/* Badges & progress */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 550; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.progress > div { height: 100%; background: var(--accent); border-radius: 99px; transition: width 0.3s; }
.progress.green > div { background: var(--green); }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; gap: 8px; }

.notice { padding: 10px 14px; border-radius: 8px; background: var(--amber-soft); color: var(--amber); margin-bottom: 10px; }
.notice.info { background: var(--accent-soft); color: var(--accent); }
.notice.error { background: var(--red-soft); color: var(--red); }
.status-line { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* Chart */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bars .bar div { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar.zero div { background: var(--border); }
.bars .bar span { font-size: 10.5px; color: var(--muted); margin-top: 4px; white-space: nowrap; }

/* Activity */
.activity { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow-y: auto; }
.activity li { padding: 7px 0; border-bottom: 1px solid var(--border); display: grid; grid-template-columns: auto 1fr; gap: 10px; font-size: 13px; }
.activity li:last-child { border-bottom: 0; }
.activity time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.activity .error { color: var(--red); }
.activity .warning { color: var(--amber); }

/* Accounts */
.account-card .meta { color: var(--muted); font-size: 12.5px; margin: 2px 0 12px; overflow-wrap: anywhere; }
.account-card .buttons { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }

/* Editor & preview */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1100px) { .editor { grid-template-columns: 1fr; } }
.preview-frame { width: 100%; height: 640px; border: 1px solid var(--border); border-radius: 8px; background: #fff; display: block; margin: 0 auto; transition: max-width 0.2s; }
.preview-subject { font-size: 13px; margin-bottom: 10px; overflow-wrap: anywhere; }
pre.text-preview { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 14px; margin: 0; max-height: 640px; overflow: auto; font-size: 12.5px; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 12, 18, 0.5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 620px; padding: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
.modal h2 { font-size: 17px; margin-bottom: 16px; }

/* Toasts */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: calc(100vw - 32px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2); max-width: 420px; }
.toast.error { background: var(--red); color: #fff; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login h1 { margin-bottom: 4px; }

/* Warmup schedule editor */
.schedule { display: grid; gap: 6px; }
.schedule-row { display: grid; grid-template-columns: 64px 110px 1fr auto; align-items: center; gap: 10px; }
.schedule-row input { padding: 5px 8px; }
input[type="time"] { max-width: 160px; }

/* Import & bulk actions */
.dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 38px 16px; text-align: center; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.dropzone:hover, .dropzone:focus, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); outline: none; }
th.highlight, td.highlight { background: var(--accent-soft); }
.bulk-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 10px; border-radius: 8px; background: var(--accent-soft); }
.modal .grid-stats { margin: 14px 0 0; }

/* Lists */
.list-name-box { padding: 14px; margin: 0 0 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.list-name-box input { background: var(--surface); font-size: 15px; }
a.badge:hover { text-decoration: none; filter: brightness(0.95); }
.toolbar select { width: auto; }

/* Email check */
.check-summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.check-pills, .check-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.check-pill { border-radius: 99px; padding: 3px 11px; font-size: 12.5px; background: var(--surface-2); }
.check-pill.green b { color: var(--green); }
.check-pill.amber b { color: var(--amber); }
.check-pill.red b { color: var(--red); }
.check-pill.active { border-color: var(--accent); background: var(--accent-soft); }
.check-panel { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 12px; margin-bottom: 14px; border-radius: 8px; background: var(--surface-2); }
.check-panel.green { background: var(--green-soft); }
.check-panel.amber { background: var(--amber-soft); }
.check-panel.red { background: var(--red-soft); }

/* Account DNS health */
.dns-block { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.dns-lines { display: flex; gap: 16px; flex-wrap: wrap; }
.dns-line { display: inline-flex; align-items: baseline; gap: 5px; cursor: help; }
.dns-line .dns-mark { font-weight: 700; }
.dns-line.green .dns-mark { color: var(--green); }
.dns-line.amber .dns-mark { color: var(--amber); }
.dns-line.red .dns-mark { color: var(--red); }

/* Lists page */
.list-rows { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-rows .list-row:last-child { border-bottom: 0; }
.list-row-all, .list-row-unlisted { border-bottom: 1px solid var(--border); }
.list-row-unlisted:last-child { border-bottom: 0; }
.list-row-main { min-width: 0; }
.list-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
