:root {
  /* Accent – brand blue (from airconditioning-goldcoast.com.au) */
  --accent: #4287cf;
  --accent-dark: #346ba6;
  --accent-dim: rgba(66,135,207,0.12);
  --accent-dim2: rgba(66,135,207,0.06);

  /* Light backgrounds — clearly layered */
  --bg:   #f0f2f5;   /* page background */
  --bg-2: #ffffff;   /* cards, panels */
  --bg-3: #f5f6f8;   /* input fields, table headers */
  --bg-4: #e8eaed;   /* borders, dividers */
  --bg-5: #dde0e5;   /* hover fills */

  /* Sidebar stays dark — contrast against light content */
  --sidebar-bg: #eef2ee;
  --sidebar-border: rgba(0,0,0,0.07);
  --sidebar-text: #6b7280;
  --sidebar-active-bg: rgba(66,135,207,0.15);
  --sidebar-active-text: #4287cf;

  /* Text — dark on light, high contrast */
  --text-primary:   #111827;   /* headings, values */
  --text-secondary: #4b5563;   /* supporting text */
  --text-muted:     #9ca3af;   /* placeholders, meta */
  --white: #ffffff;

  /* Status colours — rich enough on light backgrounds */
  --green:      #059669;
  --green-dim:  rgba(5,150,105,0.1);
  --orange:     #d97706;
  --orange-dim: rgba(217,119,6,0.1);
  --red:        #dc2626;
  --red-dim:    rgba(220,38,38,0.1);
  --purple:     #7c3aed;
  --purple-dim: rgba(124,58,237,0.1);
  --blue:       #2563eb;
  --blue-dim:   rgba(37,99,235,0.1);

  /* Legacy aliases */
  --navy:   var(--sidebar-bg);
  --navy-2: var(--bg-2);
  --navy-3: var(--bg-3);
  --navy-4: var(--bg-4);
  --muted:  var(--text-muted);
  --text:   var(--text-primary);

  --radius: 14px;
  --sidebar-w: 230px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.13), 0 4px 12px rgba(0,0,0,0.07);
  --border: rgba(0,0,0,0.08);
}

* { margin:0; padding:0; box-sizing:border-box; }
html { overscroll-behavior: none; }
button, a, input, select, textarea { touch-action: manipulation; }

body.modal-open {
  position: fixed;
  left: 0;
  right: 0;
  overflow: hidden;
}

body {
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: none;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  border-right: 1px solid var(--bg-4);
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sidebar-border);
}
.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.logo-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 3px;
}

.sidebar-nav {
  padding: 16px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: 10px 10px 4px;
  opacity: 0.6;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.18s;
  font-size: 14px;
  font-weight: 500;
  color: var(--sidebar-text);
  position: relative;
}
.nav-item:hover { background: var(--accent-dim); color: var(--accent); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border: 1px solid rgba(66,135,207,0.2);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-user {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #ffffff;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: 11px; color: var(--sidebar-text); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.topbar-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}
.topbar-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.btn {
  padding: 9px 18px;
  border-radius: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(66,135,207,0.25);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 5px 16px rgba(66,135,207,0.35); }
.btn-ghost {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(66,135,207,0.2);
}
.btn-ghost:hover { background: rgba(66,135,207,0.18); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
  background: var(--bg);
}
.content::-webkit-scrollbar { width: 5px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 4px; }

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── DASHBOARD ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(66,135,207,0.2); }
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0;
  width: 80px; height: 80px;
  border-radius: 50%;
  opacity: 0.08;
  transform: translate(30px, -30px);
}
.stat-card.blue::after { background: var(--accent); }
.stat-card.green::after { background: var(--green); }
.stat-card.orange::after { background: var(--orange); }
.stat-card.purple::after { background: var(--purple); }

.stat-icon { font-size: 22px; margin-bottom: 14px; }
.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 5px;
  font-weight: 500;
}
.stat-change { font-size: 11px; font-weight: 600; margin-top: 8px; }
.stat-change.up { color: var(--green); }
.stat-change.neutral { color: var(--text-muted); }

.dash-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
}

.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.card-action {
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
}
.card-action:hover { text-decoration: underline; }

/* Job list items */
.job-item {
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 8px;
  padding: 10px 8px;
  margin: 0 -8px;
  border-bottom: 1px solid var(--border);
}
.job-item:hover { background: rgba(66,135,207,0.05); }

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

.job-color {
  width: 4px;
  height: 38px;
  border-radius: 4px;
  flex-shrink: 0;
}
.job-info { flex: 1; min-width: 0; }
.job-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.job-detail {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.job-meta { text-align: right; flex-shrink: 0; }
.job-time {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
}
.job-tech {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.badge-scheduled { background: var(--blue-dim); color: var(--blue); }
.badge-progress { background: var(--orange-dim); color: var(--orange); }
.badge-complete { background: var(--green-dim); color: var(--green); }
.badge-quote { background: var(--purple-dim); color: var(--purple); }
.badge-cancelled { background: var(--red-dim); color: var(--red); }
.badge-on-hold { background: var(--purple-dim); color: var(--purple); }

/* Techs */
.tech-list { display: flex; flex-direction: column; gap: 12px; }
.tech-item { display: flex; align-items: center; gap: 12px; }
.tech-avatar {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; color: #ffffff;
  flex-shrink: 0;
}
.tech-name { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tech-jobs { font-size: 11px; color: var(--text-secondary); }
.tech-bar-wrap {
  flex: 1; height: 5px;
  background: var(--bg-4);
  border-radius: 5px;
  overflow: hidden;
}
.tech-bar { height: 100%; border-radius: 5px; transition: width 0.6s ease; }

/* ── SCHEDULE PAGE ── */
.schedule-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.week-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.week-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--accent-dim);
  border: 1px solid rgba(66,135,207,0.2);
  color: var(--accent);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: all 0.15s;
}
.week-btn:hover { background: rgba(66,135,207,0.2); }
.week-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 180px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: 70px repeat(7, 1fr);
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-header {
  padding: 12px 8px;
  text-align: center;
  border-bottom: 1px solid var(--bg-4);
  font-size: 12px;
  font-weight: 600;
  background: var(--bg-3);
}
.cal-header.day-head { color: var(--text-primary); }
.cal-header.day-head.today {
  color: var(--accent);
  background: var(--accent-dim);
}
.cal-day-name { font-size: 11px; color: var(--text-secondary); margin-bottom: 2px; font-weight: 500; }
.cal-day-num { font-size: 18px; font-weight: 800; }

.cal-time {
  padding: 0 8px;
  height: 82px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 8px;
  border-right: 1px solid var(--bg-4);
  border-bottom: 1px solid var(--bg-3);
  background: var(--bg-3);
}
.cal-time span {
  font-size: 10px;
  font-family: 'DM Mono', monospace;
  color: var(--text-muted);
}

.cal-cell {
  min-height: 82px;
  border-right: 1px solid var(--bg-3);
  border-bottom: 1px solid var(--bg-3);
  padding: 4px;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
  background: var(--white);
}
.cal-cell:hover { background: var(--accent-dim2); }
.cal-cell:hover .cal-cell-hint { opacity: 1; }
.cal-cell.today-col { background: rgba(66,135,207,0.03); }
.cal-cell.today-col:hover { background: var(--accent-dim2); }

.cal-cell-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
  font-weight: 300;
}

.cal-event {
  border-radius: 7px;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  line-height: 1.3;
  overflow: hidden;
  min-height: calc(100% - 6px);
  height: auto;
}
.cal-event:hover { opacity: 0.85; transform: scale(0.98); }
.cal-event.install { background: rgba(26,123,191,0.12); color: #1259a0; border-left: 3px solid var(--blue); }
.cal-event.service { background: rgba(26,158,95,0.12); color: #126b40; border-left: 3px solid var(--green); }
.cal-event.repair  { background: rgba(66,135,207,0.14); color: #a05010; border-left: 3px solid var(--orange); }

.event-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-tech { font-size: 10px; opacity: 0.75; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event-address { font-size: 10px; opacity: 0.65; margin-top: 2px; word-break: break-word; line-height: 1.3; }

/* ── DRAG & DROP ── */
.cal-event-ghost {
  opacity: 0.85; transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.1);
  border-radius: 7px; pointer-events: none; z-index: 9999;
}
.cal-cell.drag-over {
  background: var(--accent-dim) !important;
  outline: 2px dashed var(--accent); outline-offset: -2px;
}
.cal-cell.drag-over-invalid {
  background: var(--red-dim) !important;
  outline: 2px dashed var(--red); outline-offset: -2px;
}
body.dragging {
  user-select: none; -webkit-user-select: none;
  overflow: hidden; touch-action: none;
}
body.dragging .cal-cell { touch-action: none; }

/* ── VIEW TOGGLE ── */
.view-toggle { display: flex; gap: 0; }
.view-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
  font-family: inherit;
}
.view-btn:first-child { border-radius: 6px 0 0 6px; }
.view-btn:last-child { border-radius: 0 6px 6px 0; }
.view-btn:not(:first-child) { border-left: none; }
.view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.view-btn:hover:not(.active) { background: var(--bg-5); }

/* ── DAY VIEW GRID ── */
.cal-day-grid {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ── MONTH VIEW GRID ── */
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.cal-month-header {
  padding: 10px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-3);
  border-bottom: 1px solid var(--bg-4);
}
.cal-month-cell {
  min-height: 80px;
  padding: 6px;
  border-right: 1px solid var(--bg-3);
  border-bottom: 1px solid var(--bg-3);
  cursor: pointer;
  transition: background 0.15s;
}
.cal-month-cell:hover:not(.empty) { background: var(--accent-dim2); }
.cal-month-cell.empty { background: var(--bg-3); cursor: default; opacity: 0.5; }
.cal-month-cell.today { background: rgba(66,135,207,0.04); }
.cal-month-date {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.cal-month-date.today {
  background: var(--accent);
  color: #fff;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.cal-month-events { display: flex; flex-wrap: wrap; gap: 3px; }
.cal-month-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.cal-month-more {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}

/* ── QUOTES PAGE ── */
.quotes-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
  align-items: center;
}
.search-input {
  flex: 1;
  max-width: 320px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(66,135,207,0.1); }

.filter-tabs {
  display: flex;
  gap: 6px;
}
.filter-tab {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
}
.filter-tab:hover { color: var(--text-primary); background: var(--bg-4); }
.filter-tab.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(66,135,207,0.2); }

.quotes-table {
  background: var(--white);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-header {
  display: grid;
  grid-template-columns: 60px 1fr 140px 100px 110px 120px;
  padding: 12px 20px;
  background: var(--bg-3);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.table-row {
  display: grid;
  grid-template-columns: 60px 1fr 140px 100px 110px 120px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.table-row:hover { background: rgba(66,135,207,0.05); }
.table-row:last-child { border-bottom: none; }

.quote-id {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  color: var(--text-muted);
}
.quote-client { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.quote-desc { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.quote-amount {
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}
.quote-date { font-size: 12px; color: var(--text-secondary); }

/* ── CUSTOMERS PAGE ── */
.customers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.customer-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}
.customer-card:hover { border-color: rgba(66,135,207,0.3); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.cust-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cust-avatar {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #ffffff;
  flex-shrink: 0;
}
.cust-name { font-size: 14px; font-weight: 700; color: var(--text-primary); }
.cust-type { font-size: 11px; color: var(--text-secondary); margin-top: 2px; }
.cust-detail { font-size: 12px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.cust-detail span { font-size: 13px; }
.cust-stats {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.cust-stat-val { font-size: 18px; font-weight: 800; color: var(--text-primary); }
.cust-stat-lbl { font-size: 10px; color: var(--text-muted); letter-spacing: 0.5px; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17,24,39,0.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px;
  width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 24px;
}
.form-row { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(66,135,207,0.1);
}
.form-select option { background: var(--bg-3); color: var(--text-primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.inv-brand-btn.active { background: var(--accent-dim2); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ── JOB DETAIL PANEL ── */
.job-detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}
.job-type-badge {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.job-detail-title { font-size: 20px; font-weight: 800; color: var(--text-primary); line-height: 1.2; }
.job-detail-meta { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.detail-field {
  background: var(--bg-3);
  border-radius: 10px;
  padding: 12px 14px;
}
.detail-field-label {
  font-size: 9px; font-weight: 700; letter-spacing: 2px;
  text-transform: uppercase; color: var(--text-secondary); margin-bottom: 5px;
}
.detail-field-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

.status-selector {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px;
}
.status-btn {
  padding: 6px 14px; border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--bg-4); transition: all 0.15s;
  font-family: 'Outfit', sans-serif;
  background: var(--bg-3); color: var(--text-secondary);
}
.status-btn:hover { color: var(--text-primary); background: var(--bg-5); }
.status-btn.active-scheduled { background: var(--blue-dim); color: var(--blue); border-color: rgba(26,123,191,0.3); }
.status-btn.active-progress { background: var(--orange-dim); color: var(--orange); border-color: rgba(66,135,207,0.3); }
.status-btn.active-complete { background: var(--green-dim); color: var(--green); border-color: rgba(26,158,95,0.3); }
.status-btn.active-on-hold { background: var(--purple-dim); color: var(--purple); border-color: rgba(124,58,237,0.3); }

.modal-danger { color: var(--red) !important; background: var(--red-dim) !important; border-color: rgba(214,59,74,0.2) !important; }
.modal-danger:hover { background: rgba(214,59,74,0.18) !important; }

/* ── TEAM MANAGEMENT PAGE ── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.team-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  transition: all 0.2s;
}
.team-card:hover { border-color: rgba(66,135,207,0.25); transform: translateY(-2px); }
.team-card-top { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.team-card-avatar {
  width: 48px; height: 48px; border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: #ffffff; flex-shrink: 0;
}
.team-card-name { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.team-card-role { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.team-card-badge {
  margin-left: auto; font-size: 10px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; background: var(--accent-dim); color: var(--accent);
  border: 1px solid rgba(66,135,207,0.2); white-space: nowrap;
}
.team-card-stats {
  display: flex; gap: 20px; padding: 12px 0; margin-bottom: 14px;
  border-top: 1px solid var(--bg-3);
  border-bottom: 1px solid var(--bg-3);
}
.team-stat-val { font-size: 20px; font-weight: 800; color: var(--text-primary); }
.team-stat-lbl { font-size: 10px; color: var(--text-muted); letter-spacing: 0.5px; margin-top: 1px; }
.team-card-pin { display: flex; align-items: center; justify-content: space-between; font-size: 12px; color: var(--text-secondary); }
.team-card-pin-dots { display: flex; gap: 5px; }
.team-card-pin-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--bg-4); border: 1px solid var(--bg-5);
}
.team-card-actions { display: flex; gap: 8px; margin-top: 14px; }
.team-btn {
  flex: 1; padding: 8px; border-radius: 8px;
  font-family: 'Outfit', sans-serif; font-size: 12px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s;
}
.team-btn-pin { background: var(--accent-dim); color: var(--accent); border-color: rgba(66,135,207,0.2); }
.team-btn-pin:hover { background: rgba(66,135,207,0.18); }
.team-btn-delete { background: var(--red-dim); color: var(--red); border-color: rgba(214,59,74,0.2); }
.team-btn-delete:hover { background: rgba(214,59,74,0.18); }

/* Email template editor */
.email-tpl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.email-tpl-card {
  background: var(--bg-2);
  border: 1px solid var(--bg-4);
  border-radius: var(--radius);
  padding: 18px;
}
.email-tpl-header {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 10px;
}
.email-tpl-body {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  min-height: 120px;
  resize: vertical;
}
.email-tpl-placeholders {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0;
}

.color-picker-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.color-swatch {
  width: 28px; height: 28px; border-radius: 8px;
  cursor: pointer; border: 2px solid transparent; transition: all 0.15s;
}
.color-swatch.selected { border-color: var(--white); transform: scale(1.15); }

.new-pin-display { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.new-pin-dot {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--bg-5); transition: all 0.15s;
  background: var(--bg-4);
}
.new-pin-dot.filled { background: var(--accent); border-color: var(--accent); }
.modal-pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.modal-pin-key {
  padding: 12px; border-radius: 10px; background: var(--bg-3);
  border: 1px solid var(--border); color: var(--text-primary);
  font-size: 15px; font-weight: 700; cursor: pointer; text-align: center;
  transition: all 0.12s; font-family: 'Outfit', sans-serif;
}
.modal-pin-key:hover { background: var(--bg-4); border-color: rgba(66,135,207,0.2); }
.modal-pin-key:active { transform: scale(0.95); }
.modal-pin-key.del { font-size: 17px; color: var(--text-secondary); }

/* ── LOGIN SCREEN ── */
#login-screen {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 500;

  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
#login-screen.hidden { display: none; }

.login-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  width: 400px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.3s ease;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo-name {
  font-size: 22px; font-weight: 800; color: var(--white);
}
.login-logo-sub {
  font-size: 11px; font-weight: 700; letter-spacing: 2.5px;
  text-transform: uppercase; color: var(--accent); margin-top: 4px;
}
.login-title {
  font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 18px;
}

.user-picker {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px;
}
.user-pick-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg-3);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  font-family: 'Outfit', sans-serif;
}
.user-pick-btn:hover { border-color: rgba(66,135,207,0.3); background: var(--bg-4); }
.user-pick-btn.selected { border-color: var(--accent); background: var(--accent-dim); }
.user-pick-avatar {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #ffffff;
  flex-shrink: 0;
}
.user-pick-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.user-pick-role { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.user-pick-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700; padding: 2px 8px;
  border-radius: 20px; background: var(--accent-dim); color: var(--accent);
  border: 1px solid rgba(66,135,207,0.2);
}

.pin-section { margin-top: 4px; }
.pin-label {
  font-size: 11px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; display: block;
}
.pin-dots {
  display: flex; gap: 10px; justify-content: center; margin-bottom: 16px;
}
.pin-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--bg-4);
  transition: all 0.15s;
  background: var(--bg-4);
}
.pin-dot.filled { background: var(--accent); border-color: var(--accent); }

.pin-pad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.pin-key {
  padding: 14px;
  border-radius: 10px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 16px; font-weight: 700;
  cursor: pointer; text-align: center;
  transition: all 0.12s;
  font-family: 'Outfit', sans-serif;
}
.pin-key:hover { background: var(--bg-4); border-color: rgba(66,135,207,0.2); }
.pin-key:active { transform: scale(0.95); }
.pin-key.del { font-size: 18px; color: var(--text-secondary); }
.pin-key.confirm { background: linear-gradient(135deg, var(--accent-dark), var(--accent)); color: #ffffff; border-color: transparent; }
.pin-key.confirm:hover { box-shadow: 0 4px 14px rgba(66,135,207,0.3); }
.pin-error {
  text-align: center; font-size: 12px; font-weight: 600;
  color: var(--red); margin-top: 10px; min-height: 18px;
  transition: opacity 0.2s;
}

.logout-btn {
  position: absolute; top: 16px; right: 16px;
  background: var(--bg-3); border: 1px solid var(--border);
  color: var(--text-secondary); border-radius: 8px; padding: 6px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  font-family: 'Outfit', sans-serif; transition: all 0.15s;
}
.logout-btn:hover { background: var(--bg-4); color: var(--text-primary); }

/* Notifications */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: #2c2c2e;
  border: none;
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  display: flex; align-items: center; gap: 10px;
  animation: toastIn 0.3s ease;
  transform: translateY(0);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hide { opacity: 0; transform: translateY(10px); }
.toast-status { background: #1a1a1c; border-left: 3px solid #ff9f0a; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
/* ── ADDRESS AUTOCOMPLETE ── */
.addr-wrap { position: relative; }
.addr-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border: 1px solid var(--bg-4);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  z-index: 999;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}
.addr-dropdown:empty { display: none; }
.addr-item {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  border-bottom: 1px solid var(--bg-3);
  line-height: 1.4;
  transition: background 0.1s;
}
.addr-item:last-child { border-bottom: none; }
.addr-item:hover, .addr-item.focused { background: var(--accent-dim); }
.addr-item-main { font-weight: 600; }
.addr-item-sub { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.addr-loading {
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
/* ══════════════════════════════════════════
   MOBILE  (≤ 768px)
   ══════════════════════════════════════════ */

/* Mobile bottom tab bar */
.mob-tabbar {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-2);
  border-top: 1px solid var(--bg-4);
  z-index: 300;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mob-tabs {
  display: flex;
}
.mob-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 11px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 600;
  font-family: 'Outfit', sans-serif;
  transition: color 0.15s;
  position: relative;
  border: none;
  background: none;
}
.mob-tab.active { color: var(--accent); }
.mob-tab:not(.active) { color: var(--text-muted); }
.mob-tab-icon { font-size: 22px; line-height: 1; }
.mob-tab-badge {
  position: absolute;
  top: 7px; right: calc(50% - 16px);
  background: var(--accent);
  color: #fff;
  font-size: 9px; font-weight: 800;
  padding: 1px 5px;
  border-radius: 10px;
  min-width: 16px; text-align: center;
  display: none;
}
.mob-tab-badge.visible { display: block; }

/* Mobile top header — compact bar */
.mob-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--bg-4);
  color: var(--text-primary);
  position: sticky;
  top: 0; z-index: 200;
  flex-shrink: 0;
}
.mob-header-left { display: flex; align-items: center; gap: 10px; }
.mob-header-page { font-size: 16px; color: var(--text-primary); font-weight: 700; }
.mob-header-right { display: flex; align-items: center; gap: 8px; }
.mob-action-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 13px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.mob-logout-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 7px 11px;
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  cursor: pointer;
}

/* FAB for schedule page */
.mob-fab {
  display: none;
  position: fixed;
  bottom: 80px; right: 20px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dark), var(--accent));
  color: #fff;
  font-size: 26px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(66,135,207,0.4);
  z-index: 250;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}
.mob-fab:active { transform: scale(0.93); }

/* Voice mic FAB — always visible */
.voice-fab {
  position: fixed;
  bottom: 80px; right: 84px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  color: #fff;
  font-size: 22px;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(99,102,241,0.4);
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}
.voice-fab.hidden { display: none; }
.voice-fab:active { transform: scale(0.93); }
.voice-fab.listening {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 4px 24px rgba(220,38,38,0.5);
  animation: pulse-mic 1.2s infinite;
}
@keyframes pulse-mic {
  0%,100% { box-shadow: 0 4px 24px rgba(220,38,38,0.5); transform: scale(1); }
  50%      { box-shadow: 0 4px 32px rgba(220,38,38,0.7); transform: scale(1.08); }
}

/* On desktop, position differently */
@media (min-width: 769px) {
  .voice-fab { bottom: 32px; right: 32px; width: 58px; height: 58px; font-size: 24px; }
}

/* Voice modal */
.voice-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 900;
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
}
.voice-modal-overlay.active { opacity: 1; pointer-events: all; }
.voice-modal {
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  padding: 28px 24px 40px;
  width: 100%; max-width: 560px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1);
}
.voice-modal-overlay.active .voice-modal { transform: translateY(0); }
.voice-mic-ring {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #818cf8);
  display: flex; align-items: center; justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  cursor: pointer;
  transition: transform 0.15s;
}
.voice-mic-ring.listening {
  background: linear-gradient(135deg, #dc2626, #ef4444);
  box-shadow: 0 4px 24px rgba(220,38,38,0.5);
  animation: pulse-mic 1.2s infinite;
}
.voice-transcript {
  background: var(--bg-3);
  border-radius: 12px;
  padding: 14px;
  font-size: 14px;
  color: var(--text-primary);
  min-height: 60px;
  margin: 16px 0;
  line-height: 1.5;
  border: 1px solid var(--border);
}
.voice-transcript.empty { color: var(--text-muted); font-style: italic; }

/* ─── SIGNATURE PAD ─── */
.sig-pad-wrap { border: 2px dashed var(--bg-4); border-radius: 10px; margin: 10px 0; overflow: hidden; background: #fff; touch-action: none; }
#sig-canvas { display: block; width: 100%; cursor: crosshair; }
.sig-display { margin-top: 10px; text-align: center; }
.sig-display img { max-width: 100%; border-radius: 8px; border: 1px solid var(--bg-4); }
.sig-meta { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

@media (max-width: 768px) {
  /* Show mobile chrome, hide desktop */
  .sidebar       { display: none !important; width: 0 !important; }
  .topbar        { display: none !important; }
  .mob-header    { display: none !important; }
  .mob-tabbar    { display: block; }

  /* Layout */
  html, body { overflow-x: hidden; }
  body { overflow: auto; }
  .main { overflow: visible; flex-direction: column; height: auto; min-height: 100vh; width: 100%; max-width: 100vw; overflow-x: hidden; }
  .content {
    padding: 16px 14px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    overflow: visible;
    padding-bottom: 100px;
    width: 100%;
    box-sizing: border-box;
  }

  /* Login */
  #login-screen { padding: 20px; align-items: flex-start; padding-top: 60px; }
  .login-box {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 28px 20px 32px;
  }

  /* Dashboard stat grid: 2 cols */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
  .stat-value { font-size: 26px; }
  .stat-icon  { font-size: 18px; margin-bottom: 10px; }

  /* Dashboard layout: stack */
  .dash-grid { grid-template-columns: 1fr; gap: 14px; }

  /* Schedule nav */
  .schedule-controls { gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
  .week-label { font-size: 13px; min-width: 0; }
  .view-toggle { order: -1; width: 100%; justify-content: center; margin-bottom: 4px; }
  .view-btn { padding: 7px 16px; font-size: 13px; min-height: 36px; }
  /* Hide + Add Job button on mobile (use big button instead) */
  .schedule-controls > .btn { display: none; }
  .mob-add-job-btn { display: block !important; }

  /* Day view: no horizontal scroll needed, better tap targets */
  .cal-day-grid { min-width: 0; }
  .cal-day-grid .cal-cell { min-height: 72px; }
  .cal-day-grid .cal-event { font-size: 13px; padding: 8px 10px; min-height: 44px; }
  .cal-day-grid .event-name { font-size: 13px; white-space: normal; line-height: 1.3; }
  .cal-day-grid .event-tech { display: block; font-size: 11px; }

  /* Month view: compact cells on mobile */
  .cal-month-cell { min-height: 52px; padding: 4px; }
  .cal-month-date { font-size: 12px; }
  .cal-month-date.today { width: 22px; height: 22px; font-size: 11px; }
  .cal-month-header { padding: 8px 4px; font-size: 10px; }
  .cal-month-dot { width: 6px; height: 6px; }
  .cal-month-more { font-size: 9px; }

  /* Fix calendar cell touch targets on Android */
  .cal-cell {
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(66,135,207,0.2);
    touch-action: manipulation;
  }
  .cal-event {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(0,0,0,0.1);
  }

  /* Calendar: horizontal scroll */
  .calendar-scroll-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  .calendar-grid { min-width: 580px; }
  .cal-time  { height: 82px; }
  .cal-cell  { min-height: 82px; }
  .cal-day-num  { font-size: 15px; }
  .cal-day-name { font-size: 10px; }
  .cal-event { font-size: 10px; padding: 4px 6px; cursor: pointer; }
  .event-name { font-size: 10px; }
  .event-tech { display: none; }

  /* Quotes */
  .quotes-toolbar { flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .search-input   { max-width: 100%; flex: 1 1 100%; }
  .filter-tabs    { flex-wrap: wrap; gap: 4px; }
  .filter-tab     { padding: 6px 10px; font-size: 11px; }
  .table-header:not(.inv-table-header) { grid-template-columns: 1fr auto auto; padding: 10px 12px; }
  .table-row:not(.inv-table-row)    { grid-template-columns: 1fr auto auto; padding: 12px 12px; }
  .table-header:not(.inv-table-header) > *:nth-child(1),
  .table-header:not(.inv-table-header) > *:nth-child(3),
  .table-header:not(.inv-table-header) > *:nth-child(5),
  .table-row:not(.inv-table-row)    > *:nth-child(1),
  .table-row:not(.inv-table-row)    > *:nth-child(3),
  .table-row:not(.inv-table-row)    > *:nth-child(5) { display: none; }

  /* Customers: single column */
  .customers-grid { grid-template-columns: 1fr; gap: 10px; }

  /* Team: single column */
  .team-grid { grid-template-columns: 1fr; gap: 10px; }
  .email-tpl-grid { grid-template-columns: 1fr; }

  /* Modals: slide up from bottom */
  .modal-overlay {
    align-items: flex-end !important;
    padding: 0 !important;
    z-index: 500;
  }
  .modal {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 22px 22px 0 0 !important;
    max-height: 92vh !important;
    overflow-y: auto !important;
    padding: 20px 18px 40px !important;
    animation: mobModalIn 0.3s cubic-bezier(0.32,0.72,0,1);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  @keyframes mobModalIn {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }
  .modal-title { font-size: 18px; margin-bottom: 18px; }

  /* Address dropdown: show above input on mobile so keyboard doesn't cover it */
  .addr-dropdown {
    top: auto;
    bottom: calc(100% + 4px);
    max-height: 180px;
  }

  .form-grid   { grid-template-columns: 1fr !important; }
  .detail-grid { grid-template-columns: 1fr !important; gap: 10px; }
  .modal-actions { flex-wrap: wrap; gap: 8px; }
  .modal-actions .btn { flex: 1; min-width: 0; text-align: center; justify-content: center; }

  /* Make all inputs and buttons easy to tap */
  .form-input, .form-select, .btn {
    min-height: 44px;
    font-size: 16px !important; /* prevents iOS/Android zoom on focus */
  }

  /* FAB */
  .mob-fab { display: flex; }
  .mob-fab.hidden { display: none; }

  /* Voice FAB position on mobile */
  .voice-fab { bottom: 84px; right: 16px; width: 52px; height: 52px; }

  /* Toast: above tab bar */
  .toast { bottom: 90px; right: 14px; left: 14px; }

  /* Invoices toolbar wrap */
  #page-invoices .quotes-toolbar { flex-direction: column; align-items: stretch; }
  #xero-connect-btn { width: 100%; justify-content: center; }

  /* Invoice line items — tighter on mobile */
  .inv-line-row { grid-template-columns: 1fr 60px 70px 28px 28px !important; gap: 6px !important; }

  /* AI buttons: stack full-width on mobile */
  .inv-line-actions { flex-direction: column; align-items: stretch; }
  .inv-ai-btns { justify-content: stretch; }
  .inv-ai-btn { flex: 1; min-height: 44px; font-size: 14px; justify-content: center; }

  /* View invoice toolbar — wrap into grid on mobile */
  .vi-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 14px 16px;
    gap: 10px;
  }
  .vi-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .vi-toolbar-actions .btn {
    min-height: 44px;
    padding: 10px 8px;
    font-size: 13px !important;
    justify-content: center;
    text-align: center;
  }
}

/* Very small phones */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-value { font-size: 22px; }
  .login-box  { padding: 22px 14px 28px; }
  .content    { padding: 12px 10px; padding-bottom: 90px; }
}

/* ── INVOICES ── */
.inv-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 4px;
}
.inv-strip-item {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.inv-strip-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}
.inv-strip-val.green { color: var(--green); }
.inv-strip-val.red   { color: var(--red); }
.inv-strip-lbl {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-weight: 500;
}

/* Invoice table overrides */
.inv-table-header {
  grid-template-columns: 28px 90px 1fr 110px 100px 110px 120px;
}
.inv-table-row {
  display: grid;
  grid-template-columns: 28px 90px 1fr 110px 100px 110px 120px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 13px;
}
.inv-check-col {
  display: flex;
  align-items: center;
  justify-content: center;
}
.inv-check-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}
.inv-table-row:hover { background: rgba(66,135,207,0.05); }
.inv-table-row:last-child { border-bottom: none; }
.inv-line-desc {
  resize: none;
  overflow: hidden;
  min-height: 38px;
  line-height: 1.4;
  font-size: 14px;
}
.inv-num { font-weight: 700; color: var(--accent); font-size: 12px; }
.inv-client-name { font-weight: 600; color: var(--text-primary); }
.inv-client-desc { font-size: 11px; color: var(--text-secondary); margin-top: 1px; }
.inv-amount { font-weight: 700; color: var(--text-primary); }
.inv-due    { font-size: 12px; color: var(--text-secondary); }
.inv-source { font-size: 11px; }
.badge-paid    { background: var(--green-dim); color: var(--green); }
.badge-unpaid  { background: var(--blue-dim);  color: var(--blue); }
.badge-overdue { background: var(--red-dim);   color: var(--red); }
.badge-emailed  { background: var(--green-dim); color: var(--green); }
.badge-not-sent { background: var(--red-dim);   color: var(--red); }

.inv-xero-icon, .inv-email-icon {
  font-size: 12px;
  margin-left: 4px;
  vertical-align: middle;
}

/* Line item row */
.inv-line-row {
  display: grid;
  grid-template-columns: 1fr 80px 90px 32px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.inv-line-del {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color 0.15s;
}
.inv-line-del:hover { color: var(--red); }

/* Invoice line actions (Add Line + AI buttons) */
.inv-line-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 4px;
}
.inv-ai-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inv-ai-btn {
  padding: 6px 14px;
  font-size: 12px;
  background: rgba(99,102,241,0.08);
  color: #6366f1;
  border-color: rgba(99,102,241,0.2);
}

/* Bulk actions bar */
.inv-bulk-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: rgba(66,135,207,0.08);
  border: 1px solid rgba(66,135,207,0.2);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}
.inv-bulk-actions {
  display: flex;
  gap: 8px;
}
.inv-bulk-btn {
  font-size: 12px;
  padding: 6px 14px;
}
.inv-bulk-delete {
  color: var(--red) !important;
  border-color: rgba(239,68,68,0.2) !important;
}

/* Payment method toggle */
.inv-payment-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.inv-payment-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 65px;
}
.inv-payment-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.inv-payment-btn {
  padding: 7px 14px;
  font-size: 12px;
  border-radius: 8px;
  transition: all 0.15s;
}
.inv-payment-btn.active {
  background: rgba(66,135,207,0.12);
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

/* Surcharge row */
.inv-surcharge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.inv-surcharge-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.inv-surcharge-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* Print area styles */
.inv-print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}
.inv-print-company { font-size: 22px; font-weight: 900; color: var(--accent); }
.inv-print-brand   { min-width: 0; flex: 1; display: flex; align-items: center; }
.inv-print-logo    { max-width: 320px; width: 100%; height: auto; display: block; }
.inv-print-contact {
  margin-top: 14px;
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.7;
}
.inv-print-dot     { margin: 0 6px; color: var(--text-muted); }
.inv-print-meta    { text-align: right; }
.inv-print-label   { font-size: 11px; font-weight: 700; letter-spacing: 2.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 2px; }
.inv-print-num     { font-size: 28px; font-weight: 900; color: var(--text-primary); }
.inv-print-date    { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }
.inv-print-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}
.inv-party-label { font-size: 10px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.inv-party-name  { font-size: 15px; font-weight: 700; color: var(--text-primary); }
.inv-party-detail{ font-size: 12px; color: var(--text-secondary); margin-top: 2px; line-height: 1.6; }
.inv-print-lines {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}
.inv-print-lines th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--bg-4);
}
.inv-print-lines td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}
.inv-print-lines tr:last-child td { border-bottom: none; }
.inv-print-totals {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 28px;
  padding-right: 14px;
}
.inv-total-row { display: flex; gap: 48px; font-size: 13px; color: var(--text-secondary); }
.inv-total-row.grand { font-size: 18px; font-weight: 900; color: var(--text-primary); margin-top: 4px; }
.inv-print-footer {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}
.inv-paid-stamp {
  display: inline-block;
  border: 3px solid var(--green);
  color: var(--green);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 4px;
  padding: 4px 16px;
  border-radius: 6px;
  transform: rotate(-8deg);
  margin-top: 12px;
  opacity: 0.8;
}

/* View invoice toolbar */
.vi-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--bg-4);
  background: var(--bg-3);
}
.vi-toolbar-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}
.vi-toolbar-actions {
  display: flex;
  gap: 8px;
}
.vi-toolbar-actions .btn {
  padding: 7px 14px;
  font-size: 12px;
}
.vi-xero-push {
  background: rgba(0,132,61,0.08);
  color: #00843d !important;
  border-color: rgba(0,132,61,0.2) !important;
}
.vi-delete { color: var(--red) !important; }

/* ── JOB PHOTOS ── */
.job-photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.job-photo-thumb { position: relative; border-radius: 8px; overflow: hidden; aspect-ratio: 1; }
.job-photo-thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.job-photo-label { position: absolute; bottom: 4px; left: 4px; font-size: 10px; background: rgba(0,0,0,0.6); color: white; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; font-weight: 700; }
.job-photo-del { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 12px; cursor: pointer; line-height: 22px; text-align: center; }

/* ── INVOICE PHOTOS ── */
.inv-photos-section {
  margin-top: 24px;
  margin-bottom: 24px;
  page-break-inside: avoid;
}
.inv-photos-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.inv-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.inv-photo-item {
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-3);
}
.inv-photo-item img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.inv-photo-label {
  font-size: 11px;
  text-align: center;
  padding: 6px 4px;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: capitalize;
}

@page { margin: 10mm; size: A4; }
@media print {
  body { background: #fff !important; color: #111 !important; margin: 0 !important; padding: 0 !important; }
  body > *:not(#modal-view-invoice) { display: none !important; }
  #modal-view-invoice { position: static !important; background: #fff !important; display: block !important; overflow: visible !important; padding: 0 !important; margin: 0 !important; }
  #modal-view-invoice > .modal { position: static !important; box-shadow: none !important; max-height: none !important; max-width: none !important; width: 100% !important; background: #fff !important; color: #111 !important; overflow: visible !important; padding: 0 !important; margin: 0 !important; border-radius: 0 !important; transform: none !important; }
  #invoice-print-area { max-height: none !important; height: auto !important; padding: 24px !important; overflow: visible !important; color: #111 !important; }
  #invoice-print-area * { color: inherit !important; }
  .vi-toolbar, .btn, button, .mob-tabbar, .mob-header, .sidebar, .no-print { display: none !important; }
  .inv-print-logo { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-photos-section { page-break-before: auto; }
  .inv-photo-item img { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .inv-paid-stamp { color: #00843d !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 768px) {
  .inv-summary-strip { grid-template-columns: 1fr 1fr; }
  .inv-table-header { grid-template-columns: 24px 58px 1fr 80px 68px; font-size: 10px; padding: 10px 10px; gap: 6px; }
  .inv-table-header > *:nth-child(5),
  .inv-table-header > *:nth-child(6) { display: none; }
  .inv-table-row { grid-template-columns: 24px 58px 1fr 80px 68px; padding: 10px 10px; gap: 6px; font-size: 12px; }
  .inv-table-row > *:nth-child(5),
  .inv-table-row > *:nth-child(6) { display: none; }

  /* Bulk bar stacks on mobile */
  .inv-bulk-bar { flex-direction: column; gap: 8px; text-align: center; }
  .inv-bulk-actions { width: 100%; justify-content: center; }
  .inv-bulk-btn { min-height: 44px; font-size: 14px; flex: 1; }

  /* Payment row stacks on mobile */
  .inv-payment-row { flex-direction: column; align-items: stretch; gap: 6px; }
  .inv-payment-btns { width: 100%; }
  .inv-payment-btn { flex: 1; min-height: 44px; font-size: 14px; text-align: center; justify-content: center; }

  /* Signature pad mobile */
  .sig-pad-wrap { margin: 8px 0; }

  /* Batch push button mobile */
  #xero-batch-btn { min-height: 44px; font-size: 14px; }

  /* Invoice print header: tighten logo for tablet widths */
  .inv-print-logo { max-width: 240px; }

  /* View-invoice toolbar wraps on mobile */
  .vi-toolbar { flex-wrap: wrap; gap: 8px; padding: 12px 14px; }
  .vi-toolbar-actions { flex-wrap: wrap; gap: 6px; }
  .vi-toolbar-actions .btn { min-height: 44px; font-size: 13px; flex: 1 1 auto; text-align: center; }
}

/* Phone-only: stack invoice header when truly narrow */
@media (max-width: 480px) {
  .inv-print-header  { flex-direction: column; gap: 16px; align-items: stretch; }
  .inv-print-meta    { text-align: left; }
  .inv-print-logo    { max-width: 200px; }
}

/* ─── RECURRENCE ─── */
.recurrence-selector { display:flex; flex-direction:column; gap:8px; }
.recurrence-options { padding:10px 0 0; display:flex; flex-direction:column; gap:10px; }
.recurrence-badge {
  display:inline-flex; align-items:center; gap:3px;
  font-size:10px; font-weight:600; color:var(--purple);
  background:var(--purple-dim); border-radius:6px; padding:2px 6px;
  margin-left:4px; vertical-align:middle;
}
.cal-event .recurrence-indicator {
  position:absolute; top:2px; right:4px; font-size:10px; opacity:0.7;
  line-height:1;
}
