:root {
  --bg: #f4f5f7; --panel: #ffffff; --border: #dfe3e8; --text: #1b1f24; --muted: #6b7280;
  --accent: #2563eb; --accent-text: #ffffff; --danger: #dc2626; --ok: #16a34a; --warn: #d97706;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #111418; --panel: #1a1f26; --border: #2b323c; --text: #e6e8eb; --muted: #9aa3ad; --accent: #4f8cff; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--text); }
h1 { font-size: 22px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 20px 0 6px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* login */
body.login { display: flex; flex-direction: column; min-height: 100vh; }
body.login main { flex: 1; align-self: center; margin: 12vh 16px 0; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 28px; max-width: 420px; width: 100%; }
.card input { width: 100%; }
.card button { width: 100%; margin-top: 12px; }

/* top */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.tabs { display: flex; gap: 2px; padding: 8px 16px 0; border-bottom: 1px solid var(--border); background: var(--panel); }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 14px; font-size: 14.5px; cursor: pointer; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.banner { background: #fef3c7; color: #78350f; padding: 8px 16px; font-size: 13.5px; }
.tab { display: none; padding: 16px; max-width: 1400px; }
.tab.active { display: block; }

/* forms */
label { display: block; margin: 0 0 10px; font-size: 13.5px; color: var(--muted); }
label.inline { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
label.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
label.check input { width: auto; margin: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; width: 100%; margin-top: 3px; }
label.inline input, label.inline select { width: auto; margin: 0; }
textarea { resize: vertical; font-family: inherit; }
#stHtml, #importText { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
button { font: inherit; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
button.ghost.danger { color: var(--danger); }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.cols { display: flex; gap: 20px; flex-wrap: wrap; }
.col { flex: 1 1 420px; min-width: 0; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.panel summary { cursor: pointer; font-weight: 600; }

/* tables */
.grid { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; font-size: 13.5px; }
.grid th, .grid td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.grid th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.grid tr:last-child td { border-bottom: 0; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid tr.dragging { opacity: .4; }
.grid tr.over td { border-top: 2px solid var(--accent); }
.handle { cursor: grab; color: var(--muted); user-select: none; }
.grid .actions button { margin-right: 4px; }
.state-accepted, .state-delivered { color: var(--ok); }
.state-failed, .state-bounced, .state-complained { color: var(--danger); }
.state-unknown, .state-submitted, .state-claimed { color: var(--warn); }
.st-unsubscribed, .st-bounced, .st-complained { color: var(--danger); }

/* preview */
#preview { width: 100%; height: 640px; background: #fff; border: 1px solid var(--border); border-radius: 8px; }

/* toast + footer */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 9; max-width: 90vw; }
footer { padding: 10px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12.5px; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-top: 24px; }
footer a { color: var(--accent); text-decoration: none; }
.tip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tip a { border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; }
.tip a:hover { border-color: var(--accent); background: var(--panel); }
