/**
 * public/css/demo.css
 * Lumina Demo Hub — Design system + all page styles
 *
 * Sections:
 *   1. Custom properties (tokens)
 *   2. Reset + base
 *   3. Typography
 *   4. Buttons
 *   5. Forms
 *   6. Cards
 *   7. Badges
 *   8. Toast notifications
 *   9. Page loader
 *  10. Navigation
 *  11. Demo banner
 *  12. Homepage — hero + persona grid
 *  13. Dashboard — KPI row
 *  14. Dashboard — panel grid
 *  15. Dashboard — lead pipeline
 *  16. Dashboard — message thread
 *  17. Dashboard — invoices
 *  18. Skeleton / shimmer
 *  19. Animations
 *  20. Responsive
 */

/* ── 1. Custom properties ────────────────────────────────────────────────────── */

:root {
  /* Background layers */
  --bg:        #09090B;
  --surface:   #111113;
  --surface-2: #18181B;
  --surface-3: #27272A;

  /* Borders */
  --border:        rgba(255,255,255,.08);
  --border-subtle: rgba(255,255,255,.05);

  /* Text */
  --text:       #F1F5F9;
  --text-muted: #94A3B8;
  --text-faint: #64748B;

  /* Accent */
  --accent:       #3B82F6;
  --accent-hover: #2563EB;
  --accent-dim:   rgba(59,130,246,.15);

  /* Tier colors */
  --tier-foundation: #10B981;
  --tier-automation: #8B5CF6;
  --tier-revenue-os: #3B82F6;

  /* Stage colors */
  --stage-new:                 #94A3B8;
  --stage-contacted:           #F59E0B;
  --stage-consultation_booked: #8B5CF6;
  --stage-converted:           #10B981;
  --stage-lost:                #EF4444;

  /* Invoice status */
  --invoice-pending:   #F59E0B;
  --invoice-paid:      #10B981;
  --invoice-cancelled: #EF4444;

  /* Message channel colors */
  --channel-whatsapp: #25D366;
  --channel-email:    #3B82F6;
  --channel-system:   #94A3B8;
  --channel-ai:       #14B8A6;

  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Radii */
  --r:    8px;
  --r-sm: 6px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Touch target minimum */
  --touch-min: 44px;

  /* Transitions */
  --t:    150ms ease;
  --t-md: 250ms ease;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow:    0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.6);
}

/* ── 2. Reset + base ─────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  background:  var(--bg);
  color:       var(--text);
  font-family: var(--font-sans);
  font-size:   .9375rem;
  line-height: 1.6;
  min-height:  100dvh;
  display:     flex;
  flex-direction: column;
  overflow-x:  hidden;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ── 3. Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -.02em;
}

.mono { font-family: var(--font-mono); }

.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm    { font-size: .8125rem; }
.text-xs    { font-size: .75rem; }

/* ── 4. Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display:         inline-flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--sp-2);
  min-height:      var(--touch-min);
  padding:         0 var(--sp-5);
  border:          1px solid transparent;
  border-radius:   var(--r);
  font-size:       .9375rem;
  font-weight:     600;
  white-space:     nowrap;
  transition:      background var(--t), color var(--t), border-color var(--t), opacity var(--t);
  position:        relative;
  overflow:        hidden;
  user-select:     none;
}

.btn-sm {
  min-height: 36px;
  padding:    0 var(--sp-4);
  font-size:  .8125rem;
}

.btn-full { width: 100%; }

/* Primary */
.btn-primary {
  background:   var(--accent);
  color:        #fff;
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled):not([aria-busy="true"]) {
  background:   var(--accent-hover);
  border-color: var(--accent-hover);
}

/* Outline */
.btn-outline {
  background:   transparent;
  color:        var(--text-muted);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled):not([aria-busy="true"]) {
  color:        var(--text);
  border-color: rgba(255,255,255,.2);
  background:   var(--surface-2);
}

/* Ghost */
.btn-ghost {
  background:   transparent;
  color:        var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled):not([aria-busy="true"]) {
  color:       var(--text);
  background:  var(--surface-2);
}

/* Danger */
.btn-danger {
  background:   transparent;
  color:        #EF4444;
  border-color: rgba(239,68,68,.3);
}
.btn-danger:hover:not(:disabled):not([aria-busy="true"]) {
  background: rgba(239,68,68,.1);
}

/* Disabled + loading */
.btn:disabled,
.btn[aria-busy="true"] {
  opacity:        .5;
  cursor:         not-allowed;
  pointer-events: none;
}

/* Spinner inside button */
.btn-spinner {
  display:        none;
  width:          16px;
  height:         16px;
  border:         2px solid rgba(255,255,255,.3);
  border-top-color: currentColor;
  border-radius:  50%;
  animation:      spin .6s linear infinite;
  flex-shrink:    0;
}

.btn[aria-busy="true"] .btn-spinner {
  display: block;
}

.btn[aria-busy="true"] .btn-text {
  visibility: hidden;
  position:   absolute;
}

/* ── 5. Forms ────────────────────────────────────────────────────────────────── */

.field {
  display:        flex;
  flex-direction: column;
  gap:            var(--sp-1);
}

.field-label {
  font-size:   .8125rem;
  font-weight: 600;
  color:       var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.input,
.select,
.textarea {
  background:   var(--surface-2);
  border:       1px solid var(--border);
  border-radius: var(--r);
  color:        var(--text);
  font-size:    .9375rem;
  padding:      0 var(--sp-3);
  min-height:   var(--touch-min);
  width:        100%;
  transition:   border-color var(--t), background var(--t);
  outline:      none;
  -webkit-appearance: none;
  appearance:   none;
}

.textarea {
  padding:    var(--sp-3);
  min-height: 80px;
  resize:     vertical;
  line-height: 1.5;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  background:   var(--surface-3);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-faint);
}

.select {
  cursor:               pointer;
  background-image:     url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748B' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat:    no-repeat;
  background-position:  right 12px center;
  padding-right:        var(--sp-8);
}

.select option { background: var(--surface-3); }

/* ── 6. Cards ────────────────────────────────────────────────────────────────── */

.card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r-lg);
  padding:       var(--sp-5);
}

.card-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  margin-bottom:   var(--sp-4);
}

.card-title {
  font-size:   .8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color:       var(--text-muted);
}

/* ── 7. Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display:       inline-flex;
  align-items:   center;
  gap:           5px;
  padding:       3px 10px;
  border-radius: 100px;
  font-size:     .75rem;
  font-weight:   700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space:   nowrap;
}

/* Tier badges */
.badge-foundation {
  background: rgba(16,185,129,.15);
  color:      var(--tier-foundation);
  border:     1px solid rgba(16,185,129,.25);
}
.badge-automation {
  background: rgba(139,92,246,.15);
  color:      var(--tier-automation);
  border:     1px solid rgba(139,92,246,.25);
}
.badge-revenue-os {
  background: rgba(59,130,246,.15);
  color:      var(--tier-revenue-os);
  border:     1px solid rgba(59,130,246,.25);
}

/* Stage badges */
.badge-stage {
  font-size:  .7rem;
  padding:    2px 8px;
}
.badge-stage-new                 { background: rgba(148,163,184,.1); color: var(--stage-new); border: 1px solid rgba(148,163,184,.2); }
.badge-stage-contacted           { background: rgba(245,158,11,.1);  color: var(--stage-contacted); border: 1px solid rgba(245,158,11,.2); }
.badge-stage-consultation_booked { background: rgba(139,92,246,.1);  color: var(--stage-consultation_booked); border: 1px solid rgba(139,92,246,.2); }
.badge-stage-converted           { background: rgba(16,185,129,.1);  color: var(--stage-converted); border: 1px solid rgba(16,185,129,.2); }
.badge-stage-lost                { background: rgba(239,68,68,.1);   color: var(--stage-lost); border: 1px solid rgba(239,68,68,.2); }

/* Invoice status badges */
.badge-invoice-pending   { background: rgba(245,158,11,.1);  color: var(--invoice-pending);   border: 1px solid rgba(245,158,11,.2); }
.badge-invoice-paid      { background: rgba(16,185,129,.1);  color: var(--invoice-paid);      border: 1px solid rgba(16,185,129,.2); }
.badge-invoice-cancelled { background: rgba(239,68,68,.1);   color: var(--invoice-cancelled); border: 1px solid rgba(239,68,68,.2); }

/* ── 8. Toast notifications ──────────────────────────────────────────────────── */

#toast-container {
  position:   fixed;
  bottom:     var(--sp-6);
  right:      var(--sp-6);
  z-index:    9999;
  display:    flex;
  flex-direction: column;
  gap:        var(--sp-2);
  max-width:  360px;
  width:      calc(100vw - var(--sp-8));
  pointer-events: none;
}

.toast {
  display:       flex;
  align-items:   flex-start;
  gap:           var(--sp-3);
  padding:       var(--sp-3) var(--sp-4);
  background:    var(--surface-3);
  border:        1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow:    var(--shadow-lg);
  pointer-events: all;
  animation:     toast-in .2s ease both;
}

.toast.leaving { animation: toast-out .2s ease both; }

.toast-success { border-left: 3px solid #10B981; }
.toast-error   { border-left: 3px solid #EF4444; }
.toast-warning { border-left: 3px solid #F59E0B; }
.toast-info    { border-left: 3px solid #3B82F6; }

.toast-icon {
  font-size:   1rem;
  line-height: 1.4;
  flex-shrink: 0;
}
.toast-success .toast-icon { color: #10B981; }
.toast-error   .toast-icon { color: #EF4444; }
.toast-warning .toast-icon { color: #F59E0B; }
.toast-info    .toast-icon { color: #3B82F6; }

.toast-body    { flex: 1; min-width: 0; }
.toast-title   { font-size: .8125rem; font-weight: 700; margin-bottom: 2px; }
.toast-msg     { font-size: .8125rem; color: var(--text-muted); line-height: 1.4; }

.toast-close {
  background:  none;
  border:      none;
  color:       var(--text-faint);
  font-size:   .9375rem;
  line-height: 1;
  padding:     2px;
  min-height:  unset;
  flex-shrink: 0;
  transition:  color var(--t);
}
.toast-close:hover { color: var(--text); }

/* ── 9. Page loader ──────────────────────────────────────────────────────────── */

.page-loader {
  position:        fixed;
  inset:           0;
  background:      var(--bg);
  z-index:         9998;
  display:         flex;
  align-items:     center;
  justify-content: center;
  transition:      opacity .3s ease;
}

.page-loader.hidden {
  opacity:        0;
  pointer-events: none;
}

.spinner {
  width:        32px;
  height:       32px;
  border:       3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation:    spin .7s linear infinite;
}

/* ── 10. Navigation ──────────────────────────────────────────────────────────── */

.demo-nav {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         0 var(--sp-6);
  height:          56px;
  border-bottom:   1px solid var(--border-subtle);
  background:      var(--bg);
  position:        sticky;
  top:             0;
  z-index:         100;
  flex-shrink:     0;
}

.demo-nav-brand {
  display:     flex;
  align-items: center;
  gap:         var(--sp-2);
  font-weight: 700;
  font-size:   1rem;
  letter-spacing: -.01em;
  color:       var(--text);
  transition:  opacity var(--t);
}
.demo-nav-brand:hover { opacity: .8; }

.demo-nav-dot {
  width:         8px;
  height:        8px;
  border-radius: 50%;
  background:    var(--accent);
  flex-shrink:   0;
}

.demo-nav-meta {
  display:     flex;
  align-items: center;
  gap:         var(--sp-3);
}

.demo-nav-clinic {
  font-size:   .8125rem;
  color:       var(--text-muted);
  font-family: var(--font-mono);
}

/* ── 11. Demo banner ─────────────────────────────────────────────────────────── */

.demo-banner {
  display:         flex;
  align-items:     center;
  justify-content: center;
  gap:             var(--sp-2);
  padding:         var(--sp-2) var(--sp-4);
  background:      rgba(245,158,11,.08);
  border-bottom:   1px solid rgba(245,158,11,.15);
  font-size:       .75rem;
  font-weight:     600;
  color:           #F59E0B;
  font-family:     var(--font-mono);
  letter-spacing:  .06em;
  text-transform:  uppercase;
  flex-shrink:     0;
}

.demo-banner-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  background:    currentColor;
  animation:     pulse 2s infinite;
  flex-shrink:   0;
}

/* ── 12. Homepage — hero + persona grid ──────────────────────────────────────── */

.demo-home-hero {
  text-align: center;
  padding:    var(--sp-12) var(--sp-6) var(--sp-8);
  max-width:  640px;
  margin:     0 auto;
}

.demo-home-eyebrow {
  font-size:      .75rem;
  font-weight:    700;
  font-family:    var(--font-mono);
  text-transform: uppercase;
  letter-spacing: .12em;
  color:          var(--accent);
  margin-bottom:  var(--sp-3);
}

.demo-home-title {
  font-size:     2.25rem;
  margin-bottom: var(--sp-4);
  background:    linear-gradient(135deg, var(--text) 0%, var(--text-muted) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.demo-home-subtitle {
  color:       var(--text-muted);
  font-size:   1.0625rem;
  line-height: 1.7;
}

/* Persona grid */
.persona-grid {
  display:   grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap:       var(--sp-5);
  padding:   0 var(--sp-6) var(--sp-12);
  max-width: 1100px;
  margin:    0 auto;
  width:     100%;
}

.persona-card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r-xl);
  overflow:      hidden;
  display:       flex;
  flex-direction: column;
  transition:    border-color var(--t-md), box-shadow var(--t-md), transform var(--t-md);
  cursor:        pointer;
}

.persona-card:hover {
  border-color: rgba(255,255,255,.15);
  box-shadow:   var(--shadow-lg);
  transform:    translateY(-2px);
}

.persona-card:focus-visible {
  outline:        2px solid var(--accent);
  outline-offset: 2px;
}

/* Tier accent bar at top of card */
.persona-card-top {
  height: 4px;
  width:  100%;
}
.persona-card[data-tier="foundation"]  .persona-card-top { background: var(--tier-foundation); }
.persona-card[data-tier="automation"]  .persona-card-top { background: var(--tier-automation); }
.persona-card[data-tier="revenue-os"]  .persona-card-top { background: var(--tier-revenue-os); }

.persona-card-header {
  display:     flex;
  align-items: center;
  justify-content: space-between;
  padding:     var(--sp-5) var(--sp-5) 0;
  flex-wrap:   wrap;
  gap:         var(--sp-2);
}

.persona-clinic-name {
  font-size:   1.125rem;
  font-weight: 700;
}

.persona-desc {
  padding:     var(--sp-3) var(--sp-5);
  color:       var(--text-muted);
  font-size:   .9rem;
  line-height: 1.6;
  flex: 1;
}

.persona-features {
  padding:    0 var(--sp-5) var(--sp-4);
  display:    flex;
  flex-direction: column;
  gap:        var(--sp-1);
}

.persona-features li {
  display:     flex;
  align-items: center;
  gap:         var(--sp-2);
  font-size:   .8125rem;
  color:       var(--text-muted);
}

.persona-features li::before {
  content:      '→';
  color:        var(--accent);
  font-family:  var(--font-mono);
  font-size:    .75rem;
  flex-shrink:  0;
}

.persona-cta {
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
}

/* ── 13. Dashboard — KPI row ─────────────────────────────────────────────────── */

.kpi-row {
  display:   grid;
  grid-template-columns: repeat(7, 1fr);
  gap:       var(--sp-3);
  padding:   var(--sp-5) var(--sp-5) 0;
}

.kpi-card {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-top:    3px solid var(--kpi-color, var(--accent));
  border-radius: var(--r-lg);
  padding:       var(--sp-4);
  position:      relative;
  overflow:      hidden;
  transition:    border-color var(--t);
}

.kpi-card.loaded .kpi-value {
  opacity: 1;
}

.kpi-label {
  font-size:      .7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color:          var(--text-faint);
  margin-bottom:  var(--sp-2);
  white-space:    nowrap;
  overflow:       hidden;
  text-overflow:  ellipsis;
}

.kpi-value {
  font-size:   1.5rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.1;
  color:       var(--text);
  opacity:     0;
  transition:  opacity .3s ease;
}

.kpi-unit {
  font-size:   .875rem;
  font-weight: 600;
  color:       var(--text-muted);
  margin-left: 2px;
}

/* ── 14. Dashboard — panel grid ──────────────────────────────────────────────── */

.dashboard-body {
  flex:     1;
  display:  flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-grid {
  display: grid;
  grid-template-columns: 320px 1fr 300px;
  gap:     var(--sp-4);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  flex:    1;
  min-height: 0;
  overflow: hidden;
}

.panel {
  background:    var(--surface);
  border:        1px solid var(--border);
  border-radius: var(--r-lg);
  display:       flex;
  flex-direction: column;
  min-height:    0;
  overflow:      hidden;
}

.panel-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         var(--sp-4) var(--sp-4) 0;
  flex-shrink:     0;
}

.panel-title {
  font-size:      .75rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color:          var(--text-muted);
}

.panel-body {
  padding:    var(--sp-3) var(--sp-4);
  flex:       1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.panel-body::-webkit-scrollbar       { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* ── 15. Dashboard — lead pipeline ───────────────────────────────────────────── */

.lead-item {
  display:       flex;
  flex-direction: column;
  gap:           var(--sp-1);
  padding:       var(--sp-3);
  border-radius: var(--r);
  cursor:        pointer;
  transition:    background var(--t);
  border:        1px solid transparent;
}

.lead-item:hover {
  background:   var(--surface-2);
  border-color: var(--border);
}

.lead-item.active {
  background:   var(--accent-dim);
  border-color: rgba(59,130,246,.3);
}

.lead-item-top {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  gap:             var(--sp-2);
}

.lead-name {
  font-weight: 600;
  font-size:   .9rem;
  flex:        1;
  min-width:   0;
  overflow:    hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-time {
  font-size:  .7rem;
  color:      var(--text-faint);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.lead-item-bottom {
  display:     flex;
  align-items: center;
  gap:         var(--sp-2);
}

.lead-phone {
  font-size:   .75rem;
  color:       var(--text-muted);
  font-family: var(--font-mono);
}

.lead-source {
  font-size:      .65rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color:          var(--text-faint);
  background:     var(--surface-3);
  padding:        1px 6px;
  border-radius:  100px;
  flex-shrink:    0;
}

/* Stage group header */
.stage-group-header {
  font-size:      .7rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: .1em;
  padding:        var(--sp-2) var(--sp-3);
  margin:         var(--sp-2) 0 var(--sp-1);
  background:     var(--surface);
  border-bottom:  1px solid var(--border-subtle);
}

/* Stage select in lead panel */
.stage-select-wrap {
  padding:      var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink:  0;
}

/* ── 16. Dashboard — message thread ──────────────────────────────────────────── */

.thread-empty {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  justify-content: center;
  height:          100%;
  gap:             var(--sp-2);
  color:           var(--text-faint);
  text-align:      center;
  padding:         var(--sp-8);
}

.thread-empty-icon {
  font-size:     2rem;
  margin-bottom: var(--sp-2);
}

.thread-empty-hint {
  font-size:  .8125rem;
  color:      var(--text-faint);
}

/* Message bubbles */
.message-bubble {
  display:        flex;
  flex-direction: column;
  gap:            4px;
  margin-bottom:  var(--sp-3);
  max-width:      85%;
}

.message-bubble.inbound  { align-self: flex-start; }
.message-bubble.outbound { align-self: flex-end; align-items: flex-end; }

.message-header {
  display:     flex;
  align-items: center;
  gap:         var(--sp-2);
}

.message-sender {
  font-size:   .7rem;
  font-weight: 700;
  color:       var(--text-faint);
}

.message-content {
  padding:       var(--sp-2) var(--sp-3);
  border-radius: var(--r-lg);
  font-size:     .875rem;
  line-height:   1.5;
  border:        1px solid transparent;
}

.message-bubble.inbound .message-content {
  background:   var(--surface-2);
  border-color: var(--border);
  border-bottom-left-radius: var(--r-sm);
}

.message-bubble.outbound .message-content {
  background:   var(--accent-dim);
  border-color: rgba(59,130,246,.2);
  border-bottom-right-radius: var(--r-sm);
}

/* AI message variant — teal */
.message-bubble.outbound.ai .message-content {
  background:   rgba(20,184,166,.1);
  border-color: rgba(20,184,166,.22);
}

.message-time {
  font-size:   .65rem;
  color:       var(--text-faint);
  font-family: var(--font-mono);
  padding:     0 var(--sp-1);
}

/* Channel indicator dot */
.message-channel-dot {
  width:         6px;
  height:        6px;
  border-radius: 50%;
  flex-shrink:   0;
}
.dot-whatsapp { background: var(--channel-whatsapp); }
.dot-email    { background: var(--channel-email); }
.dot-system   { background: var(--channel-system); }
.dot-ai       { background: var(--channel-ai); }

/* Thread list container */
.thread-messages {
  display:        flex;
  flex-direction: column;
  gap:            0;
  padding:        var(--sp-3) var(--sp-4);
  flex:           1;
  overflow-y:     auto;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}

.thread-messages::-webkit-scrollbar       { width: 4px; }
.thread-messages::-webkit-scrollbar-track { background: transparent; }
.thread-messages::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* Compose area */
.compose-wrap {
  border-top:     1px solid var(--border-subtle);
  padding:        var(--sp-3) var(--sp-4);
  flex-shrink:    0;
  display:        flex;
  flex-direction: column;
  gap:            var(--sp-2);
}

.channel-tabs {
  display: flex;
  gap:     var(--sp-1);
}

.channel-tab {
  min-height:   32px;
  padding:      0 var(--sp-3);
  background:   transparent;
  border:       1px solid var(--border);
  border-radius: var(--r-sm);
  color:        var(--text-faint);
  font-size:    .75rem;
  font-weight:  600;
  cursor:       pointer;
  transition:   background var(--t), color var(--t), border-color var(--t);
}

.channel-tab.active,
.channel-tab[aria-selected="true"] {
  background:   var(--surface-3);
  color:        var(--text);
  border-color: var(--border);
}

.channel-tab:hover:not(.active) {
  color:       var(--text-muted);
  background:  var(--surface-2);
}

.compose-row {
  display: flex;
  gap:     var(--sp-2);
  align-items: flex-end;
}

.compose-input {
  flex: 1;
}

.send-icon { font-size: .875rem; }

/* ── 17. Dashboard — invoices ─────────────────────────────────────────────────── */

.invoice-item {
  display:       flex;
  align-items:   center;
  gap:           var(--sp-3);
  padding:       var(--sp-3);
  border-radius: var(--r);
  border:        1px solid var(--border-subtle);
  margin-bottom: var(--sp-2);
  transition:    border-color var(--t);
}

.invoice-item:hover { border-color: var(--border); }

.invoice-info {
  flex:    1;
  min-width: 0;
}

.invoice-patient {
  font-weight: 600;
  font-size:   .875rem;
  white-space: nowrap;
  overflow:    hidden;
  text-overflow: ellipsis;
}

.invoice-amount {
  font-family: var(--font-mono);
  font-size:   .8125rem;
  color:       var(--text-muted);
  margin-top:  1px;
}

.invoice-summary {
  display:   flex;
  gap:       var(--sp-4);
  padding:   var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.invoice-summary-item {
  display:        flex;
  flex-direction: column;
  gap:            2px;
}

.invoice-summary-label {
  font-size:      .65rem;
  font-weight:    700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color:          var(--text-faint);
}

.invoice-summary-value {
  font-family: var(--font-mono);
  font-size:   .9375rem;
  font-weight: 700;
  color:       var(--text);
}

/* ── 18. Skeleton / shimmer ──────────────────────────────────────────────────── */

.skeleton {
  background:    var(--surface-2);
  border-radius: var(--r-sm);
  position:      relative;
  overflow:      hidden;
}

.skeleton::after {
  content:   '';
  position:  absolute;
  inset:     0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,.04) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

.skel-kpi-value {
  height:       32px;
  width:        80%;
  margin-top:   var(--sp-1);
}

.skel-text-sm {
  height:       12px;
  width:        60%;
}

.skel-lead {
  height:       60px;
  margin-bottom: var(--sp-2);
  border-radius: var(--r);
}

/* ── 19. Animations ──────────────────────────────────────────────────────────── */

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

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toast-out {
  from { opacity: 1; transform: scale(1); }
  to   { opacity: 0; transform: scale(.95); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 20. Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .kpi-row {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (max-width: 900px) {
  .panel-grid {
    grid-template-columns: 1fr;
    grid-template-rows:    auto auto auto;
    overflow:              auto;
  }

  .panel {
    max-height: 420px;
  }
}

@media (max-width: 768px) {
  .demo-nav {
    padding: 0 var(--sp-4);
  }

  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
    padding:               var(--sp-4) var(--sp-4) 0;
  }

  .panel-grid {
    padding: var(--sp-3) var(--sp-4) var(--sp-4);
    gap:     var(--sp-3);
  }

  .demo-home-title { font-size: 1.75rem; }

  .persona-grid {
    grid-template-columns: 1fr;
    padding:               0 var(--sp-4) var(--sp-8);
  }
}

@media (max-width: 480px) {
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  #toast-container {
    bottom: var(--sp-4);
    right:  var(--sp-4);
    left:   var(--sp-4);
    width:  auto;
  }

  .demo-home-hero {
    padding: var(--sp-8) var(--sp-4) var(--sp-6);
  }
}
