/* ============================================================
   Best AI Solutions — Design System v2 (Locked 2026-05-27)
   Source of truth: memory/design-system.md
   ──────────────────────────────────────────────────────────────
   LOCKSTEP CONTRACT (Phase 5a, 2026-05-28):
   This file MUST stay byte-identical to:
     app/shared/src/styles/design-system.css
   When changing one, change the other.
   ──────────────────────────────────────────────────────────────
   Linked by prototypes via:
     <link rel="stylesheet" href="assets/design-system.css">
   Imported by React apps (admin + control-center) via:
     import '../../shared/src/styles/design-system.css'
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. FOUNDATIONS — Theme Variables
   Light "Stone" defaults; dark mode via .dark-mode class on <html>.
   ────────────────────────────────────────────────────────────*/
:root {
  --bg:               #f1f5f9;
  --bg-body:          #f1f5f9;
  --bg-card:          #ffffff;
  --bg-sidebar:       #f8fafc;
  --bg-header:        #ffffff;
  --bg-input:         #f1f5f9;
  --bg-task:          #f1f5f9;
  --border:           #cbd5e1;
  --border-light:     #e2e8f0;
  --text-primary:     #1e293b;
  --text-secondary:   #475569;
  --text-muted:       #94a3b8;
  --text-dim:         #94a3b8;
  --accent:           #3b82f6;
  --accent-hover:     #2563eb;
  --accent-light:     #dbeafe;
  --accent-text:      #1d4ed8;
  --success:          #22c55e;
  --success-light:    #dcfce7;
  --warning:          #f59e0b;
  --danger:           #ef4444;
  --sidebar-active:   #dbeafe;
  --sidebar-hover:    #e2e8f0;
  --row-hover:  #eff6ff;
  --card-shadow:      0 2px 6px rgba(0,0,0,0.06);
  --shadow-lg:        0 4px 14px rgba(0,0,0,0.1);
}

.dark-mode {
  --bg:               #0f172a;
  --bg-body:          #0f172a;
  --bg-card:          #1e293b;
  --bg-sidebar:       #0f172a;
  --bg-header:        #0f172a;
  --bg-input:         #1e293b;
  --bg-task:          #334155;
  --border:           #334155;
  --border-light:     #334155;
  --text-primary:     #e2e8f0;
  --text-secondary:   #94a3b8;
  --text-muted:       #475569;
  --text-dim:         #475569;
  --sidebar-hover:    #1e293b;
  --row-hover:  #243353;
  --sidebar-active:   #1e3a5f;
}

/* ────────────────────────────────────────────────────────────
   2. THEME UTILITIES — shared across components
   ────────────────────────────────────────────────────────────*/
.theme-text             { color: var(--text-primary); }
.theme-text-primary     { color: var(--text-primary); }   /* alias of .theme-text — see Lesson 6 / Keystone follow-up */
.theme-text-secondary   { color: var(--text-secondary); }
.theme-text-muted       { color: var(--text-muted); }
.theme-text-dim         { color: var(--text-dim); }
.theme-border           { border-color: var(--border); }
.theme-border-light     { border-color: var(--border-light); }
.theme-input            { background-color: var(--bg-card); border-color: var(--border); color: var(--text-primary); }
.theme-sidebar          { background-color: var(--bg-sidebar); border-color: var(--border); }
.theme-header           { background-color: var(--bg-header); border-color: var(--border); }
.theme-body             { background-color: var(--bg-body); color: var(--text-primary); }
.theme-bg               { background-color: var(--bg); }
.theme-bg-body          { background-color: var(--bg-body); }
.theme-bg-card          { background-color: var(--bg-card); }
.theme-bg-input         { background-color: var(--bg-input); }
.theme-bg-sidebar       { background-color: var(--bg-sidebar); }
.theme-bg-header        { background-color: var(--bg-header); }
.theme-bg-task          { background-color: var(--bg-task); }
.theme-divide > * + *   { border-top: 1px solid var(--border-light); }

/* ────────────────────────────────────────────────────────────
   3. BUTTONS — 5 types + 3 size modifiers + icon-only + block
   Base: font-semibold rounded-lg transition-colors w/ disabled
   ────────────────────────────────────────────────────────────*/
.btn-primary, .btn-secondary, .btn-danger, .btn-success, .btn-warning, .btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 600;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: background-color 150ms, border-color 150ms, color 150ms;
  cursor: pointer;
  white-space: nowrap;
  border: 1px solid transparent;
}
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled, .btn-success:disabled, .btn-warning:disabled, .btn-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary           { background-color: #2563eb; color: #ffffff; }
.btn-primary:hover     { background-color: #1d4ed8; }

.btn-secondary         { background-color: var(--bg-card); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover   { border-color: #60a5fa; }

.btn-danger            { background-color: #dc2626; color: #ffffff; }
.btn-danger:hover      { background-color: #b91c1c; }

.btn-success           { background-color: #059669; color: #ffffff; }
.btn-success:hover     { background-color: #047857; }

.btn-warning           { background-color: #d97706; color: #ffffff; }
.btn-warning:hover     { background-color: #b45309; }

.btn-link {
  background: transparent;
  color: #2563eb;
  padding: 0;
  border: 0;
}
.btn-link:hover        { color: #1d4ed8; text-decoration: underline; }

/* Option button — selectable card pattern */
.btn-option {
  display: block;
  width: 100%;
  text-align: left;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  transition: border-color 150ms, background-color 150ms;
  cursor: pointer;
}
.btn-option:hover      { border-color: #93c5fd; }
.btn-option-active     { border-color: #3b82f6; background-color: #eff6ff; }
.dark-mode .btn-option-active { background-color: rgba(30, 58, 138, 0.2); }

/* Icon-only button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem;
  border-radius: 0.5rem;
  background: transparent;
  color: var(--text-muted);
  transition: background-color 150ms, color 150ms;
  cursor: pointer;
  border: 0;
}
.btn-icon:hover        { background-color: #f1f5f9; color: #3b82f6; }
.dark-mode .btn-icon:hover { background-color: rgba(51, 65, 85, 0.5); }

/* Size modifiers */
.btn-sm                { font-size: 0.75rem; padding: 0.375rem 0.75rem; }
.btn-lg                { font-size: 1rem; padding: 0.625rem 1.25rem; }

/* Layout modifier */
.btn-block             { width: 100%; }

/* Feature modifier — wizard commit buttons (larger rounding + shadow) */
.btn-feature {
  border-radius: 0.75rem;             /* rounded-xl */
  padding: 0.625rem 1rem;             /* py-2.5 px-4 */
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

/* Toggle switch — used in Settings notifications + Reports preferences.
   Apply .toggle-track to the <button role="switch">, .toggle-knob to its child.
   Add .toggle-track-on when checked; the knob's translate handled by .toggle-knob-on. */
.toggle-track {
  position: relative;
  width: 2.5rem;             /* w-10 */
  height: 1.25rem;           /* h-5 */
  border-radius: 9999px;
  background-color: #cbd5e1;  /* slate-300 */
  transition: background-color 150ms;
  flex-shrink: 0;
  border: 0;
  cursor: pointer;
}
.dark-mode .toggle-track       { background-color: #475569; } /* slate-600 */
.toggle-track-on               { background-color: #2563eb; } /* blue-600 — wins via specificity since rule is after .toggle-track */
.toggle-track-on:hover         { background-color: #1d4ed8; }
.toggle-track:disabled         { opacity: 0.5; cursor: not-allowed; }

.toggle-knob {
  position: absolute;
  top: 0.125rem;              /* top-0.5 */
  left: 0.125rem;             /* translate-x-0.5 default position */
  width: 1rem;                /* w-4 */
  height: 1rem;               /* h-4 */
  border-radius: 9999px;
  background-color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  transition: transform 150ms;
}
.toggle-knob-on                { transform: translateX(1.25rem); } /* translate-x-5 */

/* ────────────────────────────────────────────────────────────
   4. FILTER PILLS — inactive base + active + color variants
   ────────────────────────────────────────────────────────────*/
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  transition: border-color 150ms, background-color 150ms, color 150ms;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover            { border-color: #60a5fa; }
.pill-active           { background-color: #2563eb; border-color: #2563eb; color: #ffffff; }
.pill-active:hover     { border-color: #1d4ed8; }

/* Color variants — active state colors */
.pill-red.pill-active     { background-color: #dc2626; border-color: #dc2626; color: #ffffff; }
.pill-amber.pill-active   { background-color: #d97706; border-color: #d97706; color: #ffffff; }
.pill-emerald.pill-active { background-color: #059669; border-color: #059669; color: #ffffff; }
.pill-purple.pill-active  { background-color: #9333ea; border-color: #9333ea; color: #ffffff; }

/* ────────────────────────────────────────────────────────────
   5. TABS — pill pattern only (D4)
   ────────────────────────────────────────────────────────────*/
.tab                   { /* identical visual to .pill */
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-secondary);
  transition: border-color 150ms, background-color 150ms, color 150ms;
  cursor: pointer;
  white-space: nowrap;
}
.tab:hover             { border-color: #60a5fa; }
.tab-active            { background-color: #2563eb; border-color: #2563eb; color: #ffffff; }
.tab-active:hover      { border-color: #1d4ed8; }
.tab-row               { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ────────────────────────────────────────────────────────────
   6. CARDS — base + clickable + KPI
   Padding applied inline per D3 (p-3 / p-4 / p-5).
   ────────────────────────────────────────────────────────────*/
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  transition: background-color 300ms, border-color 300ms;
}
.card-clickable        { cursor: pointer; transition: box-shadow 150ms, border-color 150ms; }
.card-clickable:hover  { box-shadow: 0 1px 2px 0 rgba(0,0,0,0.05); border-color: #93c5fd; }

.card-kpi              { /* compose with .card */ padding: 1rem; text-align: center; }

/* ────────────────────────────────────────────────────────────
   7. SECTION HEADERS — chevron always right + 180° rotation
   ────────────────────────────────────────────────────────────*/
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0;
}
.section-header-left   { display: flex; align-items: center; gap: 0.75rem; }
.section-header-right  { display: flex; align-items: center; gap: 0.75rem; }
.section-header-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.section-title         { font-weight: 600; color: var(--text-primary); }
.section-subtitle      { font-size: 0.75rem; color: var(--text-muted); }
.section-chevron       { font-size: 0.75rem; color: var(--text-muted); transition: transform 150ms; }
.section-chevron.rotate-180 { transform: rotate(180deg); }
.section-body          { margin-top: 1rem; }

/* ────────────────────────────────────────────────────────────
   8. MODALS
   ────────────────────────────────────────────────────────────*/
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background-color: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-panel {
  background-color: var(--bg-card);
  border-radius: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  max-width: 42rem;        /* 2xl */
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-panel-sm { max-width: 28rem; }
.modal-panel-lg { max-width: 56rem; }
.modal-panel-xl { max-width: 72rem; }

.modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title           { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.modal-body            { padding: 1.5rem; flex: 1; overflow-y: auto; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background-color: var(--bg-sidebar);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* ────────────────────────────────────────────────────────────
   9. TABLES
   ────────────────────────────────────────────────────────────*/
.table-base            { width: 100%; font-size: 0.875rem; border-collapse: collapse; }
.table-header          { background-color: var(--bg-sidebar); text-align: left; }
.table-header-cell {
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table-row             { border-top: 1px solid var(--border); transition: background-color 150ms; }
.table-row-hover:hover { background-color: var(--row-hover); }
/* Element-agnostic interactive-row highlight. Use on any clickable row that
   isn't a <tr> (list rows, accordion/expandable rows, activity-feed rows) so
   tables AND lists share one canonical hover (var(--row-hover)). Handles light
   + dark via the token — no per-element hover:bg-* / dark:hover:bg-* needed. */
.row-hover { transition: background-color 150ms; }
.row-hover:hover { background-color: var(--row-hover); }
/* .table-row-expandable means the row is clickable. Implies cursor:pointer
   AND a hover-bg affordance so users get visual feedback. The hover bg
   matches .table-row-hover for consistency. Folded 2026-05-28: the class
   previously only set cursor, leaving rows clickable without visual
   feedback on scroll-over. */
.table-row-expandable        { cursor: pointer; background-color: var(--bg-card); }
.table-row-expandable:hover  { background-color: var(--row-hover); }
.table-row-expanded {
  background-color: var(--bg-sidebar);
  padding: 0.75rem 1rem;
}

/* ────────────────────────────────────────────────────────────
   10. BADGES — 6 color variants, all dark-mode-safe
   ────────────────────────────────────────────────────────────*/
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
}
.badge-count { padding: 0.125rem 0.5rem; }

.badge-blue    { background-color: #dbeafe; color: #1d4ed8; }
.dark-mode .badge-blue    { background-color: rgba(30, 58, 138, 0.5); color: #93c5fd; }
.badge-emerald { background-color: #d1fae5; color: #047857; }
.dark-mode .badge-emerald { background-color: rgba(6, 78, 59, 0.5); color: #6ee7b7; }
.badge-amber   { background-color: #fef3c7; color: #b45309; }
.dark-mode .badge-amber   { background-color: rgba(120, 53, 15, 0.5); color: #fcd34d; }
.badge-red     { background-color: #fee2e2; color: #b91c1c; }
.dark-mode .badge-red     { background-color: rgba(127, 29, 29, 0.5); color: #fca5a5; }
.badge-slate   { background-color: #e2e8f0; color: #334155; }
.dark-mode .badge-slate   { background-color: #334155; color: #cbd5e1; }
.badge-purple  { background-color: #f3e8ff; color: #7e22ce; }
.dark-mode .badge-purple  { background-color: rgba(88, 28, 135, 0.5); color: #d8b4fe; }

/* Brand-identity badges (LOCKED 2026-05-28) — agent identity colors.
   These ENCODE brand semantics and are NEVER substituted with .badge-blue etc. */
.badge-brand-social   { background-color: #faf5ff; color: #6b21a8; }   /* Social Agent = purple */
.badge-brand-video    { background-color: #fef2f2; color: #991b1b; }   /* Video Agent = red */
.badge-brand-ads      { background-color: #fff7ed; color: #9a3412; }   /* Ads Agent = orange */
.badge-brand-google   { background-color: #eff6ff; color: #1d4ed8; }   /* Google Agent = blue */
.badge-brand-nurture  { background-color: #f0fdf4; color: #166534; }   /* Nurture Agent = green */
.badge-brand-web      { background-color: #f0fdfa; color: #115e59; }   /* Web Agent = teal */
.badge-brand-story    { background-color: #fff1f2; color: #9f1239; }   /* Story Agent = rose */
.badge-brand-phone    { background-color: #ecfeff; color: #155e75; }   /* Phone Agent = cyan */

.dark-mode .badge-brand-social   { background-color: rgba(88, 28, 135, 0.4); color: #d8b4fe; }
.dark-mode .badge-brand-video    { background-color: rgba(127, 29, 29, 0.4); color: #fca5a5; }
.dark-mode .badge-brand-ads      { background-color: rgba(154, 52, 18, 0.4); color: #fdba74; }
.dark-mode .badge-brand-google   { background-color: rgba(30, 58, 138, 0.4); color: #93c5fd; }
.dark-mode .badge-brand-nurture  { background-color: rgba(22, 101, 52, 0.4); color: #86efac; }
.dark-mode .badge-brand-web      { background-color: rgba(17, 94, 89, 0.4); color: #5eead4; }
.dark-mode .badge-brand-story    { background-color: rgba(159, 18, 57, 0.4); color: #fda4af; }
.dark-mode .badge-brand-phone    { background-color: rgba(21, 94, 117, 0.4); color: #67e8f9; }

/* Platform badges — external platform identity colors (Facebook/IG/Nextdoor/YouTube/Google) */
.badge-platform-facebook  { background-color: #eff6ff; color: #1e40af; }
.badge-platform-instagram { background-color: #fdf2f8; color: #be185d; }
.badge-platform-nextdoor  { background-color: #f0fdf4; color: #15803d; }
.badge-platform-youtube   { background-color: #fef2f2; color: #b91c1c; }
.badge-platform-google    { background-color: #f0f9ff; color: #0369a1; }

.dark-mode .badge-platform-facebook  { background-color: rgba(30, 64, 175, 0.4); color: #93c5fd; }
.dark-mode .badge-platform-instagram { background-color: rgba(190, 24, 93, 0.4); color: #f9a8d4; }
.dark-mode .badge-platform-nextdoor  { background-color: rgba(21, 128, 61, 0.4); color: #86efac; }
.dark-mode .badge-platform-youtube   { background-color: rgba(185, 28, 28, 0.4); color: #fca5a5; }
.dark-mode .badge-platform-google    { background-color: rgba(3, 105, 161, 0.4); color: #7dd3fc; }

/* Source-identity badges (added 2026-05-28) — encodes which behind-the-scenes
   system produced an event. Used on Super Admin Workforce Activity feed where
   operators scan a column of source badges and need to parse them at a glance.
   Each source gets a distinct shade so identity is visually unambiguous. */
.badge-source-agent          { background-color: #e2e8f0; color: #334155; } /* slate — catchall */
.badge-source-sentinel       { background-color: #fee2e2; color: #b91c1c; } /* red — system alerts */
.badge-source-wire-audit     { background-color: #ecfeff; color: #155e75; } /* cyan — static analysis */
.badge-source-keystone       { background-color: #fef3c7; color: #b45309; } /* amber — config drift */
.badge-source-ops-triage     { background-color: #dbeafe; color: #1d4ed8; } /* blue — alert routing */
.badge-source-diagnostic     { background-color: #f3e8ff; color: #7e22ce; } /* purple — investigation */
.badge-source-pipeline       { background-color: #d1fae5; color: #047857; } /* emerald — CI/CD */
.badge-source-lessons        { background-color: #e0e7ff; color: #4338ca; } /* indigo — meta-learning */
.badge-source-platform-issue { background-color: #fff1f2; color: #9f1239; } /* rose — user-facing bug */
.badge-source-approval       { background-color: #f0fdfa; color: #115e59; } /* teal — approval flow */

.dark-mode .badge-source-agent          { background-color: #334155;                  color: #cbd5e1; }
.dark-mode .badge-source-sentinel       { background-color: rgba(127, 29, 29, 0.5);   color: #fca5a5; }
.dark-mode .badge-source-wire-audit     { background-color: rgba(21, 94, 117, 0.4);   color: #67e8f9; }
.dark-mode .badge-source-keystone       { background-color: rgba(120, 53, 15, 0.5);   color: #fcd34d; }
.dark-mode .badge-source-ops-triage     { background-color: rgba(30, 58, 138, 0.5);   color: #93c5fd; }
.dark-mode .badge-source-diagnostic     { background-color: rgba(88, 28, 135, 0.5);   color: #d8b4fe; }
.dark-mode .badge-source-pipeline       { background-color: rgba(6, 78, 59, 0.5);     color: #6ee7b7; }
.dark-mode .badge-source-lessons        { background-color: rgba(55, 48, 163, 0.5);   color: #a5b4fc; }
.dark-mode .badge-source-platform-issue { background-color: rgba(159, 18, 57, 0.4);   color: #fda4af; }
.dark-mode .badge-source-approval       { background-color: rgba(17, 94, 89, 0.4);    color: #5eead4; }

/* Trade-identity badges (added 2026-05-28) — encodes business trade on
   Super Admin Clients page (and any future trade-aware surface). Light
   bg + dark text to match other identity-badge patterns. Per-trade colors
   are arbitrary visual assignment for at-a-glance scanning. */
.badge-trade-plumber       { background-color: #dbeafe; color: #1d4ed8; } /* blue */
.badge-trade-roofer        { background-color: #ffedd5; color: #9a3412; } /* orange */
.badge-trade-hvac          { background-color: #d1fae5; color: #047857; } /* emerald */
.badge-trade-cpa           { background-color: #ede9fe; color: #5b21b6; } /* violet */
.badge-trade-insurance     { background-color: #e0f2fe; color: #075985; } /* sky */
.badge-trade-bookkeeper    { background-color: #e0e7ff; color: #4338ca; } /* indigo */
.badge-trade-electrician   { background-color: #fef3c7; color: #b45309; } /* amber */
.badge-trade-painter       { background-color: #fce7f3; color: #be185d; } /* pink */
.badge-trade-pest-control  { background-color: #ecfccb; color: #4d7c0f; } /* lime */
.badge-trade-landscaper    { background-color: #dcfce7; color: #15803d; } /* green */
.badge-trade-handyman      { background-color: #ccfbf1; color: #115e59; } /* teal */
.badge-trade-other         { background-color: #e2e8f0; color: #334155; } /* slate — fallback */

.dark-mode .badge-trade-plumber       { background-color: rgba(30, 58, 138, 0.4); color: #93c5fd; }
.dark-mode .badge-trade-roofer        { background-color: rgba(154, 52, 18, 0.4); color: #fdba74; }
.dark-mode .badge-trade-hvac          { background-color: rgba(6, 78, 59, 0.4);   color: #6ee7b7; }
.dark-mode .badge-trade-cpa           { background-color: rgba(91, 33, 182, 0.4); color: #c4b5fd; }
.dark-mode .badge-trade-insurance     { background-color: rgba(7, 89, 133, 0.4);  color: #7dd3fc; }
.dark-mode .badge-trade-bookkeeper    { background-color: rgba(55, 48, 163, 0.4); color: #a5b4fc; }
.dark-mode .badge-trade-electrician   { background-color: rgba(120, 53, 15, 0.4); color: #fcd34d; }
.dark-mode .badge-trade-painter       { background-color: rgba(190, 24, 93, 0.4); color: #f9a8d4; }
.dark-mode .badge-trade-pest-control  { background-color: rgba(77, 124, 15, 0.4); color: #bef264; }
.dark-mode .badge-trade-landscaper    { background-color: rgba(21, 128, 61, 0.4); color: #86efac; }
.dark-mode .badge-trade-handyman      { background-color: rgba(17, 94, 89, 0.4);  color: #5eead4; }
.dark-mode .badge-trade-other         { background-color: #334155;                color: #cbd5e1; }

/* Badge overlay dot — small count indicator on icon-button overlays
   (e.g., approval count on a sidebar nav icon). Distinct from .badge-count
   which is a standalone inline count. Apply to a positioned <span> wrapping
   an icon-button. Added 2026-05-28. */
.badge-overlay-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.25rem;
  border-radius: 9999px;
  font-size: 0.625rem;       /* text-[10px] */
  font-weight: 600;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: #dc2626;  /* red-600 — default attention color */
  color: #ffffff;
  border: 2px solid var(--bg-card);  /* keeps dot crisp against card backgrounds */
}
.badge-overlay-dot-blue    { background-color: #2563eb; }
.badge-overlay-dot-amber   { background-color: #d97706; }
.badge-overlay-dot-emerald { background-color: #059669; }
.dark-mode .badge-overlay-dot { border-color: var(--bg-card); }

/* ────────────────────────────────────────────────────────────
   10b. AVA BUBBLES (added 2026-05-28)
   First-bubble = blue. Subsequent same-page = green. Match AvaBubble
   React component variants. The avatar uses the documented Ava-avatar
   locked-size exception (see Foundations — typography is bespoke for
   Ava: sm=32px / md=56px / lg=80px, not the canonical avatar scale).
   ────────────────────────────────────────────────────────────*/
/* Base .ava-bubble — typography only. Background + border come from
   a variant class (-blue / -green / -white). NO default bg here, because
   any default would silently shadow the variant on bubbles that omit one.
   Consolidated 2026-05-28 from two competing definitions (the second
   hard-coded blue as the default and broke .ava-bubble-white). */
.ava-bubble {
  display: flex;
  gap: 0.5rem;
  border-radius: 0.75rem;
  padding: 0.75rem;
  font-size: 0.875rem;
  color: #334155;             /* slate-700 — canonical Ava body text */
  line-height: 1.5;
}
.ava-bubble-blue  { background-color: #eff6ff; border: 1px solid #bfdbfe; }
.ava-bubble-green { background-color: #f0fdf4; border: 1px solid #bbf7d0; }
.ava-bubble-white { background-color: var(--bg-card); border: 1px solid var(--border); }
.dark-mode .ava-bubble       { color: #cbd5e1; }
.dark-mode .ava-bubble-blue  { background-color: rgba(30, 58, 138, 0.2); border-color: rgba(59, 130, 246, 0.3); }
.dark-mode .ava-bubble-green { background-color: rgba(22, 101, 52, 0.2); border-color: rgba(34, 197, 94, 0.3); }
/* .ava-bubble-white auto-themes via CSS vars (bg-card + border) — no dark override needed. */

/* Brand gradient band — recurring branded full-width header / hero band
   used in org chart, hero sections, Ava welcome cards. Blue→cyan
   diagonal. Apply to a div with white text inside. Added 2026-05-28. */
.brand-gradient-band {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  color: #ffffff;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
}
.brand-gradient-band-emerald { background: linear-gradient(135deg, #059669 0%, #06b6d4 100%); }
.brand-gradient-band-purple  { background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%); }
.brand-gradient-band-amber   { background: linear-gradient(135deg, #d97706 0%, #f43f5e 100%); }

/* Stat tile inset — nested stat block inside a colored card (AgentCard
   pattern). Smaller padding, subtle bg, used to display a metric inside
   an already-tinted container. Added 2026-05-28. */
.stat-tile-inset {
  background-color: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}
.stat-tile-inset .stat-tile-label { font-size: 0.625rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }
.stat-tile-inset .stat-tile-value { font-size: 1.125rem; font-weight: 700; }
.dark-mode .stat-tile-inset {
  background-color: rgba(15, 23, 42, 0.4);
  border-color: rgba(255, 255, 255, 0.08);
}

/* ────────────────────────────────────────────────────────────
   11. FORM INPUTS — focus ring always blue-500
   ────────────────────────────────────────────────────────────*/
.input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  background-color: var(--bg-card);
  color: var(--text-primary);
  transition: border-color 150ms, box-shadow 150ms;
}
.input::placeholder    { color: #94a3b8; }
.input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}
.input-textarea        { resize: vertical; min-height: 80px; }
.input-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}
/* Compact inline select — date-range filters, approval-mode pickers, location switcher.
   Self-contained so it never depends on Tailwind utility ordering. Reserves right
   padding for the styled chevron so the arrow never overlaps the last character. */
.input-select-sm {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  display: inline-block;
  font-size: 0.75rem;
  line-height: 1rem;
  padding: 0.25rem 1.75rem 0.25rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  background-color: var(--bg-card);
  color: var(--text-primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 0.9rem;
  cursor: pointer;
  transition: border-color 150ms, box-shadow 150ms;
}
.input-select-sm:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}
.input-checkbox, .input-radio {
  width: 1rem;
  height: 1rem;
  border: 1px solid #cbd5e1;
  color: #2563eb;
}
.input-checkbox        { border-radius: 0.25rem; }
.input-radio           { border-radius: 9999px; }
.input-checkbox:focus, .input-radio:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}
.input-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}
.input-help            { margin-top: 0.25rem; font-size: 0.75rem; color: var(--text-muted); }
.input-error           { margin-top: 0.25rem; font-size: 0.75rem; color: #dc2626; }
.input-error-state     { border-color: #fca5a5; }
.input-error-state:focus { border-color: #ef4444; box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3); }

/* ────────────────────────────────────────────────────────────
   12. ALERTS / CALLOUTS — including Ava bubble
   ────────────────────────────────────────────────────────────*/
.alert {
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  border: 1px solid;
}
.alert-icon            { flex-shrink: 0; margin-top: 0.125rem; }
.alert-body            { flex: 1; font-size: 0.875rem; line-height: 1.4; }

.alert-info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}
.dark-mode .alert-info {
  background-color: rgba(59, 130, 246, 0.1);
  border-color: rgba(59, 130, 246, 0.3);
  color: #bfdbfe;
}

.alert-warning {
  background-color: #fffbeb;
  border-color: #fde68a;
  color: #78350f;
}
.dark-mode .alert-warning {
  background-color: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.alert-success {
  background-color: #ecfdf5;
  border-color: #a7f3d0;
  color: #064e3b;
}
.dark-mode .alert-success {
  background-color: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-danger {
  background-color: #fef2f2;
  border-color: #fecaca;
  color: #7f1d1d;
}
.dark-mode .alert-danger {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Violet variant — feature spotlight / Story Agent / screen-share help context */
.alert-violet {
  background-color: #f5f3ff;
  border-color: #ddd6fe;
  color: #5b21b6;
}
.dark-mode .alert-violet {
  background-color: rgba(139, 92, 246, 0.1);
  border-color: rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
}

/* Ava bubble — avatar + text helpers. Base .ava-bubble lives at the top
   of this file in the canonical Ava-bubble block. The duplicate base rule
   here (which hard-coded blue as the default bg) was removed 2026-05-28
   after it silently shadowed .ava-bubble-white — same shadowing bug class
   as S25 (duplicate top-level key in Alpine x-data), but for CSS rules. */
.ava-bubble-avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  margin-top: 0.125rem;
}
.ava-bubble-text       { font-size: 0.875rem; color: #334155; line-height: 1.4; }
.dark-mode .ava-bubble-text { color: #cbd5e1; }

/* ────────────────────────────────────────────────────────────
   13. PROGRESS BARS — color rule locked
   ────────────────────────────────────────────────────────────*/
.progress {
  background-color: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}
.dark-mode .progress   { background-color: #334155; }
.progress-thin         { height: 0.25rem; }
.progress-md           { height: 0.375rem; }
.progress-thick        { height: 0.5rem; }

.progress-bar {
  height: 100%;
  border-radius: 9999px;
  transition: width 300ms ease;
}
.progress-bar-violet   { background-color: #8b5cf6; }
.progress-bar-emerald  { background-color: #10b981; }
.progress-bar-blue     { background-color: #3b82f6; }
.progress-bar-amber    { background-color: #f59e0b; }
.progress-bar-red      { background-color: #ef4444; }

/* ────────────────────────────────────────────────────────────
   14. STATUS INDICATORS
   ────────────────────────────────────────────────────────────*/
.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
}
.status-dot-online     { background-color: #10b981; }
.status-dot-busy       { background-color: #f59e0b; }
.status-dot-offline    { background-color: #94a3b8; }
.status-dot-pulse      { animation: dot-pulse 1.5s ease-in-out infinite; }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.spinner               { display: inline-block; animation: spin 1s linear infinite; }
.spinner-blue          { color: #3b82f6; }
.spinner-slate         { color: #94a3b8; }
.spinner-purple        { color: #9333ea; }   /* Stripe brand */
.spinner-emerald       { color: #10b981; }
.spinner-red           { color: #ef4444; }
.spinner-amber         { color: #f59e0b; }
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ────────────────────────────────────────────────────────────
   15. AVATARS
   ────────────────────────────────────────────────────────────*/
.avatar-sm             { width: 1.5rem; height: 1.5rem; border-radius: 9999px; }
.avatar-md             { width: 2rem; height: 2rem; border-radius: 9999px; }
.avatar-lg             { width: 2.5rem; height: 2.5rem; border-radius: 9999px; }
.avatar-xl             { width: 3.5rem; height: 3.5rem; border-radius: 9999px; }
.avatar-2xl            { width: 5rem; height: 5rem; border-radius: 9999px; }

.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
}
.avatar-sm.avatar-initials  { font-size: 0.75rem; }
.avatar-md.avatar-initials  { font-size: 0.75rem; }
.avatar-lg.avatar-initials  { font-size: 0.875rem; }
.avatar-xl.avatar-initials  { font-size: 1rem; }
.avatar-2xl.avatar-initials { font-size: 1.125rem; }

.avatar-online-dot {
  position: absolute;
  top: -0.125rem;
  right: -0.125rem;
  width: 0.75rem;
  height: 0.75rem;
  background-color: #10b981;
  border-radius: 9999px;
  border: 2px solid #ffffff;
}
.dark-mode .avatar-online-dot { border-color: var(--bg-card); }

/* ────────────────────────────────────────────────────────────
   16. DETAIL PAGE HEADER
   ────────────────────────────────────────────────────────────*/
.detail-header-back {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #2563eb;
  font-weight: 500;
  margin-bottom: 0.75rem;
  transition: color 150ms;
  text-decoration: none;
}
.detail-header-back:hover { color: #1d4ed8; }
.detail-header-row     { display: flex; align-items: flex-start; gap: 1rem; }
.detail-header-info    { flex: 1; min-width: 0; }
.detail-header-title   { font-size: 1.25rem; font-weight: 700; color: var(--text-primary); }
.detail-header-meta    { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ────────────────────────────────────────────────────────────
   17. EMPTY / ZERO STATES
   ────────────────────────────────────────────────────────────*/
.empty-state           { text-align: center; padding: 3rem 1.5rem; }
.empty-state-icon {
  display: block;
  font-size: 2.25rem;
  color: #cbd5e1;
  margin-bottom: 0.75rem;
}
.dark-mode .empty-state-icon { color: #475569; }
.empty-state-title     { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); margin-bottom: 0.25rem; }
.empty-state-body      { font-size: 0.75rem; color: var(--text-muted); max-width: 28rem; margin: 0 auto; }

/* ────────────────────────────────────────────────────────────
   18. LISTS — action list / timeline / feed
   ────────────────────────────────────────────────────────────*/
.list-action {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.list-action-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 0.5rem;
  transition: background-color 150ms;
}
.list-action-item:hover { background-color: var(--row-hover); }
.list-action-item-amber   { border-left-color: #f59e0b; }
.list-action-item-blue    { border-left-color: #3b82f6; }
.list-action-item-emerald { border-left-color: #10b981; }
.list-action-item-red     { border-left-color: #ef4444; }

.list-timeline         { display: flex; flex-direction: column; gap: 0.75rem; }
.list-timeline-item    { display: flex; align-items: flex-start; gap: 0.75rem; }

.list-feed > * + *     { border-top: 1px solid var(--border); }

/* ────────────────────────────────────────────────────────────
   19. SIDEBAR + UTILITIES — carried from existing prototypes
   ────────────────────────────────────────────────────────────*/
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  transition: background-color 150ms, color 150ms;
}
.sidebar-link:hover    { background-color: var(--sidebar-hover); }
.sidebar-link.active   { background-color: var(--sidebar-active); border-left: 3px solid #3b82f6; }

/* ============================================================
   END design-system.css
   Total: 19 sections (16 components + 3 foundations)
   ============================================================ */
