/* ============================================
   FILLER ACCELERATOR — DESIGN SYSTEM
   ============================================ */

:root {
  /* Brand Colors */
  --brand-primary: #1a56db;
  --brand-primary-hover: #1344b0;
  --brand-primary-light: #e8effc;
  --brand-accent: #f59e0b;
  --brand-accent-hover: #d97706;

  /* Neutrals */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status Colors */
  --green: #059669;
  --green-light: #ecfdf5;
  --red: #dc2626;
  --red-light: #fef2f2;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --yellow: #ca8a04;
  --yellow-light: #fefce8;

  /* Semantic surfaces — added 2026-05-05 for dark mode support.
     Use these instead of hardcoding `white` for card-like backgrounds
     so [data-theme="dark"] can flip them in one place. */
  --surface:           #ffffff;   /* default card / modal background  */
  --surface-elevated:  #ffffff;   /* dropdowns, tooltips, popovers    */
  --surface-sunken:    #f8fafc;   /* page background under cards      */
  --border:            #e2e8f0;   /* default 1px borders              */
  --text:              #1e293b;   /* default body text                */
  --text-muted:        #64748b;   /* secondary text                   */

  /* ============================================
     SEMANTIC TOKENS — Phase 2 of the 2026-06-06 visual accessibility
     audit (docs/notes/2026-06-06_visual_accessibility_audit.md).
     Every name below was already referenced in css/ or js/ WITHOUT a
     definition (silently falling back to light-only hex values), or is
     a new status/interaction token. All pairs verified ≥4.5:1 (text)
     / ≥3:1 (UI) on their intended surfaces in BOTH themes.
     RULE: never hardcode a color outside this file — add a token.
     ============================================ */

  /* Aliases for undefined names already in the wild */
  --primary:             var(--brand-primary);
  --accent:              var(--brand-primary);
  --brand-text:          #0f172a;
  --text-primary:        var(--text);
  --text-secondary:      #475569;   /* 7.58:1 on white — working secondary text */
  --text-placeholder:    #64748b;   /* 4.76:1 — stop using --gray-400 for text  */

  /* Surfaces */
  --surface-alt:         #f1f5f9;   /* secondary surface: wells, table headers  */
  --surface-muted:       #f8fafc;
  --surface-accent-soft: #eff6ff;
  --brand-primary-soft:  #dbeafe;
  --gallery-letterbox:   #0f172a;   /* photo letterboxing — dark in both themes */

  /* Borders */
  --border-subtle:       #e2e8f0;
  --border-strong:       #94a3b8;   /* inputs + interactive outlines            */
  --divider:             #e2e8f0;

  /* Status triads: -bg (tint) + -text (on tint) + solid accent.
     Use these for ALL new badges/banners/status text. */
  --success-bg:    #d1fae5;
  --success-text:  #065f46;   /* 6.78:1 on --success-bg */
  --success-solid: #047857;   /* 5.48:1 as text on white */
  --warning-bg:    #fef3c7;
  --warning-text:  #92400e;   /* 6.37:1 on --warning-bg */
  --warning:       #f59e0b;   /* solid marker/border use only — NOT text */
  --danger-bg:     #fee2e2;
  --danger-text:   #991b1b;   /* 6.80:1 on --danger-bg */
  --danger:        #dc2626;   /* solid fills w/ white text (4.63:1) — both themes */
  --danger-border: #fecaca;
  --info-bg:       #dbeafe;
  --info-text:     #1e40af;   /* 7.0:1 on --info-bg */
  --info-solid:    #1d4ed8;   /* 6.70:1 as text on white */
  --violet-bg:     #ede9fe;   /* pipeline / trainee accent family */
  --violet-text:   #5b21b6;   /* 8.7:1 on --violet-bg */

  /* Interaction */
  --link:          #1d4ed8;
  --hover-bg:      #f1f5f9;
  --active-bg:     #e8effc;
  --active-text:   #1a56db;
  --focus-ring:    #1a56db;
  --disabled-text: #94a3b8;
  --disabled-bg:   #f1f5f9;

  /* Layout */
  --sidebar-width: 240px;
  --nav-height: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.12);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);

  /* Typography */
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
}

/* ============================================
   DARK THEME — applied when html[data-theme="dark"]
   Flips the gray scale (50 ↔ 900, etc) plus surfaces and shadows.
   Brand colors stay constant; status colors get darker tinted
   backgrounds so badges remain readable on dark surfaces.
   ============================================ */

html[data-theme="dark"] {
  /* Inverted neutrals — same names, darker values, so existing
     `var(--gray-50)` references on backgrounds become dark and
     `var(--gray-900)` references on text become light. */
  --gray-50:  #0f172a;   /* darkest — page background sits here     */
  --gray-100: #1e293b;
  --gray-200: #334155;   /* borders                                  */
  --gray-300: #475569;
  --gray-400: #64748b;   /* mid-tone (used for muted icons/text)     */
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;   /* primary body text                        */
  --gray-900: #f8fafc;   /* high-contrast headings                   */

  /* Brand: lighten primary slightly so it pops against dark bg. */
  --brand-primary:        #5b8def;
  --brand-primary-hover:  #7aa3f5;
  --brand-primary-light:  #1e2b4a;
  --brand-accent:         #fbbf24;
  --brand-accent-hover:   #fcd34d;

  /* Status -light backgrounds become subtle dark tints — keep the
     hue cue, drop the brightness so they don't glare. */
  --green-light:  #0d2c22;
  --red-light:    #2f1416;
  --orange-light: #2a190a;
  --blue-light:   #142544;
  --yellow-light: #2c220a;

  /* Surfaces */
  --surface:          #1e293b;   /* card / modal bg                  */
  --surface-elevated: #273449;   /* slightly lifted: dropdowns, etc  */
  --surface-sunken:   #0f172a;   /* page bg                          */
  --border:           #334155;
  --text:             #e2e8f0;
  --text-muted:       #94a3b8;

  /* Shadows: deeper + slightly higher alpha because dark surfaces
     swallow the default 5-12% black shadow values. */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.40);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.45);
  --shadow-lg:   0 12px 32px rgba(0,0,0,0.55);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.40), 0 1px 2px rgba(0,0,0,0.30);

  /* ===== Semantic tokens — dark values (Phase 2, 2026-06-06 audit).
     --primary/--accent/--text-primary auto-flip via their var()
     aliases; everything else is overridden here. ===== */
  --brand-text:          #f8fafc;
  --text-secondary:      #cbd5e1;   /* 9.85:1 on card */
  --text-placeholder:    #94a3b8;   /* 5.71:1 on card */

  --surface-alt:         #273449;
  --surface-muted:       #16203a;
  --surface-accent-soft: #142544;
  --brand-primary-soft:  #1e2b4a;
  /* --gallery-letterbox stays dark in both themes — no override */

  --border-subtle:       #2a3850;
  --border-strong:       #64748b;   /* 3.07:1 vs card */
  --divider:             #2a3850;

  --success-bg:    #0d2c22;
  --success-text:  #6ee7b7;   /* 9.84:1 on --success-bg */
  --success-solid: #34d399;   /* 7.61:1 as text on card */
  --warning-bg:    #2c220a;
  --warning-text:  #fcd34d;   /* 10.87:1 on --warning-bg */
  --warning:       #fbbf24;
  --danger-bg:     #2f1416;
  --danger-text:   #fca5a5;   /* 8.98:1 on --danger-bg */
  /* --danger stays #dc2626: solid fills keep white text in both themes */
  --danger-border: #5b2a2a;
  --info-bg:       #142544;
  --info-text:     #93c5fd;   /* 8.45:1 on --info-bg */
  --info-solid:    #60a5fa;   /* 5.75:1 as text on card */
  --violet-bg:     #2a1d4d;
  --violet-text:   #c4b5fd;   /* 8.9:1 on --violet-bg */

  --link:          #7aa3f5;   /* 5.84:1 on card */
  --hover-bg:      #273449;
  --active-bg:     #1e2b4a;
  --active-text:   #7aa3f5;
  --focus-ring:    #7aa3f5;
  --disabled-text: #64748b;
  --disabled-bg:   #1a2436;

  /* Native form controls + scrollbars + autofill. */
  color-scheme: dark;
}

/* ============================================
   GLOBAL FOCUS RING — Phase 2 (2026-06-06 audit). Keyboard-visible
   focus on every interactive element, both themes. :focus-visible
   only fires for keyboard/AT focus, so mouse clicks stay clean.
   ============================================ */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* Smooth-ish transition when toggling. Limited to colors so
   layouts don't animate when the theme changes. */
html, body, .main-content, .sidebar, .lead-card, .modal-card,
.lb-table-wrap, .lb-stat-card, .seller-property-card,
.team-leaderboard, .coming-up-section {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  /* Use the semantic --text and --surface-sunken vars (which point at
     the gray scale) so dark theme inherits cleanly. */
  color: var(--text);
  background: var(--surface-sunken);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  line-height: 1.3;
  font-weight: 600;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a {
  color: var(--brand-primary);
  text-decoration: none;
}

button {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
}

input, select, textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  z-index: 9999;
  transition: opacity 0.4s ease;
}

.loading-screen.loading-fade-out {
  opacity: 0;
}

.loading-content {
  text-align: center;
}

.loading-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 1.8rem;
}

.logo-text {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--gray-900);
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

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

/* ============================================
   TOP NAVIGATION
   ============================================ */

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-logo .logo-icon { font-size: 1.3rem; }
.nav-logo .logo-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
}

.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius-sm);
}

.menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--gray-700);
  border-radius: 1px;
  transition: 0.2s;
}

.nav-center { flex: 1; max-width: 480px; margin: 0 24px; }

.search-bar {
  position: relative;
  width: 100%;
}

.search-bar .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.search-bar input {
  width: 100%;
  height: 40px;
  padding: 0 16px 0 40px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-full);
  background: var(--gray-50);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
}

.search-bar input:focus {
  border-color: var(--brand-primary);
  background: var(--surface);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-icon-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  position: relative;
  transition: background 0.15s;
}

.nav-icon-btn:hover { background: var(--gray-100); }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.user-menu { position: relative; }

.user-avatar-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-dropdown {
  position: absolute;
  top: 48px;
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 200;
}

.dropdown-header {
  padding: 14px 16px;
}

.dropdown-name {
  display: block;
  font-weight: 600;
  color: var(--gray-900);
}

.dropdown-role {
  display: block;
  font-size: 0.8rem;
  color: var(--gray-500);
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--gray-200);
}

.dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 16px;
  font-size: 0.9rem;
  color: var(--gray-700);
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: var(--gray-50);
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  position: fixed;
  top: var(--nav-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--gray-200);
  padding: 16px 0;
  overflow-y: auto;
  z-index: 90;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  width: 100%;
  text-align: left;
}

.sidebar-link:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

.sidebar-link.active {
  background: var(--brand-primary-light);
  color: var(--brand-primary);
}

.sidebar-link svg { flex-shrink: 0; }

.sidebar-section {
  margin-top: 16px;
  padding: 0 8px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-400);
  padding: 8px 14px 4px;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.main-content {
  margin-top: var(--nav-height);
  padding: 28px 32px;
  min-height: calc(100vh - var(--nav-height));
}

.main-content.has-sidebar {
  margin-left: var(--sidebar-width);
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: var(--shadow-lg);
}

.toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-info { background: var(--gray-800); }
.toast-success { background: var(--green); }
.toast-error { background: var(--red); }
.toast-warning { background: var(--orange); }

/* ============================================
   COMMON ELEMENTS
   ============================================ */

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.dashboard-subtitle {
  color: var(--gray-500);
  font-size: 0.95rem;
  margin-top: 4px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 32px 0 16px;
}

.section-title {
  font-size: 1.15rem;
  font-weight: 600;
}

.loading-placeholder {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
  font-size: 0.95rem;
}

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--gray-500);
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--gray-700);
}

.empty-subtle {
  color: var(--gray-400);
  font-size: 0.9rem;
  padding: 16px;
}

.text-btn {
  color: var(--brand-primary);
  font-weight: 500;
  font-size: 0.9rem;
}

.text-btn:hover { text-decoration: underline; }

.text-btn-danger { color: var(--red); }

/* ============================================
   STATS CARDS
   ============================================ */

.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

/* Clickable KPI tiles (dashboard Market-KPIs deep-links, 2026-07-18). */
.stat-card-link {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.stat-card-link:hover,
.stat-card-link:focus-visible {
  box-shadow: var(--shadow-md);
  border-color: var(--brand-primary);
}

.stat-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  font-family: var(--font-display);
}

.stat-label {
  font-size: 0.85rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* 2026-07-03 — modals were cramped (text hugging the edges). More padding
   on every side + a wider default card so content has room to breathe. */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 32px 0;
}

.modal-header h3 { font-size: 1.2rem; }

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  color: var(--gray-500);
}

.modal-close:hover { background: var(--gray-100); }

.modal-subtitle {
  padding: 8px 32px 0;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.modal-body { padding: 20px 32px; }
.modal-footer { padding: 4px 32px 28px; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .menu-toggle { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 95;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
  }

  .main-content.has-sidebar {
    margin-left: 0;
  }

  .main-content {
    padding: 20px 16px;
  }

  .nav-center { display: none; }

  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

@media (max-width: 480px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   GLOBAL TOOLTIP (2026-06-14) — instant styled hover tip
   Upgrades every element with a `title` (see js/utils/tooltip.js).
   ============================================ */
.fa-tooltip {
  position: fixed;
  z-index: 4000;
  display: none;
  max-width: 260px;
  background: #1e293b;
  color: #fff;
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 7px 10px;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.28);
  pointer-events: none;
}
.fa-tooltip.is-visible { display: block; }

/* ============================================
   MOBILE BOTTOM TAB BAR (2026-07-22)
   Phone-width app navigation — the "real app" feel from Cameron's
   Slow Flips one-pager. Desktop never sees it. Items injected by
   App.renderMobileTabbar(); .is-active tracks the current route.
   ============================================ */
.mobile-tabbar {
  display: none;
}

@media (max-width: 768px) {
  .mobile-tabbar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1500;
    background: var(--bg-card, #ffffff);
    border-top: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
    /* iPhone home-indicator clearance when installed as a PWA */
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .mobile-tabbar .mtab {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px 6px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 10.5px;
    font-weight: 600;
    color: var(--text-muted, #6b7280);
    -webkit-tap-highlight-color: transparent;
  }

  .mobile-tabbar .mtab-icon {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-tabbar .mtab.is-active {
    color: var(--brand-primary, #1a56db);
  }

  /* Keep page content clear of the fixed bar (60px bar + safe area). */
  body.has-mobile-tabbar #main-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }
}

/* ============================================
   MOBILE HEADER + INTAKE MODAL FIXES (2026-07-22)
   ============================================ */
@media (max-width: 768px) {
  /* Full wordmark wrapped to three broken lines on phones — swap to the
     short mark and keep it on one line. */
  .nav-logo .logo-text-full { display: none; }
  .nav-logo .logo-text-short { display: inline !important; white-space: nowrap; }
  .nav-logo { flex-wrap: nowrap; }
}

@media (max-width: 640px) {
  /* 2026-07-28 (Adam's beta report — couldn't schedule a showing on
     mobile): generalized from the seller-intake-only fix. EVERY modal
     becomes a full-bleed scrollable sheet on phones, so no form field
     or submit button can ever sit off-screen. */
  .modal-overlay {
    padding: 0 !important;
    align-items: flex-start !important;
  }
  .modal-card {
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    max-height: 100dvh;
    overflow-y: auto;
    box-sizing: border-box;
  }
  .modal-card input,
  .modal-card select,
  .modal-card textarea {
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* ============================================
   MOBILE TOP-NAV FIT (2026-07-26)
   First beta feedback (Sheri): the avatar/user-menu button — the way
   into Switch view + Sign out — was pushed off the right edge on
   phones. Tighten the bar and drop the two least-critical buttons on
   small screens: refresh (data live-refreshes anyway; still available
   on desktop) and the theme toggle (OS preference still applies).
   The avatar must ALWAYS be visible.
   ============================================ */
@media (max-width: 600px) {
  .top-nav {
    padding-left: 8px;
    padding-right: 8px;
    gap: 4px;
  }

  .nav-left { gap: 6px; min-width: 0; }

  .nav-logo .logo-text-short {
    font-size: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #refresh-btn,
  #theme-toggle-btn {
    display: none !important;
  }

  .nav-right {
    flex-shrink: 0;
    gap: 4px;
  }

  .nav-icon-btn {
    width: 36px;
    height: 36px;
    padding: 6px;
  }

  .user-avatar-btn {
    flex-shrink: 0;
  }
}

@media (max-width: 380px) {
  /* Very small phones: icon-only brand so the right side always fits. */
  .nav-logo .logo-text-short { display: none !important; }
}

/* ============================================
   TEAM MESSAGES (2026-07-26)
   Desktop: people rail + chat pane. Mobile: horizontal avatar chips on
   top, chat below. Beta feedback fix: the composer is INPUT-dominant —
   big text field, compact circular send button.
   ============================================ */
.tm-layout {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.tm-people { flex: 0 0 250px; min-width: 0; }
.tm-thread { flex: 1; min-width: 0; }

.tm-people-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.tm-person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  width: 100%;
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background 0.15s;
}
.tm-person:last-child { border-bottom: none; }
.tm-person:hover { background: var(--hover-bg); }
.tm-person.is-active { background: var(--active-bg); }

.tm-person-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.tm-person-meta { min-width: 0; }
.tm-person-name {
  display: block;
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tm-person-role {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.tm-chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  height: min(64vh, 560px);
}

.tm-chat-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}

.tm-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tm-bubble-wrap { max-width: 78%; align-self: flex-start; }
.tm-bubble-wrap.is-mine { align-self: flex-end; }

.tm-bubble {
  background: var(--surface-alt, #f1f5f9);
  color: var(--text);
  padding: 9px 13px;
  border-radius: 14px 14px 14px 4px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.tm-bubble-wrap.is-mine .tm-bubble {
  background: var(--brand-primary);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.tm-bubble-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.tm-bubble-wrap.is-mine .tm-bubble-meta { text-align: right; }

/* Composer: the input is the star; send is a compact circle. */
.tm-form {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  align-items: center;
}

.tm-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 13px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  font: inherit;
  font-size: 15px;
  background: var(--surface);
  color: var(--text);
}

.tm-send {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--brand-primary);
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tm-send:hover { background: var(--brand-primary-hover); }

@media (max-width: 700px) {
  .tm-layout { flex-direction: column; gap: 10px; }

  .tm-people { flex: 1 1 auto; width: 100%; }

  /* Horizontal avatar chips instead of a tall list. */
  .tm-people-list {
    display: flex;
    overflow-x: auto;
    border-radius: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .tm-person {
    flex: 0 0 auto;
    flex-direction: column;
    gap: 4px;
    width: 86px;
    padding: 10px 6px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    text-align: center;
  }
  .tm-person:last-child { border-right: none; }

  .tm-person-avatar { width: 40px; height: 40px; }
  .tm-person-meta { text-align: center; width: 100%; }
  .tm-person-name { font-size: 11px; }
  .tm-person-role { font-size: 9.5px; }

  .tm-thread { width: 100%; }
  .tm-chat { height: min(62vh, 520px); }
}

/* ============================================
   FEEDBACK BUTTON vs MOBILE TAB BAR (2026-07-28)
   Beta feedback (Adam): the floating 💬 Feedback button was buried
   under the bottom tab bar on phones. Lift it clear of the bar +
   iPhone home indicator.
   ============================================ */
@media (max-width: 768px) {
  #feedback-fab {
    bottom: calc(76px + env(safe-area-inset-bottom, 0px)) !important;
  }
}
