/* ═══════════════════════════════════════════════════════════════════
   Project Waypoint — LeafHome family design system
   Modeled on Field Canvassing Ops + Anomaly Dashboard
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Oswald:wght@500;600;700&display=swap');

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

:root {
  /* ── LeafHome brand greens ──────────────────────── */
  --green-900: #0a2e1d;
  --green-800: #0f4d2a;
  --green-700: #1a6b3b;
  --green-600: #22884c;
  --green-500: #2da55a;
  --green-100: #d4edd8;
  --green-50:  #ecf7ee;
  --accent:    #00a86b;

  /* ── Status palette ────────────────────────────── */
  --red-700:    #991b1b;
  --red-600:    #b91c1c;
  --red-500:    #dc2626;
  --red-100:    #fee2e2;
  --red-50:     #fef2f2;
  --amber-700:  #92400e;
  --amber-600:  #b45309;
  --amber-200:  #fde68a;
  --amber-100:  #fef3c7;
  --amber-50:   #fffbeb;
  --orange-600: #c2410c;
  --orange-500: #ea580c;
  --orange-100: #ffedd5;
  --purple-700: #6b21a8;
  --purple-600: #7e22ce;
  --purple-100: #f3e8ff;
  --blue-700:   #1d4ed8;
  --blue-600:   #2563eb;
  --blue-100:   #dbeafe;

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

  /* ── Shadows ───────────────────────────────────── */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow:    0 1px 3px 0 rgba(15, 23, 42, 0.08), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);

  /* ── Type ──────────────────────────────────────── */
  --display: 'Oswald', system-ui, sans-serif;
  --sans:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', system-ui, 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

::selection { background: var(--green-600); color: var(--white); }

body {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ════════════════════════════════════════════════════
   TOPBAR (matches the LeafHome dashboard pattern)
   ════════════════════════════════════════════════════ */
.topbar {
  background: var(--green-900);
  border-bottom: 1px solid var(--green-800);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: stretch; gap: 18px;
  position: sticky; top: 0; z-index: 100;
}
.header-left  { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 0 0 auto; }
.header-right { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: 0 0 auto; }

/* Tabs sit inline in the green topbar — to the right of the brand and to the
 * left of the user/sign-out controls. They stretch the full topbar height so
 * the active tab's underline lands cleanly at the bottom edge. (v0.3.44) */
.topbar .tabs.tabs-bare {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  margin: 0 !important;
  max-width: none !important;
  display: flex;
  align-items: stretch;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
}
.topbar .tabs.tabs-bare .tab {
  background: transparent;
  color: rgba(255, 255, 255, 0.65);
  padding: 0 16px;
  border-radius: 0;
  box-shadow: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.topbar .tabs.tabs-bare .tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}
.topbar .tabs.tabs-bare .tab.active {
  color: #ffffff;
  background: transparent;
  box-shadow: inset 0 -3px 0 var(--green-500);
}

.logo-mark {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--green-500);
  color: var(--white);
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18);
}
.logo-text {
  display: flex; flex-direction: column;
  line-height: 1.15;
}
.logo-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  color: var(--white);
  letter-spacing: 0.01em;
}
.logo-sub {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.6);
}

.user-chip {
  display: flex; flex-direction: column;
  align-items: flex-end; line-height: 1.2;
  padding-right: 4px;
}
.user-name { font-size: 13px; font-weight: 500; color: var(--white); }
.user-role {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.55);
}

.header-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.header-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--white);
}

/* ════════════════════════════════════════════════════
   MAIN LAYOUT
   ════════════════════════════════════════════════════ */
.app-main {
  padding: 24px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

.page-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}
.page-sub {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

/* ════════════════════════════════════════════════════
   STAT / KPI CARDS
   (Field Canvass Ops uses these on every page)
   ════════════════════════════════════════════════════ */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 18px 18px 16px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.stat-card.s-total::before  { background: var(--green-700); }
.stat-card.s-green::before  { background: var(--rating-juicy-border); }
.stat-card.s-lime::before   { background: var(--rating-desirable-border); }
.stat-card.s-red::before    { background: var(--red-600); }
.stat-card.s-amber::before  { background: var(--rating-medium-border); }
.stat-card.s-orange::before { background: var(--orange-500); }
.stat-card.s-purple::before { background: var(--purple-600); }
.stat-card.s-blue::before   { background: var(--blue-600); }

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--gray-500);
  font-weight: 600;
  margin-bottom: 8px;
}
.stat-num {
  font-family: var(--display);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.05;
  color: var(--gray-900);
}
.stat-card.s-green  .stat-num { color: var(--rating-juicy-fg); }
.stat-card.s-lime   .stat-num { color: var(--rating-desirable-fg); }
.stat-card.s-red    .stat-num { color: var(--red-600); }
.stat-card.s-amber  .stat-num { color: var(--rating-medium-fg); }
.stat-card.s-orange .stat-num { color: var(--orange-500); }
.stat-card.s-purple .stat-num { color: var(--purple-600); }
.stat-card.s-blue   .stat-num { color: var(--blue-600); }
.stat-sub {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ════════════════════════════════════════════════════
   PANELS / CARDS
   ════════════════════════════════════════════════════ */
.panel {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--gray-100);
}
.panel-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}
.panel-sub { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ════════════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  padding: 4px 4px 0;
}
.tab {
  background: transparent;
  border: 0;
  padding: 12px 16px 13px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray-500);
  border-radius: 6px 6px 0 0;
  transition: color 0.15s, background 0.15s;
}
.tab:hover { color: var(--gray-900); background: var(--gray-50); }
.tab.active {
  color: var(--green-900);
  background: var(--white);
  box-shadow: inset 0 -2px 0 var(--green-700);
}

/* ════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-700);
  transition: all 0.15s;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-primary {
  background: var(--green-600);
  border-color: var(--green-700);
  color: var(--white);
}
.btn-primary:hover { background: var(--green-700); border-color: var(--green-800); }

/* ════════════════════════════════════════════════════
   FORMS
   ════════════════════════════════════════════════════ */
input, select, textarea {
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: var(--white);
  color: var(--gray-900);
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(45, 165, 90, 0.12);
}

/* ════════════════════════════════════════════════════
   TABLES
   ════════════════════════════════════════════════════ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--gray-100); color: var(--gray-800); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--gray-50); }

/* ════════════════════════════════════════════════════
   BADGES / TAGS / PILLS
   ════════════════════════════════════════════════════ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-green  { background: var(--green-50);  color: var(--green-700); }
.badge-lime   { background: #f0f9e8;          color: #4d7c2e; }
.badge-darkgreen { background: #dcfce7;       color: #166534; }
.badge-orange { background: #ffedd5;          color: #c2410c; }
.badge-yellow { background: #fef9c3;          color: #a16207; }
.badge-amber  { background: var(--amber-100); color: var(--amber-700); }
.badge-red    { background: var(--red-100);   color: var(--red-700); }
.badge-blue   { background: var(--blue-100);  color: var(--blue-700); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-700); }
.badge-purple { background: var(--purple-100); color: var(--purple-700); }

/* ════════════════════════════════════════════════════
   SCORE BADGE (Waypoint-specific)
   ════════════════════════════════════════════════════ */
.score-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 96px; height: 96px;
  border-radius: 50%;
  font-family: var(--display);
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.score-badge .score-value { font-size: 36px; line-height: 1; }
.score-badge .score-rating {
  font-size: 10px; margin-top: 4px;
  text-transform: uppercase; letter-spacing: 0.12em;
  font-weight: 600;
}
.score-juicy     { background: var(--rating-juicy-bg);     color: var(--rating-juicy-fg);     border: 2px solid var(--rating-juicy-border); }
.score-desirable { background: var(--rating-desirable-bg); color: var(--rating-desirable-fg); border: 2px solid var(--rating-desirable-border); }
.score-medium    { background: var(--rating-medium-bg);    color: var(--rating-medium-fg);    border: 2px solid var(--rating-medium-border); }
.score-low       { background: var(--rating-low-bg);       color: var(--rating-low-fg);       border: 2px solid var(--rating-low-border); }

/* ════════════════════════════════════════════════════
   SCORE BREAKDOWN ROW
   ════════════════════════════════════════════════════ */
.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  border-bottom: 1px solid var(--gray-100);
}
.metric-row:last-child { border-bottom: none; }
.metric-name {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; color: var(--gray-800);
}
.metric-value {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-weight: 600; color: var(--gray-900);
}
.metric-modifier {
  font-family: var(--display);
  font-size: 14px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  min-width: 36px;
  text-align: center;
}
.metric-modifier.pos { background: var(--green-50);  color: var(--green-700); }
.metric-modifier.neg { background: var(--red-50);    color: var(--red-700); }

.dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-pass    { background: var(--green-500); }
.dot-partial { background: var(--amber-600); }
.dot-fail    { background: var(--red-500); }
.dot-unknown { background: var(--gray-400); }

/* ════════════════════════════════════════════════════
   GRIDS
   ════════════════════════════════════════════════════ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-map { display: grid; grid-template-columns: 1fr 400px; gap: 16px; min-height: calc(100vh - 180px); }
@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-map { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════
   LOADING STATES
   ════════════════════════════════════════════════════ */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--gray-100) 25%, var(--gray-200) 50%, var(--gray-100) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 6px;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ════════════════════════════════════════════════════
   LOGIN SCREEN
   ════════════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(45, 165, 90, 0.08), transparent 60%),
    linear-gradient(180deg, var(--gray-50) 0%, #eef3ee 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--green-700), var(--green-500));
}
.login-eyebrow {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--green-700);
  margin-bottom: 6px;
}
.login-title {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 600;
  color: var(--green-900);
  letter-spacing: 0.01em;
  margin-bottom: 4px;
}
.login-sub { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }

.login-field { display: block; margin-bottom: 14px; }
.login-field span {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.login-submit {
  width: 100%;
  background: var(--green-600);
  border: 1px solid var(--green-700);
  color: var(--white);
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.15s;
  margin-top: 8px;
}
.login-submit:hover { background: var(--green-700); }

.login-error {
  background: var(--red-50);
  border: 1px solid var(--red-100);
  color: var(--red-700);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 12px;
}

/* ════════════════════════════════════════════════════
   MAP CONTAINER (for Mapbox)
   ════════════════════════════════════════════════════ */
.map-container {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  position: relative;
  min-height: 600px;
}
.mapboxgl-popup-content {
  font-family: var(--sans);
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

/* ════════════════════════════════════════════════════
   MOBILE / PHONE OPTIMIZATIONS
   ════════════════════════════════════════════════════ */

/* Compact topbar on phone — two stacked rows: brand+minimum-controls on top,
 * full-width scrollable tab strip below. Decorative popovers (Score / How scored)
 * and the user-name chip are hidden on phone to keep the row uncluttered;
 * the colorblind eye + Sign Out remain. (v0.3.45) */
@media (max-width: 768px) {
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 0;
    gap: 0;
    align-items: center;
  }
  .topbar .header-left {
    padding: 0 12px;
    height: 56px;
    flex: 1 1 auto;
    min-width: 0;
  }
  .topbar .header-right {
    padding: 0 12px;
    height: 56px;
    margin-left: auto;
    gap: 6px;
  }
  .topbar .tabs.tabs-bare {
    order: 99;                    /* force to second row regardless of source order */
    flex: 0 0 100%;
    height: 44px;
    border-top: 1px solid var(--green-800);
    padding: 0 4px !important;
    gap: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .topbar .tabs.tabs-bare::-webkit-scrollbar { display: none; }
  .topbar .tabs.tabs-bare .tab {
    padding: 0 12px;
    font-size: 11px;
    flex: 0 0 auto;
  }
  .logo-mark { width: 32px; height: 32px; font-size: 13px; }
  .logo-name { font-size: 15px; }
  .logo-sub  { display: none; }              /* "Territory Intelligence" — saves room */
  #scorePopWrap,
  #howScoredPopWrap,
  .user-chip { display: none; }              /* hide on phone, keep eye + Sign Out */
  .header-btn {
    padding: 6px 10px;
    font-size: 10px;
    letter-spacing: 0.03em;
  }

  /* Main content */
  .app-main {
    padding: 12px;
  }

  /* Search bar — stack vertically */
  .panel {
    padding: 14px;
  }
  .app-main > .panel:first-child {
    flex-direction: column;
    gap: 8px !important;
    padding: 12px !important;
  }
  .app-main > .panel:first-child > div:first-child {
    width: 100%;
  }
  .app-main > .panel:first-child select#officeSelect {
    width: 100% !important;
  }

  /* Map: make it short and prominent */
  .grid-map {
    grid-template-columns: 1fr;
    gap: 10px;
    min-height: auto;
  }
  .map-container {
    min-height: 320px;
    height: 45vh;
    max-height: 480px;
  }

  /* Result panel: full width below map */
  #resultPanel {
    /* v0.3.49: clear the sticky topbar (header row + tab row) when we auto-scroll
       the scan result into view after a territory tap. */
    scroll-margin-top: 108px;
  }
  #resultPanel .panel {
    padding: 16px;
    margin-bottom: 8px;
  }

  /* Score badge — slightly smaller on phone */
  .score-badge { width: 80px; height: 80px; }
  .score-badge .score-value { font-size: 30px; }
  .score-badge .score-rating { font-size: 9px; }

  /* Stats: 2 columns instead of 4 */
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-num { font-size: 24px; }

  /* Tables on phone */
  th, td { padding: 8px 8px; font-size: 12px; }
  thead th { font-size: 9.5px; letter-spacing: 0.06em; }

  /* Panel titles smaller */
  .page-title { font-size: 22px; }
  .panel-title { font-size: 15px; }

  /* Metric rows: tighter */
  .metric-row { padding: 9px 0; }
  .metric-name, .metric-value { font-size: 13px; }
  .metric-modifier { font-size: 13px; padding: 1px 7px; min-width: 32px; }

  /* Buttons: bigger tap targets */
  .btn, .login-submit { min-height: 44px; }
  input, select { min-height: 44px; }

  /* Login card */
  .login-screen { padding: 16px; }
  .login-card { padding: 24px; }
  .login-title { font-size: 24px; }

  /* Make map controls bigger so they're tappable */
  .mapboxgl-ctrl-group button {
    width: 36px !important;
    height: 36px !important;
  }
}

/* Extra-narrow phones */
@media (max-width: 380px) {
  .logo-text { display: none; }  /* Just show the W mark on tiny screens */
  .header-btn { padding: 5px 8px; font-size: 9px; }
  .stats { grid-template-columns: 1fr; }
}

/* Touch-friendly: prevent zoom on input focus (iOS Safari) */
@media (max-width: 768px) {
  input, select, textarea { font-size: 16px; }
}

/* ════════════════════════════════════════════════════
   MAP LEGEND OVERLAY
   ════════════════════════════════════════════════════ */
.map-legend {
  position: absolute;
  bottom: 12px; left: 12px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  font-size: 12px;
  z-index: 5;
}
.legend-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--gray-800);
  padding: 2px 0;
}
.legend-swatch {
  display: inline-block;
  width: 14px; height: 14px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════
   ZONE LIST ROWS (Top zones, Favorites, History)
   ════════════════════════════════════════════════════ */
.zone-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background 0.1s;
}
.zone-row:hover { background: var(--gray-50); }
.zone-row:last-child { border-bottom: none; }
.zone-score-pill {
  width: 52px; height: 52px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border-radius: 8px;
  font-family: var(--display);
  font-weight: 700;
  flex-shrink: 0;
}
.zone-score-pill .v { font-size: 18px; line-height: 1; }
.zone-score-pill .r { font-size: 8px; margin-top: 2px; letter-spacing: 0.08em; }
.zone-row-body { flex: 1; min-width: 0; }
.zone-row-title { font-size: 14px; font-weight: 600; color: var(--gray-900); margin-bottom: 2px; }
.zone-row-meta { font-size: 12px; color: var(--gray-500); }
.zone-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.icon-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
}
.icon-btn:hover { background: var(--gray-50); color: var(--gray-900); }
.icon-btn.fav-on { background: #fef3c7; border-color: #fde68a; color: #92400e; }

/* ════════════════════════════════════════════════════
   DRAW MODE
   ════════════════════════════════════════════════════ */
.btn.draw-active {
  background: var(--green-50);
  border-color: var(--green-500);
  color: var(--green-700);
}
.mapbox-gl-draw_polygon { display: none !important; } /* hide built-in toolbar, we use our own button */

/* Mobile tweaks for new components */
@media (max-width: 768px) {
  .map-legend {
    bottom: 8px; left: 8px;
    padding: 8px 10px;
    font-size: 11px;
  }
  .legend-title { font-size: 9px; }
  .legend-row { font-size: 11px; }
  .legend-swatch { width: 12px; height: 12px; }

  .tabs {
    max-width: none;
    margin: 8px 12px 0;
    padding: 3px 3px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .tab {
    padding: 10px 12px 11px;
    font-size: 11px;
    flex-shrink: 0;
  }

  .zone-row { padding: 10px 0; gap: 10px; }
  .zone-score-pill { width: 44px; height: 44px; }
  .zone-score-pill .v { font-size: 16px; }
  .zone-row-title { font-size: 13px; }
  .zone-row-meta { font-size: 11px; }
}

/* ════════════════════════════════════════════════════
   OFFICE PICKER (used in admin invite + user editor)
   ════════════════════════════════════════════════════ */
.office-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  max-height: 280px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.office-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 10px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  cursor: pointer;
  user-select: -webkit-user-select: none;
  min-height: 38px;
  transition: all 0.12s;
}
.office-picker label:has(input:checked) {
  background: var(--green-50);
  border-color: var(--green-500);
  color: var(--green-900);
  font-weight: 500;
}
.office-picker input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin: 0;
  border: 1.5px solid var(--gray-400);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  position: relative;
}
.office-picker input[type="checkbox"]:checked {
  background: var(--green-600);
  border-color: var(--green-600);
}
.office-picker input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.office-picker label .office-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}

/* On wider screens, allow more columns */
@media (min-width: 600px) {
  .office-picker {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

/* Map style toggle (top-left of map) */
.map-style-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1;
  display: flex;
  background: white;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.18);
  overflow: hidden;
  font-family: var(--sans);
}
.map-style-toggle button {
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 600;
  border: 0;
  background: white;
  cursor: pointer;
  color: var(--gray-700);
  transition: background 0.15s, color 0.15s;
  text-transform: none;
  letter-spacing: 0;
  min-height: auto;
}
.map-style-toggle button + button {
  border-left: 1px solid var(--gray-200);
}
.map-style-toggle button:hover {
  background: var(--gray-50);
}
.map-style-toggle button.active {
  background: var(--green-700);
  color: white;
}
.map-style-toggle button.active:hover {
  background: var(--green-800);
}
@media (max-width: 600px) {
  .map-style-toggle button { padding: 6px 9px; font-size: 10px; }
}

/* AI Briefing Banner — appears above the map after a turf is selected */
.ai-brief-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
  border: 1px solid #e9d5ff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(76, 29, 149, 0.06);
  animation: slideDownFade 0.3s ease-out;
}
.ai-brief-banner.hidden { display: none; }
.ai-brief-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}
.ai-brief-body {
  flex: 1;
  min-width: 0;
}
.ai-brief-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: #7c3aed;
  margin-bottom: 4px;
}
.ai-brief-content {
  font-size: 14px;
  line-height: 1.55;
  color: #3b0764;
  font-family: var(--sans);
}
.ai-brief-content.loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #7c3aed;
  font-style: italic;
}
.ai-brief-content.loading::before {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid #e9d5ff;
  border-top-color: #7c3aed;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  flex-shrink: 0;
}
.ai-brief-content.error {
  color: #b91c1c;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Same-Day Mode toggle */
.mode-toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.mode-toggle:hover { background: var(--gray-100); }
.mode-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.mode-toggle-track {
  position: relative;
  flex-shrink: 0;
  width: 38px;
  height: 22px;
  background: var(--gray-300);
  border-radius: 11px;
  transition: background 0.18s;
  margin-top: 2px;
}
.mode-toggle-dot {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  transition: transform 0.18s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.mode-toggle input:checked + .mode-toggle-track {
  background: linear-gradient(90deg, #f59e0b 0%, #eab308 100%);
}
.mode-toggle input:checked + .mode-toggle-track .mode-toggle-dot {
  transform: translateX(16px);
}
.mode-toggle-label {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-800);
  flex: 1;
}
.mode-toggle-hint {
  width: 100%;
  font-size: 11px;
  font-weight: 400;
  color: var(--gray-500);
  line-height: 1.35;
}
.mode-toggle input:checked ~ .mode-toggle-label { color: var(--green-900); }

/* Same-day eligibility badge on zone rows */
.same-day-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: linear-gradient(90deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Brand → home affordance */
#brandHome { cursor: pointer; user-select: none; transition: opacity 0.15s; }
#brandHome:hover { opacity: 0.85; }
#brandHome:focus-visible { outline: 2px solid rgba(255,255,255,0.4); outline-offset: 4px; border-radius: 4px; }

/* Auto-update banner — appears at the top of the page when a new deploy is detected */
.update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: linear-gradient(90deg, #0a2e1d 0%, #1a6b3b 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  animation: slideDownBanner 0.35s ease-out;
}
.update-banner-hiding {
  animation: slideUpBanner 0.3s ease-in forwards;
}
.update-banner-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 10px 16px;
  font-size: 13px;
  font-family: var(--sans);
}
.update-banner-icon { font-size: 16px; }
.update-banner-text { flex: 1; font-weight: 500; }
.update-banner-btn {
  background: white;
  color: #0a2e1d;
  border: 0;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
}
.update-banner-btn:hover { background: #ecf7ee; }
.update-banner-btn:active { transform: scale(0.97); }
.update-banner-dismiss {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.7);
  font-size: 20px;
  line-height: 1;
  padding: 2px 8px;
  cursor: pointer;
  border-radius: 4px;
}
.update-banner-dismiss:hover { color: white; background: rgba(255,255,255,0.1); }

@keyframes slideDownBanner {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes slideUpBanner {
  from { transform: translateY(0); opacity: 1; }
  to   { transform: translateY(-100%); opacity: 0; }
}
@media (max-width: 600px) {
  .update-banner-text { font-size: 12px; }
  .update-banner-inner { padding: 8px 12px; gap: 8px; }
}

/* v0.3.8 — colorblind toggle + knocked/favorite button states */
.header-icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.header-icon-btn.active {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}
.btn.fav-on {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}
.btn.knock-on {
  background: #16a34a;
  color: white;
  border-color: #16a34a;
}

/* ═══════════════════════════════════════════════════════
   v0.3.9 — Colorblind dropdown, fullscreen map, HV slider
   ═══════════════════════════════════════════════════════ */

/* Colorblind mode dropdown in header */
/* ════════════════════════════════════════════════════
   HEADER POPOVERS (v0.3.10) — Score / How scored / Colorblind
   Replaces the old .cb-mode-wrap dropdown with three matching icon-style
   buttons in the header that each open an anchored popover panel.
   ════════════════════════════════════════════════════ */
.hdr-pop {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.hdr-pop-btn {
  /* Inherits .header-btn — this just tightens the icon variant */
  cursor: pointer;
}
.hdr-pop-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}
.hdr-pop-btn-icon {
  padding: 6px 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hdr-pop-btn-icon svg { display: block; }

.hdr-pop-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  max-width: 340px;
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18), 0 4px 10px rgba(15, 23, 42, 0.08);
  padding: 14px 16px;
  z-index: 1200;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
  /* hidden by default — JS toggles .is-open */
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity 0.12s ease, transform 0.12s ease, visibility 0.12s;
}
.hdr-pop-panel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.hdr-pop-panel-wide { min-width: 340px; max-width: 400px; }

.hdr-pop-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
  margin: 0 0 10px;
}

/* Score legend layout */
.hdr-pop-legend { display: flex; flex-direction: column; gap: 8px; }
.hdr-pop-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hdr-pop-swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(15, 23, 42, 0.12);
}
.hdr-pop-row-text { display: flex; align-items: baseline; gap: 8px; }
.hdr-pop-row-name { font-size: 13px; font-weight: 700; color: #0f172a; }
.hdr-pop-row-sub  { font-size: 12px; color: #64748b; }

/* How-scored factor list */
.hdr-pop-factors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
}
.hdr-pop-factors li {
  border-left: 3px solid #22884c;
  padding: 2px 0 2px 10px;
}
.hdr-pop-factor-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.hdr-pop-factor-name { font-size: 13px; font-weight: 700; color: #0f172a; }
.hdr-pop-factor-pts  { font-size: 11px; font-weight: 700; color: #22884c; white-space: nowrap; }
.hdr-pop-factor-note { font-size: 12px; color: #475569; line-height: 1.4; margin-top: 2px; }

/* Colorblind segmented control */
.hdr-pop-seg {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.hdr-pop-seg-btn {
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.hdr-pop-seg-btn:hover { border-color: #94a3b8; background: #f8fafc; }
.hdr-pop-seg-btn.is-active {
  background: #0a2e1d;
  border-color: #0a2e1d;
  color: #fff;
}

/* Responsive: keep popovers anchored to header but cap width on small screens */
@media (max-width: 720px) {
  .hdr-pop-btn { padding: 6px 9px; font-size: 10px; }
  .hdr-pop-btn-icon { padding: 5px 7px; }
  .hdr-pop-panel { min-width: 200px; max-width: calc(100vw - 24px); padding: 12px; }
  .hdr-pop-panel-wide { min-width: 260px; }
}

/* Home value slider overlay on map — sits BELOW the existing style toggle */
.map-hv-filter {
  position: absolute;
  top: 52px;        /* style toggle is ~32px tall at top:10px, so 52px clears it */
  left: 10px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  z-index: 5;
  width: 240px;
  font-family: var(--display, system-ui, sans-serif);
}
.hv-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.hv-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}
.hv-filter-value {
  font-size: 13px;
  font-weight: 700;
  color: #16a34a;
  font-variant-numeric: tabular-nums;
}
.hv-filter-value.inactive { color: #64748b; font-weight: 500; }
.map-hv-filter input[type="range"] {
  width: 100%;
  margin: 4px 0 2px;
  accent-color: #16a34a;
}
.hv-filter-hint {
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.3;
}

/* Fullscreen toggle button — sits to the right of .map-style-toggle in its own box */
.map-fs-btn {
  position: absolute;
  top: 10px;
  left: 254px;     /* clears style toggle (~190px) + pin button (~34px) + gap */
  z-index: 2;
  width: 34px;
  height: 32px;
  padding: 0;
  background: white;
  border: 0;
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.18);
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.map-fs-btn:hover { background: #f1f5f9; }
.map-fs-btn[aria-pressed="true"] {
  background: #1d4ed8;
  color: white;
}

/* Fullscreen mode: map fills viewport, page chrome hides */
body.map-fullscreen { overflow: hidden; }
/* v0.3.14: keep .topbar + #aiBriefBanner visible in fullscreen.
   Only hide page-tabs, other pages, and panels.
   v0.3.20: #aiBriefBanner now lives inside #resultPanel, so we use
   display:contents on the wrapper + display:none on its panel children. */
body.map-fullscreen .tabs,
body.map-fullscreen .app-main > .page:not(#page-map),
body.map-fullscreen #page-map > .panel,
body.map-fullscreen #resultPanel > .panel {
  display: none !important;
}
body.map-fullscreen #resultPanel {
  display: contents;
}
/* Pin topbar to top of viewport above the map */
body.map-fullscreen .topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
}
/* AI brief: float as a slim banner just below the topbar, centered */
body.map-fullscreen #aiBriefBanner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1099;
  max-width: 720px;
  width: calc(100% - 32px);
  margin: 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}
body.map-fullscreen .app-main { padding: 0 !important; margin: 0 !important; max-width: none; }
body.map-fullscreen #page-map { padding: 0; margin: 0; }
body.map-fullscreen .grid-map { display: block; margin: 0 !important; }
body.map-fullscreen #mapShell {
  position: fixed !important;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: calc(100vh - 60px);
  z-index: 1000;
}
body.map-fullscreen .map-container { height: calc(100vh - 60px) !important; border-radius: 0 !important; }

/* Fullscreen overlay: floating scan panel on the right */
body.map-fullscreen #resultPanel.fs-overlay {
  display: block !important;
  position: fixed;
  top: 72px;
  right: 12px;
  bottom: 12px;
  width: 380px;
  max-width: calc(100vw - 24px);
  z-index: 1010;
  overflow-y: auto;
  background: white;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  padding: 0;
}
body.map-fullscreen #resultPanel.fs-overlay .panel { box-shadow: none; margin: 0; }

/* Fullscreen toolbar (the collapsed search/office/draw dropdown) */
.fs-toolbar { display: none; }
body.map-fullscreen .fs-toolbar {
  display: block;
  position: absolute;
  top: 10px;
  left: 298px;  /* style toggle + pin button + fs button + gaps */
  z-index: 1011;
}
.fs-toolbar-trigger {
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.fs-toolbar-trigger:hover { background: #f8fafc; }
.fs-toolbar-trigger[aria-expanded="true"] { background: #1d4ed8; color: white; border-color: #1d4ed8; }
.fs-toolbar-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 280px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
  padding: 12px;
}
.fs-toolbar-menu.open { display: block; }
.fs-toolbar-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}
.fs-toolbar-section:last-child { border-bottom: 0; }
.fs-toolbar-section input,
.fs-toolbar-section select { width: 100%; }
.fs-toolbar-fullwidth { width: 100%; justify-content: center; }

/* Mobile fullscreen tweaks */
@media (max-width: 720px) {
  body.map-fullscreen #resultPanel.fs-overlay {
    top: auto;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    max-height: 55vh;
    border-radius: 10px 10px 0 0;
  }
  /* On narrow screens, slot the new overlays in a clear stack:
     row 1 (top:10): style toggle (left:10) | ⛶ (left:210)
     row 2 (top:52): hv slider (left:10)
     row 3 (top:130): fs-toolbar trigger in fullscreen only */
  body.map-fullscreen .fs-toolbar { top: 130px; left: 10px; }
  .map-hv-filter { width: calc(100vw - 24px); max-width: 240px; }
}

/* ═══════════════ v0.3.18: AI Search tab + page ═══════════════ */
.tab.tab-ai {
  color: #6b21a8;
  font-weight: 700;
}
.tab.tab-ai.active::after {
  background: #a855f7;
}
/* When the AI Search tab lives in the dark-green topbar, bump the purple
 * to a lighter shade so it stays vibrant against the background. */
.topbar .tab.tab-ai           { color: #c084fc; }
.topbar .tab.tab-ai:hover     { color: #e9d5ff; }
.topbar .tab.tab-ai.active    { color: #e9d5ff; box-shadow: inset 0 -3px 0 #a855f7; }

.ai-search-layout {
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  min-height: 70vh;
  gap: 0;
}
.ai-search-chat {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--gray-200);
  background: white;
  min-width: 0;
}
.ai-search-prompt-wrap {
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}
.ai-search-response {
  padding: 16px;
  background: linear-gradient(135deg, #faf5ff 0%, #fdf4ff 100%);
  border-top: 1px solid #e9d5ff;
  margin: 0;
  overflow-y: auto;
  flex: 1;
}
.ai-search-map-wrap {
  position: relative;
  min-height: 480px;
  background: var(--gray-50);
}
.ai-search-map-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  max-width: 260px;
}
.ai-search-map-overlay .btn {
  white-space: nowrap;
}
/* When draw is active, change the run button to indicate ready */
#aiRunBtn:not(:disabled) {
  background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%);
  border-color: #7c3aed;
}
#aiRunBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .ai-search-layout {
    grid-template-columns: 1fr;
  }
  .ai-search-chat {
    border-right: 0;
    border-bottom: 1px solid var(--gray-200);
  }
  .ai-search-map-wrap {
    min-height: 360px;
  }
}

/* ═══════════════ v0.3.19: in-map Pin tool button ═══════════════ */
.map-tool-btn {
  position: absolute;
  top: 10px;
  left: 210px;     /* clears the ~190px-wide style toggle */
  z-index: 2;
  width: 34px;
  height: 34px;
  background: white;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 6px;
  box-shadow: 0 1px 4px rgba(15,23,42,0.18);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, transform 0.1s;
}
.map-tool-btn:hover { background: #f8fafc; }
.map-tool-btn.draw-active {
  background: #15803d;
  color: white;
  border-color: #15803d;
}
.map-tool-btn:active { transform: scale(0.96); }

/* ═══════════════ v0.3.20: cleaner top toolbar styling ═══════════════ */
/* v0.3.21: two-row layout — primary search row up top, secondary controls below. */
.panel.map-toolbar {
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  border-radius: 0 0 10px 10px;
  border: 1px solid var(--gray-200);
  border-top: 0;
  background: white;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}
.toolbar-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar-row-primary input {
  flex: 1;
  min-width: 200px;
}
.toolbar-row-primary #searchBtn {
  white-space: nowrap;
  min-width: 84px;
}
.toolbar-row-secondary {
  justify-content: space-between;
}
.toolbar-row-secondary select {
  flex: 0 1 260px;
  min-width: 170px;
  max-width: 320px;
}
.toolbar-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar-tools .btn {
  white-space: nowrap;
}
.toolbar-tools .btn.draw-active {
  background: #15803d;
  color: white;
  border-color: #15803d;
}

/* Tighten the gap between the toolbar and the map below */
#page-map .grid-map {
  margin-top: 12px;
}

/* Tab strip — keep the rounded top but drop the bottom border so it sits flush
 * with the toolbar that immediately follows. */
.tabs {
  margin-bottom: 0;
}

/* Floating draw-mode hint that appears at the bottom of the map */
.draw-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.92);
  color: white;
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 3;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  pointer-events: none;
  max-width: calc(100% - 40px);
  text-align: center;
}
.draw-hint.show { display: flex; }

/* ═══════════════ v0.3.24: pill-island top bar ═══════════════ */
/* Tabs sit minimally on the page background — no white card, no rounded corners
 * floating awkwardly. The toolbar below is a full rounded pill. */
.tabs.tabs-bare {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 10px 16px 4px !important;
  margin: 0 auto !important;
  max-width: 1400px;
  display: flex;
  gap: 4px;
}
.tabs.tabs-bare .tab {
  background: transparent;
}
/* Toolbar = clean fully-rounded pill, fully contained on all four sides */
.panel.map-toolbar {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  border-radius: 14px;
  border: 1px solid var(--gray-200);
  background: white;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}
/* Tighten the gap between the toolbar pill and the map */
#page-map .grid-map {
  margin-top: 12px;
}

/* ═══════════════ v0.3.26: colorblind variables for badges + status ═══════════════ */
/* Default palette (OFF) — dark green / orange / yellow / grey (v0.3.34) */
:root {
  --rating-juicy-bg: #dcfce7;     --rating-juicy-fg: #166534;     --rating-juicy-border: #22c55e;
  --rating-desirable-bg: #ffedd5; --rating-desirable-fg: #c2410c; --rating-desirable-border: #f97316;
  --rating-medium-bg: #fef9c3;    --rating-medium-fg: #a16207;    --rating-medium-border: #eab308;
  --rating-low-bg: #f1f5f9;       --rating-low-fg: #64748b;       --rating-low-border: #cbd5e1;
}
/* Deuteranopia (red-green): blue / light-blue / yellow / gray */
body[data-cb-mode="deuteranopia"] {
  --rating-juicy-bg: #dbeafe;     --rating-juicy-fg: #1e3a8a;     --rating-juicy-border: #1d4ed8;
  --rating-desirable-bg: #e0f2fe; --rating-desirable-fg: #075985; --rating-desirable-border: #0284c7;
  --rating-medium-bg: #fef9c3;    --rating-medium-fg: #854d0e;    --rating-medium-border: #facc15;
  --rating-low-bg: #f1f5f9;       --rating-low-fg: #475569;       --rating-low-border: #94a3b8;
}
/* Tritanopia (blue-yellow): teal / mint / pink / gray */
body[data-cb-mode="tritanopia"] {
  --rating-juicy-bg: #ccfbf1;     --rating-juicy-fg: #115e59;     --rating-juicy-border: #0d9488;
  --rating-desirable-bg: #ecfdf5; --rating-desirable-fg: #065f46; --rating-desirable-border: #5eead4;
  --rating-medium-bg: #fce7f3;    --rating-medium-fg: #831843;    --rating-medium-border: #db2777;
  --rating-low-bg: #f1f5f9;       --rating-low-fg: #475569;       --rating-low-border: #94a3b8;
}
/* Monochrome (achromatopsia): brightness-only distinction */
body[data-cb-mode="monochrome"] {
  --rating-juicy-bg: #0f172a;     --rating-juicy-fg: #ffffff;     --rating-juicy-border: #000000;
  --rating-desirable-bg: #cbd5e1; --rating-desirable-fg: #1e293b; --rating-desirable-border: #475569;
  --rating-medium-bg: #e2e8f0;    --rating-medium-fg: #334155;    --rating-medium-border: #94a3b8;
  --rating-low-bg: #f8fafc;       --rating-low-fg: #94a3b8;       --rating-low-border: #e2e8f0;
}

/* ═══════════════ v0.3.26: PDF export selection modal ═══════════════ */
.export-modal {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.export-modal.hidden { display: none; }
.export-modal-card {
  background: white;
  border-radius: 14px;
  width: 100%; max-width: 640px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  overflow: hidden;
}
.export-modal-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-200);
  gap: 16px;
}
.export-modal-title { font-family: var(--display); font-size: 18px; font-weight: 600; color: #0f172a; }
.export-modal-sub   { font-size: 12px; color: #64748b; margin-top: 4px; line-height: 1.4; }
.export-modal-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--gray-100);
  background: #f8fafc;
}
.export-modal-list {
  overflow-y: auto;
  padding: 8px 12px;
  flex: 1;
  min-height: 200px;
}
.export-modal-list-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s;
}
.export-modal-list-row:hover { background: #f1f5f9; }
.export-modal-list-row input { width: 18px; height: 18px; cursor: pointer; }
.export-modal-list-row .row-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  min-width: 60px; justify-content: center;
}
.export-modal-list-row .row-body { flex: 1; min-width: 0; }
.export-modal-list-row .row-title { font-size: 14px; font-weight: 600; color: #0f172a; }
.export-modal-list-row .row-meta  { font-size: 12px; color: #64748b; margin-top: 2px; }
.export-modal-footer {
  display: flex; gap: 10px; align-items: center;
  padding: 14px 20px;
  border-top: 1px solid var(--gray-200);
  background: #f8fafc;
}

/* v0.3.35: inline remove (×) button on saved turf rows */
.fav-remove-btn {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid #fecaca;
  background: white;
  color: #dc2626;
  font-size: 18px; line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  align-self: center;
  margin-left: 8px;
}
.fav-remove-btn:hover { background: #fef2f2; border-color: #f87171; }
.fav-remove-btn:disabled { opacity: 0.5; cursor: wait; }

/* ═══════════════════════════════════════════════════════════════════
   APPLE-STYLE THEME LAYER — v0.3.54
   Light polish + automatic Dark Mode (prefers-color-scheme). SF system font
   for UI (Oswald kept for --display). LeafHome green accent retained.
   Appended last so it overrides the base rules above. Dark mode remaps the
   neutral scale (verified safe — dark grays are never used as backgrounds)
   and flips the --white surfaces; --white is left intact (it doubles as
   text-on-green). Inline hardcoded colors in markup/JS are handled separately.
   ═══════════════════════════════════════════════════════════════════ */
:root {
  --app-bg:           #f2f2f7;
  --surface:          #ffffff;
  --surface-2:        #f3f3f6;
  --label:            #1c1c1e;
  --label-2:          #3c3c43;
  --label-3:          #8a8a8e;
  --separator:        rgba(60,60,67,0.16);
  --separator-strong: rgba(60,60,67,0.28);
  --radius-card:      14px;
  --radius-ctl:       10px;
  --shadow-card:      0 1px 2px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.06);
}

body { background: var(--app-bg); }

/* Apple rounding + softer surfaces (applies in both light and dark) */
.panel       { border-radius: var(--radius-card); box-shadow: var(--shadow-card); border: 1px solid var(--separator); }
.stat-card   { border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.login-card  { border-radius: 22px; box-shadow: 0 12px 44px rgba(0,0,0,0.14); }
.btn         { border-radius: var(--radius-ctl); }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--green-700); border-color: var(--green-700); }
input, select, textarea { border-radius: var(--radius-ctl); }
.badge       { border-radius: 980px; }

/* ── Automatic Dark Mode ───────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root {
    --app-bg:           #000000;
    --surface:          #1c1c1e;
    --surface-2:        #2c2c2e;
    --label:            #ffffff;
    --label-2:          rgba(235,235,245,0.60);
    --label-3:          rgba(235,235,245,0.40);
    --separator:        rgba(84,84,88,0.45);
    --separator-strong: rgba(84,84,88,0.65);
    --shadow-card:      0 1px 2px rgba(0,0,0,0.45), 0 10px 28px rgba(0,0,0,0.55);

    /* Remap neutral scale so token-based components flip automatically. */
    --gray-900: #f2f2f7;
    --gray-800: #e5e5ea;
    --gray-700: #d1d1d6;
    --gray-600: #aeaeb2;
    --gray-500: #98989d;
    --gray-400: #8e8e93;
    --gray-300: rgba(84,84,88,0.55);
    --gray-200: rgba(84,84,88,0.38);
    --gray-100: #2c2c2e;
    --gray-50:  #1c1c1e;
  }

  body { color: var(--label); }

  /* Surfaces that hard-code white as their background */
  .panel, .stat-card, .login-card, .ai-search-response,
  .modal, .modal-card, .modal-content, .menu, .popover, .dropdown, .sheet {
    background: var(--surface) !important;
    color: var(--label);
  }
  .panel { border-color: var(--separator); }

  input, select, textarea {
    background: var(--surface-2) !important;
    color: var(--label) !important;
    border-color: var(--separator-strong) !important;
  }
  ::placeholder { color: var(--label-3) !important; }

  .btn { background: var(--surface-2); color: var(--label); border-color: var(--separator-strong); }
  .btn:hover { background: #3a3a3c; border-color: var(--separator-strong); }
  .btn-primary, .login-submit { background: var(--accent); color: #fff; border-color: var(--accent); }
  .btn-primary:hover { background: var(--green-600); }

  .tab { color: rgba(235,235,245,0.62); }
  .tab:hover { color: #fff; background: rgba(255,255,255,0.08); }

  .metric-modifier.pos { background: rgba(48,209,88,0.18); color: #30d158; }
  .metric-modifier.neg { background: rgba(255,69,58,0.18);  color: #ff453a; }

  /* Mapbox UI follows dark */
  .mapboxgl-popup-content { background: #1c1c1e !important; color: var(--label) !important; }
  .mapboxgl-popup-tip { border-top-color: #1c1c1e !important; border-bottom-color: #1c1c1e !important; }
  .mapboxgl-ctrl-group { background: #1c1c1e !important; }
}

/* ── Phase 3 polish (v0.3.55): focus rings, transitions, dark badge tints ── */
.btn, .stat-card, .panel {
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
input:focus-visible, select:focus-visible, textarea:focus-visible,
.btn:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,168,107,0.18);
}

@media (prefers-color-scheme: dark) {
  /* Apple-style translucent tinted badges instead of bright light pills */
  .badge-green, .badge-darkgreen { background: rgba(48,209,88,0.18)  !important; color: #30d158 !important; }
  .badge-lime                    { background: rgba(120,220,90,0.18) !important; color: #9be15d !important; }
  .badge-amber, .badge-yellow    { background: rgba(255,214,10,0.16) !important; color: #ffd60a !important; }
  .badge-orange                  { background: rgba(255,159,10,0.18) !important; color: #ff9f0a !important; }
  .badge-red                     { background: rgba(255,69,58,0.18)  !important; color: #ff453a !important; }
  .badge-blue                    { background: rgba(10,132,255,0.18) !important; color: #0a84ff !important; }
  .badge-purple                  { background: rgba(191,90,242,0.18) !important; color: #bf5af2 !important; }
  .badge-gray                    { background: rgba(142,142,147,0.22)!important; color: #aeaeb2 !important; }
  input:focus, textarea:focus, select:focus { box-shadow: 0 0 0 3px rgba(48,209,88,0.25); }
}

/* ── Turf Planner ───────────────────────────────────────────── */
.planner-tabs{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:14px}
.planner-tab{font-size:12px;padding:6px 12px}
.planner-day-head{display:flex;justify-content:space-between;align-items:center;font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.04em;color:var(--label-2);margin:16px 0 6px;padding-bottom:5px;border-bottom:1px solid var(--separator)}
.planner-day-head.is-today{color:#15803d;border-bottom-color:#86efac}
.planner-day-count{font-weight:400;color:var(--label-3)}
.planner-empty-day{font-size:12px;color:var(--label-3);padding:2px 2px 8px}
.planner-card{display:flex;align-items:flex-start;gap:10px;padding:10px;border:1px solid var(--separator-strong);border-radius:10px;margin-bottom:8px;background:var(--surface);cursor:pointer;transition:border-color .12s,box-shadow .12s}
.planner-card:hover{border-color:var(--label-3);box-shadow:var(--shadow-card)}
.planner-card-body{flex:1;min-width:0}
.planner-card-title{font-weight:600;font-size:14px;color:var(--label);display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.planner-card-sub{font-size:12px;color:var(--label-3);margin-top:2px}
.planner-card-controls{display:flex;align-items:center;gap:8px;margin-top:8px;flex-wrap:wrap}
.planner-date-label{display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--label-2)}
.planner-date{font-size:12px;padding:4px 6px;border:1px solid var(--separator-strong);border-radius:6px;background:var(--surface);color:var(--label)}
.planner-mini{font-size:11px;padding:4px 9px;border:1px solid var(--separator-strong);border-radius:6px;background:var(--surface-2);color:var(--label-2);cursor:pointer}
.planner-mini:hover{border-color:var(--label-3)}
.planner-done{color:#15803d}
.planner-readonly{font-size:12px;color:var(--label-3)}

/* ── Regions & Offices console ─────────────────────────────────────────── */
.region-row{display:flex;align-items:center;gap:14px;padding:11px 12px;border:1px solid var(--separator);border-radius:9px;margin-bottom:8px;background:var(--bg-elevated,#fff)}
.region-row .region-main{flex:1;min-width:0}
.region-row .region-name{font-size:14px;font-weight:600;color:var(--label-1)}
.region-row .region-meta{font-size:12px;color:var(--label-3);margin-top:2px}
.region-row .region-assign{font-size:12px;color:var(--label-2);display:flex;align-items:center;gap:6px;white-space:nowrap}
.region-row .region-assign select{font-size:13px;padding:6px 8px;border:1px solid var(--separator-strong);border-radius:6px;max-width:200px}
.regions-table{width:100%;border-collapse:collapse;font-size:13px}
.regions-table th{text-align:left;font-size:11px;letter-spacing:.04em;text-transform:uppercase;color:var(--label-3);font-weight:600;padding:6px 10px;border-bottom:1px solid var(--separator)}
.regions-table td{padding:8px 10px;border-bottom:1px solid var(--separator);vertical-align:middle;color:var(--label-1)}
.regions-table tr:last-child td{border-bottom:none}
.regions-table select,.regions-table input{font-size:13px;padding:6px 8px;border:1px solid var(--separator-strong);border-radius:6px;width:100%;max-width:190px;background:var(--bg-elevated,#fff);color:var(--label-1)}
.regions-table input::placeholder{color:var(--label-3)}
#officesTable{overflow-x:auto}

/* ── Manage-users / region / office modals ─────────────────────────────── */
.wb-form .wb-field{margin-bottom:12px}
.wb-form .wb-field label{display:block;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--label-2);margin-bottom:5px}
.wb-form .wb-field input,.wb-form .wb-field select{width:100%;font-size:14px;padding:9px 11px;border:1px solid var(--separator-strong);border-radius:8px;box-sizing:border-box;background:var(--bg-elevated,#fff);color:var(--label-1)}
.wb-form .wb-field input:disabled{background:var(--gray-100,#f1f5f9);color:var(--label-3);cursor:not-allowed}
#ueOffices label{display:flex;align-items:center;gap:8px;font-size:13px;padding:5px 2px;cursor:pointer}
#ueOffices label input{width:16px;height:16px}

/* ===================== Admin redesign (Regions / Users) ===================== */
.adm-tabs{display:flex;gap:4px;border-bottom:1px solid #e5e7eb;margin-bottom:18px}
.adm-tab{padding:10px 18px;font-size:14px;font-weight:600;color:#6b7280;background:none;border:none;border-bottom:2px solid transparent;cursor:pointer}
.adm-tab:hover{color:#374151}
.adm-tab.active{color:#15803d;border-bottom-color:#15803d}
.adm-tabpane.hidden{display:none}

.adm-card{background:#fff;border:1px solid #e6e8ec;border-radius:16px;padding:22px 24px;margin-bottom:16px;box-shadow:0 1px 2px rgba(16,24,40,.04)}
.adm-h{font-size:19px;font-weight:800;color:#111827;display:flex;align-items:center;gap:10px;line-height:1.2}
.adm-h::before{content:"";width:4px;height:20px;background:#15803d;border-radius:2px;display:inline-block;flex:0 0 auto}
.adm-count{font-size:13px;color:#9ca3af;font-weight:600}
.adm-sub{font-size:13px;color:#6b7280;margin:6px 0 0}
.adm-muted{font-size:13px;color:#9ca3af;padding:10px 0}
.adm-minilabel{font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:#6b7280;font-weight:700;margin-bottom:6px}

.adm-createrow,.adm-addrow,.adm-importrow{display:flex;gap:10px;flex-wrap:wrap;align-items:center}
.adm-createrow{margin-top:16px}
.adm-importrow{margin-top:16px}
.adm-addrow{margin-top:14px;padding-top:14px;border-top:1px solid #eef0f3}
.adm-filterbar{display:flex;gap:12px;flex-wrap:wrap;align-items:center;background:#f9fafb;border:1px solid #eef0f3;border-radius:10px;padding:12px;margin:16px 0}
.adm-fl{font-size:12px;color:#6b7280;display:flex;align-items:center;gap:6px;white-space:nowrap}
.adm-input{border:1px solid #d1d5db;border-radius:8px;padding:9px 11px;font-size:14px;flex:1;min-width:160px;color:#111827;background:#fff}
.adm-input:focus{outline:none;border-color:#15803d;box-shadow:0 0 0 3px rgba(21,128,61,.12)}
.adm-select{border:1px solid #d1d5db;border-radius:8px;padding:8px 10px;font-size:13px;background:#fff;color:#111827}
.adm-select-full{width:100%;margin-bottom:4px}
.adm-tablewrap{overflow-x:auto}

.adm-btn{padding:8px 15px;border-radius:8px;font-size:13px;font-weight:600;border:1px solid transparent;cursor:pointer;line-height:1}
.adm-btn-green{background:#15803d;color:#fff}
.adm-btn-green:hover{background:#166534}
.adm-btn-outline{background:#fff;border-color:#d1d5db;color:#374151}
.adm-btn-outline:hover{background:#f9fafb}
.adm-btn-del{background:#fff;border-color:#fecaca;color:#dc2626}
.adm-btn-del:hover{background:#fef2f2}
.adm-btn-edit{background:#fff;border-color:#bbf7d0;color:#15803d}
.adm-btn-edit:hover{background:#f0fdf4}

/* Region cards */
.regions-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(360px,1fr));gap:18px;margin-top:18px}
.region-card{border:1px solid #e6e8ec;border-radius:14px;padding:18px;background:#fff;display:flex;flex-direction:column}
.region-card-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:12px}
.region-card-name{font-size:18px;font-weight:800;color:#111827}
.region-card-tools{display:flex;align-items:center;gap:10px}
.region-card-count{font-size:13px;color:#6b7280}
.region-card-trash{background:none;border:none;cursor:pointer;font-size:15px;opacity:.55;line-height:1}
.region-card-trash:hover{opacity:1}
.region-card-label{font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:#6b7280;font-weight:700;margin:10px 0 5px}
.region-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px}
.region-chip{display:inline-flex;align-items:center;gap:6px;background:#dcfce7;color:#166534;border-radius:999px;padding:5px 11px;font-size:13px;font-weight:500}
.region-chip-x{background:none;border:none;color:#166534;opacity:.6;cursor:pointer;font-size:15px;line-height:1;padding:0}
.region-chip-x:hover{opacity:1}
.region-addoffices{margin-top:14px;align-self:flex-start;border:1px dashed #86efac;color:#15803d;background:#f0fdf4;border-radius:8px;padding:8px 16px;font-size:13px;font-weight:600;cursor:pointer}
.region-addoffices:hover{background:#dcfce7}
.region-addpicker{margin-top:12px;border-top:1px solid #eef0f3;padding-top:12px}
.region-addpicker.hidden{display:none}
.region-addlist{max-height:200px;overflow-y:auto;border:1px solid #e5e7eb;border-radius:8px;padding:6px}
.region-addopt{display:block;padding:5px 7px;font-size:13px;cursor:pointer;border-radius:6px}
.region-addopt:hover{background:#f3f4f6}
.region-addopt em{color:#9ca3af;font-style:normal}

/* Tables (offices + users) */
.adm-table{width:100%;border-collapse:collapse;font-size:13px}
.adm-table thead th{text-align:left;font-size:11px;text-transform:uppercase;letter-spacing:.05em;color:#6b7280;font-weight:700;padding:11px 12px;background:#f9fafb;border-bottom:1px solid #e5e7eb}
.adm-table tbody td{padding:10px 12px;border-bottom:1px solid #eef0f3;vertical-align:middle;color:#111827}
.adm-table tbody tr:last-child td{border-bottom:none}
.adm-cell-input,.adm-cell-select{border:1px solid #d1d5db;border-radius:8px;padding:7px 9px;font-size:13px;width:100%;background:#fff;color:#111827}
.adm-cell-select{min-width:150px}
.adm-table-users thead th{background:#14532d;color:#fff;border-bottom:none}
.adm-table-users thead th:first-child{border-top-left-radius:8px}
.adm-table-users thead th:last-child{border-top-right-radius:8px}
.adm-name{font-weight:600}
.adm-email{color:#6b7280}
.adm-officecell{max-width:380px;font-size:12px;color:#374151;line-height:1.5}
.adm-lastseen{white-space:nowrap;font-size:12px;color:#374151}
.adm-actions{white-space:nowrap;text-align:right}
.adm-actions .adm-btn{margin-left:6px}
.adm-row-inactive{opacity:.5}

/* Role badges */
.adm-badge{display:inline-block;padding:5px 11px;border-radius:999px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;line-height:1.3}
.adm-badge-blue{background:#dbeafe;color:#1e40af}
.adm-badge-amber{background:#fef3c7;color:#92400e}
.adm-badge-green{background:#dcfce7;color:#166534}
.adm-badge-gray{background:#eef1f5;color:#475569}

/* Status */
.adm-status{font-size:13px;font-weight:600;display:inline-flex;align-items:center;gap:6px}
.adm-status::before{content:"";width:8px;height:8px;border-radius:50%;display:inline-block}
.adm-status-on{color:#15803d}
.adm-status-on::before{background:#16a34a}
.adm-status-off{color:#9ca3af}
.adm-status-off::before{background:none;border:1.5px solid #cbd5e1}

/* Product-line map toggle (LeafFilter / Water Solutions) */
.product-toggle{position:fixed;top:62px;left:50%;transform:translateX(-50%);z-index:1200;display:flex;gap:2px;background:#fff;border:1px solid #e2e6ea;border-radius:999px;padding:3px;box-shadow:0 4px 14px rgba(16,24,40,.14)}
.product-toggle .pt-btn{border:none;background:none;cursor:pointer;font-size:13px;font-weight:600;color:#4b5563;padding:7px 16px;border-radius:999px;line-height:1}
.product-toggle .pt-btn:hover{color:#111827}
.product-toggle .pt-btn.active{background:#15803d;color:#fff}
/* LHWS (Water Solutions): recolor the whole site chrome green→blue by overriding
   the brand --green-* vars. Zone/tier colors use --rating-* and stay green/orange/grey. */
body[data-product="water"]{
  --green-900:#0a1f3d; --green-800:#123a63; --green-700:#1857a0;
  --green-600:#1d6fc4; --green-500:#2d86e0; --green-100:#d6e6f7; --green-50:#eef5fc;
  --accent:#2563eb;
}
body[data-product="water"] .product-toggle .pt-btn.active{background:#1d6fc4}
body[data-product="water"] .btn.fav-on,
body[data-product="water"] .btn.knock-on{background:#1d6fc4;border-color:#1d6fc4}
body[data-product="water"] .hv-filter-value{color:#1d6fc4}
body[data-product="water"] .map-hv-filter input[type="range"]{accent-color:#1d6fc4}
