:root {
  --navy: #11292F;
  --green: #3E8868;
  --amber: #E9A944;
  --bg: #F5FAF9;
  --panel: #ffffff;
  --line: #dfe6e6;
  --text: #11292F;
  --muted: #6b7d84;
  --danger: #b4342b;
  --radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1a1e;
    --panel: #142a30;
    --line: #24444d;
    --text: #e8f1f0;
    --muted: #90a8ae;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 22px;
  background: var(--navy);
  color: #fff;
  position: sticky; top: 0; z-index: 20;
}
header h1 { font-size: 16px; margin: 0; font-weight: 600; letter-spacing: .2px; }
header .spacer { flex: 1; }
header .stat { font-size: 13px; opacity: .8; }

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 99px;
}
.badge.dry  { background: var(--amber); color: var(--navy); }
.badge.live { background: var(--danger); color: #fff; }

main { padding: 20px 22px 120px; max-width: 1400px; margin: 0 auto; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.panel > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.panel-body { padding: 14px 16px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters input[type=search], .filters select {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); font-size: 14px; min-width: 150px;
}
.filters input[type=search] { flex: 1; min-width: 220px; }
label.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

button {
  font: inherit; font-size: 14px; padding: 8px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--green); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
button.warn    { background: var(--amber); border-color: var(--amber); color: var(--navy); font-weight: 600; }
button.ghost   { background: transparent; }
button.link    { background: none; border: none; color: var(--green); text-decoration: underline; padding: 0; }

/* ------------------------------------------------------------------ table */
/* Setting overflow on one axis makes the other compute to `auto`, so this is
   a scroll container in both directions. Sticky headers inside therefore
   resolve against this box, not the page — which is why `top` must be 0.
   Any other value shifts the header down over the first row and hides it. */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); }
th {
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); font-weight: 600; white-space: nowrap;
  position: sticky; top: 0; background: var(--panel); z-index: 5;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--green); }
th .arrow { opacity: .45; font-size: 10px; }
tbody tr:hover { background: color-mix(in srgb, var(--green) 7%, transparent); }
td.name { font-weight: 600; }
td.muted, .muted { color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.col-check { width: 34px; }

.pill {
  display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green);
  white-space: nowrap;
}
.pill.new { background: color-mix(in srgb, var(--muted) 18%, transparent); color: var(--muted); }
.pill.sent { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.pill.queued { background: color-mix(in srgb, var(--amber) 25%, transparent); color: #8a6410; }
.pill.failed, .pill.bounced, .pill.unsubscribed {
  background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger);
}

/* select-all-matching banner */
.selectall {
  padding: 9px 14px; font-size: 13px;
  background: color-mix(in srgb, var(--amber) 18%, transparent);
  border-bottom: 1px solid var(--line);
}

/* --------------------------------------------------------------- actionbar */
.actionbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: var(--panel); border-top: 1px solid var(--line);
  box-shadow: 0 -3px 14px rgba(0,0,0,.07);
  z-index: 30;
}
.actionbar .count { font-weight: 600; }
.actionbar .spacer { flex: 1; }

/* ------------------------------------------------------------------ modal */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0;
  background: var(--panel); color: var(--text); max-width: 720px; width: 92vw;
}
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog h3 { margin: 0; padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 15px; }
dialog .body { padding: 16px 18px; max-height: 68vh; overflow: auto; }
dialog .foot {
  padding: 12px 18px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.field input, .field select, .field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 14px;
}
.field .hint { font-size: 12px; color: var(--muted); }

.preview-frame {
  width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

pre.dns {
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px; overflow-x: auto; font-size: 12px; margin: 0;
}

/* -------------------------------------------------------------- credits */
.credit-meter {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 12px; margin-bottom: 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  font-size: 13px;
}
.credit-meter .bar {
  flex: 1; min-width: 120px; height: 8px; border-radius: 99px;
  background: color-mix(in srgb, var(--muted) 20%, transparent);
  overflow: hidden;
}
.credit-meter .bar > i {
  display: block; height: 100%; border-radius: 99px;
  background: var(--green); transition: width .4s;
}
.credit-meter .bar > i.low { background: var(--amber); }
.credit-meter .bar > i.critical { background: var(--danger); }
.credit-meter strong { font-variant-numeric: tabular-nums; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.toast {
  position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 18px; border-radius: 6px;
  font-size: 14px; z-index: 60; box-shadow: 0 4px 14px rgba(0,0,0,.25);
}
.toast.err { background: var(--danger); }
