/* ── nRev.ai Brand Colors ── */
:root {
  --purple:       #9333ea;
  --purple-med:   #7F44C8;
  --purple-dark:  #6733a8;
  --purple-light: #f3e8ff;
  --purple-50:    #faf5ff;
  --orange:       #fa6d32;
  --orange-light: #fff3ed;
  --heading:      #221e2d;
  --body:         #534e62;
  --border:       #ece4f5;
  --gray-50:      #fafaf9;
  --gray-100:     #f5f5f4;
  --gray-200:     #e7e5e4;
  --gray-400:     #a8a29e;
  --white:        #ffffff;
  --green:        #22c55e;
  --green-light:  #dcfce7;
  --blue:         #3b82f6;
  --red:          #ef4444;
  --red-light:    #fee2e2;
  --sidebar-w:    240px;
  --topbar-h:     54px;
  --radius:       10px;
  --shadow:       0 1px 3px rgba(34,30,45,.07), 0 4px 12px rgba(34,30,45,.05);
}

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

html, body {
  height: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--gray-50);
  color: var(--body);
  font-size: 13.5px;
}

/* ── Layout ── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
}
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ── Sidebar ── */
.sidebar-logo {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 16px 14px; border-bottom: 1px solid var(--border);
}
.logo-text { font-size: 16px; font-weight: 800; color: var(--heading); letter-spacing: -.4px; }
.sidebar-nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 7px;
  color: var(--body); text-decoration: none;
  font-weight: 500; font-size: 13px;
  transition: background .12s, color .12s;
  margin-bottom: 1px; cursor: pointer;
}
.nav-item:hover { background: var(--purple-50); color: var(--purple); }
.nav-item.active { background: var(--purple-light); color: var(--purple); font-weight: 700; }
.nav-item svg { flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 20px;
  background: var(--gray-100); color: var(--body);
}
.nav-badge.orange { background: var(--orange-light); color: var(--orange); }
.nav-badge.green  { background: var(--green-light);  color: #16a34a; }
.sidebar-footer { padding: 14px 14px 18px; border-top: 1px solid var(--border); }
.campaign-pill {
  font-size: 12px; font-weight: 700;
  background: var(--purple-light); color: var(--purple);
  padding: 5px 10px; border-radius: 20px; margin-bottom: 8px; display: inline-block;
}
.sidebar-meta { font-size: 11.5px; color: var(--gray-400); }

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 16px; font-weight: 800; color: var(--heading); }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.source-badge {
  display: flex; align-items: center; gap: 5px;
  font-size: 11.5px; color: var(--green); font-weight: 600;
  background: var(--green-light); padding: 4px 10px; border-radius: 20px;
}
.date-badge { font-size: 12px; color: var(--gray-400); background: var(--gray-100); padding: 4px 10px; border-radius: 20px; }

/* ── Topbar action buttons ── */
.settings-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--white);
  color: var(--body); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s, color .12s;
}
.settings-btn:hover { border-color: #22c55e; color: #16a34a; background: var(--green-light); }
.sheet-sync-badge { color: #22c55e; font-size: 10px; margin-left: 2px; }

/* ── Settings Modal ── */
.settings-overlay {
  position: fixed; inset: 0; background: rgba(34,30,45,.45);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.settings-modal {
  background: var(--white); border-radius: 14px; width: 480px; max-width: 95vw;
  box-shadow: 0 8px 40px rgba(34,30,45,.18); overflow: hidden;
}
.settings-modal-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  background: var(--gray-50);
}
.modal-close-btn {
  background: none; border: none; cursor: pointer;
  font-size: 16px; color: var(--gray-400); padding: 2px 6px; border-radius: 5px;
  transition: background .12s;
}
.modal-close-btn:hover { background: var(--gray-100); color: var(--heading); }
.settings-body { padding: 20px; display: flex; flex-direction: column; gap: 0; }
.settings-section {
  padding: 16px 0; border-bottom: 1px solid var(--border);
}
.settings-section:last-of-type { border-bottom: none; }
.settings-section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--gray-400); margin-bottom: 10px;
}
.composio-status-row { display: flex; align-items: center; gap: 8px; }
.status-dot {
  width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0;
  transition: background .3s;
}
.status-dot.active  { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
.status-dot.pending { background: var(--orange); box-shadow: 0 0 0 3px rgba(250,109,50,.15); }
.status-dot.loading { background: var(--gray-400); animation: pulse 1s infinite; }
.status-dot.error   { background: var(--red); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

.auth-link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 7px;
  background: var(--green-light); border: 1px solid #86efac;
  color: #16a34a; font-size: 12.5px; font-weight: 600;
  text-decoration: none; cursor: pointer; font-family: inherit;
  transition: background .12s;
}
.auth-link-btn:hover { background: #dcfce7; }
.change-account-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 7px;
  background: #fef3c7; border: 1px solid #fcd34d;
  color: #92400e; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s;
}
.change-account-btn:hover { background: #fde68a; }
.check-status-btn {
  padding: 7px 12px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--white); color: var(--body); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s;
}
.check-status-btn:hover { background: var(--gray-100); }
.search-sheet-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 7px;
  background: var(--purple-light); border: 1px solid var(--border);
  color: var(--purple); font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: inherit; transition: background .12s;
}
.search-sheet-btn:hover { background: #e9d5ff; }
.search-result-lbl { font-size: 12px; color: #16a34a; font-weight: 500; align-self: center; }
.settings-label { font-size: 12px; font-weight: 600; color: var(--body); margin-bottom: 5px; }
.settings-hint { font-size: 11.5px; color: var(--gray-400); line-height: 1.5; }
.settings-input {
  width: 100%; border: 1px solid var(--border); border-radius: 7px;
  padding: 8px 11px; font-family: inherit; font-size: 13px;
  color: var(--heading); outline: none; margin-top: 6px;
}
.settings-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(147,51,234,.08); }
.settings-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px 20px; border-top: 1px solid var(--border);
}
.settings-cancel-btn {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--white); color: var(--body); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.settings-save-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px; border: none;
  background: var(--purple); color: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: background .12s;
}
.settings-save-btn:hover { background: var(--purple-dark); }

/* ── Upload button ── */
.upload-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: 1.5px dashed var(--border); border-radius: 20px;
  background: var(--white); font-family: inherit; font-size: 11.5px; font-weight: 700;
  color: var(--purple); cursor: pointer; transition: all .12s; white-space: nowrap;
}
.upload-btn:hover { border-color: var(--purple); background: var(--purple-light); }

/* ── Sync controls ── */
.sync-wrap { display: flex; align-items: center; gap: 8px; }
.sync-time-ago {
  font-size: 10.5px; font-weight: 500; opacity: .75;
  padding-left: 6px; margin-left: 2px; border-left: 1px solid rgba(22,163,74,.35);
}
.sync-countdown { font-size: 11.5px; color: var(--gray-400); white-space: nowrap; }
.sync-countdown strong { color: var(--body); }
.sync-btn {
  padding: 4px 11px; border: 1px solid var(--border); border-radius: 20px;
  background: var(--white); font-family: inherit; font-size: 11.5px; font-weight: 600;
  color: var(--body); cursor: pointer; transition: all .12s; white-space: nowrap;
}
.sync-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-light); }
.sync-btn:disabled { opacity: .55; cursor: not-allowed; }
.source-badge.syncing { animation: syncPulse 1.1s ease-in-out infinite; }
@keyframes syncPulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── Pages ── */
.page { display: none; padding: 20px 24px; flex: 1; animation: fadeIn .18s ease; }
.page.active { display: block; }
.page-inbox { padding: 0 !important; overflow: hidden; }
@keyframes fadeIn { from { opacity:0; transform:translateY(5px); } to { opacity:1; transform:none; } }
.page-note {
  display: flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; margin-bottom: 16px;
}
.readonly-note { background: var(--gray-100); color: var(--body); border: 1px solid var(--gray-200); }
.editable-note { background: #fefce8; color: #854d0e; border: 1px solid #fef08a; }
.editable-note strong { color: #713f12; }

/* ── Card ── */
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.card-hdr { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-hdr h3 { font-size: 14px; font-weight: 700; color: var(--heading); }
.sub-label { font-size: 11.5px; color: var(--gray-400); }
.muted { font-size: 12px; font-weight: 400; color: var(--gray-400); }

/* ── KPI Row ── */
.kpi-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px; }
.kpi-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.kpi-label { font-size: 12px; color: var(--body); margin-bottom: 6px; font-weight: 500; }
.kpi-val { font-size: 26px; font-weight: 800; color: var(--heading); line-height: 1; margin-bottom: 4px; }
.kpi-sub { font-size: 11.5px; color: var(--gray-400); }
.accent-purple { color: var(--purple); }
.accent-green  { color: #16a34a; }
.accent-orange { color: var(--orange); }

/* ── Dash Grid ── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Outreach Funnel (fixed horizontal bar chart) ── */
.funnel { display: flex; flex-direction: column; gap: 11px; padding-top: 4px; }
.funnel-row {
  display: grid;
  grid-template-columns: 100px 1fr 70px;
  align-items: center;
  gap: 10px;
}
.funnel-lbl { font-size: 12px; font-weight: 600; color: var(--body); text-align: right; }
.funnel-track {
  height: 30px; background: var(--gray-100); border-radius: 6px; overflow: hidden;
}
.funnel-fill { height: 100%; border-radius: 6px; min-width: 4px; }
.funnel-val-r { font-size: 13px; font-weight: 800; color: var(--heading); white-space: nowrap; min-width: 90px; }
.funnel-val-r .pct {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  color: #fff;
  background: var(--purple);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: 4px;
  letter-spacing: .02em;
  vertical-align: middle;
}
.funnel-val-r .pct.orange { background: var(--orange); }
.funnel-val-r .pct.muted   { background: var(--gray-400); }

/* ── Insight Bars ── */
.insight-bars { display: flex; flex-direction: column; gap: 10px; }
.insight-row { display: flex; align-items: center; gap: 12px; }
.insight-label { font-size: 12.5px; color: var(--body); width: 200px; flex-shrink: 0; }
.insight-track { flex: 1; height: 8px; background: var(--gray-100); border-radius: 99px; overflow: hidden; }
.insight-fill { height: 100%; background: var(--purple); border-radius: 99px; }
.insight-count { font-size: 12.5px; font-weight: 700; color: var(--heading); width: 32px; text-align: right; }

/* ── Log Stats ── */
.log-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.log-stat-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-align: center;
}
.log-stat-val { font-size: 28px; font-weight: 800; color: var(--heading); }
.log-stat-label { font-size: 12px; color: var(--gray-400); margin-top: 3px; }

/* ── Data Tables ── */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
.data-table thead th {
  background: var(--gray-50); padding: 9px 12px; text-align: left;
  font-weight: 600; color: var(--body); border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.data-table tbody tr { border-bottom: 1px solid var(--border); }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: var(--purple-50); }
.data-table tbody td { padding: 9px 12px; color: var(--heading); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
}
.badge-yes   { background: var(--green-light); color: #16a34a; }
.badge-no    { background: var(--gray-100);    color: var(--gray-400); }
.badge-sent  { background: var(--purple-light);color: var(--purple); }
.badge-sched { background: #fefce8;             color: #854d0e; }
.badge-reply { background: var(--green-light); color: #16a34a; }
.thread-link { font-size: 11.5px; color: var(--purple); text-decoration: none; font-weight: 600; }
.thread-link:hover { text-decoration: underline; }
.profile-link {
  color: var(--purple); text-decoration: none; font-weight: 500; font-size: 12.5px;
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}
.profile-link:hover { text-decoration: underline; }

/* ── Selects ── */
.sel {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--white); font-family: inherit; font-size: 12.5px; color: var(--heading); outline: none; cursor: pointer;
}
.sel:focus { border-color: var(--purple); }
.sel.sm { font-size: 12px; padding: 5px 8px; }

/* ── Message Queue search ── */
.queue-search-wrap {
  position: relative; display: flex; align-items: center;
  margin-bottom: 16px;
}
.queue-search-ico {
  position: absolute; left: 12px; color: var(--gray-400); pointer-events: none; flex-shrink: 0;
}
.queue-search {
  width: 100%; padding: 9px 36px 9px 34px;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13px; color: var(--heading); outline: none;
  background: var(--white); transition: border-color .12s;
}
.queue-search:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(147,51,234,.1); }
.queue-search-clear {
  position: absolute; right: 12px; font-size: 12px; color: var(--gray-400);
  cursor: pointer; display: none; padding: 2px 4px;
}
.queue-search-clear:hover { color: var(--heading); }
.queue-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 48px; color: var(--gray-400); text-align: center;
}
.queue-empty svg { opacity: .3; }
.queue-empty p { font-size: 14px; font-weight: 500; }

/* ── Message Queue contacts ── */
.queue-contacts { display: flex; flex-direction: column; gap: 20px; }
.contact-block {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.contact-block-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 18px;
  background: var(--purple-50); border-bottom: 1px solid var(--border);
}
.contact-avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--purple); color: #fff;
  font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.contact-name { font-weight: 700; font-size: 14px; color: var(--heading); }
.contact-meta { font-size: 12px; color: var(--gray-400); }
.contact-replied {
  margin-left: auto; background: var(--green-light); color: #16a34a;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
}
.msg-steps { display: flex; flex-direction: column; overflow-x: auto; }
.msg-step-row {
  display: grid;
  grid-template-columns: 60px 120px 130px 140px 1fr 130px;
  gap: 0; border-bottom: 1px solid var(--border); align-items: start;
  min-width: 700px;
}
.msg-step-row:last-child { border-bottom: none; }
.msg-step-row > * { padding: 12px 14px; border-right: 1px solid var(--border); font-size: 12.5px; }
.msg-step-row > *:last-child { border-right: none; }
.step-num { font-weight: 800; font-size: 14px; color: var(--purple); display: flex; align-items: center; justify-content: center; }
.step-label { font-size: 11px; font-weight: 500; color: var(--gray-400); margin-bottom: 2px; }
.step-val { font-size: 12.5px; color: var(--heading); }
.msg-body-cell { display: flex; flex-direction: column; gap: 8px; }
.msg-body-ro {
  font-size: 12.5px; color: var(--heading); line-height: 1.6;
  background: var(--gray-50); border-radius: 6px; padding: 10px 12px;
  border: 1px solid var(--border); white-space: pre-wrap;
}
.msg-body-editable {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--purple);
  border-radius: 7px; font-family: inherit; font-size: 12.5px;
  color: var(--heading); line-height: 1.6; resize: vertical; outline: none;
  background: #fff; transition: box-shadow .15s;
}
.msg-body-editable:focus { box-shadow: 0 0 0 3px rgba(147,51,234,.15); }
.edit-indicator { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; color: var(--purple); }
.edit-dot { width: 6px; height: 6px; background: var(--purple); border-radius: 50%; }
.save-btn {
  padding: 5px 14px; border: none; border-radius: 6px; background: var(--purple); color: #fff;
  font-family: inherit; font-size: 12px; font-weight: 700; cursor: pointer; transition: background .12s;
}
.save-btn:hover { background: var(--purple-dark); }
.saved-badge {
  font-size: 11px; font-weight: 700; color: #16a34a;
  background: var(--green-light); padding: 3px 9px; border-radius: 20px; display: none;
}

/* ── Unified Inbox ── */
.inbox-layout { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--topbar-h)); overflow: hidden; background: var(--white); }
.inbox-sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; background: var(--white); }
.inbox-sidebar-hdr { padding: 12px 14px 10px; border-bottom: 1px solid var(--border); background: var(--gray-50); flex-shrink: 0; }
.inbox-filter-tabs { display: flex; gap: 4px; margin-bottom: 10px; }
.inbox-tab {
  flex: 1; padding: 5px 6px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--white); font-family: inherit; font-size: 11.5px; font-weight: 600; color: var(--body);
  cursor: pointer; transition: all .12s; display: flex; align-items: center; justify-content: center; gap: 4px;
}
.inbox-tab.active { background: var(--purple); color: #fff; border-color: var(--purple); }
.inbox-tab:not(.active):hover { border-color: var(--purple); color: var(--purple); }
.inbox-tab-count { font-size: 10px; font-weight: 800; background: rgba(255,255,255,.25); padding: 0 4px; border-radius: 20px; }
.inbox-tab:not(.active) .inbox-tab-count { background: var(--gray-100); color: var(--gray-400); }
.inbox-search-wrap { position: relative; }
.inbox-search-ico { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.inbox-search { width: 100%; padding: 7px 10px 7px 28px; border: 1px solid var(--border); border-radius: 7px; font-family: inherit; font-size: 12.5px; outline: none; background: var(--white); }
.inbox-search:focus { border-color: var(--purple); }
.inbox-contact-list { flex: 1; overflow-y: auto; }
.inbox-contact-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .1s; border-left: 3px solid transparent;
}
.inbox-contact-item:hover { background: var(--purple-50); }
.inbox-contact-item.active { background: var(--purple-50); border-left-color: var(--purple); }
.inbox-av { width: 36px; height: 36px; border-radius: 50%; background: var(--purple); color: #fff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.inbox-av.lg { width: 40px; height: 40px; font-size: 14px; }
.inbox-ci { flex: 1; min-width: 0; }
.inbox-ci-name { font-weight: 700; font-size: 13px; color: var(--heading); }
.inbox-ci-preview { font-size: 11.5px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.inbox-ci-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.inbox-ci-date { font-size: 10.5px; color: var(--gray-400); }
.inbox-conversation { display: flex; flex-direction: column; overflow: hidden; background: var(--gray-50); }
.inbox-conv-hdr { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); background: var(--white); flex-shrink: 0; min-height: 68px; }
.inbox-conv-name { font-weight: 700; font-size: 15px; color: var(--heading); }
.inbox-conv-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.inbox-empty-state { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; color: var(--gray-400); }
.inbox-empty-state svg { opacity: .3; flex-shrink: 0; }
.inbox-empty-state p { font-size: 13px; font-weight: 500; }
.inbox-messages { flex: 1; overflow-y: auto; padding: 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.inbox-msg-wrap { display: flex; flex-direction: column; max-width: 72%; }
.inbox-msg-wrap.out { align-self: flex-end; align-items: flex-end; }
.inbox-msg-wrap.in  { align-self: flex-start; align-items: flex-start; }
.inbox-msg-meta { display: flex; align-items: center; gap: 5px; margin-bottom: 5px; font-size: 11px; }
.inbox-step-lbl { background: var(--purple-light); color: var(--purple); font-size: 10.5px; font-weight: 700; padding: 2px 7px; border-radius: 20px; }
.inbox-msg-date { color: var(--gray-400); }
.inbox-msg-bubble { padding: 11px 15px; border-radius: 14px; font-size: 13px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }
.bubble-sent  { background: var(--purple); color: #fff; border-bottom-right-radius: 4px; }
.bubble-sched { background: #fefce8; color: #713f12; border: 1px dashed #fde047; border-bottom-right-radius: 4px; }
.bubble-recv  { background: var(--white); color: var(--heading); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.inbox-date-divider { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--gray-400); font-weight: 600; margin: 4px 0; }
.inbox-date-divider::before, .inbox-date-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Templates — fully editable ── */
.tpl-add-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.tpl-add-btn {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 16px; background: var(--white);
  border: 1.5px dashed var(--purple); border-radius: 8px;
  color: var(--purple); font-size: 13px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s;
}
.tpl-add-btn:hover { background: var(--purple-light); border-color: var(--purple-dark); }
.tpl-count-lbl { font-size: 12px; color: var(--gray-400); font-weight: 500; }
.tpl-empty { padding: 40px 20px; text-align: center; color: var(--gray-400); font-size: 13.5px; }

.templates-list { display: flex; flex-direction: column; gap: 14px; }
.template-card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.template-card-header {
  display: grid; grid-template-columns: 80px 80px 140px 1fr auto;
  gap: 12px; align-items: end;
  background: var(--purple-50); border-bottom: 1px solid var(--border); padding: 12px 16px;
}
.tpl-field-group { display: flex; flex-direction: column; gap: 4px; }
.tpl-step-label { font-size: 10px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .04em; }
.tpl-input {
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 9px; font-family: inherit; font-size: 13px;
  color: var(--heading); background: var(--white); outline: none; width: 100%;
}
.tpl-input:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(147,51,234,.08); }
.tpl-input-sm { max-width: 70px; }
.tpl-card-actions { display: flex; align-items: flex-end; padding-bottom: 1px; }
.tpl-delete-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 11px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--white);
  color: var(--red); font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .12s, border-color .12s;
}
.tpl-delete-btn:hover { background: var(--red-light); border-color: var(--red); }

.template-body-grid { display: grid; grid-template-columns: 1fr 1fr; }
.template-body-grid > div { padding: 14px 16px; border-right: 1px solid var(--border); }
.template-body-grid > div:last-child { border-right: none; }
.tpl-section-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; color: var(--gray-400); letter-spacing: .04em; margin-bottom: 6px; }
.tpl-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-family: inherit; font-size: 13px;
  color: var(--heading); line-height: 1.6; resize: vertical; outline: none;
}
.tpl-textarea:focus { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(147,51,234,.08); }
.tpl-footer {
  padding: 7px 16px; background: var(--gray-50);
  border-top: 1px solid var(--border); min-height: 32px;
  display: flex; align-items: center;
}
.tpl-saved-lbl { font-size: 12px; font-weight: 600; color: #16a34a; opacity: 0; transition: opacity .3s; }

/* ── Upload overlay ── */
.upload-overlay {
  position: fixed; inset: 0; background: rgba(34,30,45,.5);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.upload-modal {
  background: var(--white); border-radius: 14px; padding: 32px 40px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.upload-spinner {
  width: 40px; height: 40px; border: 3px solid var(--border);
  border-top-color: var(--purple); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-modal-title { font-size: 16px; font-weight: 700; color: var(--heading); }
.upload-modal-sub { font-size: 13px; color: var(--gray-400); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: #221e2d; color: #fff;
  padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px);
  transition: all .2s ease; pointer-events: none; z-index: 999;
}
.toast.show { opacity: 1; transform: none; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 200px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .inbox-layout { grid-template-columns: 240px 1fr; }
}
