:root {
  --sidebar-bg: #0f172a;
  --sidebar-fg: #94a3b8;
  --sidebar-active: #6366f1;
  --page-bg: #f4f6fb;
  --card-bg: #ffffff;
  --border: #e5e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #0ea5e9;
  --bs-primary: #6366f1;
  --bs-primary-rgb: 99, 102, 241;
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

body { background: var(--page-bg); color: var(--text); font-size: 14px; }
a { color: var(--primary); }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark);
  --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-active-bg: var(--primary-dark); --bs-btn-disabled-bg: var(--primary); }
.btn-outline-primary { --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary); --bs-btn-active-bg: var(--primary-dark); }
.btn { font-weight: 500; border-radius: 8px; }
.form-control, .form-select { border-radius: 8px; border-color: var(--border); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem rgba(99,102,241,.15); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-label { font-weight: 600; font-size: 13px; color: #334155; margin-bottom: 4px; }
.form-text { font-size: 12px; }

/* shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-fg); display: flex;
  flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1040; }
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px; color: #fff; font-weight: 800; font-size: 19px;
  text-decoration: none; letter-spacing: -.3px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #818cf8, #6366f1 50%, #a855f7); color: #fff; font-size: 15px; }
.nav-section { padding: 0 12px; flex: 1; }
.nav-label { text-transform: uppercase; font-size: 10.5px; letter-spacing: 1px; font-weight: 700; color: #475569;
  padding: 18px 10px 6px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px; color: var(--sidebar-fg);
  text-decoration: none; font-weight: 500; margin-bottom: 2px; transition: all .15s; }
.nav-item i { font-size: 16px; }
.nav-item:hover { background: rgba(148,163,184,.1); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 14px rgba(99,102,241,.35); }
.sidebar-foot { padding: 12px; border-top: 1px solid #1e293b; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 16px 28px; background: rgba(255,255,255,.85);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1030; min-height: 68px; }
.topbar-title { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.topbar-title small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 8px; }
.content { padding: 24px 28px 60px; }
@media (max-width: 991px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
}

/* cards */
.card { border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 1px 2px rgba(15,23,42,.04); background: var(--card-bg); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); padding: 14px 18px; font-weight: 700; display: flex;
  align-items: center; gap: 8px; }
.card-header .small { font-weight: 500; }
.card-body { padding: 18px; }
.stat-card { padding: 18px; display: flex; flex-direction: column; gap: 4px; height: 100%; }
.stat-card .stat-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.stat-card .stat-label { color: var(--muted); font-weight: 500; font-size: 12.5px; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); }
.tint-indigo { background: #eef2ff; color: #4f46e5; }
.tint-green { background: #ecfdf5; color: #059669; }
.tint-amber { background: #fffbeb; color: #d97706; }
.tint-red { background: #fef2f2; color: #dc2626; }
.tint-sky { background: #f0f9ff; color: #0284c7; }
.tint-purple { background: #faf5ff; color: #9333ea; }
.tint-slate { background: #f1f5f9; color: #475569; }
.tint-pink { background: #fdf2f8; color: #db2777; }

/* tables */
.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 10px 14px; border-color: var(--border); vertical-align: middle; }
.table thead th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 700;
  background: #f8fafc; border-bottom-width: 1px; white-space: nowrap; }
.table-hover tbody tr:hover { --bs-table-hover-bg: #f8faff; }
.table a { text-decoration: none; font-weight: 600; }

/* badges */
.badge-status { font-weight: 600; font-size: 11.5px; padding: 5px 9px; border-radius: 6px; text-transform: capitalize; }
.st-draft { background: #f1f5f9; color: #475569; }
.st-scheduled { background: #f0f9ff; color: #0369a1; }
.st-running { background: #ecfdf5; color: #047857; }
.st-paused { background: #fffbeb; color: #b45309; }
.st-completed { background: #eef2ff; color: #4338ca; }
.st-cancelled { background: #fef2f2; color: #b91c1c; }
.st-pending, .st-sending { background: #f1f5f9; color: #475569; }
.st-sent { background: #ecfdf5; color: #047857; }
.st-bounced { background: #fef2f2; color: #b91c1c; }
.st-failed { background: #fff1f2; color: #be123c; }
.st-suppressed { background: #faf5ff; color: #7e22ce; }
.r-bounce { background: #fef2f2; color: #b91c1c; }
.r-unsubscribe { background: #fffbeb; color: #b45309; }
.r-complaint { background: #fdf2f8; color: #be185d; }
.r-manual { background: #f1f5f9; color: #475569; }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .55 } }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-live { background: var(--success); box-shadow: 0 0 0 0 rgba(16,185,129,.6); animation: ping 1.6s infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(16,185,129,.6) } 100% { box-shadow: 0 0 0 8px rgba(16,185,129,0) } }

.progress { height: 8px; border-radius: 99px; background: #eef0f6; }
.progress-bar { background: linear-gradient(90deg, #818cf8, #6366f1); }
.progress-thin { height: 5px; }

/* emailer gallery */
.thumb-card { overflow: hidden; transition: transform .15s, box-shadow .15s; }
.thumb-card:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.08); }
.thumb-wrap { height: 230px; overflow: hidden; position: relative; background: #f1f5f9; border-bottom: 1px solid var(--border); }
.thumb-wrap iframe { width: 800px; height: 920px; border: 0; transform: scale(.4); transform-origin: 0 0; pointer-events: none; position: absolute; left: 50%; margin-left: -160px; }
.starter-card { cursor: pointer; border: 2px solid var(--border); border-radius: 12px; overflow: hidden; transition: all .15s; background: #fff; }
.starter-card:hover { border-color: #c7d2fe; }
.starter-card.selected { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,.15); }
.starter-card .thumb-wrap { height: 150px; }
.starter-card .thumb-wrap iframe { transform: scale(.25); margin-left: -100px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state i { font-size: 48px; color: #c7d2fe; display: block; margin-bottom: 12px; }
.empty-state h5 { color: var(--text); font-weight: 700; }

.section-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff; display: inline-grid;
  place-items: center; font-size: 13px; font-weight: 700; flex-shrink: 0; }
.select-tile { border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; display: flex;
  align-items: center; gap: 10px; transition: all .12s; background: #fff; height: 100%; }
.select-tile:hover { border-color: #c7d2fe; }
.select-tile:has(input:checked) { border-color: var(--primary); background: #f5f7ff; }
.select-tile input { margin: 0; }
.color-chip { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex-shrink: 0; }
.mono { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-size: 12.5px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); font-weight: 500; }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.tag-chip { display: inline-block; background: #eef2ff; color: #4338ca; border-radius: 6px; padding: 2px 8px; margin: 2px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; cursor: pointer; border: 0; }
.tag-chip:hover { background: #e0e7ff; }
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.funnel-row .lbl { width: 110px; font-weight: 600; font-size: 13px; }
.funnel-row .bar { flex: 1; height: 26px; background: #f1f5f9; border-radius: 6px; overflow: hidden; }
.funnel-row .bar span { display: block; height: 100%; border-radius: 6px; }
.funnel-row .val { width: 110px; text-align: right; font-size: 13px; font-weight: 600; }
.live-feed { max-height: 330px; overflow-y: auto; }
.live-feed .ev { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.live-feed .ev:last-child { border-bottom: 0; }
.pagination { --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary); margin: 0; }
.nav-pills .nav-link.active { background: var(--primary); }
.nav-pills .nav-link { color: var(--muted); font-weight: 600; border-radius: 8px; padding: 6px 12px; font-size: 13px; }

/* login */
.login-page { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 20% 20%, #312e81 0, transparent 45%), radial-gradient(circle at 80% 80%, #6b21a8 0, transparent 40%), #0f172a; }
.login-card { width: 100%; max-width: 400px; border-radius: 18px; padding: 36px; background: #fff; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.text-purple { color: #9333ea; }

/* multi-tenant chrome */
.workspace-chip { display: flex; align-items: center; gap: 10px; margin: 0 12px 4px; padding: 10px 12px; border-radius: 10px;
  background: rgba(148,163,184,.08); color: #e2e8f0; }
.workspace-chip > i { font-size: 18px; color: #a5b4fc; }
.ws-avatar { width: 32px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center; flex-shrink: 0;
  background: linear-gradient(135deg, #22d3ee, #6366f1); color: #fff; font-weight: 700; font-size: 14px; }
.ws-avatar.sm { width: 24px; height: 24px; font-size: 12px; border-radius: 6px; }
.ws-name { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.ws-plan { font-size: 11.5px; color: #94a3b8; text-transform: capitalize; }
.usage-mini { display: block; margin: 8px 12px 12px; padding: 12px; border-radius: 10px; background: rgba(148,163,184,.08);
  color: #94a3b8; font-size: 11.5px; }
.usage-mini:hover { background: rgba(148,163,184,.14); }
.usage-mini .progress { background: #1e293b; }
.acting-banner { background: linear-gradient(90deg, #f59e0b, #f97316); color: #fff; padding: 8px 28px; font-weight: 500; font-size: 13px; }
.plan-card { border: 2px solid var(--border); border-radius: 14px; padding: 22px; height: 100%; background: #fff; }
.plan-card.current { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99,102,241,.12); }
.plan-card .price { font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.meter-label { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.role-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; padding: 3px 8px; border-radius: 6px; }
.role-owner { background: #fdf4ff; color: #a21caf; }
.role-admin { background: #eef2ff; color: #4338ca; }
.role-member { background: #ecfdf5; color: #047857; }
.role-viewer { background: #f1f5f9; color: #475569; }
