/* Merchant portal chrome + dashboard + leads — ported from mockups/dashboard.html
   and mockups/backend-leads.html. */

body { background: #f5f5f0; }
:root { --sidebar-w: 240px; }

/* SIDEBAR */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--brand-primary, #2a2a2a);
  color: #fff;
  padding: 1.5rem 0;
  display: flex; flex-direction: column;
  z-index: 40;
}
.sidebar-brand {
  padding: 0 1.25rem 1.5rem;
  font-family: 'Cabin', sans-serif;
  font-weight: 600; font-size: 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 0.5rem;
}
.sidebar-brand a { color: #fff; text-decoration: none; }
.sidebar-brand small { display: block; font-size: 0.7rem; color: rgba(255,255,255,0.4); font-family: 'Inter', sans-serif; font-weight: 400; margin-top: 0.25rem; }
.sidebar-nav { flex: 1; padding: 0.5rem 0; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 1.25rem;
  color: rgba(255,255,255,0.5);
  text-decoration: none; font-size: 0.85rem; font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,0.05); }
.sidebar-nav a.active {
  color: #fff; background: rgba(255,255,255,0.08);
  border-left-color: #fff;
}
.sidebar-nav a svg { flex-shrink: 0; opacity: 0.6; }
.sidebar-nav a.active svg { opacity: 1; }
.sidebar-nav a .soon {
  margin-left: auto; font-size: 0.55rem; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: rgba(255,255,255,0.3);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 9999px; padding: 0.1rem 0.4rem;
}
.sidebar-nav a .nav-badge {
  background: #3b82f6; color: #fff; font-size: 0.6rem; font-weight: 700;
  padding: 0.1rem 0.4rem; border-radius: 9999px; margin-left: auto;
}
.sidebar-section {
  font-size: 0.65rem; font-weight: 700; color: rgba(255,255,255,0.25);
  text-transform: uppercase; letter-spacing: 0.15em;
  padding: 1.25rem 1.25rem 0.5rem;
}
.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 0.75rem;
}
.sidebar-avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
}
.sidebar-user { font-size: 0.8rem; font-weight: 600; }
.sidebar-plan { font-size: 0.65rem; color: rgba(255,255,255,0.4); }
.sidebar-logout {
  margin-left: auto; color: rgba(255,255,255,0.35); display: flex;
}
.sidebar-logout:hover { color: #fff; }

/* MAIN */
.main {
  margin-left: var(--sidebar-w);
  padding: 2rem;
  min-height: 100vh;
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 2rem;
}
.topbar h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.5rem; font-weight: 700;
}
.topbar-sub { font-size: 0.85rem; color: #888; margin-top: 0.25rem; }
.topbar-actions { display: flex; gap: 0.75rem; }
.btn-outline {
  padding: 0.5rem 1rem; background: transparent; color: #555;
  border: 1px solid #ddd; border-radius: 0.75rem;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  transition: all 0.2s; text-decoration: none;
}
.btn-outline:hover { border-color: #aaa; }
.btn-dark {
  padding: 0.5rem 1rem; background: var(--brand-primary, #2a2a2a); color: #fff;
  border: none; border-radius: 0.75rem;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
  text-decoration: none;
}

/* WELCOME BANNER (post-signup) */
.welcome-banner {
  background: linear-gradient(135deg, #16a34a, #15803d);
  border-radius: 1rem; padding: 1.25rem 1.5rem; color: #fff;
  margin-bottom: 1.5rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.welcome-banner strong { font-family: 'Outfit', sans-serif; }
.welcome-banner a { color: #fff; font-weight: 700; }

/* STATS ROW */
.stats-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: #fff; border-radius: 1rem; padding: 1.25rem;
  border: 1px solid #eee;
}
.stat-label { font-size: 0.75rem; color: #888; font-weight: 500; margin-bottom: 0.5rem; }
.stat-value {
  font-family: 'Outfit', sans-serif;
  font-size: 1.75rem; font-weight: 700; color: #1a1a1a;
}
.stat-change { font-size: 0.7rem; font-weight: 600; margin-top: 0.25rem; }
.stat-up { color: #16a34a; }
.stat-down { color: #dc2626; }
.stat-sub { font-size: 0.7rem; color: #888; margin-top: 0.25rem; }

/* GRID LAYOUT */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }

/* CARDS */
.card {
  background: #fff; border-radius: 1rem; border: 1px solid #eee;
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex; justify-content: space-between; align-items: center;
}
.card-title { font-weight: 700; font-size: 0.95rem; }
.card-action {
  font-size: 0.75rem; color: #888; text-decoration: none;
  font-weight: 600; transition: color 0.2s;
}
.card-action:hover { color: var(--brand-primary, #2a2a2a); }
.card-body { padding: 1.25rem; }
.card-empty { color: #999; font-size: 0.85rem; padding: 1rem 0; text-align: center; }

/* LEAD ROWS (dashboard) */
.lead-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f5f5f5;
}
.lead-row:last-child { border-bottom: none; }
.lead-avatar {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  background: #f0f0f0; display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: #888; flex-shrink: 0;
}
.lead-info { flex: 1; }
.lead-name { font-weight: 600; font-size: 0.875rem; }
.lead-name-link { color: inherit; text-decoration: none; }
.lead-name-link:hover { text-decoration: underline; }
.lead-detail { font-size: 0.75rem; color: #888; }
.lead-time { font-size: 0.7rem; color: #aaa; white-space: nowrap; }
.lead-status {
  padding: 0.2rem 0.6rem; border-radius: 9999px;
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; display: inline-block;
}
.status-new { background: rgba(59,130,246,0.1); color: #3b82f6; }
.status-replied { background: rgba(22,163,74,0.1); color: #16a34a; }
.status-booked { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.status-lost { background: rgba(220,38,38,0.1); color: #dc2626; }

/* APPOINTMENTS (dashboard) */
.appt-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f5f5f5;
}
.appt-row:last-child { border-bottom: none; }
.appt-time-block { text-align: center; min-width: 3rem; }
.appt-time { font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 0.9rem; color: #1a1a1a; }
.appt-period { font-size: 0.65rem; color: #888; text-transform: uppercase; }
.appt-info { flex: 1; }
.appt-service { font-weight: 600; font-size: 0.85rem; }
.appt-client { font-size: 0.75rem; color: #888; }
.appt-duration {
  font-size: 0.7rem; color: #aaa;
  padding: 0.2rem 0.5rem; border-radius: 0.4rem;
  background: #f5f5f5;
}

/* MESSAGES (dashboard) */
.msg-row {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f5f5f5;
}
.msg-row:last-child { border-bottom: none; }
.msg-avatar {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: #f0f0f0; display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; font-weight: 700; color: #888; flex-shrink: 0;
  margin-top: 0.1rem;
}
.msg-content { flex: 1; }
.msg-name { font-weight: 600; font-size: 0.8rem; }
.msg-text { font-size: 0.8rem; color: #666; line-height: 1.5; margin-top: 0.15rem; }
.msg-time { font-size: 0.65rem; color: #bbb; margin-top: 0.25rem; }
.msg-unread { position: relative; }
.msg-unread::after {
  content: '';
  position: absolute; top: 0.75rem; right: 0;
  width: 6px; height: 6px; border-radius: 50%;
  background: #3b82f6;
}

/* REWARDS (dashboard) */
.reward-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f5f5f5;
  font-size: 0.85rem;
}
.reward-row:last-child { border-bottom: none; }
.reward-name { font-weight: 600; }
.reward-points { color: #888; font-size: 0.8rem; }
.reward-bar { height: 4px; border-radius: 2px; background: #f0f0f0; margin-top: 0.25rem; }
.reward-fill { height: 100%; border-radius: 2px; background: var(--brand-primary, #2a2a2a); }

/* UPSELL BANNER */
.upsell-banner {
  background: linear-gradient(135deg, var(--brand-primary, #2a2a2a), #3a3a3a);
  border-radius: 1rem; padding: 1.5rem;
  color: #fff; margin-top: 1.5rem;
}
.upsell-banner h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1rem; font-weight: 700; margin-bottom: 0.5rem;
}
.upsell-banner p { font-size: 0.8rem; color: rgba(255,255,255,0.7); line-height: 1.5; margin-bottom: 1rem; }
.btn-upsell {
  padding: 0.5rem 1rem; background: #fff; color: var(--brand-primary, #2a2a2a);
  border: none; border-radius: 0.75rem; font-size: 0.8rem; font-weight: 700;
  cursor: pointer; text-decoration: none; display: inline-block;
}

/* FILTER BAR (leads screen) */
.filter-bar {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
}
.filter-pills { display: contents; } /* pills act as direct flex children on desktop; becomes the scroll row on mobile */
.filter-btn {
  padding: 0.45rem 0.9rem; border-radius: 9999px;
  font-size: 0.8rem; font-weight: 600; cursor: pointer;
  border: 1px solid #ddd; background: #fff; color: #666;
  transition: all 0.2s; text-decoration: none;
}
.filter-btn:hover { border-color: #aaa; }
.filter-btn.active { background: var(--brand-primary, #2a2a2a); color: #fff; border-color: var(--brand-primary, #2a2a2a); }
.filter-count {
  font-size: 0.65rem; background: rgba(255,255,255,0.3); padding: 0.1rem 0.4rem;
  border-radius: 9999px; margin-left: 0.25rem;
}
.filter-btn:not(.active) .filter-count { background: rgba(42,42,42,0.08); }
.search-input {
  padding: 0.45rem 0.9rem; border: 1px solid #ddd; border-radius: 0.75rem;
  font-size: 0.8rem; font-family: inherit; outline: none;
  width: 200px; transition: border-color 0.2s;
}
.search-input:focus { border-color: #999; }

/* SOURCE BREAKDOWN */
.source-bar { display: flex; gap: 0.75rem; margin-top: 0.5rem; flex-wrap: wrap; }
.source-item { font-size: 0.7rem; color: #666; }
.source-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: 0.25rem; vertical-align: middle;
}
.source-directory { background: #3b82f6; }
.source-direct { background: #8b5cf6; }
.source-referral { background: #f59e0b; }

/* LEADS TABLE */
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th {
  text-align: left; font-size: 0.7rem; font-weight: 700;
  color: #888; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.75rem 1rem; border-bottom: 1px solid #f0f0f0;
}
.leads-table td {
  padding: 0.85rem 1rem; border-bottom: 1px solid #f5f5f5;
  font-size: 0.85rem; vertical-align: middle;
}
.leads-table tr:last-child td { border-bottom: none; }
.leads-table tbody tr:hover { background: #fafaf8; }
.lead-cell { display: flex; align-items: center; gap: 0.75rem; }
.lead-service { font-size: 0.75rem; color: #888; }
.lead-source {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: 0.75rem; color: #666;
}
.lead-date { font-size: 0.75rem; color: #999; white-space: nowrap; }
.lead-actions { display: flex; gap: 0.4rem; }
.lead-actions form { display: inline; }
.btn-sm {
  padding: 0.3rem 0.6rem; border-radius: 0.5rem;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  border: 1px solid #ddd; background: #fff; color: #555;
  transition: all 0.2s; text-decoration: none; display: inline-block;
}
.btn-sm:hover { border-color: #999; }
.btn-sm-dark {
  padding: 0.3rem 0.6rem; border-radius: 0.5rem;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  border: none; background: var(--brand-primary, #2a2a2a); color: #fff;
  text-decoration: none; display: inline-block;
}
.btn-sm-archive {
  padding: 0.3rem 0.6rem; border-radius: 0.5rem;
  font-size: 0.7rem; font-weight: 600; cursor: pointer;
  border: 1px solid #eee; background: transparent; color: #bbb;
  transition: all 0.2s;
}
.btn-sm-archive:hover { color: #888; border-color: #ccc; }

/* GATED LEADS (free plan past the limit) */
tr.lead-gated .lead-name,
tr.lead-gated .lead-service,
tr.lead-gated td:nth-child(2) { filter: blur(5px); user-select: none; }
tr.lead-gated { position: relative; }
.gate-banner {
  background: linear-gradient(135deg, var(--brand-primary, #2a2a2a), #3a3a3a);
  color: #fff; border-radius: 1rem; padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.gate-banner p { font-size: 0.85rem; color: rgba(255,255,255,0.75); margin-top: 0.25rem; }
.gate-banner strong { font-family: 'Outfit', sans-serif; font-size: 1rem; }

@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .leads-table { font-size: 0.8rem; }
}
@media (min-width: 641px) and (max-width: 1024px) {
  .lead-actions { display: none; }
}
@media (max-width: 640px) {
  .stats-row { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-input { width: 100%; }
}

/* =====================================================================
   MOBILE CHROME (<=768px) — layout swap: sidebar -> sticky header + bottom
   nav + More sheet. Desktop (>=769px) is untouched by anything below.
   ===================================================================== */

.m-portal-header,
.bottom-nav,
.more-sheet-overlay,
.more-sheet,
.m-stats-pills,
.leads-cards {
  display: none;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 0; }

  /* MOBILE HEADER */
  .m-portal-header {
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
    background: rgba(42,42,42,0.95); backdrop-filter: blur(12px);
    padding: 12px 16px;
    /* Installed-PWA full screen (viewport-fit=cover): keep the header content
       below the iOS status bar; env() is 0 everywhere else. */
    padding-top: calc(12px + env(safe-area-inset-top));
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .m-portal-header .brand-small {
    font-family: 'Cabin', sans-serif; font-size: 0.75rem;
    color: rgba(255,255,255,0.4);
  }
  .m-portal-header .page-title {
    font-family: 'Outfit', sans-serif; font-weight: 600;
    font-size: 1.1rem; color: #fff;
  }
  .m-portal-header .avatar-circle {
    width: 32px; height: 32px; border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff;
    text-decoration: none; flex-shrink: 0;
  }

  /* BOTTOM NAV */
  .bottom-nav {
    display: flex; justify-content: space-around; align-items: center;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: #2a2a2a;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,0.1);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    color: rgba(255,255,255,0.5); text-decoration: none;
    font-size: 10px; font-weight: 600; font-family: 'Inter', sans-serif;
    padding: 4px 12px; min-height: 44px; justify-content: center;
    background: none; border: none; cursor: pointer;
    transition: color 0.2s;
  }
  .bottom-nav a.active, .bottom-nav button.active { color: #fff; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .nav-icon-wrap { position: relative; display: inline-flex; }
  .nav-unread-dot {
    position: absolute; top: -1px; right: -1px;
    width: 8px; height: 8px; border-radius: 50%;
    background: #ef4444; border: 1.5px solid #2a2a2a;
  }

  /* MORE SHEET */
  .more-sheet-overlay {
    display: block;
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    z-index: 199; opacity: 0; pointer-events: none;
    transition: opacity 0.3s;
  }
  .more-sheet-overlay.open { opacity: 1; pointer-events: auto; }
  .more-sheet {
    display: block;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
    background: #fff;
    border-radius: 1.25rem 1.25rem 0 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(100%);
    transition: transform 0.3s;
  }
  .more-sheet.open { transform: translateY(0); }
  .more-sheet-handle {
    width: 36px; height: 4px; border-radius: 2px;
    background: #ddd; margin: 0 auto 14px;
  }
  .more-sheet-identity {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.25rem 1rem; border-bottom: 1px solid #f0f0f0; margin-bottom: 0.5rem;
  }
  .more-sheet-avatar {
    width: 2.25rem; height: 2.25rem; border-radius: 50%;
    background: rgba(42,42,42,0.08);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700; color: var(--brand-primary, #2a2a2a); flex-shrink: 0;
  }
  .more-sheet-name { font-size: 0.9rem; font-weight: 600; }
  .more-sheet-plan { font-size: 0.7rem; color: #888; }
  .more-sheet-row {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 0.25rem; min-height: 44px;
    color: var(--brand-primary, #2a2a2a); text-decoration: none;
    font-size: 0.9rem; font-weight: 500;
    border: none; background: none; width: 100%; text-align: left;
    font-family: inherit; cursor: pointer;
  }
  .more-sheet-row svg { flex-shrink: 0; opacity: 0.6; }
  .more-sheet-row .soon {
    margin-left: auto; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.06em;
    text-transform: uppercase; color: #999;
    border: 1px solid #ddd; border-radius: 9999px; padding: 0.1rem 0.5rem;
  }
  .more-sheet-row-disabled { color: #999; cursor: default; }
  .more-sheet-row-danger { color: #dc2626; }

  /* Bottom-nav clearance on every portal screen's content container.
     The body prefix out-specifies messages.css's ".main:has(> .messages-layout)
     { padding: 0 }" — that file loads AFTER portal.css, so an equal-specificity
     selector here would lose the cascade. */
  .main,
  body .main:has(> .messages-layout) {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
  }

  /* Generic fallback padding for any screen without a page-specific override below
     (e.g. payments.php uses the base .topbar/.card/.stats-row with no dual mobile markup). */
  .main > .topbar { padding: 20px 16px 0; margin-bottom: 1.25rem; }
  .main > .stats-row { padding: 0 16px; }
  .main > .card { margin: 0 16px; border-radius: 1rem; }
  .main > .notice-amber { margin: 0 16px 1.25rem; }
}

/* =====================================================================
   DASHBOARD MOBILE (spec 6B-2)
   ===================================================================== */
@media (max-width: 768px) {
  .main .topbar { padding: 20px 16px 0; }
  .main .topbar h1 {
    font-family: 'Outfit', sans-serif; font-weight: 700; font-size: 1.35rem;
  }
  .main .topbar-sub { font-size: 0.8rem; color: #888; }
  .main .topbar-actions { display: none; }
  .welcome-banner { margin: 16px; }

  .stats-row {
    grid-template-columns: 1fr 1fr; gap: 12px;
    padding: 0 16px; margin-bottom: 24px;
  }
  .stat-card {
    background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 1rem;
    padding: 16px;
  }
  .stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; }
  .stat-value { font-size: 1.5rem; }
  .stat-change { font-size: 0.65rem; padding: 2px 6px; border-radius: 9999px; }
  .stat-up { background: #dcfce7; color: #16a34a; display: inline-block; }

  .dashboard-grid { display: block; padding: 0 16px; }
  .dashboard-grid > div { margin-bottom: 24px; }

  /* Recent leads -> compact lead cards */
  .card-header { padding: 0; border-bottom: none; margin-bottom: 12px; background: none; }
  .card-title { font-family: 'Outfit', sans-serif; font-weight: 600; font-size: 1.05rem; }
  .card-action { color: #6366f1; font-size: 0.75rem; }
  .card { background: none; border: none; border-radius: 0; }
  .card-body { padding: 0; }

  .lead-row {
    background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 1rem;
    padding: 14px 16px; margin-bottom: 10px; border-bottom: none;
    gap: 12px;
  }
  .lead-avatar {
    width: 40px; height: 40px; font-size: 0.7rem; color: #fff;
    background: var(--m-avatar-bg, #f0f0f0);
  }
  .lead-name { font-size: 0.85rem; }
  /* Mockup (mobile-backend-dashboard) shows a detail line under the name —
     keep it, clamped to one line so long messages can't stack the card. */
  .lead-info { min-width: 0; }
  .lead-detail {
    margin-top: 1px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .lead-status {
    font-size: 0.6rem; padding: 3px 8px;
  }
  .lead-time { font-size: 0.65rem; }

  /* Today's schedule timeline */
  .appt-row {
    background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 1rem;
    padding: 12px 14px; margin-bottom: 12px; border-bottom: none;
    border-left: 3px solid #6366f1;
    align-items: flex-start;
  }
  .appt-time-block {
    text-align: right; min-width: 56px; padding-top: 2px;
  }
  .appt-service { font-size: 0.85rem; }
  .appt-client { font-size: 0.75rem; }
  .appt-duration { font-size: 0.65rem; }

  /* Messages + rewards blocks stack (already block-level via dashboard-grid change above) */
  .msg-row, .reward-row {
    background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 1rem;
    padding: 12px 14px; margin-bottom: 10px; border-bottom: none;
  }

  .upsell-banner { border-radius: 1.25rem; padding: 20px; }
  .btn-upsell { min-height: 44px; display: inline-flex; align-items: center; padding: 0 20px; }
}

/* =====================================================================
   LEADS MOBILE (spec 6B-3)
   ===================================================================== */
@media (max-width: 768px) {
  .main .topbar { padding: 20px 16px 0; margin-bottom: 0.5rem; }

  .gate-banner { margin: 0 16px 1.25rem; }

  /* Leads: desktop 4-stat-card row is replaced by mobile pill row */
  .leads-page .stats-row { display: none; }
  .m-stats-pills {
    display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin: 0 0 1.25rem; padding: 0 16px;
  }
  .m-stats-pills::-webkit-scrollbar { display: none; }
  .m-stats-pills .stat-pill {
    flex-shrink: 0; background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 9999px;
    padding: 8px 16px; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
  }
  .m-stats-pills .pill-count {
    font-family: 'Outfit', sans-serif; font-weight: 700; margin-right: 4px;
  }
  .m-stats-pills .pill-label { color: #888; }

  /* Filter bar: pills become a horizontal scroll row (.filter-pills), search
     form drops to a full-width block below. .filter-bar itself is a plain block
     so the old 640px flex-direction rule can't stack the pills. No edge-bleed
     margins: .main has zero padding on mobile. */
  .filter-bar { display: block; margin: 0 0 1rem; padding: 0 16px; }
  .filter-pills {
    display: flex; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; gap: 8px;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .filter-pills .filter-btn { flex-shrink: 0; min-height: 44px; display: inline-flex; align-items: center; }
  .filter-bar form { width: 100%; margin-top: 0.75rem; }
  .filter-bar > div[style*="flex:1"] { display: none; }

  /* Desktop table hidden, mobile card list shown */
  .leads-table { display: none; }
  .leads-cards { display: block; padding: 0 16px; }
  .card > .card-header { padding: 1rem 1.25rem 0; }

  .m-lead-card {
    background: rgba(255,255,255,0.8); backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.3); border-radius: 1rem;
    padding: 14px 16px; margin-bottom: 10px;
    color: inherit;
    transition: transform 0.15s;
  }
  .m-lead-card[data-href] { cursor: pointer; }
  .m-lead-card:active { transform: scale(0.98); }
  .m-lead-card.lead-gated .m-lead-name,
  .m-lead-card.lead-gated .m-lead-row { filter: blur(5px); user-select: none; }
  .m-lead-top { display: flex; align-items: center; gap: 12px; }
  .m-lead-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff; flex-shrink: 0;
  }
  .m-lead-info { flex: 1; min-width: 0; }
  .m-lead-name { font-weight: 600; font-size: 0.85rem; }
  .m-lead-row { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
  .m-lead-service { font-size: 0.75rem; color: #888; }
  .m-lead-price { font-size: 0.75rem; font-weight: 600; color: var(--brand-primary, #2a2a2a); }
  .m-lead-dot { width: 3px; height: 3px; border-radius: 50%; background: #ccc; flex-shrink: 0; }
  .m-lead-right {
    display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0;
  }
  .m-lead-time { font-size: 0.65rem; color: #aaa; }

  /* Shared status badge pill (spec: mobile design system) */
  .status-badge {
    display: inline-block; font-size: 0.6rem; font-weight: 700;
    padding: 3px 8px; border-radius: 9999px; text-transform: uppercase;
    letter-spacing: 0.3px;
  }
  .badge-new { background: #dcfce7; color: #16a34a; }
  .badge-replied { background: #dbeafe; color: #2563eb; }
  .badge-booked { background: #ede9fe; color: #7c3aed; }
  .badge-lost { background: #f3f4f6; color: #9ca3af; }

  .m-quick-actions { display: flex; gap: 8px; margin-top: 6px; }
  .m-quick-action {
    width: 32px; height: 32px; border-radius: 50%;
    background: rgba(0,0,0,0.05);
    display: flex; align-items: center; justify-content: center;
    color: #666; flex-shrink: 0;
  }
  .m-quick-action svg { width: 16px; height: 16px; }

  .m-lead-actions {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; width: 100%;
  }
  .m-lead-actions form { flex: 1 1 auto; min-width: 72px; }
  .m-lead-actions .btn-sm,
  .m-lead-actions .btn-sm-dark,
  .m-lead-actions .btn-sm-archive {
    width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: center;
  }
}


/* PORTAL LOGIN */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #f8f7f2; padding: 1.5rem;
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 1.5rem;
  padding: 2.5rem 2rem;
  box-shadow: 0 20px 40px rgba(42,42,42,0.12); border: 1px solid #eee;
}
.login-logo {
  font-family: 'Cabin', sans-serif; font-weight: 600; font-size: 1.6rem; color: #2a2a2a;
  text-align: center;
}
.login-sub {
  text-align: center; font-size: 0.8rem; color: #888; margin: 0.35rem 0 2rem;
}
.login-card .form-label { display: block; font-size: 0.8rem; font-weight: 600; color: #333; margin-bottom: 0.4rem; }
.login-card .form-input {
  width: 100%; padding: 0.75rem 1rem;
  border: 1.5px solid #ddd; border-radius: 0.75rem;
  font-size: 0.9rem; font-family: inherit; outline: none;
  margin-bottom: 1.1rem;
}
.login-card .form-input:focus { border-color: #2a2a2a; box-shadow: 0 0 0 3px rgba(42,42,42,0.08); }
@media (max-width: 768px) {
  .login-wrap { padding: 16px; }
  .login-card { padding: 2rem 1.5rem; }
  .login-card .form-input { font-size: 16px; }
}
.login-error {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: 0.75rem; padding: 0.6rem 1rem; font-size: 0.82rem; margin-bottom: 1.1rem;
}
.login-ok {
  background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534;
  border-radius: 0.75rem; padding: 0.6rem 1rem; font-size: 0.82rem; margin-bottom: 1.1rem; line-height: 1.5;
}
.login-btn {
  width: 100%; padding: 0.85rem; background: #2a2a2a; color: #fff;
  border: none; border-radius: 0.75rem; font-weight: 700; font-size: 0.95rem; cursor: pointer;
}
.login-btn:hover { background: #1a1a1a; }
.login-foot { text-align: center; margin-top: 1.5rem; font-size: 0.8rem; color: #999; }
.login-foot a { color: #2a2a2a; font-weight: 600; }

/* ===== PWA install banner (dashboard, under the greeting) — chunk 6E ===== */
.pwa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: #2a2a2a;
  color: #fff;
  border-radius: 1rem;
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.25rem;
}
.pwa-install-banner-text { display: flex; flex-direction: column; gap: 2px; }
.pwa-install-banner-text strong { font-size: 0.95rem; font-weight: 700; }
.pwa-install-banner-text span { font-size: 0.8rem; color: rgba(255,255,255,0.7); }
.pwa-install-banner-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pwa-install-banner-install {
  background: #fff; color: #2a2a2a; border: none; border-radius: 9999px;
  padding: 8px 18px; font-weight: 700; font-size: 0.85rem; cursor: pointer; min-height: 40px;
}
.pwa-install-banner-install:active { transform: scale(0.98); }
.pwa-install-banner-dismiss {
  background: transparent; color: rgba(255,255,255,0.6); border: none;
  font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 4px;
}
