/* ============================================================
   SMEmail — theme
   ============================================================ */
:root {
    --bg:            #f4f5fb;
    --card:          #ffffff;
    --sidebar-bg:    #111827;
    --sidebar-bg2:   #0b1220;
    --sidebar-fg:    #cbd5e1;
    --sidebar-fg-mut:#7c89a0;
    --sidebar-active:#6366f1;
    --accent:        #6366f1;
    --accent-2:      #8b5cf6;
    --accent-hover:  #4f46e5;
    --text:          #1e293b;
    --muted:         #64748b;
    --line:          #e6e8f0;
    --line-soft:     #eef0f6;
    --good:          #059669;
    --warn:          #d97706;
    --bad:           #dc2626;
    --radius:        14px;
    --radius-sm:     9px;
    --shadow:        0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
    --shadow-md:     0 4px 16px rgba(16,24,40,.08);
    --sidebar-w:     244px;
    --sidebar-w-col: 72px;
    --topbar-h:      62px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.2rem; font-weight: 600; }
h3 { font-size: 1.02rem; font-weight: 600; margin: 1.6rem 0 .6rem; }
code { background: var(--line-soft); padding: .08rem .35rem; border-radius: 5px; font-size: .85em; }
pre { background: #0b1220; color: #e2e8f0; padding: .9rem; border-radius: var(--radius-sm); overflow-x: auto; font-size: .82rem; }

/* ---------- Layout shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: width .18s ease;
    flex-shrink: 0;
}
.sidebar-top {
    display: flex; align-items: center; gap: .65rem;
    padding: 1rem 1.1rem; height: var(--topbar-h);
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-top .logo { width: 34px; height: 34px; flex-shrink: 0; }
.sidebar-top .wordmark { font-weight: 700; font-size: 1.08rem; color: #fff; letter-spacing: -.01em; white-space: nowrap; }
.collapse-btn {
    margin-left: auto; background: transparent; border: none; color: var(--sidebar-fg-mut);
    cursor: pointer; font-size: 1.15rem; padding: .2rem; border-radius: 6px; line-height: 1;
}
.collapse-btn:hover { color: #fff; background: rgba(255,255,255,.08); }

.nav { padding: .8rem .6rem; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-section { color: var(--sidebar-fg-mut); font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; padding: .9rem .7rem .35rem; }
.nav-item {
    display: flex; align-items: center; gap: .8rem;
    color: var(--sidebar-fg); text-decoration: none;
    padding: .6rem .75rem; border-radius: 9px; font-weight: 500; font-size: .92rem;
    white-space: nowrap; transition: background .12s, color .12s;
}
.nav-item i { font-size: 1.12rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item span { transition: opacity .15s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; text-decoration: none; }
.nav-item.active { background: var(--sidebar-active); color: #fff; box-shadow: 0 4px 12px rgba(99,102,241,.35); }

/* Collapsed state */
.app.sidebar-collapsed .sidebar { width: var(--sidebar-w-col); }
.app.sidebar-collapsed .wordmark,
.app.sidebar-collapsed .nav-item span,
.app.sidebar-collapsed .nav-section { display: none; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding: .6rem; }
.app.sidebar-collapsed .sidebar-top { justify-content: center; padding: 1rem .5rem; }
.app.sidebar-collapsed .collapse-btn { margin-left: 0; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h); background: var(--card); border-bottom: 1px solid var(--line);
    display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-weight: 600; font-size: 1.02rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .8rem; }
.user-chip {
    display: inline-flex; align-items: center; gap: .5rem; color: var(--muted);
    font-weight: 500; font-size: .9rem; padding: .35rem .6rem; border-radius: 999px;
}
.user-chip i { font-size: 1.4rem; color: var(--accent); }

.content { padding: 1.6rem 1.8rem; flex: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.2rem 1.3rem;
}
.card-title { font-weight: 600; font-size: 1rem; margin: 0 0 1rem; display: flex; align-items: center; gap: .5rem; }
.card-title .muted { font-weight: 400; color: var(--muted); font-size: .82rem; margin-left: auto; }

/* ---------- KPI cards ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1.1rem; margin: 0 0 1.4rem; }
.kpi {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 1.15rem 1.25rem; display: flex; align-items: flex-start; gap: 1rem;
}
.kpi .kpi-icon {
    width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center;
    font-size: 1.3rem; color: #fff; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.kpi .kpi-icon.green { background: linear-gradient(135deg, #10b981, #059669); }
.kpi .kpi-icon.amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
.kpi .kpi-icon.slate { background: linear-gradient(135deg, #64748b, #475569); }
.kpi h4 { margin: 0 0 .2rem; color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .num { font-size: 1.65rem; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.kpi .sub { color: var(--muted); font-size: .78rem; margin-top: .15rem; }

/* ---------- Dashboard grid ---------- */
.dash-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.2rem; align-items: start; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-wrap { position: relative; height: 280px; }

/* ---------- Tables ---------- */
.grid { border-collapse: separate; border-spacing: 0; width: 100%; background: var(--card);
        border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.grid th, .grid td { padding: .72rem .9rem; text-align: left; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.grid thead th { background: #fafbfe; color: var(--muted); font-weight: 600; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: #fafbff; }
.grid a { color: var(--accent); font-weight: 500; }

/* ---------- Buttons ---------- */
button, .btn {
    font-family: inherit; font-size: .9rem; font-weight: 500;
    padding: .5rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--line);
    background: var(--card); color: var(--text); cursor: pointer; transition: all .12s;
    display: inline-flex; align-items: center; gap: .4rem;
}
button:hover { background: #f8fafc; border-color: #cdd3e0; }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none; box-shadow: 0 4px 12px rgba(99,102,241,.3); }
button.primary:hover { filter: brightness(1.05); }

/* ---------- Forms ---------- */
input, textarea, select {
    font-family: inherit; font-size: .92rem; padding: .5rem .65rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card); color: var(--text);
    transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
input[type=text], input:not([type]) { min-width: 320px; }
textarea { min-width: 480px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
label { display: block; margin-bottom: .25rem; }
.form-row { margin-bottom: 1.1rem; max-width: 640px; }
.form-row label { font-weight: 600; font-size: .88rem; }
.form-row small { display: block; color: var(--muted); margin-top: .25rem; font-size: .8rem; }
.actions { margin-top: 1.2rem; padding-top: 1.1rem; border-top: 1px solid var(--line); display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.actions .status { margin-left: .25rem; color: var(--muted); font-style: italic; }
.status { color: var(--muted); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: 1.3rem; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap;
           background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); }
.filters label { font-weight: 500; display: inline; margin: 0; }
.filters .ck { display: flex; align-items: center; gap: .4rem; }

/* ---------- Status pills ---------- */
.status-pill { padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 600; display: inline-block; }
.status-draft     { background: #eef1f6; color: #475569; }
.status-scheduled { background: #e0edff; color: #1e40af; }
.status-sending   { background: #fef3c7; color: #92400e; }
.status-sent      { background: #d1fae5; color: #065f46; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-paused    { background: #ffedd5; color: #9a3412; }
.status-failed    { background: #fee2e2; color: #991b1b; }

/* ---------- Attribute lists / mapping ---------- */
.attr-list { list-style: none; padding: 0; margin: .4rem 0; }
.attr-list li { display: flex; align-items: center; gap: .45rem; padding: .4rem 0; border-bottom: 1px solid var(--line-soft); }
.attr-list .num { width: 1.5rem; color: var(--muted); font-weight: 600; }
.attr-list .name { flex: 1; max-width: 260px; }
.map-cols { display: flex; gap: 1.4rem; margin-top: 1rem; flex-wrap: wrap; }
.map-col { flex: 1; min-width: 320px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.map-col h3 { margin-top: 0; }
.add-row { display: flex; gap: .45rem; align-items: center; margin-top: .7rem; flex-wrap: wrap; }
.add-row input { min-width: 160px; }

.empty { background: var(--card); padding: 1.6rem; border: 1px dashed #cbd5e1; border-radius: var(--radius); color: var(--muted); }
details { margin-top: 1rem; }
details summary { cursor: pointer; color: var(--muted); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; }
.tab {
    background: transparent; border: none; border-bottom: 2px solid transparent;
    padding: .6rem 1rem; border-radius: 0; color: var(--muted); font-weight: 600; cursor: pointer;
}
.tab:hover { background: transparent; color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Reputation dashboard ---------- */
.domain-tabs { border-bottom: none; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.2rem; }
.domain-tabs .tab {
    display: inline-flex; align-items: center; gap: .45rem;
    border: 1px solid var(--line); border-radius: 8px; background: #fff;
    padding: .45rem .85rem; color: var(--text); font-weight: 600;
}
.domain-tabs .tab:hover { border-color: var(--accent); }
.domain-tabs .tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.rep-dot { width: .6rem; height: .6rem; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.rep-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.rep-tile { text-align: center; }
.rep-big { font-size: 1.8rem; font-weight: 700; margin: .3rem 0; }
.gauge-wrap { position: relative; width: 150px; height: 84px; margin: .4rem auto .2rem; }
.rep-word { font-weight: 700; letter-spacing: .03em; }
.rep-charts { display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1rem; }
.mini-chart { width: 180px; text-align: center; }
.mini-title { font-weight: 600; color: var(--muted); margin-bottom: .4rem; }
.donut-wrap { position: relative; width: 120px; height: 120px; margin: 0 auto; }
.empty-mini { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .85rem; text-align: center; }
.mini-cap { margin-top: .5rem; font-size: .85rem; color: var(--muted); }

/* trends */
.trend-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.trend-metric { max-width: 320px; }
.range-btns { display: flex; gap: .4rem; flex-wrap: wrap; }
.range-btn {
    border: 1px solid var(--line); background: #fff; border-radius: 6px;
    padding: .35rem .7rem; cursor: pointer; color: var(--muted); font-weight: 600;
}
.range-btn:hover { border-color: var(--accent); color: var(--text); }
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.trend-wrap { position: relative; height: 300px; }
.trend-table-wrap { max-height: 320px; overflow: auto; margin-top: 1rem; }

/* ---------- Campaign row actions ---------- */
.row-actions { display: flex; align-items: center; gap: .7rem; }
.btn-stop {
    border: 1px solid #dc2626; background: #fff; color: #dc2626;
    border-radius: 6px; padding: .25rem .6rem; cursor: pointer; font-weight: 600;
}
.btn-stop:hover { background: #dc2626; color: #fff; }

/* ---------- Calendar ---------- */
.cal-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.cal-title { font-weight: 700; font-size: 1.1rem; min-width: 180px; text-align: center; }
.cal-today { margin-left: .5rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: #fafbfe; padding: .5rem; text-align: center; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cal-cell { background: #fff; min-height: 104px; padding: .35rem .4rem; display: flex; flex-direction: column; gap: .2rem; }
.cal-cell.cal-other { background: #fafbfe; color: #cbd5e1; }
.cal-cell.cal-now { background: #f5f5ff; }
.cal-date { font-size: .8rem; font-weight: 600; color: var(--muted); }
.cal-cell.cal-now .cal-date { color: var(--accent); }
.cal-event {
    display: block; font-size: .72rem; font-weight: 600; padding: .15rem .4rem; border-radius: 5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none;
}
.cal-event:hover { text-decoration: none; filter: brightness(.96); }
/* Calendar event colors by status */
.cal-event.status-draft     { background: #fde68a; color: #854d0e; }   /* yellow */
.cal-event.status-scheduled { background: #fdba74; color: #7c2d12; }   /* orange */
.cal-event.status-sent      { background: #86efac; color: #065f46; }   /* green */
.cal-event.status-sending   { background: #fed7aa; color: #9a3412; }
.cal-event.status-cancelled,
.cal-event.status-failed    { background: #fecaca; color: #991b1b; }

.page-head { display: flex; align-items: center; margin-bottom: 1.3rem; gap: 1rem; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.muted { color: var(--muted); }

/* ---------- Auth ---------- */
.auth-shell {
    min-height: 100vh; display: grid; place-items: center; padding: 2rem;
    background: radial-gradient(1200px 600px at 20% -10%, #1e1b4b 0%, #0b1220 55%);
}
.auth-card {
    background: var(--card); border-radius: 18px; box-shadow: 0 20px 60px rgba(2,6,23,.5);
    padding: 2.2rem 2.2rem 2rem; width: 100%; max-width: 400px;
}
.auth-card h1 { margin: .2rem 0 0; }
.auth-card .muted { margin: 0 0 1.4rem; }
.auth-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.4rem; }
.auth-brand img { width: 40px; height: 40px; }
.auth-brand-text { font-weight: 700; font-size: 1.2rem; }
.auth-card .form-row { max-width: none; }
.auth-card input { width: 100%; min-width: 0; }
.auth-error {
    background: #fee2e2; color: #991b1b; border: 1px solid #fecaca;
    padding: .6rem .8rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-size: .88rem;
    display: flex; align-items: center; gap: .4rem;
}

/* ---------- Progress bar ---------- */
.bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 999px; transition: width .3s; }

/* ---------- Inline warning banner ---------- */
.warn-banner {
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
    padding: .7rem .9rem; border-radius: var(--radius-sm); margin: 1rem 0; font-size: .9rem;
    display: flex; align-items: flex-start; gap: .55rem;
}
.warn-banner i { font-size: 1.1rem; margin-top: .05rem; }

/* ---------- Template editor ---------- */
.tpl-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1.4rem; margin-bottom: 1rem; }
.tpl-meta .form-row { max-width: none; margin-bottom: .8rem; }
.tpl-meta input { width: 100%; min-width: 0; }
.gjs-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }

/* ---- GrapesJS light theme + smaller icons ---- */
.gjs-one-bg { background-color: #f8fafc; }            /* panels background (was dark) */
.gjs-two-color, .gjs-two-color-h:hover { color: #334155; }  /* icons / text */
.gjs-three-bg { background-color: #6366f1; color: #fff; }   /* active accent */
.gjs-four-color, .gjs-four-color-h:hover { color: #6366f1; }
.gjs-pn-panel { background: #f8fafc; border-color: #e6e8f0; }
.gjs-pn-btn { font-size: 13px; }
.gjs-cv-canvas { background-color: #eef0f6; }
.gjs-block {
    min-height: auto; padding: 8px 4px; font-size: 10.5px;
    border-color: #e6e8f0; border-radius: 8px;
}
.gjs-block:hover { border-color: #6366f1; }
.gjs-block svg, .gjs-block__media svg { width: 20px; height: 20px; }
.gjs-block-label { margin-top: 4px; }
.gjs-title, .gjs-sm-sector-title, .gjs-category-title { font-size: 12px; }
.preview-pane { position: sticky; top: 80px; }
.html-preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }

/* ---------- Template gallery ---------- */
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1.2rem; margin-bottom: 1.6rem; }
.tpl-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s; }
.tpl-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.tpl-thumb { height: 190px; overflow: hidden; border-bottom: 1px solid var(--line-soft); background: #fff; position: relative; }
.tpl-thumb iframe { width: 250%; height: 475px; border: 0; transform: scale(0.4); transform-origin: top left; pointer-events: none; }
.tpl-card-body { padding: .8rem .9rem; display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.tpl-name { font-weight: 600; }
.tpl-desc { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tpl-action { margin-top: .6rem; width: 100%; justify-content: center; }
.tpl-actions { margin-top: .6rem; display: flex; gap: .4rem; }
.tpl-actions .btn, .tpl-actions button { flex: 1; justify-content: center; font-size: .82rem; padding: .4rem; }

/* ---------- Segment builder ---------- */
.seg-title { font-size: 1.45rem; font-weight: 700; border: none; padding: .1rem .2rem; min-width: 360px; background: transparent; }
.seg-title:focus { background: #fff; box-shadow: 0 0 0 3px rgba(99,102,241,.14); }
.seg-layout { display: grid; grid-template-columns: 250px 1fr 280px; gap: 1.2rem; align-items: start; }
@media (max-width: 1200px) { .seg-layout { grid-template-columns: 1fr; } }

.seg-palette { position: sticky; top: 80px; }
.seg-palette .card-title { margin-bottom: .7rem; }
/* high specificity to beat the global input:not([type]) min-width:320px */
.seg-palette input.seg-search { width: 100%; min-width: 0; margin: 0 0 .9rem; display: block; box-sizing: border-box; }
.attr-cards { display: flex; flex-direction: column; gap: .35rem; max-height: 440px; overflow-y: auto; overflow-x: hidden; padding-top: .15rem; border-top: 1px solid var(--line-soft); }
.attr-card { display: flex; align-items: center; gap: .55rem; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 9px; background: #fff; cursor: pointer; font-size: .85rem; text-align: left; transition: all .12s; width: 100%; }
.attr-card span { white-space: normal; word-break: break-word; }
.attr-card:hover { border-color: var(--accent); background: #f5f5ff; color: var(--accent); }
.attr-card i { font-size: 1.05rem; color: var(--accent); flex-shrink: 0; }

/* ---------- Checklist value picker ---------- */
.checklist { flex: 1 1 100%; min-width: 320px; }
.rule-card input.checklist-filter { width: 100%; min-width: 0; margin-bottom: .4rem; font-size: .82rem; box-sizing: border-box; }
.checklist-items { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .35rem .5rem; background: #fff; }
.checklist-empty { color: var(--muted); font-size: .82rem; padding: .3rem; }

/* Toggle chips for value selection */
.chip-list {
    display: flex; flex-wrap: wrap; gap: .45rem;
    max-height: 360px; overflow-y: auto;
    padding: .5rem .6rem;
    border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fafafd;
}
.chip {
    padding: .35rem .75rem; border: 1px solid var(--line); border-radius: 999px;
    background: #fff; color: var(--text); cursor: pointer; font-size: .84rem; font-weight: 500;
    flex: 0 0 auto; transition: all .12s; line-height: 1.3;
}
.chip:hover { border-color: var(--accent); background: #f5f5ff; }
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 2px 6px rgba(99,102,241,.3); }
.chip.active:hover { background: var(--accent-hover); }

.seg-combine { margin: .4rem 0 1rem; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: .5rem; }
.seg-combine select { font-weight: 600; color: var(--text); }
.rule-card { display: flex; align-items: center; gap: .5rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; margin-bottom: .6rem; box-shadow: var(--shadow); flex-wrap: wrap; }
.rule-card select, .rule-card input { min-width: 0; }
.rule-card input { flex: 1; min-width: 120px; }
.rule-op { color: var(--muted); font-size: .85rem; }
.rule-remove { margin-left: auto; border: none; background: transparent; color: var(--muted); padding: .3rem; }
.rule-remove:hover { color: var(--bad); background: #fee2e2; }

.seg-reach { position: sticky; top: 80px; text-align: center; }
.reach-donut { position: relative; height: 200px; margin: .5rem auto 1rem; }
.reach-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.reach-num { font-size: 1.7rem; font-weight: 700; letter-spacing: -.02em; }

/* ---------- Send option cards ---------- */
.send-options { display: flex; gap: 1rem; flex-wrap: wrap; }
.send-opt {
    flex: 1; min-width: 240px; display: flex; align-items: center; gap: .9rem; text-align: left;
    background: #fff; border: 2px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; cursor: pointer;
}
.send-opt:hover { border-color: #cdd3e0; background: #fff; }
.send-opt.active { border-color: var(--accent); background: #f5f5ff; box-shadow: 0 4px 14px rgba(99,102,241,.15); }
.send-opt i { font-size: 1.5rem; color: var(--accent); }
.send-opt strong { display: block; font-size: 1rem; }
.send-opt .muted { font-size: .82rem; }

/* ---------- Carded edit form ---------- */
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2rem; align-items: start; margin-bottom: 1.2rem; }
@media (max-width: 980px) { .edit-grid { grid-template-columns: 1fr; } }
.edit-grid .edit-card { margin-bottom: 0; max-width: none; }
.edit-card { margin-bottom: 1.2rem; max-width: 900px; }
.schedule-card { max-width: none; }
.edit-card .form-row { max-width: none; }
.edit-card input:not([type=checkbox]), .edit-card select { width: 100%; min-width: 0; box-sizing: border-box; }
/* gradient icon tile in each card header */
.edit-card .card-title { gap: .6rem; align-items: center; }
.edit-card .card-title > i:first-child {
    width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center;
    color: #fff; font-size: .95rem; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
}

/* ---------- Calendar: unscheduled drafts strip ---------- */
.cal-unscheduled { margin-top: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; box-shadow: var(--shadow); }
.cal-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }

/* ---------- Contact profile ---------- */
.profile-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.2rem; }
.profile-dl { display: grid; grid-template-columns: 1fr; gap: 0; margin: 0; }
.profile-dl dt { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; margin-top: .7rem; }
.profile-dl dt:first-child { margin-top: 0; }
.profile-dl dd { margin: .1rem 0 0; font-size: .95rem; font-weight: 500; }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ---------- Template editor: variable legend ---------- */
.var-legend {
    display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
    padding: .7rem .9rem; margin: 0 0 1rem;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
    border: 1px solid #e0e7ff; border-radius: 10px;
}
.var-legend-label { font-size: .78rem; color: #475569; font-weight: 600;
    display: inline-flex; align-items: center; gap: .35rem; margin-right: .3rem; }
.var-chip {
    background: #fff; border: 1px solid #c7d2fe; border-radius: 8px;
    padding: .35rem .65rem; cursor: pointer; font-family: inherit;
    display: inline-flex; align-items: center; gap: .5rem;
    transition: border-color .12s, background .12s, transform .05s;
}
.var-chip:hover { border-color: #6366f1; background: #eef2ff; }
.var-chip:active { transform: scale(.98); }
.var-chip code { background: transparent; color: #4338ca; font-size: .82rem; font-weight: 600; padding: 0; }
.var-chip-desc { color: #64748b; font-size: .75rem; }
.var-chip-copied { color: #16a34a; font-size: .8rem; font-weight: 600;
    display: inline-flex; align-items: center; gap: .3rem; margin-left: auto; }
.var-chip-copied code { background: transparent; color: inherit; font-weight: inherit; padding: 0; }
