:root {
  --bg: #f5f6f8; --panel: #fff; --ink: #14171c; --muted: #6b7280; --line: #e5e7eb; --line-2: #f0f1f3;
  --accent: #2554d6; --accent-ink: #fff; --accent-soft: rgba(37, 84, 214, .12);
  --ok: #138a4e; --ok-soft: #e6f5ec; --bad: #c8322e; --bad-soft: #fdecec; --warn: #a76100; --warn-soft: #fdf3e2;
  --skip: #9aa1ad; --rest: #e9ebef; --radius: 12px; --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a20; --ink: #e8eaee; --muted: #959cab; --line: #2a2f38; --line-2: #20242b;
    --accent: #6b8cff; --accent-ink: #0f1115; --accent-soft: rgba(107, 140, 255, .16);
    --ok: #3fbf7f; --ok-soft: rgba(63, 191, 127, .14); --bad: #f06a64; --bad-soft: rgba(240, 106, 100, .14);
    --warn: #f0b05a; --warn-soft: rgba(240, 176, 90, .14); --skip: #6b7280; --rest: #262b33; --shadow: none;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: .86em; }
code { background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
pre { background: var(--line-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
h1 { font-size: 24px; margin: 2px 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; color: var(--ink); }
.center { text-align: center; }
.err-text { color: var(--bad); }
.warn-text { color: var(--warn) !important; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--ink); display: flex; align-items: center; gap: 6px; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--accent); color: var(--accent-ink); border-radius: 6px; padding: 1px 6px; font-size: 13px; letter-spacing: .04em; }
.brand.big { font-size: 24px; justify-content: center; margin-bottom: 16px; }
.topbar nav { display: flex; gap: 4px; flex: 1; }
.topbar nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; white-space: nowrap; }
.topbar nav a.on, .topbar nav a:hover { color: var(--ink); background: var(--line-2); text-decoration: none; }
.logout { display: flex; align-items: center; gap: 10px; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow-x: auto; }
.card.narrow { max-width: 420px; margin: 8vh auto; }
.card.empty { text-align: center; padding: 48px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head.pad { padding: 16px 20px; margin: 0; border-bottom: 1px solid var(--line); }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 14px; margin-bottom: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-big { padding: 12px 22px; font-size: 15px; }
.btn-link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }
.btn-link.danger, .danger { color: var(--bad); }

.flash { padding: 10px 14px; border-radius: 8px; margin: 0 0 16px; font-size: 14px; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-err { background: var(--bad-soft); color: var(--bad); }
.flash-info { background: var(--accent-soft); color: var(--ink); }
pre.err { white-space: pre-wrap; color: var(--bad); }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--line-2); color: var(--muted); white-space: nowrap; }
.b-sending, .b-tested, .b-sent, .b-delivered, .b-completed { background: var(--ok-soft); color: var(--ok); }
.b-opened, .b-clicked { background: var(--accent-soft); color: var(--accent); }
.b-paused, .b-queued, .b-soft_bounced, .b-manual { background: var(--warn-soft); color: var(--warn); }
.b-failed, .b-bounced, .b-spam, .b-rejected, .b-cancelled, .b-unsubscribed { background: var(--bad-soft); color: var(--bad); }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--line-2); }
.table td { padding: 11px 20px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 7px 10px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; }
.card:not(.flush) .table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: block; overflow-x: auto; margin-top: 14px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--line); }
.pager .muted { margin-right: auto; }

/* steps */
.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 20px; flex-wrap: wrap; }
.steps li { padding: 6px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--muted); }
.steps li.done { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.steps li.done::before { content: "✓ "; }

/* editor + preview */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; }
.editor-left { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
#html { flex: 1; min-height: 420px; font-family: var(--mono); font-size: 12.5px; line-height: 1.5; tab-size: 2; white-space: pre; }
.dropzone { border: 1.5px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; transition: .15s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tags code.warn { background: var(--warn-soft); color: var(--warn); }
.editor-right { display: flex; flex-direction: column; min-width: 0; }
.preview-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.preview-subject { font-size: 14px; padding: 9px 12px; border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; background: var(--line-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-frame { flex: 1; border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: #e9ebef; display: flex; justify-content: center; overflow: hidden; min-height: 520px; }
.preview-frame iframe { width: 100%; height: 100%; min-height: 520px; border: 0; background: #fff; transition: width .2s; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; padding: 4px 10px; border: 0; background: var(--panel); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

/* test + import */
.test-row { display: flex; gap: 10px; align-items: stretch; }
.test-row textarea { flex: 1; }
.test-log { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; }
.test-log li { padding: 8px 12px; border-radius: 8px; font-size: 14px; }
.test-log li.ok { background: var(--ok-soft); color: var(--ok); }
.test-log li.err { background: var(--bad-soft); color: var(--bad); }
.upload-bar { height: 6px; background: var(--rest); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.upload-bar div { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.import-stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 14px; }
.import-stats div { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.import-stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.import-stats span { font-size: 12px; color: var(--muted); }
.import-stats .good b { color: var(--ok); }
.import-stats .bad b { color: var(--bad); }

.checklist { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
.checklist li.ok { color: var(--ok); }
.send-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.send-row .btn-big { margin-left: auto; }

/* live meter */
.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meter-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 28px; align-items: center; }
.meter-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.meter-pct { font-size: 56px; font-weight: 700; letter-spacing: -.03em; font-variant-numeric: tabular-nums; line-height: 1; }
.meter-pct-sign { font-size: 24px; font-weight: 600; color: var(--muted); margin-left: 2px; }
.meter-sub { color: var(--muted); }
.meter-sub b { color: var(--ink); font-variant-numeric: tabular-nums; }
.bar { height: 18px; border-radius: 99px; background: var(--rest); overflow: hidden; display: flex; }
.bar > div { height: 100%; transition: width .6s ease; }
.seg-ok { background: var(--ok); }
.seg-bad { background: var(--bad); }
.seg-skip { background: var(--skip); }
.meter-card.live .seg-ok { background-image: linear-gradient(45deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%); background-size: 24px 24px; animation: stripes 1s linear infinite; }
@keyframes stripes { to { background-position: 24px 0; } }
@media (prefers-reduced-motion: reduce) { .meter-card.live .seg-ok { animation: none; } }
.meter-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 12px; font-size: 13px; color: var(--muted); }
.meter-legend b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.skip { background: var(--skip); } .dot.rest { background: var(--rest); border: 1px solid var(--line); }
.meter-side { display: grid; grid-template-columns: repeat(3, auto); gap: 4px 28px; align-items: end; }
.meter-side canvas { grid-column: 1 / -1; width: 100%; height: 48px; margin-top: 8px; }
.kpi span { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi small { color: var(--muted); font-size: 12px; }
.mode-note { grid-column: 1 / -1; color: var(--muted); margin-top: -8px; }
.mode-note.ok { color: var(--ok); } .mode-note.warn { color: var(--warn); }
.mode-note:empty { display: none; }

.funnel { display: grid; grid-template-columns: repeat(7, 1fr); gap: 12px; margin-bottom: 20px; }
.fcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.fcard span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.fcard b { display: block; font-size: 24px; font-variant-numeric: tabular-nums; }
.fcard small { color: var(--muted); font-size: 12px; }
.fcard.bad b { color: var(--bad); }

.report-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.feed { list-style: none; padding: 0; margin: 0; max-height: 620px; overflow-y: auto; display: flex; flex-direction: column; }
.ev { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-2); font-size: 13px; animation: fadein .3s; }
.ev-b { overflow-wrap: anywhere; }
.ev-i { text-align: center; color: var(--muted); }
.ev-sent .ev-i, .ev-delivered .ev-i { color: var(--ok); }
.ev-opened .ev-i, .ev-clicked .ev-i { color: var(--accent); }
.ev-failed .ev-i, .ev-bounced .ev-i, .ev-spam .ev-i, .ev-rejected .ev-i { color: var(--bad); }
.ev b { text-transform: capitalize; }
@keyframes fadein { from { opacity: 0; transform: translateY(-3px); } }

.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.settings .card { margin: 0; }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 12px 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }

@media (max-width: 1000px) {
  .editor, .report-grid, .meter-card { grid-template-columns: 1fr; }
  .funnel { grid-template-columns: repeat(4, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .wrap { padding: 16px; }
  .topbar { padding: 0 16px; gap: 12px; overflow-x: auto; }
  .logout .muted { display: none; }
  .funnel, .import-stats { grid-template-columns: repeat(2, 1fr); }
  .meter-side { grid-template-columns: repeat(3, 1fr); gap: 4px 12px; }
  .test-row { flex-direction: column; }
  .table th, .table td { padding: 9px 12px; }
}

/* deliverability warnings */
.lint { background: var(--warn-soft); color: var(--ink); border: 1px solid var(--warn); border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.lint-title { font-weight: 700; color: var(--warn); margin-bottom: 4px; }
.lint ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 4px; }

/* Email providers (Sending setup) */
#providers { margin-bottom: 20px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; margin: 12px 0; }
.table-wrap form { display: inline; }
.provider-form { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 16px; }
.provider-form h3 { margin: 0 0 12px; font-size: 16px; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 14px; }
.ok-text { color: var(--ok); }
.provider-pick { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin: 0 0 14px; }
.provider-pick select { min-width: 260px; }
.check-inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); }
.provider-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 10px 0 0; border-top: 1px solid var(--line-2); margin-top: 10px; grid-column: 1 / -1; }
.provider-bar select { padding: 4px 8px; }
.export-group { display: inline-flex; gap: 6px; align-items: center; }
.card .table-wrap .table { display: table; border: 0; border-radius: 0; margin: 0; }
.warn-text { color: var(--warn, #b7791f); }
.hook { margin-top: 6px; } .hook input { width: 100%; margin-top: 6px; font-size: 12px; } .hook p { margin: 6px 0 0; }

/* Users page */
.btn-small { padding: 4px 10px; font-size: 13px; }
.num-input { width: 110px; }
.users-table tr.off td { opacity: .6; }
.row-menu { position: relative; }
.row-menu summary { list-style: none; cursor: pointer; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu-body { position: absolute; right: 0; top: 100%; z-index: 5; display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 8px 24px rgba(16, 24, 40, .12); min-width: 280px; }

/* Send readiness panel (campaign step 1) */
.lint.readiness { background: var(--panel); border-color: var(--line); }
.readiness.r-good { border-color: var(--ok); }
.readiness.r-ok { border-color: var(--warn); }
.readiness.r-bad { border-color: var(--bad); }
.ready-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.ready-score { display: flex; flex-direction: column; line-height: 1.1; min-width: 92px; }
.ready-score b { font-size: 28px; }
.ready-score span { font-size: 12px; color: var(--muted); }
.r-good .ready-score b { color: var(--ok); } .r-ok .ready-score b { color: var(--warn); } .r-bad .ready-score b { color: var(--bad); }
.ready-main { flex: 1; min-width: 160px; }
.ready-bar { height: 8px; border-radius: 99px; background: var(--rest); overflow: hidden; }
.ready-bar div { height: 100%; border-radius: 99px; background: var(--ok); transition: width .3s; }
.r-ok .ready-bar div { background: var(--warn); } .r-bad .ready-bar div { background: var(--bad); }
.ready-label { font-size: 13px; font-weight: 600; margin-top: 4px; }
.readiness .lint-title { color: var(--ink); margin-top: 10px; }
.risk-tag { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; border-radius: 4px; padding: 0 5px; margin-right: 2px; }
.risk-high .risk-tag { background: var(--bad-soft); color: var(--bad); }
.risk-medium .risk-tag { background: var(--warn-soft); color: var(--warn); }
.risk-low .risk-tag { background: var(--line-2); color: var(--muted); }
