/* Crewzee CRM — Mobile-first responsive */

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

:root {
  --navy: #0C2340;
  --navy-light: #1a3a5c;
  --navy-dark: #081829;
  --orange: #EE7624;
  --orange-dark: #d4651d;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #1a1a1a;
  --text-2: #666;
  --text-3: #999;
  --border: #e0e0e0;
  --success: #0d9f6e;
  --warning: #d97706;
  --error: #dc2626;
  --sidebar-w: 220px;
  --bg-2: #F9FAFB;
  --hover: #F9FAFB;
  --text-link: #2563EB;
}

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

/* html needs the same overflow + height treatment as body — iOS will
 * scroll whichever ancestor isn't pinned, and a runaway html scroll
 * is what tucks the topbar under the Dynamic Island after a keyboard
 * dismiss in the PWA. */
html {
  overflow: hidden;
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  /* 100vh overshoots on iOS Safari (URL bar area is included in the
   * measurement); -webkit-fill-available works on older WebKit; 100dvh
   * (dynamic viewport height) is the modern fix. Later wins for browsers
   * that support each. */
  height: 100vh;
  height: -webkit-fill-available;
  height: 100dvh;
}

/* ============================================
   APP SHELL
   ============================================ */

.crm-shell {
  display: flex;
  height: 100vh;
  position: relative;
}

/* ============================================
   SIDEBAR (desktop only)
   ============================================ */

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0E2847 0%, #091D36 100%);
  color: white;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--navy-light);
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
/* Background-image at 140% zoom — same 36x36 navy square, but the C
 * inside is visually larger because we're showing the center crop of
 * an oversized background. Matches the owner's "less padding around
 * the C, same square size" ask. */
.sidebar-logo-mark {
  width: 36px;
  height: 36px;
  background: url('/assets/icons/icon-192.png?v=297') center/140% no-repeat;
  border-radius: 6px;
}

.sidebar-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.6);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: white;
  background: var(--navy-light);
}

.nav-item.active {
  color: white;
  background: var(--navy-light);
  border-left-color: var(--orange);
}

/* Susie gets top billing in the sidebar — filled orange button
 * (CTA-style) so the AI surface reads as the front door of the app.
 * Sits above all the standard nav items; overrides the default nav-item
 * look (transparent + dim text) with a solid orange tile + white text.
 *
 * Active-state interaction: the existing .nav-item.active rule below
 * would otherwise set a navy-light background. We keep the orange and
 * just deepen it slightly with a brighter brand orange + a subtle
 * inset shadow so the user can still tell it's the currently selected
 * screen without losing the visual identity.
 */
.nav-item.nav-item-susie {
  background: var(--orange);
  color: white;
  font-weight: 700;
  letter-spacing: 0.2px;
  margin: 6px 10px 10px 10px;
  /* Base .nav-item is width: 100% — combined with our 10px lateral
   * margins, that becomes 100% + 20px and overflows the sidebar,
   * producing a horizontal scrollbar at the bottom. Subtract the
   * margins from the width so the button stays inside its container. */
  width: calc(100% - 20px);
  box-sizing: border-box;
  padding: 12px 14px;
  border-radius: 8px;
  border-left: 3px solid transparent;
  box-shadow: 0 1px 3px rgba(238, 118, 36, 0.35);
}
.nav-item.nav-item-susie:hover {
  background: #ff8a3d;
  color: white;
  filter: brightness(1.05);
}
.nav-item.nav-item-susie.active {
  background: var(--orange);
  color: white;
  border-left-color: transparent;
  box-shadow: 0 1px 3px rgba(238, 118, 36, 0.35), inset 0 0 0 2px rgba(255, 255, 255, 0.25);
}
.nav-item.nav-item-susie .nav-icon,
.nav-item.nav-item-susie .nav-icon svg {
  color: white;
}

.nav-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--navy-light);
}

.sidebar-user {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

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

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  /* padding-top adds env(safe-area-inset-top) so the topbar stays below
   * the iOS status bar / Dynamic Island even when it expands (active
   * call, recording, hotspot). Without this the hamburger ends up
   * under the Dynamic Island and becomes untappable. */
  padding: calc(12px + env(safe-area-inset-top, 0px)) 20px 12px 20px;
  background: linear-gradient(180deg, #0F2A4A 0%, #0C2340 100%);
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  /* Sticky position guards against iOS keyboard dismiss scrolling the
   * document up — topbar stays pinned to the visible top regardless. */
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Global search */
.topbar-search-wrap {
  flex: 1;
  position: relative;
  max-width: 500px;
}

.global-search-input {
  width: 100%;
  padding: 8px 14px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: rgba(255,255,255,0.08);
  color: white;
}

.global-search-input::placeholder { color: rgba(255,255,255,0.45); }

.global-search-input:focus {
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.12);
}

.global-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}

.search-result-group {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  background: var(--bg);
}

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  font-size: 14px;
}

.search-result-item:hover, .search-result-item:active {
  background: #f8f8f8;
}

.search-result-item strong {
  color: var(--navy);
}

/* ── Global search dropdown (gs-*) ── */
.gs-group-label {
  padding: 6px 14px 3px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-3);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.gs-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.1s;
}
.gs-item:last-child { border-bottom: none; }
.gs-item:hover, .gs-item:active { background: var(--bg); }
.gs-item-icon { font-size: 16px; flex-shrink: 0; }
.gs-item-text { min-width: 0; }
.gs-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.gs-item-sub {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.gs-empty {
  padding: 16px 14px;
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

.search-result-item .search-result-sub {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: white;
}

.topbar-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex: 1;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  padding: 8px 16px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.topbar-btn:active { background: var(--orange-dark); }
.topbar-btn:disabled { opacity: 0.5; cursor: default; pointer-events: none; }

/* Screen container */
.screen-container {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

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

/* ============================================
   DASHBOARD
   ============================================ */

/* ── Dashboard quick actions ── */
.dash-quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.dash-quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-quick-btn:hover { border-color: var(--orange); box-shadow: 0 2px 8px rgba(238,118,36,0.15); }
.dash-quick-icon { display: inline-flex; align-items: center; }
.dash-quick-icon svg { width: 16px; height: 16px; }

/* ── Dashboard lower two-column ── */
.dash-lower {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
@media (max-width: 700px) { .dash-lower { grid-template-columns: 1fr; } }

.dash-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.dash-section-header h2 { margin-bottom: 0; }

/* ── Overdue alert banner ── */
.dash-overdue-banner {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  color: #856404;
  margin-bottom: 16px;
}

/* ── Today's tasks in dashboard ── */
.dash-task-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.dash-task-item:last-child { border-bottom: none; }
.dash-task-item.done { opacity: 0.55; }

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

.dash-card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.dash-card-label {
  font-size: 11px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  margin-bottom: 8px;
}

.dash-card-value {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 36px;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
  margin-top: 4px;
}

.dash-section h2 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.activity-list {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  overflow: hidden;
}

.dash-activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.dash-activity-item:last-child { border-bottom: none; }
.dash-activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  margin-top: 6px;
  flex-shrink: 0;
}

.activity-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.activity-item:last-child { border-bottom: none; }

.activity-time {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 4px;
}

/* ============================================
   PIPELINE / KANBAN BOARD
   ============================================ */

.pipeline-header {
  margin-bottom: 8px;
}

.pipeline-filters {
  display: flex;
  gap: 8px;
}

.pipeline-filters select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--card);
}

.kanban-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 16px;
  height: calc(100vh - 165px);
  align-items: stretch;
}

.kanban-column {
  min-width: 260px;
  max-width: 300px;
  flex-shrink: 0;
  background: var(--bg);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kanban-col-header {
  padding: 12px 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 3px solid var(--navy);
}

.kanban-col-count {
  background: var(--navy);
  color: white;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
}

/* Reports funnel */
.funnel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.funnel-label {
  width: 130px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  flex-shrink: 0;
}

.funnel-bar-wrap {
  flex: 1;
  background: var(--bg);
  border-radius: 4px;
  height: 28px;
  overflow: hidden;
}

.funnel-bar {
  height: 100%;
  background: var(--navy);
  border-radius: 4px;
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding-left: 8px;
  min-width: 24px;
  transition: width 0.3s ease;
}

.funnel-value {
  width: 90px;
  font-size: 13px;
  color: var(--success);
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
}

/* Reports */
#reports-content { padding: 16px; }
.report-range-btn { font-size: 12px; padding: 5px 12px; }
.funnel-value { color: var(--text-2); } /* override the green — value is neutral */

/* Settings */
.settings-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
  flex-wrap: nowrap;
  overflow-x: auto;
}

.settings-tab {
  padding: 10px 14px;
  border: none;
  background: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.settings-tab:hover { color: var(--navy); }
.settings-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

.settings-panel {
  max-width: 1100px;
}

.settings-field {
  margin-bottom: 14px;
}

.settings-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-2);
  margin-bottom: 4px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.settings-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  min-height: 40px;
  border-radius: 6px;
  font-size: 14px;
  box-sizing: border-box;
}
.settings-input:focus { outline: none; border-color: var(--orange); }

.settings-stage-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.settings-stage-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 6px;
  font-size: 14px;
}

.settings-stage-item > div:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.settings-stage-order {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  width: 24px;
  text-align: center;
}

.settings-stage-name {
  flex: 1;
  font-weight: 500;
}

.settings-stage-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background: #d1fae5;
  color: #065f46;
}
.settings-stage-badge.closed { background: #e5e7eb; color: var(--text-2); }

/* Pipeline list view */
.pipeline-list-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.pipeline-list-table th {
  text-align: left;
  padding: 12px 14px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-3);
  border-bottom: 2px solid var(--navy);
  background: var(--bg);
}

.pipeline-list-table td {
  padding: 12px 14px;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}

.pipeline-list-table tbody tr:nth-child(even) { background: #F9FAFB; }
.pipeline-list-row { cursor: pointer; transition: background 0.15s; }
.pipeline-list-row:hover { background: #f8f9fa; }

.kanban-col-total {
  padding: 4px 14px 8px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  font-weight: 600;
  color: var(--success);
  border-bottom: 1px solid var(--border);
}

.kanban-col-cards {
  flex: 1;
  padding: 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.kanban-card {
  background: var(--card);
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow 0.15s;
  border-left: 4px solid #94A3B8;
}

.kanban-card:active {
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.kanban-card.dragging {
  opacity: 0.4;
}

.kanban-col-cards.drag-over {
  background: rgba(238, 118, 36, 0.08);
  border: 2px dashed var(--orange);
  border-radius: 8px;
}

.kanban-card-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
}

.kanban-card-address {
  font-size: 12px;
  color: var(--text-2);
}

.kanban-card-contact {
  font-size: 12px;
  color: var(--text-link);
  font-weight: 500;
  margin-top: 4px;
  cursor: pointer;
}

.kanban-card-contact:hover {
  text-decoration: underline;
}

.kanban-card-amount {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--orange);
  margin-top: 8px;
}

.kanban-card-meta {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
}

/* ============================================
   CONTACTS
   ============================================ */

.contacts-header {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.search-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  outline: none;
}

.search-input:focus { border-color: var(--navy); }

.contacts-list {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

.contact-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.1s;
}

.contact-row:active { background: #f8f8f8; }
.contact-row:last-child { border-bottom: none; }

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--navy);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.contact-info { flex: 1; min-width: 0; }

.contact-name {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-detail {
  font-size: 13px;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  background: #e8f5e9;
  color: var(--success);
  font-weight: 600;
  flex-shrink: 0;
}

/* ============================================
   CALENDAR
   ============================================ */

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.calendar-header h2 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
}

.cal-nav {
  background: none;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 18px;
  cursor: pointer;
}

.calendar-grid {
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  padding: 16px;
}

.cal-view-toggle {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  align-items: center;
}

.cal-view-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
}
.cal-view-btn.active { background: var(--navy); color: white; border-color: var(--navy); }

.cal-grid-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}

.cal-day-header {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 0;
}

.cal-grid-body {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  min-width: 0; /* grid container respects parent width even if children "want" more */
}

.cal-cell {
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  transition: background 0.15s;
  /* CRITICAL: grid items default to min-width: auto, which resolves to the
   * intrinsic min-content width. Combined with .cal-task-chip's
   * `white-space: nowrap`, that made each cell grow to fit its longest
   * chip — pushing the whole 7-column grid wider than the viewport on
   * mobile. Forcing min-width: 0 lets the cell honor its 1fr share, and
   * the chip's overflow:hidden + ellipsis can actually take effect.
   */
  min-width: 0;
  overflow: hidden;
}
.cal-cell:hover { background: #f8f9fa; }
.cal-cell.cal-empty { background: #fafafa; border-color: transparent; cursor: default; }
.cal-cell.cal-today { background: #fff7ed; border-color: var(--orange); }

.cal-cell-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.cal-today .cal-cell-num { color: var(--orange); }

.cal-task-chip {
  background: var(--navy);
  color: white;
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 4px;
  margin-bottom: 3px;
  min-height: 22px;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  max-width: 100%; /* don't exceed parent cell — pairs with .cal-cell min-width:0 */
  min-width: 0;
  box-sizing: border-box;
}
.cal-ext-event {
  background: #e8f4fd !important;
  color: #1a73e8 !important;
  border: 1px solid #c5dff7;
  cursor: default;
  font-size: 10px;
}
.cal-task-chip.done { opacity: 0.45; text-decoration: line-through; }
.cal-task-chip:hover { filter: brightness(1.15); }

.cal-week-day-header { cursor: pointer; }
.cal-week-day-header:hover { background: var(--bg); }

.cal-empty-slot {
  font-size: 12px;
  color: var(--text-3);
  padding: 6px 4px;
  cursor: pointer;
  border-radius: 4px;
}
.cal-empty-slot:hover { color: var(--orange); }

/* Week view */
.cal-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.cal-week-day {
  background: #fafafa;
  border-radius: 8px;
  border: 1px solid var(--border);
  min-height: 200px;
}
.cal-week-day.cal-today { border-color: var(--orange); background: #fff7ed; }

.cal-week-day-header {
  padding: 8px 10px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  color: var(--navy);
}

.cal-week-day-body { padding: 8px; }

/* Day view */
.cal-day-detail { padding: 0; }
.cal-day-detail h3 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  color: var(--navy);
  margin-bottom: 16px;
}

.cal-time-slot {
  display: flex;
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.cal-time-label {
  width: 80px;
  padding: 8px;
  font-size: 12px;
  color: var(--text-3);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}

.cal-time-content {
  flex: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.cal-time-content:hover { background: #f8f9fa; }

/* ============================================
   JOB DETAIL
   ============================================ */

.job-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.job-detail-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--navy);
}

.job-detail-address {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 4px;
}

.job-back-btn {
  background: none;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-2);
}

/* Pipeline progress */
.pipeline-progress {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.pipeline-step {
  flex: 1;
  min-width: 0;
  padding: 8px 4px;
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-3);
  background: #f0f0f0;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pipeline-step.completed {
  background: var(--success);
  color: white;
}

.pipeline-step.current {
  background: var(--orange);
  color: white;
}

/* Job detail sections */
.job-sections {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.job-section {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.job-section-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--navy);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
}

/* Pipeline progress bar */
.pipeline-progress {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding: 16px 20px;
  background: var(--card);
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  overflow-x: auto;
}

.progress-step {
  flex: 1;
  text-align: center;
  position: relative;
  min-width: 60px;
}

.progress-step::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}

.progress-step:last-child::after { display: none; }
.progress-step.past::after { background: var(--success); }
.progress-step.current::after { background: var(--border); }

.progress-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  margin: 0 auto 6px;
  position: relative;
  z-index: 1;
  border: 2px solid var(--border);
  background: white;
}

.progress-step.past .progress-dot { background: var(--success); border-color: var(--success); }
.progress-step.current .progress-dot { background: var(--orange); border-color: var(--orange); box-shadow: 0 0 0 4px rgba(238,118,36,0.2); }
.progress-step.future .progress-dot { background: white; border-color: var(--border); }

.progress-label {
  font-size: 10px;
  color: var(--text-3);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.progress-step.current .progress-label { color: var(--orange); font-weight: 700; }
.progress-step.past .progress-label { color: var(--success); }

/* Job detail tabs */
.job-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.job-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  background: none;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
}

.job-tab:hover { color: var(--navy); }
.job-tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.job-tab-panel { display: none; }
.job-tab-panel.active { display: block; }

/* Activity items */
.activity-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-time {
  font-size: 11px;
  color: var(--text-3);
  margin-bottom: 4px;
}
.activity-body {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

/* Task items */
.task-item {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.task-item:last-child { border-bottom: none; }
.task-item.task-done { opacity: 0.5; }
.task-check { font-size: 20px; cursor: pointer; line-height: 1; }
.task-content { flex: 1; }
.task-subject { font-size: 14px; font-weight: 600; color: var(--text); }
.task-body { font-size: 13px; color: var(--text-2); margin-top: 2px; }
.task-meta { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* File items */
.file-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.file-item:last-child { border-bottom: none; }
.file-meta { font-size: 12px; color: var(--text-3); }

/* Estimate list items */
.estimate-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.estimate-list-item:hover { background: var(--bg); margin: 0 -20px; padding: 12px 20px; }
.estimate-list-item:last-child { border-bottom: none; }

.estimate-status {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.3px;
}
.estimate-status-default { background: #e5e7eb; color: var(--text-2); }
.estimate-status-success { background: #d1fae5; color: #065f46; }
.estimate-status-error { background: #fee2e2; color: #991b1b; }
.estimate-status-warning { background: #fff7ed; color: #c2410c; }

/* Estimate Editor Overlay */
.estimate-editor-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.estimate-editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  background: var(--navy);
  color: white;
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 8px;
}

.est-back-btn {
  background: none;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

.est-name-input {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 18px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  width: 250px;
}

.est-profile-select {
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
}

.estimate-editor-body {
  flex: 1;
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

/* Sections */
.est-section {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

.est-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--navy);
}

.est-section-name {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  border: none;
  background: none;
  color: var(--navy);
  padding: 4px 0;
  flex: 1;
}
.est-section-name:focus { outline: none; border-bottom: 1px solid var(--orange); }

.est-section-delete {
  background: none;
  border: none;
  color: var(--error);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}

/* Line items table */
.est-items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.est-items-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--text-3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--border);
}

.est-items-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.est-items-table tbody tr:nth-child(even) { background: #F9FAFB; }

.est-item-name { font-weight: 600; color: var(--text); }
.est-item-desc { font-size: 11px; color: var(--text-3); margin-top: 2px; }

.est-input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 13px;
  width: 70px;
  text-align: right;
}
.est-input:focus { outline: none; border-color: var(--orange); }

.est-line-total { font-weight: 600; text-align: right; font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums; font-size: 13px; }

.est-remove-item {
  background: none;
  border: none;
  color: var(--error);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
}

.est-add-item-btn, .est-add-section-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 8px;
  background: none;
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.est-add-item-btn:hover, .est-add-section-btn:hover {
  border-color: var(--orange);
  color: var(--orange);
}

.est-section-total {
  text-align: right;
  padding: 10px 6px 0;
  font-weight: 700;
  font-size: 14px;
  color: var(--navy);
}

/* Totals footer */
.estimate-totals {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1), 0 1px 4px rgba(0,0,0,0.06);
  border: 1px solid #E5E7EB;
}

.est-total-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.est-total-row:last-child { border-bottom: none; }

.est-grand-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  border-top: 2px solid var(--navy);
  padding-top: 12px;
  margin-top: 4px;
}

/* Product Picker */
.product-picker-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1100;
  display: flex;
  justify-content: center;
  align-items: center;
}

.product-picker {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.product-picker-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
}

.product-picker-search {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
}

.product-picker-list {
  overflow-y: auto;
  flex: 1;
}

.product-picker-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.product-picker-item:hover { background: var(--bg); }

/* ============================================
   SUSIE ORB
   ============================================ */

.susie-orb {
  position: fixed;
  bottom: 80px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: radial-gradient(circle at 35% 35%, #F59A4A 0%, #EE7624 50%, #D96A1F 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(238,118,36,0.35), 0 2px 4px rgba(238,118,36,0.2);
  z-index: 100;
  transition: transform 0.2s, box-shadow 0.2s;
}

.susie-orb:active {
  transform: scale(0.92);
}

.susie-orb.pulse {
  animation: orbPulse 2s ease-in-out infinite;
}

@keyframes orbPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(12,35,64,0.4); }
  50% { box-shadow: 0 4px 24px rgba(238,118,36,0.6); }
}

/* Susie Panel */
.susie-panel {
  position: fixed;
  bottom: 0;
  right: 0;
  width: 100%;
  max-width: 460px;
  height: 70vh;
  min-height: 500px;
  background: var(--card);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

.susie-panel.hidden { display: none; }

.susie-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: var(--navy);
  color: white;
  border-radius: 20px 20px 0 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.susie-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}
.susie-close-btn:hover { color: white; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.chat-bubble p { margin: 0; }

.chat-bubble.user {
  align-self: flex-end;
  background: var(--navy);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-bubble.assistant {
  align-self: flex-start;
  background: #f0f2f5;
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.chat-input-bar input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  font-size: 15px;
  outline: none;
}

.chat-input-bar input:focus { border-color: var(--navy); }

.chat-send-btn {
  padding: 8px 16px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.chat-send-btn:disabled { opacity: 0.5; }

/* ============================================
   BOTTOM TABS (mobile only)
   ============================================ */

.bottom-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 6px 0;
  padding-bottom: env(safe-area-inset-bottom, 6px);
  z-index: 50;
}

.btab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}

.btab.active { color: var(--orange); }

.btab-icon { font-size: 20px; }

/* ============================================
   UTILITIES
   ============================================ */

.hidden { display: none !important; }

.placeholder {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
}

.container {
  max-width: 600px;
  margin: 0 auto;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--border);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

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

.error {
  background: #fef2f2;
  color: var(--error);
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

/* Auth bar in topbar */
.auth-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,0.7);
}

.auth-bar button {
  background: none;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
}

/* Full-page auth screen (replaces overlay approach) */
body.auth-active .sidebar,
body.auth-active .main-content,
body.auth-active .topbar,
body.auth-active .mobile-bottom-nav,
body.auth-active .susie-orb { display: none !important; }

.auth-page {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, #0C2340 0%, #1a3a5c 50%, #0C2340 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.auth-page-logo {
  margin-bottom: 32px;
  text-align: center;
}
/* The img is display:block so text-align doesn't center it — needs
 * explicit horizontal auto margin to sit centered above the wordmark. */
.auth-page-logo img { margin: 0 auto; }
.auth-page-logo svg { width: 64px; height: 64px; }
.auth-page-logo .auth-brand-name {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: white;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 12px;
}

.auth-page .auth-modal {
  background: white;
  border-radius: 16px;
  padding: 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

/* Legacy auth overlay (kept for profile setup modal) */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
}

.auth-modal {
  background: var(--card);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.auth-modal h2 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 22px;
  margin-bottom: 20px;
  text-align: center;
  color: var(--navy);
}

.auth-modal .form-group { margin-bottom: 14px; }

.auth-modal label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 4px;
}

.auth-modal input[type="email"],
.auth-modal input[type="password"],
.auth-modal input[type="text"],
.auth-modal input[type="tel"],
.auth-modal input[type="number"] {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.auth-modal input:focus { outline: none; border-color: var(--navy); }

.auth-submit {
  display: block;
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.auth-toggle {
  display: block;
  text-align: center;
  margin-top: 14px;
  font-size: 14px;
  color: var(--orange);
  cursor: pointer;
  background: none;
  border: none;
}

.auth-error { color: var(--error); font-size: 13px; margin-top: 8px; text-align: center; }

/* OAuth buttons */
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  margin-bottom: 8px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

/* Form modals */
.form-modal {
  background: var(--card);
  border-radius: 12px;
  padding: 0;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  margin: 20px auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.form-modal-header {
  flex-shrink: 0;
}

.form-modal-body {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
}

.form-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--navy);
  color: white;
}

.form-modal-header h2 {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0;
}

.form-modal-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  opacity: 0.7;
}

.form-modal-close:hover { opacity: 1; }

.form-modal .form-group {
  padding: 0 24px;
  margin-top: 14px;
}

.form-modal .form-group:first-of-type { margin-top: 20px; }

.form-modal label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--card);
  outline: none;
}

.form-input:focus { border-color: var(--orange); }

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Quill editor overrides for email form */
.form-modal .ql-container { border-radius: 0 0 8px 8px; border-color: var(--border); font-size: 14px; }
.form-modal .ql-toolbar { border-radius: 8px 8px 0 0; border-color: var(--border); background: var(--bg); }
.form-modal .ql-editor { min-height: 120px; }
.form-modal .ql-editor.ql-blank::before { font-style: normal; color: var(--text-3); }

/* Email attachment tags */
.email-attach-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text);
}

.form-modal .auth-error {
  padding: 0 24px;
}

.form-submit {
  display: block;
  width: calc(100% - 48px);
  margin: 20px 24px 24px;
  padding: 14px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.form-submit:active { background: var(--orange-dark); }
.form-submit:disabled { opacity: 0.5; }

/* Contact picker rows */
.contact-picker-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}

.contact-picker-row:active { background: #f8f8f8; }
.contact-picker-row:last-child { border-bottom: none; }

/* Products & Packages */
.products-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border);
}

.products-tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.products-tab.active {
  color: var(--orange);
  border-bottom-color: var(--orange);
}

.products-panel { display: none; }
.products-panel.active { display: block; }

.product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.product-row:active { background: #f8f8f8; }

.product-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--orange);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

.product-info { flex: 1; min-width: 0; }

.product-name {
  font-weight: 600;
  font-size: 14px;
}

.product-meta {
  font-size: 12px;
  color: var(--text-2);
  margin-top: 2px;
}

.product-costs {
  text-align: right;
  flex-shrink: 0;
}

.product-cost-material {
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}

.product-cost-labor {
  font-size: 12px;
  color: var(--text-2);
}

/* Package card */
.package-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  border-left: 4px solid #94A3B8;
  cursor: pointer;
}

.package-card:active { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }

.package-name {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.package-meta {
  font-size: 13px;
  color: var(--text-2);
  margin-top: 4px;
}

.package-markup {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
  margin-top: 8px;
}

/* Takeoff-specific styles (from existing) */
.upload-area {
  border: 3px dashed var(--border);
  border-radius: 16px;
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--card);
  margin-bottom: 16px;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--orange);
  background: #fef3ec;
}

.upload-area .icon { font-size: 48px; margin-bottom: 12px; display: block; }
.upload-area h2 { font-size: 20px; margin-bottom: 8px; }
.upload-area p { color: var(--text-2); font-size: 14px; }

.input-options { margin-bottom: 16px; }

.input-btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.input-hint { font-size: 13px; font-weight: 400; color: var(--text-2); }

/* BOM and proposal buttons */
.proposal-btn, .jn-save-btn, .confirm-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin: 12px 0 8px;
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.proposal-btn { background: var(--navy); }
.jn-save-btn { background: var(--orange); }
.confirm-btn { background: var(--success); }

.start-over-btn, .reupload-btn {
  display: block;
  width: 100%;
  padding: 12px;
  margin-bottom: 16px;
  background: none;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text-2);
  cursor: pointer;
}

/* Validation */
.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

.card-header h2 { font-size: 18px; font-weight: 600; }

.provider-badge {
  background: var(--orange);
  color: white;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
}

.badge-llm { background: var(--success); margin-left: 6px; }
.badge-ocr { background: #7c3aed; margin-left: 6px; }

.validation-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.val-field label {
  font-size: 12px;
  color: var(--text-2);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.val-field input {
  width: 100%;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.val-field input:focus { outline: none; border-color: var(--navy); }
.val-field.val-warning input { border-color: var(--warning); background: #fffbeb; }

.address-card { border-left: 4px solid #94A3B8; }

.address-field label {
  font-size: 14px;
  font-weight: 600;
  color: var(--orange);
  text-transform: uppercase;
  display: block;
  margin-bottom: 6px;
}

.address-field input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}

.address-shake { animation: shake 0.5s ease; border-color: var(--error) !important; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.waste-selector { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.waste-options { display: flex; flex-direction: column; gap: 8px; }

.waste-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
}

.waste-option:has(input:checked) { border-color: var(--orange); background: #fef3ec; }

.waste-option input[type="radio"] { accent-color: var(--orange); }
.waste-option-label { font-weight: 500; flex: 1; }
.waste-option-value { font-weight: 700; color: var(--orange); }

.bom-item { padding: 12px 0; border-bottom: 1px solid var(--border); }
.bom-item:last-child { border-bottom: none; }
.bom-header { display: flex; justify-content: space-between; align-items: center; }
.bom-label { font-size: 16px; font-weight: 600; }
.bom-qty { font-size: 18px; font-weight: 700; color: var(--orange); }
.bom-note { font-size: 13px; color: var(--text-2); margin-top: 4px; }

.save-status { text-align: center; font-size: 13px; color: var(--success); margin-top: 8px; }

.pitch-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.pitch-table th { text-align: left; padding: 6px 8px; border-bottom: 2px solid var(--border); font-size: 12px; text-transform: uppercase; color: var(--text-2); }
.pitch-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.pitch-table tbody tr:nth-child(even) { background: #F9FAFB; }

.waste-info { font-size: 14px; color: var(--success); font-weight: 500; margin-bottom: 12px; }

.comparison-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.comparison-table th { text-align: left; padding: 6px; border-bottom: 2px solid var(--border); font-size: 11px; text-transform: uppercase; color: var(--text-2); }
.comparison-table td { padding: 6px; border-bottom: 1px solid var(--border); }
.comparison-table tbody tr:nth-child(even) { background: #F9FAFB; }
.comparison-table .diff-less { color: var(--success); font-weight: 600; }
.comparison-table .diff-more { color: var(--warning); font-weight: 600; }

.waste-comparison { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }

.structure-block { margin-bottom: 24px; }
.structure-block + .structure-block { padding-top: 24px; border-top: 3px solid var(--orange); }

.validation-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fffbeb;
  border: 2px solid var(--warning);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 12px 0;
  font-size: 14px;
  color: var(--warning);
  font-weight: 500;
  cursor: pointer;
}

.validation-notice input[type="checkbox"] { accent-color: var(--warning); }
.validation-notice-shake { animation: shake 0.5s ease; }

.measurements-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.meas-item { display: flex; flex-direction: column; }
.meas-label { font-size: 12px; color: var(--text-2); text-transform: uppercase; }
.meas-value { font-size: 18px; font-weight: 600; margin-top: 2px; }

.photo-tip-modal {
  background: var(--card);
  border-radius: 16px;
  padding: 32px 24px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.photo-tip-icon { font-size: 48px; display: block; margin-bottom: 16px; }
.photo-tip-modal p { font-size: 18px; font-weight: 500; line-height: 1.4; margin-bottom: 20px; }

.waste-custom-input {
  width: 60px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 16px;
  text-align: center;
}

.waste-pct-sign { font-weight: 700; color: var(--orange); }

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */

@media (max-width: 768px) {
  .sidebar { display: none !important; }

  .sidebar.open {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 260px;
    z-index: 200;
  }

  .crm-shell { flex-direction: column; }

  .menu-toggle { display: block; }

  .bottom-tabs { display: flex; }

  /* Susie orb sits 20px above the home indicator gesture area. */
  .susie-orb { bottom: calc(20px + env(safe-area-inset-bottom, 0px)); right: 20px; }

  /* Screen container — bottom padding clears the iPhone home indicator
   * plus enough breathing room (48px) above the last list item so the
   * user's thumb can comfortably tap the last row without grazing the
   * row above. (r00441 dropped this to 20px after the bottom nav came
   * out; bumped to 48px in r00442 after on-device thumb test.) */
  .screen-container { padding: 12px; padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px)); }

  .dashboard-grid { grid-template-columns: 1fr 1fr; }

  .kanban-column { min-width: 220px; }

  .susie-panel {
    max-width: 100%;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }

  .topbar-title { font-size: 16px; }

  .job-sections { grid-template-columns: 1fr; }

  /* Estimate editor mobile */
  .estimate-editor-header { flex-direction: column; align-items: stretch; }
  .est-name-input { width: 100%; }
  .est-items-table { font-size: 11px; }
  .est-items-table th, .est-items-table td { padding: 6px 3px; }
  .est-input { width: 55px; font-size: 11px; }

  /* Calendar mobile — tight padding so 7 cells fit a phone viewport
   * without sacrificing readability of the chip text inside each. */
  .cal-grid-body { gap: 1px; }
  .cal-cell { min-height: 50px; font-size: 11px; padding: 2px; }
  .cal-cell-num { font-size: 11px; margin-bottom: 2px; }
  .cal-day-header { font-size: 10px; padding: 4px 0; }
  .cal-task-chip { font-size: 9px; padding: 2px 4px; min-height: 18px; margin-bottom: 2px; }
  .cal-ext-event { font-size: 9px; }
  .cal-week-grid { grid-template-columns: 1fr; }
  .cal-time-label { width: 60px; font-size: 11px; }

  /* Pipeline header mobile */
  .pipeline-filters { flex-wrap: wrap; gap: 4px; }
  .pipeline-filters select { font-size: 12px; padding: 4px 8px; }

  /* Settings mobile */
  .settings-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .settings-tab { font-size: 12px; padding: 8px 12px; white-space: nowrap; }

  /* Reports mobile */
  .funnel-label { width: 80px; font-size: 11px; }
  .funnel-value { width: 60px; font-size: 11px; }

  /* Job tabs mobile */
  .job-tabs { overflow-x: auto; flex-wrap: nowrap; }
  .job-tab { font-size: 12px; padding: 8px 12px; white-space: nowrap; }

  /* Progress bar mobile */
  .pipeline-progress { padding: 12px 8px; }
  .progress-label { font-size: 8px; }
  .progress-dot { width: 14px; height: 14px; }

  /* Pipeline list table — horizontal scroll + hide low-priority columns */
  .pipeline-list-table { font-size: 12px; display: block; overflow-x: auto; }
  .pipeline-list-table th:nth-child(5),
  .pipeline-list-table td:nth-child(5),
  .pipeline-list-table th:nth-child(6),
  .pipeline-list-table td:nth-child(6) { display: none; } /* hide Type + Created */

  /* Search: shrink on very small screens */
  .topbar-search-wrap { min-width: 0; }
  .global-search-input { font-size: 13px; padding: 7px 10px; }
  .topbar-btn { padding: 7px 12px; font-size: 13px; }

  /* Settings stage list — tighter on mobile */
  .settings-stage-item { gap: 6px; }
  .settings-stage-order { width: 20px; font-size: 12px; }
  .settings-stage-name { font-size: 13px; }

  /* Team settings form */
  .settings-panel .topbar-btn { width: 100%; }
}

/* Desktop: two-column job detail */
@media (min-width: 769px) {
  .bottom-tabs { display: none; }

  .susie-orb { bottom: 24px; right: 24px; }

  .susie-panel {
    bottom: 0;
    right: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 0;
  }

  .job-sections {
    grid-template-columns: 2fr 1fr;
  }

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

/* ============================================================
   MILESTONES
   ============================================================ */

.milestone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.milestone-row:last-child { border-bottom: none; }
.milestone-row:hover { background: var(--bg); border-radius: 6px; }

.milestone-checkbox {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--success);
  flex-shrink: 0;
}

.milestone-name {
  flex: 1;
  font-size: 13px;
  line-height: 1.4;
}
.milestone-name.done {
  text-decoration: line-through;
  color: var(--text-3);
}

.milestone-completed-at {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 2px;
}

.milestone-delete-btn {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 15px;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
  opacity: 0.6;
}
.milestone-delete-btn:hover { color: var(--error); opacity: 1; }

.milestone-progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 10px;
}
.milestone-progress-fill {
  height: 4px;
  background: var(--success);
  border-radius: 2px;
  transition: width 0.35s ease;
}

/* Milestone editor panel inside settings stage rows */
.milestone-editor-panel {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  background: var(--background);
  border-radius: 6px;
  border: 1px solid var(--border);
}

/* Stage selector on job detail */
.stage-selector {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 28px 5px 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-1);
  cursor: pointer;
  min-width: 140px;
  transition: border-color 0.2s;
}
.stage-selector:hover { border-color: var(--orange); }
.stage-selector:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(238,118,36,0.15); }

/* Progress step milestone count badge */
.progress-milestone-count {
  font-size: 9px;
  color: var(--text-3);
  margin-top: 3px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.progress-step.current .progress-milestone-count { color: var(--orange); }

/* ============================================================
   MODAL SYSTEM — shared overlay + card (used everywhere)
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  padding: 16px;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeInOverlay 0.15s ease;
}

@keyframes fadeInOverlay {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  background: var(--card);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: slideUpCard 0.2s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes slideUpCard {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
}

.modal-close {
  background: var(--bg);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

/* Mobile modal = full-width bottom sheet */
@media (max-width: 600px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: 100%;
    max-height: 92vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    animation: slideUpSheet 0.22s cubic-bezier(0.32,0.72,0,1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  @keyframes slideUpSheet {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
}

/* ============================================================
   GLOBAL MOBILE POLISH
   ============================================================ */

/* Prevent iOS font-size zoom on focus — all inputs need 16px minimum */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="search"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Minimum tap target 44px for all interactive elements */
  button:not(.est-remove-item):not(.modal-close):not(.btab):not(.nav-item),
  .topbar-btn,
  .cal-view-btn {
    min-height: 44px;
  }
  .btab { min-height: 52px; }

  /* Topbar: collapse search on very small screens, bigger hit areas */
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar-search-wrap { max-width: none; }

  /* Topbar right-side buttons: stack or shrink label */
  .topbar-actions { gap: 6px; }

  /* Screen container bottom padding handled in the earlier @media block
   * (clears the iPhone home indicator only — bottom-tabs removed r00441). */

  /* Kanban: ensure horizontal scroll doesn't clip */
  .kanban-board { -webkit-overflow-scrolling: touch; }
  .kanban-column { min-width: 200px; }

  /* Cards: slightly tighter */
  .dash-card { padding: 14px; }
  .dash-card-value { font-size: 26px; }

  /* Job detail header — prevent overflow */
  .job-detail-header { flex-wrap: wrap; gap: 8px; }
  .job-detail-title { font-size: 18px; word-break: break-word; }

  /* Estimate list items — readable on small screens */
  .estimate-list-item { padding: 12px 0; gap: 8px; }

  /* Settings panel: full width, less side padding */
  .settings-panel { padding: 0; }
  .settings-field { padding: 10px 0; }

  /* Funnel bars: tighter labels */
  .funnel-row { gap: 6px; }

  /* Reports: charts stack */
  #charts-row { grid-template-columns: 1fr !important; }

  /* Proposal share modal input — full width */
  .modal-body input[type="text"] { width: 100%; }

  /* Susie panel full-height on mobile */
  .susie-panel {
    height: 75vh;
    max-height: 75vh;
  }

  /* PO/LO detail modals — tighter tables */
  .modal-body table { font-size: 12px; }
  .modal-body table td, .modal-body table th { padding: 5px 3px; }

  /* Task modal: grid → single column */
  #task-modal-overlay .modal-body [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

/* Very small screens (iPhone SE, etc.) */
@media (max-width: 375px) {
  .topbar-title { font-size: 14px; }
  .topbar-btn { font-size: 12px; padding: 6px 10px; }
  .job-tab { font-size: 11px; padding: 7px 9px; }
  .progress-label { display: none; } /* too cramped — hide stage labels, keep dots */
  .progress-dot { width: 12px; height: 12px; }
  .dash-card-value { font-size: 22px; }
}

/* ── Active states — better touch feedback ── */
@media (hover: none) {
  /* Devices without hover (touchscreens) — use :active instead */
  .estimate-list-item:active { background: var(--bg); }
  .topbar-btn:active { filter: brightness(0.9); }
  .btab:active { opacity: 0.7; }
  /* .nav-item:active background removed — iOS Safari leaks :active state
   * when the touchend lands off-element (sidebar slides closed mid-tap),
   * making the previously-tapped nav item look like it's still selected.
   * The native -webkit-tap-highlight-color flash is enough press feedback;
   * the .nav-item.active class (real selection state) still indicates the
   * current screen. */
  .modal-close:active { background: var(--border); }
  .dash-card:active { box-shadow: 0 0 0 2px var(--orange); }

  /* Remove hover effects that don't work on touch */
  .estimate-list-item:hover { background: transparent; margin: 0; padding: 12px 0; }
}

/* ============================================
   ACTION BAR (replaces stacked full-width buttons)
   ============================================ */

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.action-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F9FAFB 100%);
  color: #374151;
  border: 1px solid #E5E7EB;
  border-radius: 8px;
  padding: 8px 14px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 500;
  font-size: 13px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: all 0.15s ease;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.2;
}

.action-bar-btn:hover {
  background: #F9FAFB;
  border-color: #D1D5DB;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.action-bar-btn.primary {
  background: linear-gradient(180deg, #F28A3D 0%, #EE7624 100%);
  color: white;
  border-color: var(--orange);
  box-shadow: 0 1px 3px rgba(238,118,36,0.3);
}

.action-bar-btn.primary:hover {
  background: linear-gradient(180deg, #EE7624 0%, #D96A1F 100%);
  border-color: var(--orange-dark);
}

.action-bar-btn.primary:active {
  background: linear-gradient(180deg, #D96A1F 0%, #EE7624 100%);
}

/* ============================================
   LUCIDE ICON SIZING
   ============================================ */

/* nav sidebar icons */
.nav-icon { display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; }

/* mobile bottom tab icons */
.btab-icon { display: flex; align-items: center; justify-content: center; }
.btab-icon svg { width: 20px; height: 20px; }

/* action bar button icons */
.action-bar-btn svg { width: 14px; height: 14px; }

/* job detail tab icons */
.job-tab svg { width: 13px; height: 13px; }

/* inline licon() helper — general use */
.licon { display: inline-flex; width: 14px; height: 14px; vertical-align: middle; flex-shrink: 0; }
.licon svg { width: 100%; height: 100%; }

/* back arrow in job header */
.job-detail-header svg { width: 22px; height: 22px; }

/* ============================================
   STATUS CHIPS
   ============================================ */

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.chip-default    { background: #F3F4F6; color: #4B5563; }
.chip-lead       { background: #DBEAFE; color: #1E40AF; }
.chip-scheduled  { background: #FEF3C7; color: #92400E; }
.chip-sent       { background: #E0E7FF; color: #3730A3; }
.chip-signed     { background: #D1FAE5; color: #065F46; }
.chip-complete   { background: #D1FAE5; color: #065F46; }
.chip-overdue    { background: #FEE2E2; color: #991B1B; }
.chip-closed     { background: #F3F4F6; color: #4B5563; }
.chip-retail     { background: #F3F4F6; color: #374151; }
.chip-insurance  { background: #EDE9FE; color: #5B21B6; }
.chip-commercial { background: #FEF9C3; color: #713F12; }

/* ============================================
   DASHBOARD QUICK BUTTON — PRIMARY VARIANT
   ============================================ */

.dash-quick-btn.primary {
  background: linear-gradient(180deg, #F28A3D 0%, #EE7624 100%);
  color: white;
  border-color: var(--orange);
  box-shadow: 0 1px 3px rgba(238,118,36,0.3);
}

.dash-quick-btn.primary:hover {
  background: linear-gradient(180deg, #EE7624 0%, #D96A1F 100%);
  border-color: var(--orange-dark);
  box-shadow: 0 2px 8px rgba(238,118,36,0.25);
}

.dash-quick-btn.primary:active {
  background: linear-gradient(180deg, #D96A1F 0%, #EE7624 100%);
}

/* ============================================
   PROPOSAL PREVIEW OVERLAY
   ============================================ */

.proposal-preview-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10000;
  background: #0C2340;
  display: flex;
  flex-direction: column;
}

.proposal-preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: linear-gradient(180deg, #0F2A4A 0%, #0C2340 100%);
  color: white;
  flex-shrink: 0;
  gap: 12px;
}

.proposal-preview-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.proposal-preview-btn:hover { background: rgba(255,255,255,0.2); }

.proposal-preview-btn.proposal-preview-close {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.15);
}

.proposal-preview-btn svg { width: 14px; height: 14px; }

.proposal-preview-frame {
  flex: 1;
  border: none;
  width: 100%;
  background: white;
}

/* ============================================
   MONOSPACE AMOUNT CELLS
   ============================================ */

.amount-cell {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  text-align: right;
}

/* ============================================
   TABLE HEADER STANDARD TREATMENT
   ============================================ */

.std-thead th {
  text-align: left;
  padding: 10px 12px;
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6B7280;
  background: #F9FAFB;
  border-bottom: 2px solid #E5E7EB;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}

.std-thead th:hover { color: #374151; }

.std-tbody tr { transition: background 0.1s; }
.std-tbody tr:hover { background: #F9FAFB; }
.std-tbody td { padding: 12px 12px; border-bottom: 1px solid #F3F4F6; font-size: 14px; }
.std-tbody tr:nth-child(even) { background: #F9FAFB; }

/* ── Standardized add-button variants ──────────────────── */
.btn-add-secondary {
  background: none !important;
  border: 2px solid var(--navy) !important;
  color: var(--navy) !important;
}
.btn-add-secondary:hover {
  background: var(--navy) !important;
  color: white !important;
}

/* Inline edit button — subtle pencil icon */
.btn-edit-inline {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.btn-edit-inline:hover {
  color: var(--navy);
  background: var(--hover, rgba(0,0,0,0.05));
}
.btn-edit-inline .licon,
.btn-edit-inline i[data-lucide] {
  width: 15px;
  height: 15px;
}

/* ============================================================
   SUSIE TAB — full-screen AI chat surface
   ============================================================ */

/* Hide the floating orb (chat widget) when the Susie tab is the
 * active screen. The widget and the tab share a backend; having both
 * on screen at once is redundant and confusing.
 * Note: the orb's class is `.susie-orb`, not `.chat-orb` — the
 * original r00395 rule had a typo and never matched, so the orb has
 * been showing on the Susie tab until this fix. */
body:has(#screen-susie.active) .susie-orb,
body:has(#screen-susie.active) .chat-panel {
  display: none !important;
}

/* The Susie tab needs its OWN height-bounded flex container with
 * internal scrolling on the messages area + a sticky input bar — the
 * Claude/ChatGPT pattern. The app's default screen layout is
 * .screen-container { padding: 20px; overflow-y: auto } with each
 * .screen as natural-height content, which works for the other tabs
 * but fights the sticky-input-bar pattern.
 *
 * When Susie is the active screen we opt the screen-container out
 * of its padding + scroll so #screen-susie itself becomes the
 * height-bounded flex parent (height inherited from .main-content via
 * .screen-container's flex:1). The Susie wrap then uses an
 * internal flex column with messages scrolling inside.
 */
.screen-container:has(#screen-susie.active) {
  padding: 0;
  overflow: hidden;
}

#screen-susie.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg, #fafbfc);
  overflow: hidden;
  /* Reserve the iPhone home indicator gesture area below the input row
   * so the entire input bar (border, background, send button) sits above
   * the indicator instead of being clipped by it. box-sizing: border-box
   * keeps the screen height at 100% — the flex column inside packs into
   * the remaining vertical space. */
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: border-box;
}

#susie-tab-root {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.susie-tab-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  box-sizing: border-box;
}

/* ---- Empty state ---- */
.susie-empty-state {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  text-align: center;
  overflow-y: auto;
}

.susie-brand {
  margin-bottom: 40px;
}
.susie-brand-icon {
  color: var(--orange, #EE7624);
  margin-bottom: 16px;
  /* Center the icon image horizontally above the headline. The .susie-
   * empty-state flex parent centers items vertically, but this child div
   * spans full width and its inline-block <img> defaults to left-aligned.
   * text-align centers it. */
  text-align: center;
}
.susie-brand-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--navy, #0C2340);
  margin: 0 0 6px 0;
  letter-spacing: -0.5px;
}
.susie-brand-tag {
  color: var(--text-3, #6b7280);
  font-size: 14px;
  margin: 0;
  max-width: 420px;
}

.susie-starter-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 560px;
}

.susie-starter-card {
  background: white;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text, #111827);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  min-height: 72px;
}
.susie-starter-card:hover {
  border-color: var(--orange, #EE7624);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

/* ---- Active conversation header ---- */
.susie-active-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  background: white;
}
.susie-active-title {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--navy, #0C2340);
}
.susie-new-chat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border, #e5e7eb);
  background: white;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-3, #6b7280);
  cursor: pointer;
}
.susie-new-chat:hover { color: var(--navy, #0C2340); border-color: var(--navy, #0C2340); }
.susie-new-chat i[data-lucide] { width: 14px; height: 14px; }

/* ---- Messages ---- */
.susie-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Stop scroll-chaining — when a new bubble lands at the bottom and
   * the scrollIntoView call hits the end, iOS would otherwise propagate
   * the scroll to ancestors, shifting the whole document up and tucking
   * the topbar under the Dynamic Island. */
  overscroll-behavior: contain;
  padding: 24px 20px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.susie-bubble {
  display: flex;
  max-width: 88%;
  animation: cmdrFadeIn 0.18s ease-out;
}
.susie-bubble.user { align-self: flex-end; }
.susie-bubble.assistant { align-self: flex-start; }

.susie-bubble-content {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.susie-bubble-content p { margin: 0; }
.susie-bubble.user .susie-bubble-content {
  background: var(--navy, #0C2340);
  color: white;
  border-bottom-right-radius: 4px;
}
.susie-bubble.assistant .susie-bubble-content {
  background: white;
  color: var(--text, #111827);
  border: 1px solid var(--border, #e5e7eb);
  border-bottom-left-radius: 4px;
}

.susie-action-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.susie-action-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  background: var(--orange, #EE7624);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s;
}
.susie-action-chip:hover { filter: brightness(1.1); }

@keyframes cmdrFadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Input bar (shared by empty + active states) — sticks at the
 *      bottom of the wrap; flex children above (.empty-state /
 *      .messages) fill the remaining space and scroll internally. */
.susie-input-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 18px 20px;
  border-top: 1px solid var(--border, #e5e7eb);
  background: white;
}
.susie-input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--border, #e5e7eb);
  border-radius: 22px;
  font-size: 15px;
  outline: none;
}
.susie-input:focus { border-color: var(--navy, #0C2340); }

.susie-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--orange, #EE7624);
  color: white;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.15s;
}
.susie-send-btn:hover { filter: brightness(1.1); }
.susie-send-btn:disabled { opacity: 0.5; cursor: default; }
.susie-send-btn i[data-lucide] { width: 18px; height: 18px; }

/* ============================================================
   PUSH-TO-TALK MIC BUTTON — shared by widget + Susie tab
   ============================================================ */
.susie-mic-btn,
.chat-mic-btn,
.susie-attach-btn,
.chat-attach-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: white;
  color: var(--navy, #0C2340);
  border: 2px solid var(--border, #e5e7eb);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.susie-mic-btn:hover,
.chat-mic-btn:hover,
.susie-attach-btn:hover,
.chat-attach-btn:hover {
  border-color: var(--navy, #0C2340);
}
.susie-mic-btn i[data-lucide],
.chat-mic-btn i[data-lucide],
.susie-attach-btn i[data-lucide],
.chat-attach-btn i[data-lucide] { width: 18px; height: 18px; }

/* Widget mic + attach are slightly smaller to fit the existing chat-input-bar height */
.chat-mic-btn,
.chat-attach-btn {
  width: 36px;
  height: 36px;
}
.chat-mic-btn i[data-lucide],
.chat-attach-btn i[data-lucide] { width: 16px; height: 16px; }

/* ============================================================
   CHAT / SUSIE FILE ATTACHMENTS — chip row above the input bar
   ============================================================ */
.chat-attachments,
.susie-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px 0;
}
.chat-attach-chip,
.susie-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg, #f4f5f7);
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-2, #555);
  max-width: 240px;
}
.chat-attach-chip i[data-lucide],
.susie-attach-chip i[data-lucide] { width: 14px; height: 14px; flex-shrink: 0; }
.chat-attach-name,
.susie-attach-name {
  font-weight: 600;
  color: var(--text-1, #1a1a2e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.chat-attach-size,
.susie-attach-size { color: var(--text-3, #888); font-size: 11px; }
.chat-attach-x,
.susie-attach-x {
  background: none;
  border: none;
  color: var(--text-3, #888);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 0 0 4px;
}
.chat-attach-x:hover,
.susie-attach-x:hover { color: #c00; }

/* Listening state — red pulsing affordance */
.susie-mic-btn.listening,
.chat-mic-btn.listening {
  background: #e53e3e;
  color: white;
  border-color: #e53e3e;
  animation: cmdrMicPulse 1.2s ease-in-out infinite;
}
@keyframes cmdrMicPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.55); }
  50%      { box-shadow: 0 0 0 8px rgba(229, 62, 62, 0); }
}

/* ============================================================
   SUSIE TAB — mobile
   ============================================================ */
@media (max-width: 768px) {
  .susie-tab-wrap { max-width: 100%; }
  .susie-empty-state { padding: 24px 16px; }
  .susie-brand-title { font-size: 26px; }
  .susie-starter-grid { grid-template-columns: 1fr; max-width: 100%; }
  .susie-starter-card { min-height: 56px; padding: 14px; font-size: 13px; }
  .susie-messages { padding: 16px 12px 8px 12px; gap: 10px; }
  .susie-bubble { max-width: 92%; }
  .susie-bubble-content { font-size: 14px; padding: 10px 14px; }
  /* Hardcoded 40px minimum bottom padding inside the input bar itself
   * — works even if env(safe-area-inset-bottom) returns 0 (older iPhones
   * without home indicator) and even if the body height chain is broken.
   * The padding lives INSIDE the bar so the white background extends
   * below the input element, giving visible clearance from the bottom. */
  .susie-input-bar { padding: 10px 12px max(40px, env(safe-area-inset-bottom, 40px)) 12px; }
  .susie-input { padding: 10px 14px; font-size: 14px; }
  .susie-send-btn,
  .susie-mic-btn { width: 38px; height: 38px; }
}

/* ===== Job Budget ===== */
.budget-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.budget-summary-header {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.budget-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.5px;
  font-weight: 600;
}
.budget-value-lg {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.budget-sub {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 2px;
}
.budget-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.budget-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}
.budget-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.budget-panel-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-1);
}
.budget-add-btn {
  font-size: 12px;
  padding: 4px 12px;
  background: var(--orange);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}
.budget-add-btn:hover { filter: brightness(1.05); }
.budget-panel-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px;
  background: var(--bg);
  border-radius: 8px;
  margin-bottom: 10px;
}
.budget-mini-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-3);
  letter-spacing: 0.5px;
  font-weight: 600;
}
.budget-mini-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.budget-cost-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.budget-cost-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-3);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 2px solid var(--border);
}
.budget-cost-table th.num,
.budget-cost-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.budget-cost-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.budget-cost-table td.actions {
  white-space: nowrap;
  text-align: right;
}
.budget-cost-table td.actions button + button { margin-left: 4px; }

@media (max-width: 720px) {
  .budget-summary-header { grid-template-columns: 1fr; }
  .budget-panels { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBILE UX SWEEP — r00438
   Sidebar close + backdrop, mobile topbar restructure, list-view
   column hiding, dashboard overflow fix, contact card stack,
   Quill toolbar shrink. Desktop unaffected.
   ============================================================ */

/* Sidebar close button (visible only on mobile via the @media block below) */
.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 6px;
  margin-left: auto;
  border-radius: 6px;
  line-height: 0;
}
.sidebar-close:hover { background: rgba(255, 255, 255, 0.08); }
.sidebar-close i { width: 22px; height: 22px; }

/* Sidebar backdrop — dims the page when the mobile flyout is open */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 150;
}
.sidebar-backdrop.visible { display: block; }

/* Sidebar footer — email + logout for mobile sign-out access */
.sidebar-user-email {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  padding: 0 4px 8px;
  word-break: break-all;
}
.sidebar-logout-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-logout-btn:hover { background: rgba(255, 255, 255, 0.14); }

/* Topbar search-toggle icon button (mobile only) */
.topbar-search-toggle {
  display: none;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 0;
}
.topbar-search-toggle:hover { background: rgba(255, 255, 255, 0.08); }
.topbar-search-toggle i { width: 18px; height: 18px; }

/* Mobile-only expanding search row (toggled by #topbar-search-toggle) */
.mobile-search-row {
  display: none;
  padding: 8px 12px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.mobile-search-row.visible { display: block; }
.mobile-search-row .global-search-input {
  width: 100%;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

@media (max-width: 768px) {
  /* Reveal mobile-only chrome */
  .sidebar-close { display: flex; align-items: center; }
  .topbar-search-toggle { display: inline-flex; align-items: center; }

  /* Hide the inline topbar search input + auth-bar on mobile — both
     have mobile-friendly homes (the expanding search row and the
     sidebar footer respectively). */
  .topbar > .topbar-search-wrap { display: none !important; }
  .topbar-actions .auth-bar { display: none !important; }

  /* Dashboard section grid items — let them shrink inside the grid track
     so the +Task / View buttons don't push past the right edge. */
  .dash-section { min-width: 0; overflow: hidden; }
  .dash-section-header { width: 100%; min-width: 0; }
  .dash-section-header > h2 { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

  /* Contact detail two-column → single column on mobile */
  .contact-detail-grid { grid-template-columns: 1fr !important; }

  /* Contacts list: hide Email (col 3) and Status (col 5). Keep
     name / phone / city + edit action. */
  #contacts-list .std-thead th:nth-child(3),
  #contacts-list .std-tbody td:nth-child(3),
  #contacts-list .std-thead th:nth-child(5),
  #contacts-list .std-tbody td:nth-child(5) { display: none; }

  /* Jobs list: hide Address (col 2) and Created (col 5). Keep Job /
     Stage / Amount. */
  #jobs-list .std-thead th:nth-child(2),
  #jobs-list .std-tbody td:nth-child(2),
  #jobs-list .std-thead th:nth-child(5),
  #jobs-list .std-tbody td:nth-child(5) { display: none; }

  /* Products list: hide SKU (col 2), UoM (col 3), Category (col 4),
     Material cost (col 5), Labor cost (col 6). Keep Product / Retail /
     Actions. */
  #products-list .std-thead th:nth-child(2),
  #products-list .std-tbody td:nth-child(2),
  #products-list .std-thead th:nth-child(3),
  #products-list .std-tbody td:nth-child(3),
  #products-list .std-thead th:nth-child(4),
  #products-list .std-tbody td:nth-child(4),
  #products-list .std-thead th:nth-child(5),
  #products-list .std-tbody td:nth-child(5),
  #products-list .std-thead th:nth-child(6),
  #products-list .std-tbody td:nth-child(6) { display: none; }

  /* Defensive clip for ALL list-view cells so any remaining columns
     truncate cleanly with ellipsis rather than overflow into neighbors. */
  #contacts-list .std-tbody td,
  #jobs-list .std-tbody td,
  #products-list .std-tbody td {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Quill rich-text toolbar in the email compose modal — buttons render
     ~32x32 at desktop. Tighten on mobile so the toolbar reads as a
     normal-sized utility strip, not a feature panel. */
  .gmail-compose .ql-toolbar button {
    width: 28px;
    height: 28px;
    padding: 2px;
  }
  .gmail-compose .ql-toolbar .ql-formats { margin-right: 8px; }
  .gmail-compose .ql-toolbar svg { width: 16px; height: 16px; }

  /* Job detail overview cards stack vertically on mobile — desktop keeps
     the 2-col grid set by the inline style. */
  .overview-cards-grid { grid-template-columns: 1fr !important; gap: 12px !important; }

  /* Shrink the Stage + Adjuster selects so they don't dominate the
     Details card on a 380px viewport. */
  .stage-selector {
    min-width: 0;
    padding: 3px 22px 3px 8px;
    font-size: 12px;
  }
  #assigned-adjuster-select {
    font-size: 12px;
    padding: 3px 22px 3px 8px;
  }

  /* Action bar: pack the 6 buttons (Note/Task/File/Email/Call/Text) onto
     one row by shrinking padding + font + icon. flex-wrap stays as a
     fallback for very narrow widths. */
  .action-bar { gap: 4px; }
  .action-bar-btn {
    padding: 6px 8px;
    font-size: 11px;
    gap: 4px;
    border-radius: 6px;
    flex: 0 0 auto;
  }
  .action-bar-btn i,
  .action-bar-btn svg { width: 14px; height: 14px; }

  /* Reports Range buttons — tighter on mobile so all 4 fit on one row
     instead of wrapping "All Time" to its own line. */
  .report-range-btn { font-size: 11px; padding: 4px 8px; }
}


