/* ===========================================================================
   RenewPulse — stylesheet
   Theme: blues (#1e40af, #3b82f6, #60a5fa) + purples (#7c3aed, #8b5cf6, #a78bfa)
   Font: Inter
   =========================================================================== */

:root {
    --blue-900: #1e3a8a;
    --blue-800: #1e40af;
    --blue-600: #3b82f6;
    --blue-400: #60a5fa;
    --purple-700: #7c3aed;
    --purple-600: #8b5cf6;
    --purple-400: #a78bfa;

    --ink: #0f172a;
    --ink-soft: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f1f5f9;
    --card: #ffffff;
    --white: #ffffff;

    --success: #16a34a;
    --success-bg: #dcfce7;
    --error: #dc2626;
    --error-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --info-bg: #dbeafe;

    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, .12), 0 8px 10px -6px rgba(15, 23, 42, .08);
    --grad: linear-gradient(135deg, var(--blue-800), var(--purple-700));
    --grad-soft: linear-gradient(135deg, var(--blue-600), var(--purple-600));
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- Landing */
.landing-body {
    background: var(--grad);
    min-height: 100vh;
}

.landing-split {
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    min-height: 100vh;
}

.hero {
    display: flex;
    align-items: center;
    padding: 64px;
    color: var(--white);
}
.hero-inner { max-width: 560px; }

.hero-brand, .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 40px;
}
.hero-brand.center { justify-content: center; }
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 34px; height: 34px;
    background: rgba(255,255,255,.18);
    border-radius: 9px;
    font-size: 18px;
}

.hero-title {
    font-size: 44px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -.02em;
    margin-bottom: 20px;
}
.hero-sub {
    font-size: 17px;
    color: rgba(255,255,255,.85);
    margin-bottom: 32px;
}
.hero-features { list-style: none; display: grid; gap: 14px; margin-bottom: 32px; }
.hero-features li { display: flex; align-items: center; gap: 12px; font-size: 15px; color: rgba(255,255,255,.92); }
.tick {
    display: inline-grid; place-items: center;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(255,255,255,.22); font-size: 12px; flex-shrink: 0;
}
.hero-badge {
    display: inline-block;
    padding: 10px 16px;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 999px;
    font-size: 13px;
    color: rgba(255,255,255,.9);
}

.auth-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    padding: 40px;
}
.auth-standalone {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.auth-card {
    background: var(--card);
    width: 100%;
    max-width: 420px;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
}
.auth-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); margin-bottom: 26px; font-size: 15px; }
.auth-links { margin-top: 22px; text-align: center; color: var(--muted); font-size: 14px; }
.auth-links .dot { margin: 0 8px; color: var(--line); }

/* ---------------------------------------------------------------- Forms */
.form { display: grid; gap: 18px; }
.field { display: grid; gap: 7px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.field-hint { font-size: 12px; color: var(--muted); }
.input {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus {
    outline: none;
    border-color: var(--blue-600);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.textarea-code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px; line-height: 1.6; resize: vertical; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L2 4h8z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.divider { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
.form-section-title { font-weight: 600; font-size: 14px; color: var(--ink-soft); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .05s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--grad); color: var(--white); box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: var(--shadow-md); text-decoration: none; }
.btn-secondary { background: var(--blue-600); color: var(--white); }
.btn-secondary:hover { background: var(--blue-800); }
.btn-ghost { background: transparent; color: var(--purple-700); border: 1px solid var(--purple-400); }
.btn-ghost:hover { background: rgba(139,92,246,.08); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* Alerts */
.alert { padding: 13px 16px; border-radius: var(--radius-sm); font-size: 14px; margin-bottom: 18px; }
.alert-success { background: var(--success-bg); color: #166534; }
.alert-error { background: var(--error-bg); color: #991b1b; }
.alert-warning { background: var(--warning-bg); color: #92400e; }
.alert-info { background: var(--info-bg); color: #1e40af; }

/* ---------------------------------------------------------------- Admin impersonation bar */
.admin-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 2000;
    height: 46px;
    background: linear-gradient(90deg, #92400e, #b45309);
    color: #fef3c7;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.admin-bar-text { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.admin-bar-icon { font-size: 17px; }
.admin-bar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-bar-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 12px; font-weight: 600;
    cursor: pointer; border: none; font-family: inherit;
    text-decoration: none; line-height: 1;
}
.admin-bar-btn-return {
    background: rgba(255,255,255,.2);
    color: #fef3c7;
    transition: background .15s;
}
.admin-bar-btn-return:hover { background: rgba(255,255,255,.35); color: #fff; text-decoration: none; }
body.has-admin-bar { padding-top: 46px; }
body.has-admin-bar .sidebar { top: 46px; height: calc(100vh - 46px); }
body.has-admin-bar .topbar { top: 46px; }

/* ---------------------------------------------------------------- App shell */
.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
    background: var(--ink);
    background: linear-gradient(180deg, #14213d, #1e1b4b);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand { color: var(--white); padding: 0 8px; margin-bottom: 34px; }
.sidebar-nav { display: grid; gap: 4px; }
.sidebar-spacer { flex: 1; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: var(--white); text-decoration: none; }
.nav-link.is-active { background: var(--grad-soft); color: var(--white); box-shadow: var(--shadow); }
.nav-icon { font-size: 16px; }

.sidebar-footer { border-top: 1px solid rgba(255,255,255,.1); padding-top: 16px; }
.user-chip { display: flex; align-items: center; gap: 11px; padding: 6px 8px; margin-bottom: 8px; }
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--grad-soft); color: var(--white);
    font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.user-name { color: var(--white); font-size: 14px; font-weight: 600; }
.user-company { font-size: 12px; color: #94a3b8; }
.logout-link { display: block; padding: 9px 14px; color: #94a3b8; font-size: 13px; }
.logout-link:hover { color: var(--white); text-decoration: none; }

.main-content { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--line);
    padding: 20px 32px;
    position: sticky; top: 0; z-index: 10;
}
.page-title { font-size: 22px; font-weight: 700; }
.content-inner { padding: 28px 32px; max-width: 1200px; width: 100%; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 24px; }
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 15px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: grid; place-items: center; font-size: 22px; flex-shrink: 0;
}
.grad-blue { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.grad-blue-2 { background: linear-gradient(135deg, #e0e7ff, #c7d2fe); }
.grad-purple { background: linear-gradient(135deg, #ede9fe, #ddd6fe); }
.grad-purple-2 { background: linear-gradient(135deg, #f3e8ff, #e9d5ff); }
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; }
.stat-label { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

/* Cards */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-title { font-size: 16px; font-weight: 700; }
.card-subtitle { font-size: 13px; color: var(--muted); }
.card-link { font-size: 13px; font-weight: 600; }
.card .form { padding: 22px; }
.card-body { padding: 22px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
    text-align: left;
    padding: 12px 22px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--line);
}
.table tbody td { padding: 14px 22px; border-bottom: 1px solid var(--line); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }
.empty-cell { text-align: center; color: var(--muted); padding: 40px 22px; }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; color: var(--muted); }

/* Pills / statuses / tags */
.pill { display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-red { background: var(--error-bg); color: #991b1b; }
.pill-amber { background: var(--warning-bg); color: #92400e; }
.pill-blue { background: var(--info-bg); color: #1e40af; }

/* Reminder chips in the dashboard table */
.reminder-cell { white-space: nowrap; }
.reminder-none { color: var(--text-muted); }
.reminder-chip {
    display: inline-block;
    margin: 1px 2px;
    padding: 2px 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    cursor: default;
}
.reminder-chip-pending { background: #dbeafe; color: #1e40af; }
.reminder-chip-sent    { background: #f0fdf4; color: #166534; text-decoration: line-through; opacity: .7; }

/* Rows-per-page preference control in card header */
.rows-pref-label {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--muted); white-space: nowrap; flex-shrink: 0;
}
.rows-pref-select {
    padding: 3px 6px; border: 1px solid var(--line); border-radius: 6px;
    font-size: 13px; background: var(--surface); color: var(--ink);
    cursor: pointer;
}
.status { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-sent { background: var(--success-bg); color: #166534; }
.status-failed { background: var(--error-bg); color: #991b1b; }
.status-skipped { background: #f1f5f9; color: var(--muted); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 7px; background: var(--purple-400); color: var(--white); border-radius: 5px; font-size: 10px; font-weight: 700; vertical-align: middle; }
.tag-blue   { background: var(--blue-600); }
.tag-purple { background: var(--purple-600); }
.tag-green  { background: #16a34a; }
.tag-amber  { background: #d97706; }

/* Cancelling-subscription row treatment */
.table tbody tr.row-cancel { background: rgba(217,119,6,.05); }
.table tbody tr.row-cancel:hover { background: rgba(217,119,6,.09); }
.table tbody tr.row-cancel > td:first-child { border-left: 3px solid #d97706; padding-left: 19px; }
.cancel-sublabel { display: block; font-size: 11px; font-weight: 600; color: #d97706; margin-top: 3px; letter-spacing: .02em; }

/* Clickable rows */
.table tbody tr[data-sub] { cursor: pointer; }

/* ── Subscription detail modal ───────────────────────────────────────────── */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(15,23,42,.5);
    backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center;
    z-index: 900;
    animation: modalFadeIn .15s ease;
}
.modal-backdrop[hidden] { display: none; }
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(15,23,42,.2);
    width: 100%; max-width: 520px;
    margin: 20px;
    animation: modalSlideUp .18s ease;
    overflow: hidden;
}
@keyframes modalSlideUp { from { transform: translateY(14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
    position: absolute; top: 16px; right: 16px;
    background: none; border: none; cursor: pointer;
    font-size: 22px; color: var(--muted); line-height: 1;
    padding: 2px 8px; border-radius: 4px; transition: background .12s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    padding: 22px 22px 18px; gap: 12px; position: relative;
}
.modal-header-text { flex: 1; min-width: 0; }
.modal-name { font-size: 16px; font-weight: 700; margin: 0 0 4px; line-height: 1.3; }
.modal-email { font-size: 13px; color: var(--muted); margin: 0; }

.modal-divider { border: none; border-top: 1px solid var(--line); }

.modal-detail-grid {
    display: grid; grid-template-columns: 1fr 1fr;
}
.modal-detail-item {
    padding: 13px 22px;
    border-bottom: 1px solid var(--line);
    border-right: 1px solid var(--line);
}
.modal-detail-item:nth-child(even) { border-right: none; }
.modal-detail-full { grid-column: 1 / -1; border-right: none; }
.modal-detail-label {
    display: block; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .07em;
    color: var(--muted); margin-bottom: 5px;
}
.modal-detail-value { font-size: 14px; font-weight: 500; color: var(--text); }
.modal-stripe-link {
    display: inline-flex; align-items: center; gap: 4px;
    font-family: ui-monospace, 'Cascadia Code', monospace;
    font-size: 12px; color: var(--blue-600); word-break: break-all;
}
.modal-stripe-link::after { content: '↗'; font-size: 11px; opacity: .7; flex-shrink: 0; }

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    background: var(--bg);
    justify-content: space-between;
}
.error-hint { color: var(--error); cursor: help; margin-left: 4px; }

/* ── Single Sender Verification wizard ──────────────────────────── */
.verify-status-ok {
    display: flex; align-items: center; gap: 12px;
    padding: 16px 20px; background: #f0fdf4;
    border: 1px solid #bbf7d0; border-radius: 8px;
    color: #15803d; font-weight: 600; font-size: 15px;
}
.verify-status-icon { font-size: 1.5em; line-height: 1; }

.verify-prompt { display: flex; flex-direction: column; gap: 16px; }
.verify-prompt-title { font-weight: 600; color: var(--ink); margin: 0 0 4px; font-size: 15px; }
.verify-prompt-desc  { margin: 0; color: var(--muted); line-height: 1.65; font-size: 14px; }

.verify-steps { display: flex; flex-direction: column; gap: 10px; background: #f9fafb; border-radius: 8px; padding: 14px 16px; list-style: none; margin: 0; }
.verify-steps li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink); line-height: 1.5; }
.verify-step-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; background: var(--purple-600);
    color: #fff; border-radius: 50%; font-size: 12px; font-weight: 700;
    flex-shrink: 0; margin-top: 1px;
}

.verify-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.verify-hint { font-size: 12px; color: var(--muted); margin: 0; }

.verify-pending { display: flex; flex-direction: column; gap: 16px; }
.verify-pending-badge {
    display: inline-flex; align-items: center; gap: 8px;
    background: #fefce8; border: 1px solid #fde68a; border-radius: 6px;
    padding: 10px 14px; font-size: 14px; color: #92400e; font-weight: 500;
}
.verify-pending-body { font-size: 14px; color: var(--muted); line-height: 1.65; }
.verify-pending-body strong { color: var(--ink); }

.verify-done {
    display: flex; align-items: flex-start; gap: 14px;
    background: #f0fdf4; border: 1px solid #bbf7d0;
    border-radius: 8px; padding: 16px 20px;
}
.verify-done-icon  { font-size: 2em; line-height: 1; }
.verify-done-body  { flex: 1; }
.verify-done-title { font-weight: 700; font-size: 15px; color: #15803d; margin: 0 0 4px; }
.verify-done-desc  { font-size: 14px; color: var(--muted); margin: 0 0 14px; line-height: 1.55; }

.btn-link-danger {
    background: none; border: none; padding: 0;
    color: var(--error, #dc2626); font-size: 13px;
    cursor: pointer; text-decoration: underline; text-underline-offset: 2px;
}
.btn-link-danger:hover { color: #b91c1c; }

/* Tabs */
.tab-bar { display: flex; gap: 4px; background: var(--white); padding: 6px; border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; }
.tab-btn {
    flex: 1;
    padding: 10px 16px;
    border: none; background: transparent;
    border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 600;
    color: var(--muted); cursor: pointer;
    transition: background .15s, color .15s;
}
.tab-btn:hover { color: var(--ink); }
.tab-btn.is-active { background: var(--grad-soft); color: var(--white); }
/* Allow <a> elements to be used as tab buttons */
a.tab-btn { display: flex; align-items: center; justify-content: center; text-decoration: none; }
/* Dot indicator for tabs that have a custom per-interval template */
.tab-dot { color: var(--blue-400); font-size: 10px; line-height: 1; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Switch */
.switch-field { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch-field input { display: none; }
.switch { position: relative; width: 44px; height: 25px; background: var(--line); border-radius: 999px; transition: background .2s; flex-shrink: 0; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; background: var(--white); border-radius: 50%; transition: transform .2s; box-shadow: var(--shadow); }
.switch-field input:checked + .switch { background: var(--purple-600); }
.switch-field input:checked + .switch::after { transform: translateX(19px); }

/* Toggle-card (checkbox as a styled on/off card) */
.toggle-card-list { display: grid; gap: 10px; margin-top: 10px; margin-bottom: 6px; }
.toggle-card { cursor: pointer; display: block; }
.toggle-card input { display: none; }
.toggle-card-body {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 15px 18px;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: border-color .15s, background .15s;
}
.toggle-card input:checked + .toggle-card-body { border-color: var(--purple-600); background: rgba(139,92,246,.04); }
.toggle-card-content { flex: 1; min-width: 0; }
.toggle-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.toggle-card-title { font-size: 14px; font-weight: 600; color: var(--ink); }
.toggle-card-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; margin: 0; }
.toggle-pill {
    flex-shrink: 0; width: 40px; height: 22px;
    background: var(--line); border-radius: 999px;
    position: relative; transition: background .2s; margin-top: 2px;
}
.toggle-pill::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; background: var(--white);
    border-radius: 50%; box-shadow: var(--shadow); transition: transform .2s;
}
.toggle-card input:checked + .toggle-card-body .toggle-pill { background: var(--purple-600); }
.toggle-card input:checked + .toggle-card-body .toggle-pill::after { transform: translateX(18px); }

/* Option-card (radio as a styled selectable card) */
.option-card-list { display: grid; gap: 10px; margin-bottom: 14px; }
.option-card { cursor: pointer; display: block; }
.option-card input { display: none; }
.option-card-body {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 15px 18px;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--white);
    transition: border-color .15s, background .15s;
}
.option-card input:checked + .option-card-body { border-color: var(--purple-600); background: rgba(139,92,246,.04); }
.option-card-radio {
    flex-shrink: 0; width: 18px; height: 18px; margin-top: 2px;
    border-radius: 50%; border: 2px solid var(--line);
    position: relative; transition: border-color .15s;
}
.option-card-radio::after {
    content: ''; position: absolute; inset: 3px;
    border-radius: 50%; background: var(--purple-600);
    opacity: 0; transition: opacity .15s;
}
.option-card input:checked + .option-card-body .option-card-radio { border-color: var(--purple-600); }
.option-card input:checked + .option-card-body .option-card-radio::after { opacity: 1; }
.option-card-text { flex: 1; min-width: 0; }
.option-card-title { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 3px; }
.option-card-desc { font-size: 12.5px; color: var(--muted); line-height: 1.5; }

/* Checkbox interval grid */
.checkbox-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 22px; }
.check-card { cursor: pointer; }
.check-card input { display: none; }
.check-card-body {
    display: grid; place-items: center; gap: 2px;
    padding: 18px 10px;
    border: 2px solid var(--line);
    border-radius: var(--radius-sm);
    transition: border-color .15s, background .15s;
}
.check-card input:checked + .check-card-body { border-color: var(--purple-600); background: rgba(139,92,246,.06); }
.check-card-num { font-size: 24px; font-weight: 800; color: var(--ink); }
.check-card-label { font-size: 12px; color: var(--muted); }

/* Template editor */
.editor-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: start; }
.side-stack { display: grid; gap: 24px; }
.merge-card .muted, .muted { color: var(--muted); font-size: 13px; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 18px 22px; }
.filter-input { flex: 1; min-width: 220px; max-width: 420px; width: auto; margin: 0; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.merge-card .muted { padding: 0 22px; margin-bottom: 8px; }
.merge-list { list-style: none; padding: 0 22px 22px; display: grid; gap: 10px; }
.merge-list li { display: flex; align-items: center; gap: 10px; }
.merge-tag {
    font-family: ui-monospace, Menlo, monospace; font-size: 12px;
    background: rgba(59,130,246,.1); color: var(--blue-800);
    border: 1px solid rgba(59,130,246,.25);
    padding: 4px 9px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.merge-tag:hover { background: rgba(59,130,246,.18); }
.merge-desc { font-size: 12.5px; color: var(--muted); }

/* ── Quill WYSIWYG editor ─────────────────────────────────────────── */
/*
   Quill inserts the toolbar as a SIBLING before #quillEditor in the parent,
   so we use .quill-wrapper to contain both the toolbar and the editor.
   DOM after Quill init:
     .quill-wrapper
       .ql-toolbar.ql-snow   ← toolbar (Quill inserted here)
       #quillEditor.ql-container.ql-snow
         .ql-editor
*/
.quill-wrapper {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--card);
    overflow: hidden;
}
.quill-wrapper .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    background: var(--bg);
    font-size: 13px;
    padding: 6px 10px;
    line-height: 1;
}
/* Restore button sizing zeroed by the global * { padding:0 } reset.
   !important on display and float: Snow CSS loads after our sheet and sets
   display:inline-block; float:left on toolbar buttons — we must win. */
.quill-wrapper .ql-toolbar.ql-snow button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    height: 26px;
    width: 28px;
    padding: 3px 5px;
    cursor: pointer;
    border: none;
    background: none;
    border-radius: 4px;
    float: none !important;
    color: var(--muted);   /* our SVGs use currentColor */
}
.quill-wrapper .ql-toolbar.ql-snow button:hover  { background: rgba(0,0,0,.06); color: var(--ink); }
.quill-wrapper .ql-toolbar.ql-snow button.ql-active { background: rgba(59,130,246,.12); color: var(--blue-800); }
.quill-wrapper .ql-toolbar.ql-snow button svg {
    width: 16px;
    height: 16px;
    display: block;
    float: none;
}
/* .ql-stroke / .ql-fill rules not needed — custom toolbar uses our own SVG
   icons with currentColor, so button color states above handle everything. */
/* HTML source toggle button */
.quill-wrapper .ql-html-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    width: 28px;
    padding: 3px 5px;
    cursor: pointer;
    border: none;
    background: none;
    border-radius: 4px;
    color: var(--muted);
}
.quill-wrapper .ql-html-toggle:hover  { background: rgba(0,0,0,.06); color: var(--blue-800); }
.quill-wrapper .ql-html-toggle.is-active { background: rgba(59,130,246,.12); color: var(--blue-800); }
.quill-wrapper .ql-toolbar.ql-snow .ql-formats {
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
}
.quill-wrapper .ql-container.ql-snow {
    border: none;
    font-size: .875rem;
}
.quill-wrapper .ql-editor {
    min-height: 180px;
    padding: 12px 14px;
    color: var(--ink);
}
/* HTML source pane */
.quill-wrapper .ql-html-pane {
    display: block;
    width: 100%;
    min-height: 220px;
    padding: 12px 14px;
    font-family: ui-monospace, 'Cascadia Code', Menlo, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink);
    background: var(--bg);
    border: none;
    border-top: 1px solid var(--line);
    resize: vertical;
    outline: none;
}
.quill-wrapper .ql-editor p { margin: 0 0 .6em; }
.quill-wrapper .ql-editor:focus { outline: none; }
.quill-wrapper:focus-within {
    outline: 2px solid var(--blue-800);
    outline-offset: -1px;
    border-color: transparent;
}
/* Link tooltip — hide when inactive, style when active */
.quill-wrapper .ql-tooltip.ql-hidden { display: none !important; }
.quill-wrapper .ql-tooltip {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,.1);
    color: var(--ink);
    padding: 6px 10px;
    font-size: 13px;
    white-space: nowrap;
    z-index: 100;
}
.quill-wrapper .ql-tooltip input[type=text] {
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
    color: var(--ink);
    outline: none;
    width: 200px;
}
.quill-wrapper .ql-tooltip input[type=text]:focus {
    border-color: var(--blue-600);
}
.quill-wrapper .ql-tooltip a.ql-action,
.quill-wrapper .ql-tooltip a.ql-remove {
    color: var(--blue-600);
    cursor: pointer;
    margin-left: 8px;
    font-size: 13px;
}
.preview-pane { padding: 22px; min-height: 200px; font-size: 14px; }
.preview-pane .preview-subject { font-weight: 700; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.inline-result { margin-top: 12px; font-size: 13px; }
.inline-result.ok { color: var(--success); }
.inline-result.err { color: var(--error); }

/* Pagination */
.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; padding: 18px; }
.page-btn { padding: 8px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.page-btn:hover { border-color: var(--blue-600); color: var(--blue-600); text-decoration: none; }
.page-info { font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- Responsive */
@media (max-width: 1024px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .editor-grid { grid-template-columns: 1fr; }
    .landing-split { grid-template-columns: 1fr; }
    .hero { padding: 48px 32px; }
}
@media (max-width: 720px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .sidebar-brand { margin-bottom: 0; margin-right: auto; }
    .sidebar-nav { flex: 0 0 100%; grid-auto-flow: column; overflow-x: auto; margin-top: 12px; }
    .sidebar-footer { flex: 0 0 100%; display: flex; align-items: center; justify-content: space-between; border-top: none; }
    .stat-grid { grid-template-columns: 1fr; }
    .checkbox-grid { grid-template-columns: repeat(2, 1fr); }
    .content-inner { padding: 20px; }
    .hero-title { font-size: 32px; }
}


/* ─────────────────────────────────────────────────────────────────────────
   Email tracking, opt-out & per-customer view (added features)
   ───────────────────────────────────────────────────────────────────────── */

/* Red status tag (Unsubscribed / Paused badges in history + customer pages) */
.tag-red { background: #dc2626; }

/* Clickable recipient link in the history summary table */
.link-strong {
    color: var(--blue-800);
    font-weight: 600;
    text-decoration: none;
}
.link-strong:hover { text-decoration: underline; }

/* Small green "opened" badge */
.open-badge {
    display: inline-block;
    padding: 1px 8px;
    background: var(--success-bg);
    color: #166534;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.table td.cell-nowrap {
    white-space: nowrap;
}

/* ── Per-customer page ── */
.cust-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}
.cust-detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px 32px;
    margin-top: 4px;
    padding: 8px 22px 6px;
}
.cust-detail-item {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.cust-detail-label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.cust-detail-value {
    font-size: 15px;
    color: var(--ink);
    font-weight: 500;
}
.cust-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-top: 18px;
    padding: 0 22px 8px;
}
.card > .inline-result {
    padding: 0 22px 18px;
}
@media (max-width: 640px) {
    .cust-detail-grid { grid-template-columns: 1fr; }
}
/* Getting started guide */
button.nav-link {
    width: 100%;
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
button.nav-link.onboarding-trigger {
    margin: 8px 12px 0;
    width: calc(100% - 24px);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(37,99,238,.12), rgba(124,58,237,.12));
}
button.nav-link.onboarding-trigger:hover {
    background: linear-gradient(135deg, rgba(37,99,238,.2), rgba(124,58,237,.2));
}
body.ob-lock { overflow: hidden; }
.ob-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.ob-backdrop[hidden] { display: none; }
.ob-modal {
    position: relative;
    width: min(640px, 100%);
    max-height: min(88vh, 820px);
    overflow: auto;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}
.ob-close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: rgba(255,255,255,.18);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}
.ob-close:hover { background: rgba(255,255,255,.3); }
.ob-hero {
    padding: 32px 32px 24px;
    background: linear-gradient(135deg, #1e3a8a 0%, #4f46e5 55%, #7c3aed 100%);
    color: #fff;
}
.ob-kicker {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    opacity: .8;
    margin-bottom: 8px;
}
.ob-title {
    margin: 0 0 8px;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -.02em;
    color: #fff;
}
.ob-lede {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(255,255,255,.86);
}
.ob-steps {
    list-style: none;
    margin: 0;
    padding: 8px 28px 8px;
}
.ob-step {
    display: flex;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #eef2f7;
}
.ob-step:last-child { border-bottom: 0; }
.ob-num {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ob-step h3 {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
}
.ob-step p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: #475569;
}
.ob-step a { color: #2563eb; font-weight: 600; }
.ob-step code {
    font-size: 12px;
    background: #f1f5f9;
    padding: 1px 6px;
    border-radius: 4px;
    color: #334155;
}
.ob-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 28px 24px;
}
@media (max-width: 560px) {
    .ob-hero, .ob-steps, .ob-footer { padding-left: 18px; padding-right: 18px; }
    .ob-footer { flex-direction: column-reverse; }
    .ob-footer .btn { width: 100%; text-align: center; }
}