:root {
  --bg: #09090b;
  --bg-2: #0f0f16;
  --sidebar: #0e0e13;
  --panel: #111117;
  --panel-2: #1a1a24;
  --border: #232330;
  --border-soft: #1d1d28;
  --text: #f0f0f4;
  --muted: #8b8b99;
  --muted-2: #5c5c6b;
  --accent: #8b5cf6;
  --accent-2: #a855f7;
  --accent-soft: rgba(139, 92, 246, .15);
  --accent-glyph: #a78bfa;
  --green: #34d399;
  --red: #f87171;
  --yellow: #ff9f43;
  --blue: #4f9cff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(0, 0, 0, .35);
  font-family: "Inter", "Segoe UI", -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #26262f; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

.app { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 230px; flex-shrink: 0;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 20px; }
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  filter: drop-shadow(0 0 10px rgba(139, 92, 246, .4));
}
.brand-mark svg { display: block; width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 14.5px; letter-spacing: .2px; }
.brand-text span { font-size: 10.5px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-group {
  font-size: 10px; font-weight: 700; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--muted-2); padding: 16px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: 0; color: var(--muted);
  padding: 9px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13.5px; font-weight: 500; text-align: left; transition: all .15s ease;
  font-family: inherit;
}
.nav-item .ic { width: 18px; text-align: center; opacity: .85; font-size: 14px; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: var(--accent); color: #fff;
  box-shadow: 0 4px 14px rgba(124, 92, 255, .35);
}
.nav-item.active .ic { opacity: 1; }
.sidebar-foot { margin-top: auto; padding: 10px 4px 2px; }
.engine-chip {
  font-size: 10.5px; color: var(--muted-2); background: var(--panel);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------------- Main ---------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; border-bottom: 1px solid var(--border);
  background: rgba(10, 10, 14, .72); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.status-pill {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel); border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 999px; font-size: 12.5px; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted-2); }
.dot.on { background: var(--green); box-shadow: 0 0 0 4px rgba(52, 211, 153, .16); animation: pulse 1.6s infinite; }
.dot.err { background: var(--red); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.topbar-actions { display: flex; gap: 10px; }

.content { padding: 26px 30px 60px; overflow-y: auto; }
h1 { font-size: 21px; margin: 0 0 18px; letter-spacing: -.2px; font-weight: 700; }
h2 { font-size: 14.5px; margin: 0; font-weight: 600; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 1.1px; color: var(--muted); margin: 4px 0 10px; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { margin-bottom: 4px; }
.page-sub { margin: 0; color: var(--muted); font-size: 12.5px; }

/* ---------------- Pages ---------------- */
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- Buttons ---------------- */
.btn {
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
  padding: 9px 15px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all .15s ease; font-family: inherit;
}
.btn:hover { border-color: #32324a; background: var(--panel-2); }
.btn-primary {
  background: var(--accent); border: 1px solid transparent; color: #fff;
  box-shadow: 0 5px 16px rgba(124, 92, 255, .3);
}
.btn-primary:hover { background: #8b6dff; }
.btn-primary.running { background: linear-gradient(135deg, #f87171, #ff9f43); box-shadow: 0 5px 16px rgba(248, 113, 113, .3); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 10px; }
.btn[disabled] { opacity: .4; cursor: default; pointer-events: none; }
.link { background: none; border: 0; color: var(--accent-glyph); cursor: pointer; font-size: 12px; font-family: inherit; }
.link:hover { text-decoration: underline; }
.icon-btn { background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.icon-btn:hover { color: var(--text); background: var(--panel-2); }

/* ---------------- KPI cards (Overview) ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; min-width: 0;
}
.kpi-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.kpi-icon {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-glyph);
  display: grid; place-items: center; font-size: 15px;
}
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 27px; font-weight: 700; letter-spacing: -.6px; line-height: 1.1; }
.kpi-delta { font-size: 11.5px; margin-top: 7px; color: var(--muted); font-weight: 600; }
.kpi-delta span { color: var(--muted-2); font-weight: 400; }
.kpi-delta.up { color: var(--green); }
.kpi-delta.down { color: var(--red); }

/* ---------------- Funnel (Pipeline Stages) ---------------- */
.funnel-head {
  display: flex; justify-content: space-between;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted-2); padding: 4px 2px 12px;
}
.funnel-row { display: grid; grid-template-columns: 1fr 58px; align-items: center; gap: 12px; margin-bottom: 10px; }
.funnel-row:last-child { margin-bottom: 2px; }
.funnel-track { min-width: 0; }
.funnel-bar {
  height: 40px; margin: 0 auto; min-width: 150px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 16px; color: #fff; font-size: 12.5px; font-weight: 600;
  border-radius: 7px;
  clip-path: polygon(0 0, 100% 0, calc(100% - 12px) 100%, 12px 100%);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .10), rgba(0, 0, 0, .12));
  transition: width .5s cubic-bezier(.22, 1, .36, 1);
}
.funnel-bar .fb-count { font-weight: 700; font-size: 12.5px; opacity: .95; }
.funnel-conv { text-align: right; font-size: 13px; font-weight: 600; }

/* ---------------- Charts ---------------- */
.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 220px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted-2); font-size: 12.5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---------------- Stat grid (Generator page) ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); opacity: .7; }
.stat.green::after { background: var(--green); }
.stat.red::after { background: var(--red); }
.stat.yellow::after { background: var(--yellow); }
.stat .num { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---------------- Cards ---------------- */
.cards-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.card.grow { min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.note { font-size: 12px; padding: 9px 11px; border-radius: 8px; background: var(--bg-2); border: 1px solid var(--border-soft); color: var(--muted); margin-bottom: 6px; }
.note.warn { border-color: rgba(255, 159, 67, .4); color: var(--yellow); }
.note.ok { border-color: rgba(52, 211, 153, .35); color: var(--green); }
.sep { border: 0; border-top: 1px solid var(--border-soft); margin: 16px 0; }

.live-status { font-size: 13px; line-height: 1.9; }
.live-status b { color: #fff; }
.recent-list .recent-item { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border-soft); font-size: 13px; }
.recent-list .recent-item:last-child { border: 0; }
.recent-item .ri-sub { color: var(--muted); font-size: 12px; }

/* ---------------- Inputs ---------------- */
.input, .textarea, select {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size: 13px; width: 100%;
  font-family: inherit; transition: border-color .15s;
}
.input:focus, .textarea:focus, select:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; line-height: 1.5; }
.textarea.code { font-family: "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
select { cursor: pointer; }
.input-xs { width: 64px; padding: 5px 8px; font-size: 12px; }
.chip-select {
  width: auto; background: var(--panel); border-color: var(--border);
  border-radius: 999px; padding: 8px 14px; font-size: 12.5px; font-weight: 500; color: var(--text);
}

/* ---------------- Toolbar ---------------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.toolbar .input { width: auto; }
#leadSearch, #emailSearch { flex: 1; min-width: 200px; }
.toolbar-spacer { flex: 1; }

/* ---------------- Table ---------------- */
.table-wrap { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; padding: 12px 14px; color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .7px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--panel-2); }
.table a { color: var(--accent-glyph); text-decoration: none; }
.table a:hover { text-decoration: underline; }
.cellname { font-weight: 600; }
.cellsub { color: var(--muted); font-size: 12px; }
.cell-subject { max-width: 340px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-notes { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted-2); font-size: 13px; }
.small-empty { padding: 18px 8px; }
#leadsCount { font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.pagination .btn[disabled] { opacity: .4; cursor: default; pointer-events: none; }

/* checkbox */
.chk { width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--border); background: var(--bg-2); cursor: pointer; display: inline-grid; place-items: center; transition: all .15s; font-size: 11px; }
.chk.on { background: var(--green); border-color: var(--green); color: #06281d; }
.table input[type="checkbox"], #selAll { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; vertical-align: middle; }
input[type="checkbox"] { accent-color: var(--accent); }

/* badges (runs / email status) */
.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.badge.success { background: rgba(52, 211, 153, .14); color: var(--green); }
.badge.failed { background: rgba(248, 113, 113, .14); color: var(--red); }
.badge.running { background: var(--accent-soft); color: var(--accent-glyph); }
.badge.stopped { background: rgba(139, 139, 153, .14); color: var(--muted); }

/* ---------------- Chips ---------------- */
.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap; text-transform: capitalize;
}
.chip-green { background: rgba(52, 211, 153, .14); color: var(--green); }
.chip-red { background: rgba(248, 113, 113, .14); color: var(--red); }
.chip-orange { background: rgba(255, 159, 67, .15); color: var(--yellow); }
.chip-blue { background: rgba(79, 156, 255, .14); color: var(--blue); }
.chip-purple { background: var(--accent-soft); color: var(--accent-glyph); }
.chip-muted { background: rgba(139, 139, 153, .13); color: var(--muted); }
/* message status */
.chip-st-sent { background: rgba(52, 211, 153, .14); color: var(--green); }
.chip-st-opened { background: var(--accent-soft); color: var(--accent-glyph); }
.chip-st-clicked { background: rgba(79, 156, 255, .14); color: var(--blue); }
.chip-st-bounced, .chip-st-failed { background: rgba(248, 113, 113, .14); color: var(--red); }
.chip-st-received { background: rgba(79, 156, 255, .14); color: var(--blue); }
.chip-st-queued { background: rgba(139, 139, 153, .13); color: var(--muted); }
/* reply kinds */
.kind-reply { background: rgba(52, 211, 153, .14); color: var(--green); }
.kind-auto-reply { background: rgba(139, 139, 153, .13); color: var(--muted); }
.kind-bounce { background: rgba(248, 113, 113, .14); color: var(--red); }
.kind-unsub { background: rgba(255, 159, 67, .15); color: var(--yellow); }
.kind-other { background: rgba(79, 156, 255, .14); color: var(--blue); }
/* meeting status */
.mt-booked { background: var(--accent-soft); color: var(--accent-glyph); }
.mt-done { background: rgba(52, 211, 153, .14); color: var(--green); }
.mt-no_show { background: rgba(255, 159, 67, .15); color: var(--yellow); }
.mt-canceled { background: rgba(139, 139, 153, .13); color: var(--muted); }

/* ---------------- Stage chips ---------------- */
.stage-chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: capitalize; white-space: nowrap;
}
.st-new { background: rgba(139, 139, 153, .13); color: var(--muted); }
.st-contacted { background: rgba(79, 124, 255, .15); color: #7ca0ff; }
.st-replied { background: rgba(46, 204, 113, .15); color: #4fdc8d; }
.st-meeting { background: rgba(255, 159, 67, .15); color: var(--yellow); }
.st-opportunity { background: rgba(142, 92, 255, .17); color: #b394ff; }
.st-won { background: rgba(52, 211, 153, .16); color: var(--green); }
.st-lost { background: rgba(255, 107, 87, .15); color: #ff8a75; }
.st-not_interested { background: rgba(139, 139, 153, .13); color: var(--muted); }
.st-bounced { background: rgba(248, 113, 113, .14); color: var(--red); }
.st-unsubscribed { background: rgba(255, 159, 67, .15); color: var(--yellow); }

/* ---------------- Sequences ---------------- */
.seq-list { display: flex; flex-direction: column; gap: 0; }
.seq-card { padding: 18px 20px; }
.seq-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.seq-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 10px; }
.seq-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.seq-meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.seq-warn { color: var(--yellow); }
.seq-stats { display: flex; gap: 22px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border-soft); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.seq-stats b { color: var(--text); font-size: 14px; margin-right: 4px; }

/* step editor */
.step-row { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; }
.step-row .input, .step-row .textarea { margin-top: 8px; }
.step-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.step-num { font-weight: 700; font-size: 12px; color: var(--accent-glyph); text-transform: uppercase; letter-spacing: .8px; }
.step-head .mini { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.step-head .mini input[type="number"] { margin-top: 0; }

/* ---------------- Replies ---------------- */
.replies-list .card { padding: 0; overflow: hidden; }
.reply-main {
  display: grid; grid-template-columns: 96px 200px 1fr 92px;
  gap: 14px; align-items: center; padding: 14px 18px; cursor: pointer;
}
.reply-main:hover { background: var(--panel-2); }
.reply-who { min-width: 0; }
.reply-sub { min-width: 0; font-size: 13px; }
.reply-sub, .reply-who .cellname { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reply-snip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.reply-date { text-align: right; }
.reply-detail { padding: 4px 18px 16px; border-top: 1px solid var(--border-soft); }
.reply-detail .email-box { margin-top: 12px; max-height: 300px; overflow: auto; }

/* ---------------- Kanban (Deals) ---------------- */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; align-items: start; }
.kanban-col { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 12px; }
.kh-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.col-open .kh-label { color: var(--blue); }
.col-won .kh-label { color: var(--green); }
.col-lost .kh-label { color: var(--red); }
.kh-meta { font-size: 11.5px; color: var(--muted); }
.kanban-cards { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.deal-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; cursor: pointer; transition: all .15s ease;
}
.deal-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.deal-name { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.deal-value { margin-top: 8px; font-size: 13px; font-weight: 700; color: var(--accent-glyph); }

/* ---------------- Pickers / lists in modals ---------------- */
.picker-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; background: var(--bg-2); }
.picker-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 14px; border: 0; border-bottom: 1px solid var(--border-soft);
  background: transparent; color: var(--text); font-size: 13px; text-align: left; cursor: pointer;
  font-family: inherit;
}
.picker-row:last-child { border-bottom: 0; }
.picker-row:hover { background: var(--panel-2); }
.pr-main { flex: 1; min-width: 0; }

.lead-label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.lead-picker { position: relative; }
.lp-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 20;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  max-height: 220px; overflow: auto; box-shadow: var(--shadow);
}
.lp-item { padding: 9px 12px; cursor: pointer; font-size: 13px; color: var(--text); }
.lp-item:hover { background: var(--accent-soft); }

/* ---------------- Suppression / webhook ---------------- */
.supp-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border-soft); font-size: 12.5px; }
.supp-row:last-child { border-bottom: 0; }
.supp-row span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.supp-form { display: flex; gap: 8px; margin-bottom: 12px; }
.supp-form .input { flex: 1; }
.supp-form select { width: 120px; }
.supp-scroll { max-height: 280px; overflow: auto; }

.webhook-box {
  display: flex; align-items: center; gap: 10px; background: var(--bg-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 12px;
}
.webhook-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; padding: 0; font-size: 12px; color: var(--accent-glyph); }
.payload-pre {
  background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 12px; font-size: 11.5px; line-height: 1.6; overflow: auto; color: var(--muted);
  font-family: "Cascadia Code", Consolas, monospace; margin: 8px 0 0;
}
.sync-result { font-size: 12px; color: var(--muted); margin-top: 10px; min-height: 16px; word-break: break-word; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 9px; color: var(--text); font-size: 13px; }
.settings-actions { display: flex; align-items: center; gap: 14px; margin: 4px 0 28px; }
.saved-flag { color: var(--green); font-size: 13px; }
code { background: var(--bg-2); padding: 1px 5px; border-radius: 5px; font-size: 12px; }

.run-card { max-width: 360px; }
.run-progress { margin-top: 12px; font-size: 12.5px; color: var(--muted); line-height: 1.8; min-height: 20px; }

/* ---------------- Modal ---------------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(4, 4, 8, .72); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; animation: fade .15s; }
.modal-overlay[hidden] { display: none; }
[hidden] { display: none !important; }
.modal { width: min(640px, 92vw); max-height: 88vh; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.modal.modal-wide { width: min(780px, 94vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.modal-body { padding: 20px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; font-size: 13px; margin-bottom: 16px; align-items: center; }
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }
.kv .v select { width: auto; min-width: 170px; }
.email-box { background: var(--bg-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; font-size: 13px; line-height: 1.6; }

/* ---------------- Toast ---------------- */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-2); border: 1px solid var(--border); color: var(--text); padding: 12px 20px; border-radius: 10px; box-shadow: var(--shadow); z-index: 80; font-size: 13px; animation: fade .2s; max-width: 80vw; }
.toast.ok { border-color: rgba(52, 211, 153, .4); }
.toast.err { border-color: rgba(248, 113, 113, .4); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
}
@media (max-width: 980px) {
  .cards-row { grid-template-columns: 1fr; }
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .kanban { grid-template-columns: 1fr; }
  .reply-main { grid-template-columns: 90px 1fr 80px; }
  .reply-sub { display: none; }
  .sidebar { width: 62px; padding: 18px 8px; }
  .brand-text, .nav-item .lbl, .engine-chip, .nav-group { display: none; }
  .nav-item { justify-content: center; padding: 12px 0; }
  .brand { justify-content: center; padding: 6px 0 22px; }
}

/* ---------------- Multi-account: user chip, impersonation, accounts page ---------------- */
.user-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--panel); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 8px;
}
.user-chip-info { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.user-chip-info strong { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-info span { font-size: 10px; color: var(--muted-2); text-transform: uppercase; letter-spacing: 1.2px; }

.impersonation-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(90deg, rgba(255, 159, 67, .16), rgba(255, 159, 67, .06));
  border-bottom: 1px solid rgba(255, 159, 67, .35);
  color: var(--yellow); padding: 9px 22px; font-size: 13px;
}
.impersonation-banner .btn {
  border: 1px solid rgba(255, 159, 67, .5); color: var(--yellow); background: transparent;
}
.impersonation-banner .btn:hover { background: rgba(255, 159, 67, .12); }

.acct-actions { display: flex; gap: 6px; white-space: nowrap; }
.acct-inactive td { opacity: .5; }

/* Client view: hide every admin-only control; reveal client-only hints. */
body.client-view [data-admin] { display: none !important; }
.client-only { display: none; }
body.client-view .client-only { display: block; }
