/* ==================================================================
   MOBILE-FIRST FOUNDATION v2
   Load AFTER style.css and AFTER mobile.css
   ==================================================================
   Design principles:
   - 44×44 minimum touch targets (Apple HIG)
   - Slim sticky headers (48px max)
   - Safe-area insets for iPhone notch/home bar
   - Larger tap-friendly form controls on mobile
   - Cards over dense tables on small screens
   - Fewer visible actions — most in overflow menus
   ================================================================== */

/* --- Universal safe-area handling for iOS notch + home bar --- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}
html { overscroll-behavior-y: contain; }

/* --- 44×44 minimum touch targets across the board --- */
@media (max-width: 768px) {
  .btn,
  button:not(.tab-btn):not(.modal-close),
  a.btn,
  input[type="submit"] {
    min-height: 44px !important;
    padding: 10px 16px !important;
    font-size: 15px !important;
  }
  .btn-sm {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
  }
  /* Form controls — big enough not to trigger iOS zoom (min 16px font) */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 44px !important;
    font-size: 16px !important;
    padding: 10px 12px !important;
  }
  /* Checkboxes/radios — bigger tap area */
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px !important;
    height: 22px !important;
    margin-right: 8px !important;
  }
  /* Labels next to checkboxes — full-row tappable */
  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    display: flex !important;
    align-items: center;
    padding: 10px 0 !important;
    min-height: 44px;
  }
}

/* --- Slim sticky header (was too tall) --- */
@media (max-width: 768px) {
  .app-header,
  header.app-header,
  .topbar {
    height: 52px !important;
    padding: 6px 12px !important;
    padding-top: calc(6px + var(--safe-top)) !important;
  }
  .app-header h1,
  .topbar .title {
    font-size: 16px !important;
    margin: 0;
  }
  .hamburger-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 10px !important;
  }
}

/* --- Modals: full-screen on mobile, not centered floating popups --- */
@media (max-width: 768px) {
  .modal-backdrop {
    padding: 0 !important;
    align-items: stretch !important;
    justify-content: stretch !important;
  }
  .modal {
    width: 100vw !important;
    max-width: 100vw !important;
    /* dvh = dynamic viewport height → accounts for Safari/Chrome bottom toolbar,
       so action buttons are never hidden behind the browser chrome */
    height: 100vh !important;
    max-height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    /* Extra bottom space so the last buttons clear the home-bar + toolbar */
    padding-bottom: calc(84px + var(--safe-bottom)) !important;
  }
  /* FIXED (not sticky) header: iOS momentum scrolling makes sticky elements
     lag and lets content slip above them. Fixed can never be out-run.
     EXACT geometry: header height == modal top padding == tabs offset,
     so there is no uncovered band anywhere for content to show through. */
  .modal { padding-top: calc(66px + var(--safe-top)) !important; }
  .modal-header {
    position: fixed !important;
    top: 0 !important; left: 0 !important; right: 0 !important;
    z-index: 40;
    height: calc(66px + var(--safe-top)) !important;
    min-height: 0 !important;
    overflow: hidden;
    display: flex; align-items: center;
    /* SOLID background — --panel is 50% transparent and let text bleed through */
    background: var(--bg-elev, #0f172a) !important;
    border-bottom: 1px solid var(--border, #334155);
    padding: 0 16px !important;
    padding-top: var(--safe-top) !important;
    margin: 0 !important;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
  }
  .modal-header h2,
  .modal-header h3 {
    font-size: 17px !important;
    margin: 0 !important;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .modal-close {
    min-width: 44px !important;
    min-height: 44px !important;
    font-size: 24px !important;
    background: transparent !important;
    border: none !important;
    padding: 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .modal-body {
    overflow-y: visible;
    padding: 16px 0 !important;
  }
  .modal-footer {
    position: sticky;
    bottom: 0;
    padding: 12px 16px calc(12px + var(--safe-bottom)) 16px !important;
    background: var(--bg-elev, #0f172a);
    border-top: 1px solid var(--border, #334155);
    flex-shrink: 0;
  }
}

/* --- Bottom-anchored primary action (mobile pattern) --- */
.mobile-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--panel, #1e293b);
  border-top: 1px solid var(--border, #334155);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  z-index: 100;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
}
.mobile-action-bar .btn {
  flex: 1;
  min-height: 48px !important;
  font-size: 16px !important;
  font-weight: 600 !important;
}

/* --- Card-style rows (replace crowded tables on mobile) --- */
.mobile-card {
  background: var(--panel, #1e293b);
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 10px;
  transition: transform 0.1s, box-shadow 0.15s;
}
.mobile-card:active {
  transform: scale(0.98);
}
.mobile-card.tappable {
  cursor: pointer;
}
.mobile-card .card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}
.mobile-card .card-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text, #f1f5f9);
}
.mobile-card .card-meta {
  font-size: 13px;
  color: var(--dim, #94a3b8);
  margin-top: 4px;
  line-height: 1.5;
}
.mobile-card .card-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: rgba(37,99,235,0.15);
  color: #60a5fa;
}
.mobile-card .card-tag.paid   { background: rgba(16,185,129,0.15); color: #10b981; }
.mobile-card .card-tag.urgent { background: rgba(239,68,68,0.15);  color: #f87171; }

/* --- On mobile, hide tables where a card equivalent exists --- */
@media (max-width: 640px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
}
@media (min-width: 641px) {
  .show-mobile { display: none !important; }
}

/* --- Inline-edit field pattern (tap to edit) --- */
.field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border, #334155);
  min-height: 60px;
  cursor: pointer;
  transition: background 0.1s;
}
.field-row:active { background: rgba(255,255,255,0.05); }
.field-row:last-child { border-bottom: none; }
.field-row .field-icon {
  font-size: 22px;
  width: 32px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.7;
}
.field-row .field-body {
  flex: 1;
  min-width: 0;
}
.field-row .field-label {
  font-size: 12px;
  color: var(--dim, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.field-row .field-value {
  font-size: 15px;
  color: var(--text, #f1f5f9);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.field-row .field-value.empty {
  color: var(--dim, #94a3b8);
  font-style: italic;
}
.field-row .field-edit-icon {
  font-size: 18px;
  color: var(--dim, #94a3b8);
  opacity: 0.5;
  flex-shrink: 0;
}

/* --- Larger toast on mobile --- */
@media (max-width: 768px) {
  .toast {
    top: auto !important;          /* style.css sets top:78px → with bottom set it became full-screen */
    left: 12px !important;
    right: 12px !important;
    bottom: calc(12px + var(--safe-bottom)) !important;
    height: auto !important;
    z-index: 400 !important;
    min-width: auto !important;
    max-width: none !important;
    padding: 14px 18px !important;
    font-size: 15px !important;
  }
}

/* --- Better empty-state on mobile --- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--dim, #94a3b8);
}
.empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 12px;
}
.empty-state .empty-title {
  font-size: 16px;
  color: var(--text, #f1f5f9);
  margin-bottom: 4px;
}
.empty-state .empty-hint {
  font-size: 14px;
  line-height: 1.5;
}

/* ==================================================================
   v2.2 MOBILE FIXES — 16.08
   1) Topbar nav clipping ("ashboard") 2) Horizontal page overflow
   3) Compact inline number inputs in modals 4) Bottom tab bar
   ================================================================== */

/* --- 1) Topbar: never clip the first nav item --------------------
   .nav is justify-content:center + overflow-x:auto — when links
   overflow, a centered flex container clips BOTH ends and the left
   side becomes unreachable. On mobile, align to the start instead. */
@media (max-width: 768px) {
  .topbar { flex-wrap: nowrap !important; gap: 8px !important; }
  .topbar .nav {
    justify-content: flex-start !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    min-width: 0;
    mask-image: linear-gradient(to right, black 92%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 92%, transparent 100%);
  }
  .topbar .nav a { scroll-snap-align: start; flex-shrink: 0; }
  .brand { flex-shrink: 0; }
  .topbar-actions { flex-shrink: 0; }
}

/* --- 2) Kill horizontal page overflow -----------------------------
   Wide tables/buttons must scroll INSIDE their card, never push the
   whole page sideways (Dashboard "Open calendar" bleeding off-screen). */
@media (max-width: 768px) {
  html, body { overflow-x: hidden !important; max-width: 100vw; }
  .page { max-width: 100% !important; overflow-x: clip; }
  .card, .grid, .grid > * { min-width: 0 !important; max-width: 100% !important; }
  .card { overflow-x: clip; }
  .card .table-wrap, .card .table-scroll { overflow-x: auto !important; }
  .flex-between > * { min-width: 0; }
  .btn, a.btn { max-width: 100%; white-space: normal; text-align: center; }
  /* Long words / phone numbers / emails wrap instead of overflowing */
  .card, .modal, td, th { overflow-wrap: break-word; word-break: break-word; }
}

/* --- 3) Inline qty/price inputs (proposal builder etc.) -----------
   The global 44px/full-padding input rule blew tiny inline number
   fields up to full-width blocks. Keep them compact and inline. */
@media (max-width: 768px) {
  .modal input[type="number"].input,
  .modal input[type="number"] {
    display: inline-block !important;
    width: auto !important;
    min-width: 64px;
    max-width: 110px;
    min-height: 40px !important;
    padding: 6px 8px !important;
    font-size: 16px !important;
    text-align: right;
  }
}

/* --- 4) Bottom tab bar (mobile only) ------------------------------ */
.mobile-tabbar { display: none; }
@media (max-width: 768px) {
  .mobile-tabbar {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 150;
    background: color-mix(in oklab, var(--bg-elev, #0f172a), transparent 8%);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--border, rgba(255,255,255,0.08));
    padding: 6px 4px calc(6px + var(--safe-bottom)) 4px;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.35);
  }
  .mobile-tabbar a, .mobile-tabbar button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 50px !important;
    padding: 4px 2px !important;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: var(--text-dim, #94a3b8);
    text-decoration: none;
    font-size: 10px !important;
    font-weight: 600;
    letter-spacing: 0.2px;
    line-height: 1.2;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-tabbar .tab-ico { font-size: 20px; line-height: 1; }
  .mobile-tabbar a.active {
    color: var(--primary, #2563eb);
    background: var(--primary-soft, rgba(37,99,235,0.12));
  }
  /* Reserve room so content isn't hidden behind the bar
     (unconditional — the bar exists on every logged-in page) */
  .page { padding-bottom: calc(84px + var(--safe-bottom)) !important; }
  .toast { top: auto !important; bottom: calc(76px + var(--safe-bottom)) !important; }
  /* Tab bar must not cover open modals */
  body:has(.modal-backdrop) .mobile-tabbar { display: none; }
}

/* --- "More" sheet items --- */
.more-sheet-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 14px 16px;
  background: var(--panel, #1e293b);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  color: var(--text, #f1f5f9);
  text-decoration: none;
  font-size: 15px; font-weight: 500;
  margin-bottom: 8px;
}
.more-sheet-item .mi { font-size: 20px; width: 28px; text-align: center; }
.more-sheet-item:active { background: rgba(37,99,235,0.15); }

/* ==================================================================
   v2.3 FIXES — 16.08 (round 2)
   ================================================================== */

/* Badges & small buttons never break mid-word ("Edi t", "IN_PROGR S") */
.badge { white-space: nowrap !important; }
@media (max-width: 768px) {
  .btn-sm { white-space: nowrap !important; }
  /* Compact modal-header action buttons (Send SMS etc.) */
  .modal-header .btn, .modal-header .btn-sm {
    min-height: 38px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    white-space: nowrap !important;
  }
}

/* --- Proposal builder: total bar pinned to real screen bottom ------
   Was position:sticky with translucent bg + negative margins → floated
   mid-screen over the list. Now: solid, fixed, safe-area aware. */
@media (max-width: 768px) {
  .prop-total-bar {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important;
    margin: 0 !important;
    padding: 10px 16px calc(10px + var(--safe-bottom)) 16px !important;
    background: var(--bg-elev, #0f172a) !important;
    border-top: 2px solid var(--border, #334155) !important;
    box-shadow: 0 -8px 24px rgba(0,0,0,0.45);
    z-index: 260 !important;
  }
  /* Content never hides behind the fixed total bar */
  #propRoot { padding-bottom: 96px; }
}
@media (min-width: 769px) {
  .prop-total-bar { background: var(--bg-elev, #0f172a) !important; } /* solid on desktop too */
}

/* --- Work orders: card list on phones, table on desktop --- */
.wo-card { cursor: pointer; }
.wo-card .wo-top {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; margin-bottom: 6px;
}
.wo-card .wo-num {
  font-family: Monaco, monospace; font-size: 12px; font-weight: 700;
  background: var(--panel-2, rgba(30,41,59,0.8));
  padding: 3px 8px; border-radius: 6px;
}
.wo-card .wo-row {
  font-size: 13px; color: var(--text-dim, #94a3b8);
  margin-top: 3px; line-height: 1.5; overflow-wrap: break-word;
}
.wo-card .wo-total {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border, rgba(255,255,255,0.08));
  display: flex; justify-content: space-between; align-items: center;
  font-weight: 700;
}

/* --- Unified client profile --- */
.profile-quick {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.profile-quick .pq-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; min-height: 52px;
  background: var(--panel, #1e293b);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  color: var(--text, #f1f5f9);
  text-decoration: none;
  font-size: 14px;
  min-width: 0;
}
.profile-quick .pq-item .pq-ico { font-size: 20px; flex-shrink: 0; }
.profile-quick .pq-item .pq-body { min-width: 0; }
.profile-quick .pq-item .pq-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted, #64748b); margin-bottom: 1px;
}
.profile-quick .pq-item .pq-val {
  font-weight: 600; font-size: 14px;
  overflow-wrap: break-word; word-break: break-word;
}
a.pq-item:active { background: rgba(37,99,235,0.15); }

.profile-section { margin: 18px 0; }
details.profile-acc {
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  background: var(--panel, #1e293b);
  margin: 10px 0;
  overflow: hidden;
}
details.profile-acc > summary {
  list-style: none;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; min-height: 52px;
  font-weight: 600; font-size: 15px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
details.profile-acc > summary::-webkit-details-marker { display: none; }
details.profile-acc > summary::after {
  content: '▾'; margin-left: auto;
  color: var(--text-dim, #94a3b8);
  transition: transform 0.2s;
}
details.profile-acc[open] > summary::after { transform: rotate(180deg); }
details.profile-acc[open] > summary { border-bottom: 1px solid var(--border, rgba(255,255,255,0.08)); }
details.profile-acc > .profile-acc-body { padding: 14px 16px; }
details.profile-acc > summary .acc-count {
  background: var(--panel-2, rgba(30,41,59,0.8));
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  color: var(--text-dim, #94a3b8); font-weight: 700;
}

/* ==================================================================
   v2.4 — day chips (today/tomorrow), Waze button
   ================================================================== */
.day-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 10px; font-weight: 800; letter-spacing: 0.4px;
  white-space: nowrap; vertical-align: middle;
}
.day-chip.chip-today    { background: rgba(245,158,11,0.18); color: #f59e0b; border: 1px solid rgba(245,158,11,0.45); }
.day-chip.chip-tomorrow { background: rgba(37,99,235,0.16);  color: #60a5fa; border: 1px solid rgba(37,99,235,0.4); }
.day-chip.chip-overdue  { background: rgba(239,68,68,0.16);  color: #f87171; border: 1px solid rgba(239,68,68,0.4); }
.day-chip.chip-future   { background: rgba(148,163,184,0.12); color: #94a3b8; border: 1px solid rgba(148,163,184,0.3); }

/* Today's jobs pop out of the list */
.wo-card.wo-today { border-left: 4px solid #f59e0b !important; }

/* Waze navigation button */
.btn.waze-btn {
  background: #33ccff !important;
  color: #0b1120 !important;
  border: none !important;
  font-weight: 800 !important;
  margin-top: 10px;
  white-space: nowrap !important;
}
.btn.waze-btn:active { opacity: 0.85; }
@media (max-width: 768px) {
  .wo-card .btn.waze-btn {
    width: 100%;
    justify-content: center;
    display: flex;
    min-height: 44px !important;
  }
}

/* Review-item inputs: stay compact inline (beats the global 44px input rule) */
@media (max-width: 768px) {
  .rev-math .rev-inp {
    display: inline-block !important;
    width: 64px !important;
    min-width: 0 !important;
    max-width: 84px !important;
    min-height: 40px !important;
    padding: 6px 4px !important;
    font-size: 16px !important;
    text-align: center !important;
  }
  .rev-math input.rev-inp[onchange*="unit_price"] { width: 80px !important; }
}

/* ==================================================================
   v2.5 — 16.08 (round 3)
   ================================================================== */

/* Topbar nav is redundant on mobile — the bottom tab bar handles
   navigation. Keep only brand + profile chip. */
@media (max-width: 768px) {
  .topbar .nav { display: none !important; }
  .topbar { justify-content: space-between !important; }
}

/* --- Client profile header: avatar + name, compact actions --- */
.client-hdr-left {
  display: flex; align-items: center; gap: 12px;
  min-width: 0; flex: 1;
}
.client-hdr-left .client-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary, #2563eb), var(--accent, #06b6d4));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 800; font-size: 16px;
  flex-shrink: 0;
}
.client-hdr-left .client-name {
  font-size: 18px; font-weight: 700; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.client-hdr-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.client-hdr-actions .btn-ico {
  min-width: 40px !important; min-height: 40px !important;
  padding: 8px !important;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px !important;
  border-radius: 10px;
  white-space: nowrap !important;
}

/* --- Inline-editable detail rows --- */
.detail-rows {
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 10px;
  background: var(--panel, #1e293b);
  overflow: hidden;
}
.detail-rows .field-row { min-height: 54px; padding: 10px 14px; }
.detail-rows .field-edit-form {
  display: flex; gap: 6px; align-items: center; flex: 1; min-width: 0;
}
.detail-rows .field-edit-form .input,
.detail-rows .field-edit-form .select {
  flex: 1; min-width: 0;
  min-height: 40px !important;
  padding: 8px 10px !important;
  font-size: 16px !important;
}
.detail-rows .field-edit-form .btn {
  min-height: 40px !important;
  min-width: 40px;
  padding: 6px 10px !important;
  flex-shrink: 0;
  white-space: nowrap !important;
}

/* ==================================================================
   v2.6 — 16.08 (round 4)
   ================================================================== */

/* btn-ico works anywhere (was scoped to header only): compact square icon buttons */
.btn-ico {
  min-width: 40px !important;
  min-height: 40px !important;
  padding: 8px !important;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px !important;
  border-radius: 10px;
  white-space: nowrap !important;
  flex-shrink: 0;
}

/* Breathing room between the sticky header and the first content block */
.profile-quick { margin-top: 18px !important; }
@media (max-width: 768px) {
  /* the pinned header needs a scroll cushion so content never sits flush under it */
  .modal .profile-page > *:first-child { scroll-margin-top: 70px; }
}

/* --- Proposal builder: ONE scroll, not nested scroll traps ----------
   The services/parts lists had their own max-height scrollboxes inside
   the scrolling modal → finger fights between two scrollers. On mobile
   the inner boxes expand fully and only the modal scrolls. */
@media (max-width: 768px) {
  #jobListWrap, #partListWrap {
    max-height: none !important;
    overflow: visible !important;
  }
  /* Keep the Services/Parts/Review tabs reachable while browsing long lists */
  .prop-tabs {
    /* FIXED like the header — sticky lags on iOS flick-scrolls and opened
       a gap under the header. Fixed tabs are welded to the header edge. */
    position: fixed !important;
    top: calc(66px + var(--safe-top)) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 39;
    margin: 0 !important;
    background: var(--bg-elev, #0f172a) !important;
  }
  /* Reserve the space the fixed tab bar occupies (buttons 52px + 2px border) */
  #propRoot { padding-top: 58px; }
}

/* ==================================================================
   v2.7 — mobile brand text: "Mr. Instalator" with a slow shine loop
   ================================================================== */
@media (max-width: 768px) {
  /* style.css hides .brand span on small screens — bring it back, centered
     in the gap between the logo and the profile chip */
  .brand { flex: 1 !important; min-width: 0; gap: 10px !important; }
  .brand .brand-text {
    display: block !important;
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.6px;
    white-space: nowrap;
    overflow: hidden;
    color: #ffffff; /* fallback if gradient text unsupported */
    background: linear-gradient(110deg,
      #ffffff 0%, #ffffff 42%,
      #7dd3fc 50%,
      #ffffff 58%, #ffffff 100%);
    background-size: 250% 100%;
    background-position: 115% 0;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* One gentle sweep, then a long calm pause — never frantic */
    animation: brandTextShine 7s ease-in-out infinite;
  }
}
@keyframes brandTextShine {
  0%       { background-position: 115% 0; }
  28%      { background-position: -35% 0; }  /* the shine glides across (~2s) */
  100%     { background-position: -35% 0; }  /* rests for the remaining ~5s */
}
/* Respect users who disable animations */
@media (prefers-reduced-motion: reduce) {
  .brand .brand-text { animation: none; -webkit-text-fill-color: #ffffff; }
}


/* ==================================================================
   v2.8 — WO modal action buttons: even grid, no clipped Romanian text
   ================================================================== */
.wo-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: stretch;
}
.wo-actions .act-paid { grid-column: 1 / -1; }
.wo-actions .btn {
  min-height: 50px !important;
  height: auto !important;
  padding: 10px 12px !important;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  white-space: normal !important;   /* long RO labels wrap, never clip */
  overflow: visible !important;
  line-height: 1.25;
  font-size: 14px !important;
  font-weight: 600;
}
.wo-actions .act-paid.btn { font-size: 15px !important; min-height: 54px !important; }
@media (min-width: 769px) {
  /* Desktop: paid full row, then the rest share one row evenly —
     auto-fit keeps them equal whether there are 2, 3 or 4 buttons */
  .wo-actions { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .wo-actions .act-paid { grid-column: 1 / -1; }
}
/* When only 3 secondary buttons exist (no admin delete / no edit), grid
   auto-flows — cells stay equal because of 1fr tracks. */

/* ==================================================================
   v2.9 — DESKTOP modal header: sticky (was unpinned — content and the
   proposal tabs scrolled right over it). Mobile keeps the fixed header.
   ================================================================== */
@media (min-width: 769px) {
  /* No top padding on the modal → the header IS the first pixel of the
     scroller and pins at exactly 0. Nothing can ever render above it. */
  .modal { padding-top: 0 !important; }
  .modal-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 40 !important;
    background: var(--bg-elev, #0f172a) !important;
    margin: 0 -24px 18px -24px !important;
    padding: 16px 24px !important;
    border-bottom: 1px solid var(--border, rgba(255,255,255,0.14)) !important;
    border-radius: 14px 14px 0 0;
  }
  /* Guard: no ancestor may create a competing clip context for sticky */
  .modal-backdrop { overflow: visible !important; }
  /* Proposal tabs pin just below the header */
  .prop-tabs {
    position: sticky;
    top: 60px;
    z-index: 25;
    background: var(--bg-elev, #0f172a) !important;
  }
  /* Bottom total bar (services/parts tabs): solid and full-bleed */
  .prop-total-bar {
    margin-left: -24px !important;
    margin-right: -24px !important;
    margin-bottom: -24px !important;
    padding: 12px 24px !important;
  }
}

/* ==================================================================
   v3.0 — DESKTOP NAV GROUPS: dropdowns so the bar never overflows
   ================================================================== */
@media (min-width: 769px) {
  .topbar .brand { flex-shrink: 0; }          /* brand can't be squashed/overlapped */
  .topbar .nav {
    display: flex; align-items: center; gap: 2px;
    flex: 1 1 auto; min-width: 0;
    overflow: visible;                         /* dropdowns must escape the bar */
  }
  .nav-group { position: relative; }
  .nav-group-btn {
    background: transparent; border: none; cursor: pointer;
    color: var(--text-dim, #94a3b8);
    font-size: 14px; font-weight: 600;
    padding: 8px 12px; border-radius: 8px;
    display: flex; align-items: center; gap: 5px; white-space: nowrap;
    font-family: inherit;
  }
  .nav-group-btn:hover { color: var(--text, #e2e8f0); background: rgba(148,163,184,0.1); }
  .nav-group.active .nav-group-btn { color: var(--primary, #2563eb); background: rgba(37,99,235,0.12); }
  .nav-caret { font-size: 10px; opacity: 0.7; }
  .nav-dropdown {
    /* !important — style.css sets .nav a/.nav > * to display:flex, which was
       forcing the dropdown open and spilling the items across the bar */
    display: none !important;
    position: absolute !important; top: calc(100% + 6px); left: 0;
    min-width: 210px; z-index: 200;
    background: var(--bg-elev, #0f172a);
    border: 1px solid var(--border, rgba(255,255,255,0.14));
    border-radius: 12px; padding: 6px;
    box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  }
  .nav-dropdown.open { display: block !important; }
  .nav-dropdown a {
    display: flex !important; align-items: center; gap: 9px;
    padding: 10px 12px; border-radius: 8px;
    color: var(--text, #e2e8f0); font-size: 14px; text-decoration: none; white-space: nowrap;
  }
  .nav-dropdown a:hover { background: rgba(148,163,184,0.14); }
  .nav-dropdown a.active { background: rgba(37,99,235,0.18); color: var(--primary, #2563eb); font-weight: 700; }
}

/* ==================================================================
   v3.1 — Technician availability slot grid (scheduling modal)
   ================================================================== */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border, #334155);
  border-radius: 10px;
  background: var(--panel-2, rgba(15,23,42,0.4));
}
.slot-grid .slot {
  padding: 9px 4px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}
.slot-grid .slot.free  { background: rgba(16,185,129,0.14); color: #10b981; border-color: rgba(16,185,129,0.3); }
.slot-grid .slot.busy  { background: rgba(239,68,68,0.16);  color: #ef4444; border-color: rgba(239,68,68,0.35); }
.slot-grid .slot.emerg { background: rgba(245,158,11,0.14); color: #f59e0b; border-color: rgba(245,158,11,0.3); }
.slot-grid .slot.chosen {
  outline: 3px solid var(--primary, #2563eb);
  outline-offset: -1px;
  background: var(--primary, #2563eb) !important;
  color: #fff !important;
}
.slot-grid .slot:hover { filter: brightness(1.25); }
.slot-x { position: absolute; top: 2px; right: 4px; font-size: 8px; }

/* ==================================================================
   v3.2 — INVENTORY on mobile: card list instead of a 9-column table
   ================================================================== */
.part-cards { display: none; }

@media (max-width: 768px) {
  .part-cards { display: block; }
  .part-cards + table.hide-mobile { display: none !important; }

  .part-card {
    background: var(--panel, #1e293b);
    border: 1px solid var(--border, rgba(255,255,255,0.08));
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    cursor: pointer;
  }
  .part-card.low { border-left: 4px solid var(--danger, #ef4444); }

  .pc-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }

  .pc-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
  .pc-chip {
    font-size: 12px; font-weight: 600;
    padding: 4px 9px; border-radius: 999px;
    background: rgba(148,163,184,0.14); color: var(--text-dim, #94a3b8);
    white-space: nowrap;
  }
  .pc-chip.ok     { background: rgba(16,185,129,0.16); color: #10b981; }
  .pc-chip.warn   { background: rgba(245,158,11,0.16); color: #f59e0b; }
  .pc-chip.danger { background: rgba(239,68,68,0.18);  color: #ef4444; }
  .pc-chip.accent { background: rgba(6,182,212,0.14);  color: #06b6d4; }

  .pc-actions { display: flex; gap: 8px; margin-top: 11px; }
  .pc-actions .btn { flex: 1; min-height: 40px; font-size: 13px; white-space: nowrap; }

  /* Toolbar: filters and buttons stack instead of squeezing */
  .parts-toolbar { flex-direction: column; align-items: stretch !important; gap: 8px; }
  .parts-toolbar > * { width: 100%; }
  .parts-toolbar .flex { flex-wrap: wrap; gap: 8px; }
  .parts-toolbar .input,
  .parts-toolbar .select { max-width: none !important; width: 100%; min-height: 44px; }
  .parts-toolbar .btn { flex: 1; min-height: 44px; }
}

/* ==================================================================
   v3.3 — GUIDED DIAGNOSTIC: responsive on desktop and mobile
   The labels are full sentences ("Curge apă / are o scurgere"), so
   buttons must wrap text rather than clip it.
   ================================================================== */
.diag-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}
.diag-btn {
  display: flex !important;
  align-items: center;
  gap: 10px;
  text-align: left;
  justify-content: flex-start !important;
  min-height: 56px;
  height: auto !important;
  padding: 10px 12px !important;
  white-space: normal !important;   /* wrap, never clip */
  line-height: 1.3;
}
.diag-ico { font-size: 20px; flex-shrink: 0; }
.diag-txt { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.diag-answers { display: flex; flex-direction: column; gap: 6px; }
.diag-answer {
  display: flex !important;
  align-items: center;
  justify-content: space-between !important;
  gap: 8px;
  text-align: left;
  min-height: 46px;
  height: auto !important;
  padding: 10px 12px !important;
  white-space: normal !important;
  line-height: 1.3;
}

.diag-svc {
  display: flex !important;
  align-items: center;
  justify-content: space-between !important;
  gap: 10px;
  text-align: left;
  min-height: 42px;
  height: auto !important;
  padding: 8px 11px !important;
  white-space: normal !important;
  line-height: 1.3;
}
.diag-svc-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }

@media (max-width: 640px) {
  .diag-grid { grid-template-columns: 1fr; }   /* one per row on phones */
  .diag-btn { min-height: 52px; font-size: 14px; }
  .diag-answer { min-height: 48px; font-size: 14px; }
}

/* ==================================================================
   v3.4 — Proposal: content must never hide behind the fixed total bar.
   The previous rule lived inside a mobile-only media query, so on
   desktop the last services/parts were covered by the total.
   ================================================================== */
/* The sticky total bar overlaps the END of the tab content, so the padding
   must be on the CONTENT area — padding on #propRoot only adds space after
   the bar, which is why the last rows stayed hidden underneath it. */
#propTabContent { padding-bottom: 120px; }
#propRoot { padding-bottom: 0; }

@media (max-width: 768px) {
  #propTabContent { padding-bottom: calc(150px + var(--safe-bottom)); }
}

/* The total bar must always sit ON TOP of the list, never be overlapped */
.prop-total-bar { z-index: 300 !important; }

/* ==================================================================
   v3.5 — Proposal total bar flush with the bottom of the modal.
   The modal has bottom padding (for the mobile tab bar). A sticky
   bar pins ABOVE that padding, leaving a strip where the list shows
   through underneath it. For the proposal modal we drop that padding
   and let the bar sit on the very edge.
   ================================================================== */
.modal.has-total-bar,
.modal:has(.prop-total-bar) {
  padding-bottom: 0 !important;
}

.prop-total-bar {
  position: sticky !important;
  bottom: 0 !important;
  margin-bottom: 0 !important;
  border-radius: 0 0 14px 14px;
  padding-bottom: calc(12px + var(--safe-bottom)) !important;
}

@media (max-width: 768px) {
  .modal.has-total-bar,
  .modal:has(.prop-total-bar) { padding-bottom: 0 !important; }
  .prop-total-bar { border-radius: 0; }
}

/* ==================================================================
   v3.6 — Notification bell and panel
   ================================================================== */
.notif-bell {
  position: relative;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.14));
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 17px;
  cursor: pointer;
  margin-right: 8px;
  color: inherit;
}
.notif-bell:hover { background: rgba(148,163,184,0.14); }
.notif-badge {
  position: absolute; top: -6px; right: -6px;
  background: #ef4444; color: #fff;
  border-radius: 999px;
  min-width: 19px; height: 19px;
  font-size: 11px; font-weight: 800; line-height: 19px;
  padding: 0 5px;
}
.notif-panel {
  position: fixed; top: 60px; right: 12px; z-index: 400;
  width: min(380px, calc(100vw - 24px));
  max-height: 70vh; overflow: hidden;
  background: var(--bg-elev, #0f172a);
  border: 1px solid var(--border, rgba(255,255,255,0.14));
  border-radius: 14px;
  box-shadow: 0 18px 48px rgba(0,0,0,0.45);
  display: flex; flex-direction: column;
}
.notif-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-bottom: 1px solid var(--border, rgba(255,255,255,0.10));
}
.notif-list { overflow-y: auto; }
.notif-item {
  display: block; padding: 12px 14px; text-decoration: none; color: inherit;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.07));
}
.notif-item:hover { background: rgba(148,163,184,0.10); }
.notif-item.unread { background: rgba(37,99,235,0.10); border-left: 3px solid var(--primary, #2563eb); }

@media (max-width: 768px) {
  .notif-panel { top: calc(58px + var(--safe-top)); right: 8px; left: 8px; width: auto; }
  .notif-bell { width: 38px; height: 38px; margin-right: 6px; }
}

/* ==================================================================
   v3.7 — LANGUAGE-PROOF LAYOUT
   Romanian labels run 20–30% longer than English ("Înregistrează plată"
   vs "Record payment"). Fixed heights and nowrap were clipping them on
   phones. Everything that holds a translated label now grows instead of
   cutting, in both languages.
   ================================================================== */

/* Buttons: never clip a label; grow taller instead */
.btn, button.btn, .st-tab, .vs-tab, .g-tab, .prop-tab {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
  height: auto;
  min-height: 40px;
}

/* Tab strips scroll rather than squeeze when labels are long */
.st-tabs, .vs-tabs, .g-tabs, .prop-tabs {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.st-tabs::-webkit-scrollbar,
.vs-tabs::-webkit-scrollbar,
.g-tabs::-webkit-scrollbar { display: none; }
.st-tab, .vs-tab, .g-tab { flex: 0 0 auto; }

/* Labels and hints wrap properly */
.label, .hint, .card-title, .page-sub, .text-sm { overflow-wrap: anywhere; }

/* Chips (holders, parts, symptoms) wrap as a group, each staying intact */
.holder, .pc-chip, .diag-svc-name { overflow-wrap: anywhere; }

/* Long words in headings shouldn't overflow the card */
h1, h2, h3, .page-title, strong { overflow-wrap: anywhere; }

@media (max-width: 768px) {
  /* Full-width action buttons stack their text rather than clipping */
  .btn { font-size: 14px; padding: 10px 12px; }
  .btn-sm { font-size: 13px; padding: 8px 10px; min-height: 38px; }

  /* Modal action rows: two long buttons side by side never fit in Romanian */
  .modal .flex.gap-2 > .btn { flex: 1 1 100%; }
  .modal .flex.gap-2 { flex-wrap: wrap; }

  /* Table headers: allow two lines instead of horizontal overflow */
  table th { white-space: normal; line-height: 1.2; font-size: 12px; }

  /* Stat tiles: long labels like "lucrări finalizate, neîncasate" */
  .stat-label, .stat-value { overflow-wrap: anywhere; }

  /* Dashboard pending tiles stack on narrow screens */
  .grid.grid-4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  /* The two-column grids inside forms collapse to one */
  .grid.grid-2, .grid.grid-3 { grid-template-columns: 1fr; }

  /* Filter chip rows scroll horizontally instead of wrapping into a wall */
  .st-tabs + div[style*="flex-wrap"] { overflow-x: auto; flex-wrap: nowrap !important; }
}

@media (max-width: 400px) {
  /* Very narrow phones: shrink slightly rather than break the layout */
  .btn { font-size: 13px; }
  .page-title { font-size: 20px; }
  .stat-value { font-size: 18px; }
}

/* ==================================================================
   v3.8 — LONG NAMES IN EITHER LANGUAGE
   Some English part names are longer than the Romanian ("Thermostatic
   radiator kit + lockshield + Honeywell head" = 55 chars). Names must
   wrap inside their row rather than push the quantity off screen.
   ================================================================== */
.vs-row strong,
.st-row strong,
.part-card strong { overflow-wrap: anywhere; hyphens: auto; }

/* Part rows: name takes the space it needs, quantity stays put */
.vs-row > .flex-between > div:first-child,
.st-row > .flex-between > div:first-child { min-width: 0; flex: 1 1 auto; }
.vs-row > .flex-between > div:last-child,
.st-row > .flex-between > div:last-child { flex: 0 0 auto; }

/* Dropdowns holding long part names */
select.select option { font-size: 14px; }
.select { max-width: 100%; text-overflow: ellipsis; }

/* Modal titles carrying a part name */
.modal-header h3 { overflow-wrap: anywhere; line-height: 1.3; }

@media (max-width: 768px) {
  /* On phones the name gets its own line above the quantity */
  .vs-row > .flex-between,
  .st-row > .flex-between { flex-wrap: wrap; }
  .vs-row > .flex-between > div:last-child,
  .st-row > .flex-between > div:last-child { text-align: left !important; }

  /* Give-parts rows: quantity + button stay together under a long name */
  #giveList .flex-between { flex-wrap: wrap; }
  #giveList .flex-between > div:last-child { margin-top: 6px; }
}

/* ==================================================================
   v3.9 — MOBILE LAYOUT CORRECTIONS
   Fixes found on a real phone: wrapped tabs, hidden search fields,
   over-nested containers squeezing content, inconsistent rows.
   ================================================================== */

/* ---- 1. TABS: one line, scroll instead of wrapping ---------------- */
.prop-tabs, .vs-tabs, .st-tabs, .g-tabs {
  display: flex !important;
  flex-wrap: nowrap !important;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 4px;
}
.prop-tabs::-webkit-scrollbar { display: none; }
.prop-tab, .vs-tab, .st-tab, .g-tab {
  white-space: nowrap !important;     /* overrides the earlier wrap rule */
  flex: 0 0 auto !important;
  min-height: 44px;
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
}
@media (max-width: 768px) {
  .prop-tab, .vs-tab, .st-tab, .g-tab { font-size: 13px; padding: 9px 12px !important; }
}
@media (max-width: 400px) {
  .prop-tab, .vs-tab, .st-tab, .g-tab { font-size: 12px; padding: 8px 10px !important; }
}

/* ---- 2. SEARCH FIELDS: never hidden under a sticky header --------- */
#propTabContent .input[placeholder],
#jobSearch, #partSearch, #stockSearch, #giveSearch {
  position: relative;
  z-index: 2;
}
#propTabContent > .field:first-child,
#propTabContent > .input:first-child { margin-top: 8px; }
#jobListWrap, #partListWrap { padding-top: 4px; }

/* ---- 3. NESTED BOXES: stop stacking borders inside a modal -------- */
@media (max-width: 768px) {
  .modal .card,
  .modal [style*="border:2px dashed"],
  .modal [style*="border:2px solid"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
  /* The problem picker sat inside three nested bordered boxes */
  #problemPickerContainer {
    padding: 10px !important;
    margin-left: -6px !important;
    margin-right: -6px !important;
  }
  #ppWizard > div { padding: 12px !important; }
  .modal { padding-left: 10px !important; padding-right: 10px !important; }

}

/* ---- 4. LIST ROWS: name left, price right, never leapfrogging ----- */
#giveList .flex-between,
.vs-row > .flex-between,
.st-row > .flex-between {
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: flex-start;
  gap: 10px;
}
#giveList .flex-between > div:first-child { flex: 1 1 auto; min-width: 0; }
#giveList .flex-between > div:last-child  { flex: 0 0 auto; margin-top: 0 !important; }

/* Service and part rows in the proposal */
.job-row, .part-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.job-row > :first-child, .part-row > :first-child { flex: 1 1 auto; min-width: 0; }
.job-row > :last-child, .part-row > :last-child { flex: 0 0 auto; text-align: right; white-space: nowrap; }

/* ---- 5. SIGNATURE: stays put, sized to the viewport --------------- */
#signaturePad, canvas#signaturePad {
  width: 100% !important;
  max-width: 100%;
  height: 180px !important;
  touch-action: none;              /* stops the page scrolling while signing */
  display: block;
}
@media (max-width: 768px) {
  #signaturePad, canvas#signaturePad { height: 150px !important; }
  .signature-wrap { position: relative; overflow: hidden; }
}

/* ---- 6. WIDER USE OF THE SCREEN ---------------------------------- */
@media (min-width: 769px) {

}
@media (max-width: 768px) {
  .page { padding-left: 10px; padding-right: 10px; }
  .card { padding: 12px; }
}

/* ---- 7. LONG LABELS everywhere ------------------------------------ */
.job-name, .part-name, .vs-row strong, .st-row strong { overflow-wrap: anywhere; }

/* ==================================================================
   v4.0 — NEW ORDER FORM: frames, chips, hours, horizontal scroll
   Four nested bordered boxes were squeezing the content into a thin
   column, symptom labels were clipped mid-word, and the modal could
   be dragged sideways.
   ================================================================== */

/* ---- 1. ONE frame, not four ---------------------------------------- */
.pp-container {
  border: 1px solid var(--border, rgba(255,255,255,0.14));
  border-radius: 12px;
  padding: 12px;
  margin: 12px 0;
  background: rgba(37,99,235,0.05);
}
.pp-wizard-box {
  padding: 12px;
  border: 1px solid rgba(37,99,235,0.45);
  border-radius: 10px;
  background: rgba(37,99,235,0.05);
}
.pp-wizard-box.done {
  border-color: #16a34a;
  background: #f0fdf4;
}
@media (max-width: 768px) {
  /* On a phone the frames cost more than they add */
  .pp-container { border: none; padding: 0; background: transparent; margin: 8px 0; }
  .pp-wizard-box { padding: 11px; }
}

/* ---- 2. SYMPTOM CHIPS: full label, never clipped ------------------- */
#ppSymptoms { display: flex; flex-wrap: wrap; gap: 7px; }
.symptom-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 13px;
  background: var(--panel-2, rgba(148,163,184,0.10));
  border: 1px solid var(--border, #334155);
  border-radius: 12px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.35;
  user-select: none;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
}
.symptom-chip input { margin: 2px 0 0 0; flex: 0 0 auto; }
.symptom-chip span { overflow-wrap: anywhere; }
.symptom-chip:has(input:checked) {
  border-color: var(--primary, #2563eb);
  background: rgba(37,99,235,0.14);
}
@media (max-width: 768px) {
  /* One per row: these labels are sentences, not tags */
  .symptom-chip { flex: 1 1 100%; border-radius: 10px; min-height: 44px; align-items: center; }
}

/* ---- 3. NO SIDEWAYS DRAGGING inside a modal ------------------------ */
.modal { overflow-x: hidden; }
/* Only wide, fixed-width things need constraining — not every element */
.modal img, .modal table, .modal pre, .modal canvas { max-width: 100%; }

/* ---- 4. HOURS GRID -------------------------------------------------
   The grid had its own 240px scroll box inside a modal that also
   scrolls: slots were hidden and the two scrollers fought each other.
   On a phone it now grows to its full height and the modal scrolls. */
.slot-grid {
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
}
.slot-grid .slot {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
@media (max-width: 768px) {
  .slot-grid {
    max-height: none !important;      /* no inner scroller on a phone */
    overflow-y: visible !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    padding: 6px;
  }
  .slot-grid .slot { min-height: 44px; font-size: 12px; padding: 8px 2px; }
  /* The weekend banner spans the row */
  .slot-grid > div[style*="grid-column"] { grid-column: 1 / -1 !important; }
}
@media (max-width: 380px) {
  .slot-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 769px) {
  .slot-grid { max-height: 300px; }
}

/* ==================================================================
   v4.1 — Proposal scroll, symptom buttons, bottom bar
   ================================================================== */

/* ---- 1. PROPOSAL LISTS scroll themselves, not the page behind ----- */
#jobListWrap, #partListWrap, #propGuide {
  overscroll-behavior: contain;      /* stops the scroll escaping to the page */
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
@media (max-width: 768px) {
  #jobListWrap, #partListWrap {
    max-height: none !important;     /* one scroller: the modal */
    overflow-y: visible !important;
  }
  /* The modal itself is the scroll surface */
  .modal { overscroll-behavior: contain; }
}
@media (min-width: 769px) {
  #jobListWrap, #partListWrap { max-height: 52vh; overflow-y: auto; }
}

/* ---- 2. SYMPTOM / PROBLEM BUTTONS: full width, no boxed frames ---- */
.pp-plain { padding: 0; border: none; background: transparent; }
.diag-grid { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px; }
.diag-btn {
  width: 100%;
  border-radius: 12px;
  min-height: 56px;
  padding: 12px 14px !important;
  font-size: 15px;
  background: var(--panel-2, rgba(148,163,184,0.10));
  border: 1px solid var(--border, rgba(255,255,255,0.14));
}
.diag-btn:hover { border-color: var(--primary, #2563eb); }
@media (max-width: 768px) {
  .diag-grid { grid-template-columns: 1fr; gap: 7px; }
  .diag-btn { min-height: 54px; font-size: 15px; }
}

/* ---- 3. BOTTOM BAR: five equal items, no clipped labels ----------- */
/* The bottom bar belongs to phones only. Writing `display: flex` without a
   media query overrode the hide rule and put it on desktop as well. */
@media (max-width: 768px) {
  .mobile-tabbar > a, .mobile-tabbar > button {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 2px;
  }
  .mobile-tabbar span:not(.tab-ico) {
    font-size: 10.5px;
    line-height: 1.15;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
}
@media (max-width: 380px) {
  .mobile-tabbar span:not(.tab-ico) { font-size: 9.5px; }
}
@media (min-width: 769px) {
  .mobile-tabbar { display: none !important; }   /* desktop uses the top nav */
}

/* ==================================================================
   v4.2 — DESKTOP RESTORED
   Several fixes aimed at phones were written without a media query and
   leaked onto desktop: single-column forms, one-per-row chips, stacked
   buttons. Desktop has the space — it should use it.
   ================================================================== */
@media (min-width: 769px) {
  /* Forms go back to two columns */
  .grid.grid-2 { grid-template-columns: 1fr 1fr !important; }
  .grid.grid-3 { grid-template-columns: repeat(3, 1fr) !important; }
  .grid.grid-4 { grid-template-columns: repeat(4, 1fr) !important; }

  /* Symptom chips sit inline again, several per row */
  .symptom-chip {
    flex: 0 1 auto !important;
    min-width: 200px;
    max-width: 340px;
    font-size: 13px;
    min-height: 40px;
  }

  /* Problem buttons: three or four across, not one giant column */
  .diag-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)) !important; }
  .diag-btn { min-height: 52px; }

  /* Modal actions side by side */
  .modal .flex.gap-2 > .btn { flex: 1 1 auto !important; }



  /* The hours grid can show more per row on a big screen */
  .slot-grid { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); max-height: 320px; }

  /* Tabs sized normally */
  .prop-tab, .vs-tab, .st-tab, .g-tab { font-size: 14px; padding: 10px 18px !important; }

  /* Stock rows use the width instead of stacking */
  .vs-row > .flex-between,
  .st-row > .flex-between { flex-wrap: nowrap !important; }
  .vs-row > .flex-between > div:last-child,
  .st-row > .flex-between > div:last-child { text-align: right !important; }

  /* Buttons keep their label on one line where there is room */
  .btn { white-space: nowrap; }
  .btn.diag-btn, .btn.diag-answer, .btn.diag-svc { white-space: normal; }

  /* Give-parts list: name left, quantity and button right */
  #giveList .flex-between > div:last-child { margin-top: 0 !important; }
}

/* The picker frame is only removed on phones; desktop keeps a light one */
@media (min-width: 769px) {
  .pp-container {
    border: 1px solid var(--border, rgba(255,255,255,0.14));
    padding: 14px;
    background: rgba(37,99,235,0.04);
  }
}


/* ==================================================================
   v4.3 — MODAL SIZING DONE PROPERLY
   Earlier rules targeted `.modal > div` — the CONTENT inside the panel —
   instead of `.modal`, the panel itself. That stretched inner elements,
   pushed the close button toward the middle and broke the header.
   `.modal` is the panel; `.modal-backdrop` centres it.
   ================================================================== */
.modal-backdrop {
  align-items: center;
  justify-content: center;
}

/* The panel: one place that decides the width */
.modal {
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

/* Header: title on the left, close pinned right.
   Stretching the first child was wrong — with a bare <h3> it made the
   title fill the row and pushed the × toward the middle. Instead the
   close button is pinned with margin-left:auto and nothing is stretched. */
.modal-header {
  display: flex !important;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
}
.modal-header > h3,
.modal-header > div:first-child {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.modal-header .modal-close {
  margin-left: auto !important;
  flex: 0 0 auto !important;
  align-self: flex-start;
}

@media (min-width: 769px) {
  /* Roomier panels where the content needs it, still centred */
  .modal { max-width: 640px; }
  .modal:has(#propTabContent),
  .modal:has(#woForm),
  .modal:has(#problemPickerContainer) { max-width: 900px; }
  .modal-backdrop { padding: 28px; }
}

@media (max-width: 768px) {
  .modal-backdrop { padding: 10px; align-items: flex-start; }
  .modal { max-width: 100%; padding: 16px; max-height: 94vh; }
}

/* ==================================================================
   v4.4 — TABLET: card view up to 1024px
   An iPad in portrait is 768–834px wide, so it was getting the desktop
   table — which has no Waze button and forces sideways scrolling. A
   technician on a tablet wants the same cards a phone gets.
   ================================================================== */
@media (min-width: 641px) and (max-width: 1024px) {
  .show-mobile { display: block !important; }
  .hide-mobile { display: none !important; }

  /* Two cards per row on a tablet — it has the width for it */
  .show-mobile { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px; }
  .mobile-card { margin-bottom: 0; }
}
@media (min-width: 641px) and (max-width: 834px) {
  /* Portrait tablet: single column reads better */
  .show-mobile { grid-template-columns: 1fr; }
}

/* The Waze button, wherever it appears */
.waze-btn {
  background: #33ccff !important;
  color: #05202b !important;
  border: none !important;
  font-weight: 700;
  white-space: nowrap;
}
td .waze-btn { padding: 5px 10px; font-size: 12px; min-height: 32px; }

/* ==================================================================
   v4.5 — ADDRESS IS THE KEY FIELD ON A JOB CARD
   A technician scanning his list needs the street before anything
   else; the city alone told him nothing useful.
   ================================================================== */
.wo-address {
  font-weight: 600;
  color: var(--text, #e2e8f0);
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.mobile-card .wo-address { margin-top: 2px; }

/* In the table the street leads, the city is secondary */
td .text-dim { font-size: 12px; }
