:root {
  --sc-bg:          #f5f6f8;
  --sc-sidebar:     #ffffff;
  --sc-card:        #ffffff;
  --sc-border:      #e4e9f4;
  --sc-accent:      #7c6fcd;
  --sc-accent-bg:   #f0eeff;
  --sc-accent2:     #f472b6;
  --sc-text:        #1e1b3a;
  --sc-muted:       #6b7280;
  --sc-heading:     #0f0c29;
}

body.sc-body {
  background: var(--sc-bg);
  color: var(--sc-text);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: 230px;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background: var(--sc-sidebar);
  border-right: 1px solid var(--sc-border);
  flex-shrink: 0;
  box-shadow: 2px 0 8px rgba(124,111,205,.06);
}

.sidebar .brand-text { color: var(--sc-heading); }
.sidebar .brand-accent { color: var(--sc-accent); }

.sidebar .nav-link {
  color: var(--sc-muted);
  border-radius: 8px;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  transition: background .15s, color .15s;
}
.sidebar .nav-link:hover {
  background: var(--sc-accent-bg);
  color: var(--sc-accent);
}
.sidebar .nav-link.active {
  background: var(--sc-accent-bg);
  color: var(--sc-accent);
  font-weight: 600;
}
.sidebar .user-email { color: var(--sc-muted); }

/* ── Cards ───────────────────────────────────── */
.sc-card {
  background: var(--sc-card);
  border: 1px solid var(--sc-border);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 4px rgba(124,111,205,.07);
}

/* ── Stat cards ──────────────────────────────── */
.stat-card-purple { border-top: 3px solid #a78bfa; }
.stat-card-pink   { border-top: 3px solid #f472b6; }
.stat-card-teal   { border-top: 3px solid #34d399; }
.stat-card-amber  { border-top: 3px solid #fbbf24; }

.stat-label { color: var(--sc-muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .4rem; }
.stat-value { color: var(--sc-heading); font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.03em; }

/* ── Stat badges ─────────────────────────────── */
.stat-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
}
.stat-badge-blue  { background: #dbeafe; color: #2563eb; }
.stat-badge-green { background: #d1fae5; color: #059669; }
.stat-badge-red   { background: #fee2e2; color: #dc2626; }
.stat-badge-amber { background: #fef3c7; color: #d97706; }
.stat-badge-purple{ background: #ede9fe; color: #7c3aed; }

/* ── Accent button ───────────────────────────── */
.btn-accent {
  background: var(--sc-heading);
  color: #fff;
  border: none;
}
.btn-accent:hover { background: #2a2650; color: #fff; }

.text-accent { color: var(--sc-accent) !important; }
.text-heading { color: var(--sc-heading); }

/* ── Secondary button (outline) ──────────────── */
.btn-secondary-sc {
  background: transparent;
  color: var(--sc-heading);
  border: 1.5px solid var(--sc-border);
  border-radius: 8px;
  padding: .35rem .9rem;
  font-weight: 500;
  font-size: .875rem;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.btn-secondary-sc:hover {
  background: var(--sc-bg);
  border-color: var(--sc-accent);
  color: var(--sc-heading);
}

/* ── Tables ──────────────────────────────────── */
.sc-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.sc-table th {
  background: #fafbff;
  color: var(--sc-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--sc-border);
}
.sc-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--sc-border);
  font-size: 0.875rem;
  vertical-align: middle;
  color: var(--sc-text);
}
.sc-table tr:last-child td { border-bottom: none; }
.sc-table tbody tr:hover td { background: #fafbff; }
.sc-table tbody tr.sc-row-active td { background: #f0f4ff; }

/* ── Matrix heat cells ───────────────────────── */
.heat-0 { background: #f5f3ff; }
.heat-1 { background: #ddd6fe; color: #4c1d95; }
.heat-2 { background: #c4b5fd; color: #3b0764; }
.heat-3 { background: #a78bfa; color: #fff; }
.heat-4 { background: #7c3aed; color: #fff; }

/* ── Auth pages ──────────────────────────────── */
.auth-wrap  { max-width: 420px; margin: 80px auto; }
.auth-card  {
  background: var(--sc-card);
  border: 1px solid var(--sc-border);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: 0 4px 24px rgba(124,111,205,.12);
}
.auth-card .form-control {
  border-color: var(--sc-border);
  color: var(--sc-text);
  background: #fff;
}
.auth-card .form-control:focus {
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(124,111,205,.18);
}
.auth-card label { color: var(--sc-muted); font-size: .85rem; }
.btn-primary {
  background: var(--sc-heading);
  border-color: var(--sc-heading);
}
.btn-primary:hover { background: #2a2650; border-color: #2a2650; }

/* ── Urgency bar ─────────────────────────────── */
.urgency-bar {
  height: 6px;
  border-radius: 3px;
  background: #e4e9f4;
  overflow: hidden;
}
.urgency-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #a78bfa, #f472b6);
}

/* ── Modal light theme ───────────────────────── */
.modal-content {
  background: #fff;
  border-color: var(--sc-border);
  color: var(--sc-text);
  border-radius: 14px;
}
.modal-header {
  border-bottom-color: var(--sc-border);
  background: #fafbff;
  border-radius: 14px 14px 0 0;
}
.modal-title { color: var(--sc-heading); font-weight: 600; }
.modal .nav-tabs { border-bottom-color: var(--sc-border); }
.modal .nav-tabs .nav-link {
  color: var(--sc-muted);
  background: transparent;
  border-color: transparent;
}
.modal .nav-tabs .nav-link:hover { color: var(--sc-accent); border-color: transparent; }
.modal .nav-tabs .nav-link.active {
  color: var(--sc-accent);
  font-weight: 600;
  border-color: var(--sc-border) var(--sc-border) #fff;
}
.modal .form-label { color: var(--sc-muted); font-size: .85rem; }
.modal .form-control { border-color: var(--sc-border); color: var(--sc-text); }
.modal .form-control:focus {
  border-color: var(--sc-accent);
  box-shadow: 0 0 0 3px rgba(124,111,205,.15);
}
.modal .form-check-label { color: var(--sc-muted); }
.modal .form-check-input:checked {
  background-color: var(--sc-accent);
  border-color: var(--sc-accent);
}

/* ── Page header ─────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--sc-heading);
  margin: 0;
  letter-spacing: -.02em;
}
.page-header p { color: var(--sc-muted); font-size: .875rem; margin: .2rem 0 0; }

/* ── Heading hierarchy ───────────────────────── */
h2, .h2 { font-size: 1.35rem; font-weight: 600; color: var(--sc-heading); }
h3, .h3 { font-size: 1.1rem;  font-weight: 600; color: var(--sc-heading); }
.modal-title { font-size: 1.1rem; font-weight: 600; color: var(--sc-heading); }

/* ── Card section header ─────────────────────── */
.card-header-sc {
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--sc-border);
  background: #fafbff;
  border-radius: 12px 12px 0 0;
  font-size: .875rem;
  font-weight: 600;
  color: var(--sc-heading);
}

/* ── Timeline calendar widget ────────────────── */
.tl-cal-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.tl-cal-month {
  background: var(--sc-card);
  border: 1px solid var(--sc-border);
  border-radius: 12px;
  padding: .75rem 1rem 1rem;
  min-width: 220px;
  flex: 1 1 220px;
  max-width: 280px;
  box-shadow: 0 1px 4px rgba(124,111,205,.06);
}
.tl-cal-month-name {
  font-size: .78rem;
  font-weight: 700;
  color: var(--sc-heading);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .55rem;
}
.tl-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.tl-cal-dow {
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sc-muted);
  text-align: center;
  padding-bottom: .3rem;
}
.tl-cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 5px;
  padding: 2px 1px 3px;
  min-height: 34px;
  gap: 2px;
}
.tl-cal-day-active {
  cursor: pointer;
  background: var(--sc-bg);
}
.tl-cal-day-active:hover {
  background: rgba(124,111,205,.1);
}
.tl-cal-day-out .tl-cal-day-num {
  opacity: .2;
}
.tl-cal-day-num {
  font-size: .68rem;
  font-weight: 600;
  color: var(--sc-heading);
  line-height: 1;
}
.tl-cal-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
}
.tl-cal-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  flex-shrink: 0;
}
.tl-grid-date-highlight {
  background: rgba(124,111,205,.18) !important;
  transition: background .3s;
}

/* ── Timeline grid (column per brand) ────────── */
.tl-grid {
  display: grid;
  border: 1px solid var(--sc-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--sc-card);
  box-shadow: 0 1px 4px rgba(124,111,205,.07);
}
.tl-grid-date-hdr {
  background: #fafbff;
  padding: .6rem .5rem;
  border-bottom: 2px solid var(--sc-border);
  font-size: .65rem;
  font-weight: 700;
  color: var(--sc-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.tl-grid-brand-hdr {
  background: #fafbff;
  padding: .6rem .75rem;
  border-bottom: 2px solid var(--sc-border);
  border-left: 1px solid var(--sc-border);
  font-size: .8rem;
  font-weight: 700;
  color: var(--sc-heading);
  display: flex;
  align-items: center;
  gap: .4rem;
  overflow: hidden;
}
.tl-grid-date-cell {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--sc-border);
  background: #fafbff;
  line-height: 1.2;
  text-align: center;
}
.tl-grid-month {
  font-size: .6rem;
  text-transform: uppercase;
  color: var(--sc-muted);
  font-weight: 600;
  letter-spacing: .04em;
}
.tl-grid-day {
  font-size: .82rem;
  font-weight: 700;
  color: var(--sc-heading);
}
.tl-grid-date-empty .tl-grid-month,
.tl-grid-date-empty .tl-grid-day {
  opacity: .35;
}
.tl-grid-cell {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--sc-border);
  border-left: 1px solid var(--sc-border);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.tl-grid-no-send {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
}
.tl-dot-empty {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--sc-border);
  display: inline-block;
  opacity: .5;
}
.tl-grid-card {
  display: block;
  background: var(--sc-bg);
  border: 1px solid var(--sc-border);
  border-radius: 8px;
  padding: .5rem .6rem;
  transition: box-shadow .15s, background .15s;
}
.tl-grid-card:hover {
  background: #fff;
  box-shadow: 0 2px 10px rgba(124,111,205,.13);
}
.tl-grid-time {
  font-size: .65rem;
  margin-bottom: .2rem;
}
.tl-grid-subject {
  font-size: .78rem;
  font-weight: 600;
  color: var(--sc-heading);
  line-height: 1.35;
  margin-bottom: .3rem;
}
.tl-metrics {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.tl-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 28px;
}
.tl-metric-label {
  font-size: .6rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sc-muted);
  font-weight: 600;
}
.tl-metric-val {
  font-size: .75rem;
  font-weight: 700;
  color: var(--sc-heading);
}

.tl-brand-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Email card grid (timeline cards view) ───── */
.email-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.email-card {
  background: #fff;
  border: 1px solid var(--sc-border);
  border-top: 3px solid var(--brand-color, var(--sc-accent));
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: 0 0 0 0;
  box-shadow: 0 1px 4px rgba(124,111,205,.07);
  transition: box-shadow .15s, transform .15s;
  position: relative;
}
.email-card:hover {
  box-shadow: 0 6px 20px rgba(124,111,205,.14);
  transform: translateY(-2px);
}
.ec-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem .6rem;
  border-bottom: 1px solid var(--sc-border);
}
.ec-brand-pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ec-datetime {
  font-size: .72rem;
  text-align: right;
  line-height: 1.3;
  flex-shrink: 0;
}
.email-card .ec-subject {
  font-size: .88rem;
  font-weight: 600;
  color: var(--sc-heading);
  line-height: 1.4;
  padding: 0 1rem;
}
.email-card .ec-metric-lbl {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--sc-muted);
  font-weight: 600;
  flex-shrink: 0;
}
.email-card .ec-metric-val {
  font-size: .8rem;
  font-weight: 700;
  color: var(--sc-heading);
  flex-shrink: 0;
}
.email-card .d-flex.align-items-center.gap-2.mb-2 {
  padding: 0 1rem;
}
.ec-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: 0 1rem;
}
.ec-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--sc-bg);
  border: 1px solid var(--sc-border);
  border-radius: 6px;
  padding: 2px 7px;
  font-size: .72rem;
  color: var(--sc-muted);
  font-weight: 500;
}
.ec-chip i { font-size: .7rem; }
.ec-chip-purple { background: #ede9fe; border-color: #c4b5fd; color: #6d28d9; }
.ec-colors {
  display: flex;
  gap: 4px;
  padding: 0 1rem;
  flex-wrap: wrap;
}
.ec-color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,.08);
  flex-shrink: 0;
}
.email-card .d-flex.flex-wrap.gap-1.mt-2 {
  padding: 0 1rem;
}
.ec-bottom-bar {
  height: 3px;
  width: 100%;
  margin-top: auto;
  flex-shrink: 0;
  opacity: .5;
}

/* ── Compare table ───────────────────────────── */
.compare-table {
  border-collapse: separate;
  border-spacing: 0;
}
.compare-table th {
  padding: .875rem 1.25rem;
  text-align: center;
  border-bottom: 1px solid var(--sc-border);
  font-size: .8rem;
  background: #fafbff;
  font-weight: 600;
  white-space: nowrap;
}
.compare-table td {
  padding: .65rem 1.25rem;
  border-bottom: 1px solid var(--sc-border);
  font-size: .875rem;
  vertical-align: middle;
  color: var(--sc-text);
}
.compare-table tbody tr:last-child td { border-bottom: none; }
.compare-table tbody tr:hover td { background: #fafbff; }
.compare-metric-lbl {
  text-align: left !important;
  color: var(--sc-muted) !important;
  font-size: .75rem !important;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  min-width: 140px;
  background: #fafbff !important;
}
.compare-winner {
  background: var(--sc-accent-bg) !important;
  color: var(--sc-accent) !important;
  font-weight: 700;
}
.compare-winner-pill {
  color: var(--sc-accent);
  font-size: .7rem;
}

/* ── Mobile sidebar ──────────────────────────── */
.sc-topbar {
  display: none;
  height: 52px;
  background: #fff;
  border-bottom: 1px solid var(--sc-border);
  position: sticky;
  top: 0;
  z-index: 200;
  flex-shrink: 0;
  align-items: center;
}
.sc-hamburger {
  background: none;
  border: none;
  padding: 6px 8px;
  color: var(--sc-heading);
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
}
.sc-hamburger:hover { background: var(--sc-accent-bg); }
.sc-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,12,41,.45);
  z-index: 299;
  opacity: 0;
  transition: opacity .2s;
}
.sc-backdrop-show {
  opacity: 1;
}
@media (max-width: 767px) {
  .sc-topbar { display: flex !important; }
  #wrapper { display: block !important; }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: none;
  }
  .sidebar.sc-sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(15,12,41,.18);
  }
  .sc-sidebar-backdrop { display: block; }
  #page-content { padding: 1rem !important; }
}

/* ── Icon buttons (accessible, hit-target sized) */
.sc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: .9rem;
  transition: background .12s, color .12s;
  text-decoration: none;
  padding: 0;
}
.sc-icon-btn:hover { background: var(--sc-accent-bg); }
.sc-icon-btn:focus-visible {
  outline: 2px solid var(--sc-accent);
  outline-offset: 2px;
}

/* ── Card-header action row: bigger touch targets  */
.card-header-sc .btn-accent {
  min-height: 30px;
  padding: 0 0.6rem;
  display: inline-flex;
  align-items: center;
  font-size: .8rem;
}
.card-header-sc a.text-accent {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  font-size: .8rem;
}

/* ── Misc ────────────────────────────────────── */
.border-sc { border-color: var(--sc-border) !important; }
a { color: var(--sc-accent); }
a:hover { color: #6a5ec4; }
code { color: var(--sc-accent2); background: #fff0f7; padding: 1px 5px; border-radius: 4px; }

/* ── Admin email calendar ────────────────────── */
.cal-grid-months {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.cal-month-card { overflow: hidden; }
.cal-month-name {
  padding: .5rem .75rem;
  font-weight: 600;
  font-size: .8rem;
  color: var(--sc-heading);
  border-bottom: 1px solid var(--sc-border);
  background: var(--sc-surface-2);
}
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 6px;
}
.cal-dow {
  text-align: center;
  font-size: .65rem;
  font-weight: 600;
  color: var(--sc-muted);
  padding: 2px 0 4px;
}
.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  cursor: default;
  min-height: 30px;
}
.cal-day-num {
  font-size: .7rem;
  line-height: 1;
  color: var(--sc-text);
}
.cal-day-out .cal-day-num { color: var(--sc-border); }
.cal-day-count {
  font-size: .62rem;
  font-weight: 700;
  line-height: 1;
  margin-top: 1px;
}
.cal-day-active {
  background: rgba(124, 111, 205, calc(0.12 + var(--h, 0) * 0.0068));
  cursor: default;
}
.cal-day-active .cal-day-num  { color: var(--sc-heading); }
.cal-day-active .cal-day-count {
  color: rgb(calc(124 - var(--h, 0) * 0.3), calc(111 - var(--h, 0) * 0.3), 205);
}
.cal-day-today {
  box-shadow: inset 0 0 0 2px #f97316;
}
.cal-day-today .cal-day-num { color: #f97316; font-weight: 700; }
/* Legend swatches */
.cal-heat-swatch {
  width: 16px; height: 16px; border-radius: 3px;
  background: rgba(124, 111, 205, calc(0.12 + var(--h, 0) * 0.0068));
  border: 1px solid var(--sc-border);
  display: inline-block;
}
.cal-today-swatch {
  width: 16px; height: 16px; border-radius: 3px;
  box-shadow: inset 0 0 0 2px #f97316;
  display: inline-block;
}

/* ── Impersonation banner ────────────────────── */
.impersonation-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  background: #fff7ed;
  border: 1px solid #f97316;
  border-radius: 8px;
  padding: .6rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .875rem;
  color: #9a3412;
}
.impersonation-bar strong { color: #7c2d12; }
#wrapper:has(.impersonation-bar) .sidebar {
  border-right-color: #f97316;
}
