:root {
  --bg: #0a0c11;
  --surface: #12151d;
  --surface-2: #1a1e28;
  --border: #262b38;
  --border-soft: #1e2330;
  --text: #eaedf4;
  --muted: #97a1b4;
  --brand-1: #6366f1;
  --brand-2: #a855f7;
  --brand: #7c8cff;
  --grad: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
  --ok: #34d399;
  --bad: #f87171;
  --warn: #fbbf24;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --radius: 14px;
}
:root[data-theme="light"] {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4fa;
  --border: #e2e7f1;
  --border-soft: #eceff6;
  --text: #141a24;
  --muted: #5a6478;
  --ok: #059669;
  --bad: #dc2626;
  --warn: #b45309;
  --shadow: 0 6px 22px rgba(20,30,60,.08);
}
:root[data-theme="light"] body {
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(99,102,241,.12), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(168,85,247,.10), transparent 55%),
    var(--bg);
}
:root[data-theme="light"] .topbar { background: rgba(255,255,255,.72); }
:root[data-theme="light"] nav a.active { background: rgba(99,102,241,.1); box-shadow: inset 0 0 0 1px rgba(99,102,241,.3); }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.55; letter-spacing: -0.01em;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(99,102,241,.18), transparent 60%),
    radial-gradient(800px 500px at 100% 0%, rgba(168,85,247,.14), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: #a9b4ff; }
h1 { font-size: 24px; font-weight: 700; margin: 0 0 20px; letter-spacing: -0.02em; }
h2 { font-size: 13px; font-weight: 600; margin: 0 0 14px; color: var(--muted);
     text-transform: uppercase; letter-spacing: .08em; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--border-soft);
       padding: 1px 6px; border-radius: 6px; font-size: 12.5px;
       font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 22px; padding: 12px 26px; flex-wrap: wrap;
  background: rgba(12,14,20,.72); backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800;
         font-size: 18px; color: var(--text); letter-spacing: -0.02em; }
.brand img { border-radius: 8px; box-shadow: 0 2px 10px rgba(124,92,255,.5); }
.brand .tag { font-size: 10px; font-weight: 700; color: #fff; letter-spacing: .06em;
  margin-left: 8px; padding: 2px 7px; border-radius: 999px; vertical-align: middle;
  background: var(--grad); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav a { color: var(--muted); font-weight: 500; font-size: 14px; padding: 6px 11px;
        border-radius: 9px; transition: all .15s; }
nav a:hover { color: var(--text); background: var(--surface-2); }
nav a.active { color: #fff; background: rgba(124,140,255,.16); box-shadow: inset 0 0 0 1px rgba(124,140,255,.35); }
.env { margin-left: auto; display: flex; gap: 7px; align-items: center; }
.pill { font-size: 12px; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill.user { color: var(--text); }
.pill.ghost { color: var(--brand); }
.pill.ghost:hover { border-color: var(--brand); color: #fff; }

/* dropdown menus in nav */
.menu { position: relative; }
.navbtn { font-family: inherit; cursor: pointer; color: var(--muted); font-weight: 500;
  font-size: 14px; padding: 6px 11px; border-radius: 9px; background: transparent;
  border: 0; transition: all .15s; }
.navbtn:hover { color: var(--text); background: var(--surface-2); }
.navbtn.active { color: #fff; background: rgba(124,140,255,.16);
  box-shadow: inset 0 0 0 1px rgba(124,140,255,.35); }
.caret { font-size: 10px; opacity: .7; }
.menu-items { position: absolute; top: 100%; left: 0; margin-top: 6px; min-width: 200px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 6px; display: none; z-index: 60; }
.menu.open .menu-items { display: block; }
.menu-items a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--muted);
  font-size: 14px; }
.menu-items a:hover { background: var(--surface-2); color: var(--text); }

/* hero CTA (Overview wizard shortcut) */
.hero { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; background: var(--grad); border-radius: var(--radius); padding: 20px 24px;
  margin-bottom: 22px; box-shadow: 0 8px 30px rgba(124,92,255,.35); }
.hero .htext { color: #fff; }
.hero .htext h2 { color: #fff; text-transform: none; letter-spacing: -0.01em; font-size: 18px; margin: 0 0 4px; }
.hero .htext p { margin: 0; color: rgba(255,255,255,.85); font-size: 14px; }
.hero .btn { background: #fff; color: #3b2a86; border: 0; font-weight: 700; }
.hero .btn:hover { filter: brightness(1.02); }

main { max-width: 1080px; margin: 0 auto; padding: 28px 26px 10px; }
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rowhead .actions { display: flex; gap: 8px; align-items: center; margin: 0; }
.rowhead form { margin: 0; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
         gap: 14px; margin-bottom: 26px; }
.tile { position: relative; display: block; color: var(--text); text-decoration: none;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 16px;
  overflow: hidden; transition: transform .15s, border-color .15s; }
a.tile:hover { border-color: var(--accent); }
a.tile .lbl { color: var(--brand); }
.tile::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--grad); opacity: .8; }
.tile:hover { transform: translateY(-2px); border-color: #333a4b; }
.tile .num { font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.tile .lbl { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.tile.ok .num { color: var(--ok); } .tile.ok::before { background: linear-gradient(135deg,#10b981,#34d399); }
.tile.bad .num { color: var(--bad); } .tile.bad::before { background: linear-gradient(135deg,#ef4444,#f87171); }

/* ---- panels ---- */
.panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow); }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
td.r, th.r { text-align: right; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }

/* ---- badges ---- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 3px 10px;
  border-radius: 999px; border: 1px solid transparent; }
.badge.pending { color: var(--warn); background: rgba(251,191,36,.12); border-color: rgba(251,191,36,.3); }
.badge.sent { color: var(--ok); background: rgba(52,211,153,.12); border-color: rgba(52,211,153,.3); }
.badge.failed { color: var(--bad); background: rgba(248,113,113,.12); border-color: rgba(248,113,113,.3); }
.badge.skipped { color: var(--muted); background: var(--surface-2); border-color: var(--border); }

/* ---- buttons ---- */
.btn, button.btn { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); padding: 8px 15px;
  border-radius: 10px; text-decoration: none; transition: all .15s; }
.btn:hover { border-color: #3a4256; color: #fff; transform: translateY(-1px); }
.btn.small { padding: 5px 11px; font-size: 12.5px; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 4px 16px rgba(124,92,255,.35); }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 6px 22px rgba(124,92,255,.5); }
.btn.rm { background: transparent; }
.actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chip { display: inline-block; text-decoration: none; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--border); padding: 6px 13px; border-radius: 999px; font-size: 13px; transition: all .15s; }
.chip:hover { color: var(--text); border-color: #3a4256; }
.chip.sel { color: #fff; background: rgba(124,140,255,.16); border-color: rgba(124,140,255,.5); }

/* ---- forms ---- */
label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
label input, label textarea, label select, .form input[type=number] {
  display: block; width: 100%; margin-top: 6px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 14px; font-family: inherit; transition: border-color .15s, box-shadow .15s; }
label input:focus, label textarea:focus, label select:focus, .form input:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(124,140,255,.2); }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } nav { display: none; } }
input[type=file] { color: var(--muted); font-size: 14px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 10px 0; position: relative; }

/* ---- form table (cockpit) ---- */
table.form td { vertical-align: top; }
.fname { font-weight: 600; color: var(--text); }
.form input[type=number] { width: 120px; text-align: right; }

/* ---- banners ---- */
.banner { padding: 13px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid var(--border);
  font-size: 14px; }
.banner.ok { color: var(--ok); background: rgba(52,211,153,.1); border-color: rgba(52,211,153,.35); }
.banner.info { color: var(--text); background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border-color: var(--border); }
.banner em { color: var(--brand); font-style: normal; font-weight: 600; }

/* ---- previews / variants / timeline ---- */
.variant .vhead, .variant-edit .vhead { font-weight: 700; margin-bottom: 8px; }
.variant-edit { background: var(--surface-2); }
.variant-edit .vhead { display: flex; justify-content: space-between; align-items: center; }
.subject { margin-bottom: 12px; }
.preview-frame { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.preview-frame iframe { width: 100%; height: 220px; border: 0; background: #fff; }
details { margin-top: 12px; } summary { cursor: pointer; color: var(--muted); }
pre { background: var(--surface-2); padding: 12px; border-radius: 10px; overflow: auto; white-space: pre-wrap; font-size: 13px; }
.stepper { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 22px; }
.stepper .step { display: flex; align-items: center; gap: 8px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 999px; color: var(--muted);
  font-size: 13px; background: var(--surface); }
.stepper .step .n { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2);
  font-size: 12px; font-weight: 700; }
.stepper .step.active { color: #fff; border-color: transparent; background: var(--grad); }
.stepper .step.active .n { background: rgba(255,255,255,.25); }
.stepper .step.done { color: var(--text); border-color: rgba(52,211,153,.4); }
.stepper .step.done .n { background: rgba(52,211,153,.2); color: var(--ok); }
.wizard { max-width: 760px; margin: 0 auto; }
.field-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 2px; }
.field-tools button { font-size: 12px; padding: 3px 9px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.timeline li:last-child { border-bottom: 0; }

/* ---- auth ---- */
.authbox { max-width: 400px; margin: 8vh auto 0; }
.authbox .brandmark { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 22px; }
.authbox .brandmark img { border-radius: 14px; box-shadow: 0 8px 30px rgba(124,92,255,.5); }
.authbox .brandmark .name { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.authbox h1 { text-align: center; font-size: 18px; }
.authbox .panel { box-shadow: 0 20px 60px rgba(0,0,0,.45); }

footer { max-width: 1080px; margin: 0 auto; padding: 24px 26px 44px; color: var(--muted); font-size: 12.5px; }
