/* ============================================================
   CommunicationLite — app.css
   Sections:
     1. Design tokens (CSS custom properties)
     2. Reset & base
     3. App shell (sidebar, topbar, content)
     4. Typography helpers
     5. Buttons
     6. Forms
     7. Cards & stat cards
     8. Tables & pagination
     9. Badges & chips
    10. Modals
    11. Toasts
    12. Login screen
    13. Wizard (campaign builder)
    14. Editor (email/SMS content)
    15. Rule builder
    16. Skeletons & empty states
    17. Misc components (tabs, dropdowns, progress, timeline)
    18. Responsive
    19. Animations & TKU dashboard components
   ============================================================ */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Brand (TKU official palette) — primary/secondary/accent are
     overwritten at runtime from tenant branding (store.js applyBranding) */
  --brand-primary: #491345;   /* --tku-purple */
  --brand-secondary: #6B3A68; /* --tku-purple-accent */
  --brand-accent: #B8893E;    /* --tku-gold — borders/accents only, never fills */

  --brand-primary-soft: #F0E6EF;   /* --tku-purple-pale */
  --brand-primary-softer: #f7f1f6;
  --brand-primary-hover: color-mix(in srgb, var(--brand-primary) 85%, black);

  /* Warm wine-tinted neutrals — no cool greys */
  --bg: #faf7f9;
  --surface: #ffffff;
  --surface-2: #F5F2F4;
  --border: #d8c9d4;
  --border-strong: #c4b0be;
  --text: #1f1219;
  --text-2: #3d2c37;
  --muted: #5f4d59;
  --muted-2: #8f7d89;

  /* Semantics — warm, muted, never neon */
  --success: #2f7f3f;
  --success-bg: #eaf3ec;
  --warning: #c89018;
  --warning-bg: #fff5e0;
  --danger: #b73228;
  --danger-bg: #f9ebe9;
  --info: #6B3A68;
  --info-bg: #F0E6EF;

  /* Notice (warm honey) */
  --notice-bg: #fff5e0;
  --notice-text: #7a4f10;
  --notice-border: #f3deaa;

  /* Geometry — purple-tinted shadows per TKU guide, never pure black */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(73, 19, 69, .06);
  --shadow: 0 1px 3px rgba(73, 19, 69, .06), 0 4px 14px rgba(73, 19, 69, .05);
  --shadow-lg: 0 10px 40px rgba(31, 18, 25, .25);

  --sidebar-w: 244px;
  --topbar-h: 64px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
          sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
img, svg { display: inline-block; vertical-align: middle; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
::placeholder { color: var(--muted-2); }

/* Boot splash */
.boot-splash {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.boot-spinner, .spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 3. App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .2s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
}
.sidebar-brand .brand-mark {
  width: 36px; height: 36px; flex: none;
  border-radius: 9px;
  background: var(--brand-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand img.brand-logo {
  max-height: 36px; max-width: 160px; object-fit: contain;
}
.sidebar-brand .brand-name {
  font-weight: 700; font-size: 15.5px; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-brand .brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px 12px; }
.nav-section-label {
  font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted-2);
  padding: 16px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  margin: 1px 0;
  border-radius: 8px;
  color: var(--text-2);
  font-weight: 500;
  font-size: 14px;
  transition: background .12s, color .12s;
}
.nav-item svg { color: var(--muted); flex: none; transition: color .12s; }
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active {
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
}
.nav-item.active svg { color: var(--brand-primary); }

.sidebar-user {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 34px; height: 34px; flex: none;
  border-radius: 50%;
  background: var(--brand-primary-soft);
  color: var(--brand-primary);
  font-weight: 700; font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  text-transform: uppercase;
}
.sidebar-user .user-meta { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-weight: 600; font-size: 13.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.icon-btn {
  background: none; border: none; cursor: pointer;
  color: var(--muted); padding: 7px; border-radius: 8px; line-height: 0;
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-bg); color: var(--danger); }

.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 26px;
}
.topbar h1 {
  font-size: 18px; font-weight: 700; letter-spacing: -.01em;
  margin: 0; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hamburger { display: none; }

.content { padding: 26px; max-width: 1280px; width: 100%; margin: 0 auto; }
.content.narrow { max-width: 860px; }

/* ---------- 4. Typography helpers ---------- */
.page-sub { color: var(--muted); margin: -14px 0 20px; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
h2.section-title { font-size: 15px; font-weight: 700; margin: 26px 0 12px; }

/* ---------- 5. Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 14px; font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-primary-hover); }
.btn-secondary {
  background: var(--surface); color: var(--text-2);
  border-color: var(--border-strong); box-shadow: var(--shadow-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-danger-outline {
  background: var(--surface); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, white);
}
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn .spinner.sm { border-color: rgba(255,255,255,.4); border-top-color: #fff; }

/* ---------- 6. Forms ---------- */
.field { margin-bottom: 16px; }
.field label, .field-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.field .error-text { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.input, .select, .textarea {
  width: 100%;
  font-family: inherit; font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 12px;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 18%, transparent);
}
.input.invalid { border-color: var(--danger); }
.textarea { resize: vertical; min-height: 90px; line-height: 1.55; }
/* TKU guideline: gold 2px borders signal interactive dropdowns (border only, never fill) */
.select {
  appearance: none;
  border: 2px solid var(--brand-accent);
  background-color: var(--surface-2);
  font-weight: 500;
  padding: 8px 31px 8px 11px; /* 1px less than .input to offset the thicker border */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235f4d59' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.form-row { display: flex; gap: 14px; }
.form-row > * { flex: 1; min-width: 0; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-primary); width: 16px; height: 16px; }
input[type="color"] {
  width: 44px; height: 34px; padding: 2px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  background: var(--surface); cursor: pointer;
}

.search-box { position: relative; }
.search-box svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--muted-2); pointer-events: none;
}
.search-box .input { padding-left: 36px; }

/* Segmented control (channel picker etc.) */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 3px; }
.segmented button {
  border: none; background: transparent; cursor: pointer;
  padding: 7px 16px; border-radius: 7px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .12s, color .12s, box-shadow .12s;
}
.segmented button.active { background: var(--surface); color: var(--brand-primary); box-shadow: var(--shadow-sm); }

/* Choice cards (radio-style big options) */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.choice-card {
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer;
  padding: 16px; text-align: left;
  transition: border-color .12s, background .12s, box-shadow .12s;
}
.choice-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.choice-card.selected {
  border-color: var(--brand-primary);
  background: var(--brand-primary-softer);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-primary) 12%, transparent);
}
.choice-card .cc-title { font-weight: 700; display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.choice-card .cc-desc { font-size: 12.5px; color: var(--muted); }

/* ---------- 7. Cards & stat cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px; }
.card-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; font-size: 15px; font-weight: 700; flex: 1; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 16px 18px;
  display: flex; gap: 14px; align-items: flex-start;
  transition: box-shadow .15s, transform .15s;
}
.stat-card:hover { box-shadow: var(--shadow); }
.stat-card .stat-icon {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--brand-primary-soft); color: var(--brand-primary);
}
.stat-card .stat-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card .stat-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-card .stat-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-card .stat-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat-card .stat-value { font-size: 24px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted-2); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }

/* Gallery card (templates, groups) */
.gallery-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  padding: 18px;
  display: flex; flex-direction: column; gap: 8px;
  cursor: pointer;
  transition: box-shadow .15s, border-color .15s, transform .15s;
}
.gallery-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); transform: translateY(-1px); }
.gallery-card .gc-title { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.gallery-card .gc-meta { font-size: 12.5px; color: var(--muted); }
.gallery-card .gc-foot { margin-top: auto; padding-top: 10px; display: flex; align-items: center; gap: 8px; }

/* Chart container */
.chart-box { position: relative; height: 280px; padding: 6px 4px; }
.chart-box.sm { height: 220px; }
.chart-fallback { display:flex; align-items:center; justify-content:center; height:100%; color: var(--muted); font-size: 13px; }

/* ---------- 8. Tables & pagination ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }
.table .cell-main { font-weight: 600; color: var(--text); }
.table .cell-sub { font-size: 12.5px; color: var(--muted); }
.table td.actions-cell { text-align: right; white-space: nowrap; }
.table td.actions-cell .icon-btn { opacity: .55; }
.table tbody tr:hover td.actions-cell .icon-btn { opacity: 1; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .search-box { width: 260px; max-width: 100%; }
.toolbar .spacer { flex: 1; }
.toolbar .select { width: auto; min-width: 140px; }

.pagination {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 13px; color: var(--muted);
}
.pagination .spacer { flex: 1; }
.pagination button {
  border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 7px; padding: 5px 10px; cursor: pointer;
  color: var(--text-2); display: inline-flex; align-items: center;
}
.pagination button:hover:not(:disabled) { background: var(--surface-2); }
.pagination button:disabled { opacity: .4; cursor: default; }

/* ---------- 9. Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  text-transform: capitalize;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-gray   { background: var(--surface-2); color: var(--muted); }
.badge-blue   { background: var(--info-bg); color: var(--info); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-amber  { background: var(--warning-bg); color: var(--warning); }
.badge-red    { background: var(--danger-bg); color: var(--danger); }
.badge-purple { background: var(--brand-primary-soft); color: var(--brand-primary); }
.badge-pulse .dot { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .25; } }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 6px 3px 11px;
  font-size: 12.5px; font-weight: 500;
}
.chip button { border: none; background: none; cursor: pointer; color: var(--muted); line-height: 0; padding: 3px; border-radius: 50%; }
.chip button:hover { color: var(--danger); background: var(--danger-bg); }

.channel-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.channel-tag svg { color: var(--muted); }

/* Filter chips row */
.chip-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-filter {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; padding: 5px 13px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--muted);
  transition: all .12s;
}
.chip-filter:hover { border-color: var(--border-strong); color: var(--text); }
.chip-filter.active {
  background: var(--brand-primary-soft); border-color: color-mix(in srgb, var(--brand-primary) 35%, white);
  color: var(--brand-primary); font-weight: 600;
}

/* ---------- 10. Modals ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(31, 18, 25, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 16px 16px;
  animation: fadeIn .15s ease;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 520px;
  animation: slideUp .18s ease;
  display: flex; flex-direction: column;
  max-height: 86vh;
}
.modal.wide { max-width: 720px; }
.modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 22px 0;
}
.modal-header h3 { margin: 0; font-size: 16.5px; font-weight: 700; flex: 1; }
.modal-body { padding: 16px 22px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px 20px;
}
@keyframes fadeIn { from { opacity: 0; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } }

/* ---------- 11. Toasts ---------- */
.toast-root {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 380px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: flex; gap: 10px; align-items: flex-start;
  font-size: 13.5px;
  animation: toastIn .2s ease;
}
.toast.leaving { animation: toastOut .2s ease forwards; }
.toast svg { flex: none; margin-top: 1px; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--danger); }
.toast.info svg { color: var(--info); }
.toast .toast-msg { flex: 1; }
@keyframes toastIn { from { opacity: 0; transform: translateX(14px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(14px); } }

/* ---------- 12. Login screen ---------- */
.auth-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(700px 380px at 15% -5%, color-mix(in srgb, var(--brand-primary) 14%, transparent), transparent),
    radial-gradient(700px 380px at 90% 110%, color-mix(in srgb, var(--brand-secondary) 12%, transparent), transparent),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 400px;
  padding: 38px 34px 30px;
}
.auth-logo {
  width: 52px; height: 52px; margin: 0 auto 16px;
  border-radius: 13px;
  background: var(--brand-primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.auth-card h1 { font-size: 21px; text-align: center; margin: 0 0 4px; letter-spacing: -.01em; }
.auth-card .auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.auth-error {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 25%, white);
  border-radius: 8px; padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
  display: flex; gap: 8px; align-items: flex-start;
}
.auth-success {
  background: var(--success-bg); color: var(--success);
  border: 1px solid color-mix(in srgb, var(--success) 25%, white);
  border-radius: 8px; padding: 10px 12px;
  font-size: 13px; margin-bottom: 16px;
}
.auth-links { text-align: center; margin-top: 18px; font-size: 13px; }
.auth-links a { cursor: pointer; }
.auth-foot { text-align: center; margin-top: 26px; color: var(--muted-2); font-size: 12px; }

/* ---------- 13. Wizard ---------- */
.wizard-steps {
  display: flex; gap: 6px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 10px 14px;
  overflow-x: auto;
}
.wizard-step {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 12px; border-radius: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--muted);
  white-space: nowrap;
  background: none; border: none; cursor: default;
}
.wizard-step .step-num {
  width: 22px; height: 22px; flex: none;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 11.5px; font-weight: 700; color: var(--muted);
}
.wizard-step.active { color: var(--brand-primary); }
.wizard-step.active .step-num { background: var(--brand-primary); border-color: var(--brand-primary); color: #fff; }
.wizard-step.done { color: var(--text-2); cursor: pointer; }
.wizard-step.done .step-num { background: var(--success-bg); border-color: transparent; color: var(--success); }
.wizard-step .step-arrow { color: var(--border-strong); margin: 0 2px; }
.wizard-actions {
  display: flex; gap: 10px; align-items: center;
  margin-top: 22px; padding-top: 18px;
  border-top: 1px solid var(--border);
}
.wizard-actions .spacer { flex: 1; }

/* Audience picker */
.group-pick {
  display: flex; align-items: center; gap: 11px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
  cursor: pointer; background: var(--surface);
  transition: border-color .12s, background .12s;
}
.group-pick:hover { border-color: var(--border-strong); }
.group-pick.selected { border-color: var(--brand-primary); background: var(--brand-primary-softer); }
.group-pick .gp-name { font-weight: 600; flex: 1; }
.group-pick .gp-count { font-size: 12.5px; color: var(--muted); }

.estimate-banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--brand-primary-soft);
  border: 1px solid color-mix(in srgb, var(--brand-primary) 25%, white);
  border-radius: var(--radius);
  padding: 13px 16px; margin-top: 16px;
  color: var(--brand-primary); font-weight: 600; font-size: 14px;
}

/* ---------- 14. Editor ---------- */
.editor-split { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 18px; align-items: start; }
.editor-toolbar {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  border: 1px solid var(--border-strong); border-bottom: none;
  border-radius: 8px 8px 0 0;
  background: var(--surface-2);
  padding: 6px 8px;
}
.editor-toolbar .tb-btn {
  border: none; background: none; cursor: pointer;
  padding: 6px 8px; border-radius: 6px; color: var(--text-2); line-height: 0;
  display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 600;
}
.editor-toolbar .tb-btn:hover { background: var(--surface); color: var(--brand-primary); }
.editor-toolbar .tb-sep { width: 1px; height: 18px; background: var(--border-strong); margin: 0 5px; }
.editor-code {
  width: 100%; min-height: 380px;
  font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
  border: 1px solid var(--border-strong); border-radius: 0 0 8px 8px;
  padding: 12px 14px; resize: vertical;
  color: var(--text); background: var(--surface);
}
.editor-code:focus { outline: none; border-color: var(--brand-primary); }
.preview-pane {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); overflow: hidden;
  position: sticky; top: calc(var(--topbar-h) + 16px);
}
.preview-pane .pp-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em;
}
.preview-pane iframe { width: 100%; height: 460px; border: none; background: #f1f2f6; display: block; }

/* SMS phone mockup */
.phone-mockup {
  width: 260px; margin: 18px auto;
  border: 10px solid #1f2937; border-radius: 34px;
  background: #fff; padding: 34px 12px 40px;
  min-height: 420px; position: relative;
  box-shadow: var(--shadow);
}
.phone-mockup::before {
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 72px; height: 8px; border-radius: 6px; background: #1f2937;
}
.sms-bubble {
  background: #e5e7eb; color: var(--text);
  border-radius: 16px 16px 16px 4px;
  padding: 10px 13px; font-size: 13.5px; line-height: 1.45;
  max-width: 100%; white-space: pre-wrap; word-break: break-word;
}
.sms-meta { text-align: center; font-size: 11px; color: var(--muted-2); margin-bottom: 10px; }
.char-counter { font-size: 12.5px; color: var(--muted); text-align: right; margin-top: 6px; }
.char-counter.over { color: var(--warning); font-weight: 600; }

/* ---------- 15. Rule builder ---------- */
.rule-builder {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); padding: 14px;
}
.rule-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.rule-row .select, .rule-row .input { width: auto; flex: 1; min-width: 120px; background-color: var(--surface); }
.rule-match { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13.5px; font-weight: 600; }
.rule-match .select { width: auto; }
.preview-count {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--brand-primary);
}

/* ---------- 16. Skeletons & empty states ---------- */
.skeleton {
  background: linear-gradient(90deg, #ece4ea 25%, #f5f0f4 50%, #ece4ea 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: 6px;
  min-height: 12px;
}
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton-row { display: flex; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.skeleton-row .skeleton { height: 14px; flex: 1; }
.skeleton-card { padding: 18px; }
.skeleton-card .skeleton { margin-bottom: 10px; }

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--muted);
}
.empty-state .es-art { margin-bottom: 18px; color: var(--muted-2); opacity: .9; }
.empty-state h3 { color: var(--text); font-size: 16px; margin: 0 0 6px; }
.empty-state p { font-size: 13.5px; max-width: 380px; margin: 0 auto 18px; }

/* ---------- 17. Misc components ---------- */
/* Status banner (campaign detail) */
.status-banner {
  display: flex; align-items: center; gap: 12px;
  border-radius: var(--radius-lg);
  padding: 14px 18px; margin-bottom: 20px;
  font-weight: 600; font-size: 14px;
  border: 1px solid;
}
.status-banner .sb-note { font-weight: 400; font-size: 13px; opacity: .85; }
.status-banner.gray  { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.status-banner.blue  { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 25%, white); color: var(--info); }
.status-banner.amber { background: var(--warning-bg); border-color: color-mix(in srgb, var(--warning) 25%, white); color: var(--warning); }
.status-banner.green { background: var(--success-bg); border-color: color-mix(in srgb, var(--success) 25%, white); color: var(--success); }
.status-banner.red   { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 25%, white); color: var(--danger); }

/* Dropdown menu */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  min-width: 190px; padding: 5px;
}
.dropdown-menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%; border: none; background: none; cursor: pointer;
  padding: 8px 11px; border-radius: 7px;
  font-size: 13.5px; color: var(--text-2); text-align: left;
}
.dropdown-menu button:hover { background: var(--surface-2); color: var(--text); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu button.danger:hover { background: var(--danger-bg); }

/* Progress bar */
.progress {
  height: 9px; border-radius: 999px; background: var(--border); overflow: hidden;
}
.progress > div {
  height: 100%; background: var(--brand-primary); border-radius: 999px;
  transition: width .25s ease;
}

/* Import mapping table */
.map-grid { display: flex; flex-direction: column; gap: 10px; }
.map-row {
  display: grid; grid-template-columns: 1fr 24px 1fr; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 13px;
}
.map-row .csv-col { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.map-row .csv-sample { font-size: 11.5px; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-row svg { color: var(--muted-2); }

/* Definition list (review step, detail pages) */
.def-list { display: grid; grid-template-columns: 160px 1fr; gap: 9px 18px; font-size: 14px; }
.def-list dt { color: var(--muted); font-weight: 500; }
.def-list dd { margin: 0; font-weight: 500; word-break: break-word; }

/* Branding preview frame */
.brand-preview iframe { width: 100%; height: 520px; border: none; background: #f1f2f6; }

/* Color field row */
.color-field { display: flex; align-items: center; gap: 10px; }
.color-field .input { flex: 1; font-family: var(--font-mono); }

/* Merge dropdown */
.merge-menu { max-height: 260px; overflow-y: auto; }

/* Back link */
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 13px; font-weight: 600;
  margin-bottom: 14px; cursor: pointer; background:none; border:none; padding: 4px 6px; border-radius: 6px;
}
.back-link:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }

/* ---------- 18. Responsive ---------- */
@media (max-width: 1080px) {
  .editor-split { grid-template-columns: 1fr; }
  .preview-pane { position: static; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    position: fixed; inset: 0; z-index: 35; background: rgba(31,18,25,.4);
  }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .content { padding: 18px; }
  .grid-2 { grid-template-columns: 1fr; }
  .choice-cards { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .def-list { grid-template-columns: 130px 1fr; }
  .toolbar .search-box { width: 100%; }
}

/* ---------- 19. Animations & TKU dashboard components ---------- */
/* Mild animations — TKU guide: 0.15–0.35s, never sluggish */
@keyframes fadeUp { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
.anim { animation: fadeUp .3s ease both; }
.anim:nth-child(2) { animation-delay: .05s; }
.anim:nth-child(3) { animation-delay: .1s; }
.anim:nth-child(4) { animation-delay: .15s; }

.card { transition: box-shadow .2s ease, transform .2s ease; }
.stat-card:hover, .gallery-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.btn { transition: background .15s ease, border-color .12s, color .12s, box-shadow .12s, transform .1s ease; }
.btn:active:not(:disabled) { transform: scale(.97); }
.nav-item { transition: background .15s ease, color .15s ease; }

/* Growing progress bars (engagement card) — width comes from --w */
.progress i.grow {
  display: block; height: 100%; width: 0;
  background: var(--brand-primary); border-radius: 999px;
  animation: growBar .35s ease-out .15s forwards;
}
@keyframes growBar { to { width: var(--w); } }

/* Executive summary strip (TKU guide 5.3) */
.exec {
  margin-bottom: 16px;
  background: var(--brand-primary-soft);
  border-left: 4px solid var(--brand-primary);
  padding: 12px 20px;
  display: flex; gap: 44px; flex-wrap: wrap; align-items: center;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.exec .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-secondary); font-weight: 600; }
.exec .val { font-size: 19px; font-weight: 600; color: var(--brand-primary); font-variant-numeric: tabular-nums; }
.exec .val small { font-size: 12px; color: var(--muted); font-weight: 500; }

/* Color-accented stat cards: tinted top bar + icon medallion */
.stat-card { position: relative; overflow: hidden; }
.stat-card .stat-value { font-variant-numeric: tabular-nums; }
.stat-card.acc { border-top: 3px solid var(--acc); }
.stat-card.acc .stat-label {
  font-size: 11.5px; color: var(--brand-secondary);
  font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
}
.stat-card .chip-ic {
  position: absolute; top: 14px; right: 14px;
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  background: var(--acc-bg, var(--brand-primary-soft));
  color: var(--acc, var(--brand-primary));
}
.a-purple { --acc: #491345; --acc-bg: #F0E6EF; }
.a-plum   { --acc: #6B3A68; --acc-bg: #f3ecf2; }
.a-green  { --acc: #2f7f3f; --acc-bg: #eaf3ec; }
.a-gold   { --acc: #B8893E; --acc-bg: #fff5e0; }

/* Chart legend dots */
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 8px; justify-content: center; flex-wrap: wrap; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* Engagement rate bars */
.rate-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12.5px; }
.rate-row .lbl { width: 78px; color: var(--muted); font-weight: 600; }
.rate-row .bar { flex: 1; }
.rate-row .val { width: 48px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Info/note banner — warm honey notice tokens */
.note {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
  color: var(--notice-text);
  border-radius: 8px; padding: 10px 14px; font-size: 12.5px;
}

/* Print-friendly-ish + reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .anim, .progress i.grow { animation-delay: 0s !important; }
  .card, .btn, .nav-item { transition: none; }
}
