/* =============================================
   HaulPro PWA v2 — Housecall Pro Style
   ============================================= */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --primary:     #0f2d6b;
  --primary-dk:  #091f4e;
  --primary-lt:  #e8eef8;
  --green:       #00a86b;
  --green-lt:    #e0f7ef;
  --orange:      #e07b10;
  --orange-lt:   #fef3e2;
  --red:         #d03030;
  --red-lt:      #fdeaea;
  --purple:      #6b4fcf;
  --purple-lt:   #f0ecfc;
  --bg:          #f0f2f5;
  --card:        #ffffff;
  --border:      #e2e6ea;
  --border-md:   #cdd2d8;
  --text:        #0f1f3d;
  --muted:       #5a6272;
  --hint:        #9aa0ad;
  --nav-bg:      #ffffff;
  --header-bg:   #0f2d6b;
  --r-card:      12px;
  --r-btn:       8px;
  --r-pill:      100px;
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 430px;
  margin: 0 auto;
  overflow-x: hidden;
  font-size: 15px;
  line-height: 1.5;
}

/* ── HEADER ── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  gap: 10px;
}
.header-logo {
  font-size: 22px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.5px;
}
.header-logo span { color: rgba(255,255,255,0.75); }
.header-date {
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  font-weight: 500;
}
.header-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  position: relative;
  padding: 7px;
  color: white;
  font-size: 20px;
  display: flex;
  align-items: center;
  border-radius: 8px;
}
.notif-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: #ff4d4d;
  border-radius: 50%;
  border: 1.5px solid var(--header-bg);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: white;
  font-size: 12px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.4);
}

/* ── BOTTOM NAV ── */
#bottom-nav {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--nav-bg);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 50;
  padding-bottom: env(safe-area-inset-bottom, 8px);
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 4px 4px;
  cursor: pointer;
  gap: 2px;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 10px;
  font-weight: 600;
  font-family: inherit;
  transition: color 0.15s;
}
.nav-item i { font-size: 22px; }
.nav-item.active { color: var(--primary); }
.nav-item.active i { color: var(--primary); }

/* ── SCREENS ── */
#screens-container { padding: 0 0 calc(84px + env(safe-area-inset-bottom, 0px)); }
.screen { display: none; }
.screen.active { display: block; }
.screen-pad { padding: 14px 16px; }

/* ── DASHBOARD HERO ── */
.dash-hero {
  background: var(--header-bg);
  margin-top: -1px;
  padding: 0 16px 20px;
  color: white;
}
.dash-hero-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding-top: 4px;
}
.hero-stat {
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.hero-stat-val { font-size: 22px; font-weight: 800; color: white; line-height: 1; }
.hero-stat-lbl { font-size: 10px; color: rgba(255,255,255,0.75); margin-top: 3px; font-weight: 600; }

/* ── MAP PLACEHOLDER ── */
.map-card {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 12px;
}
.map-area {
  height: 160px;
  background: #e8eef5;
  position: relative;
  overflow: hidden;
}
.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(180,195,215,0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(180,195,215,0.4) 1px, transparent 1px);
  background-size: 30px 30px;
}
.map-road-h {
  position: absolute;
  left: 0; right: 0;
  height: 8px;
  background: white;
  opacity: 0.8;
}
.map-road-v {
  position: absolute;
  top: 0; bottom: 0;
  width: 8px;
  background: white;
  opacity: 0.8;
}
.map-pin {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
}
.map-pin-dot {
  width: 28px; height: 28px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.map-pin-dot i {
  transform: rotate(45deg);
  font-size: 13px;
  color: white;
}
.map-pin-label {
  font-size: 10px;
  font-weight: 700;
  background: white;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 3px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
  white-space: nowrap;
  color: var(--text);
}
.map-footer {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── SECTION TITLE ── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--hint);
  letter-spacing: 0.8px;
  text-transform: uppercase;
  margin: 18px 0 8px;
}
.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 8px;
}
.section-row .section-label { margin: 0; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 10px;
}
.card-flat {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  overflow: hidden;
  margin-bottom: 10px;
}
.card-inner-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-inner-row:last-child { border-bottom: none; }

/* ── JOB CARDS ── */
.job-card {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  padding: 14px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.job-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
}
.job-card.active-job::before  { background: var(--primary); }
.job-card.done-job::before    { background: var(--green); }
.job-card.upcoming::before    { background: var(--orange); }
.job-card.cancelled::before   { background: var(--hint); }
.job-time  { font-size: 12px; font-weight: 700; color: var(--primary); }
.job-name  { font-size: 15px; font-weight: 700; margin: 3px 0 2px; }
.job-addr  { font-size: 12px; color: var(--muted); }
.job-type  { font-size: 12px; color: var(--muted); margin-top: 2px; }
.job-actions { display: flex; gap: 7px; margin-top: 11px; flex-wrap: wrap; }

/* ── STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--r-card);
  border: 1px solid var(--border);
  padding: 14px;
}
.stat-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── PILLS ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.pill i { font-size: 11px; }
.pill-blue   { background: var(--primary-lt); color: var(--primary-dk); }
.pill-green  { background: var(--green-lt);   color: #145c2c; }
.pill-orange { background: var(--orange-lt);  color: #8a4d00; }
.pill-red    { background: var(--red-lt);     color: #8a1a1a; }
.pill-gray   { background: #f0f2f5;           color: var(--muted); }
.pill-purple { background: var(--purple-lt);  color: var(--purple); }
.pill-primary{ background: var(--primary);    color: white; }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-btn);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:active { opacity: 0.8; transform: scale(0.97); }
.btn-primary  { background: var(--primary);  color: white; }
.btn-green    { background: var(--green);    color: white; }
.btn-orange   { background: var(--orange);   color: white; }
.btn-red      { background: var(--red);      color: white; }
.btn-secondary{ background: #f0f2f5;         color: var(--text); border: 1px solid var(--border); }
.btn-outline  { background: white; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-white    { background: white; color: var(--primary); font-weight: 700; }
.btn-sm       { padding: 7px 12px; font-size: 12px; }
.btn-full     { width: 100%; }
.btn-grid     { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn-grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 10px; }

/* ── FORM ── */
.form-group { margin-bottom: 13px; }
.form-label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.form-input {
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1.5px solid var(--border-md);
  font-size: 14px;
  font-family: inherit;
  background: #fafbfc;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  -webkit-appearance: none;
}
.form-input:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 3px rgba(26,111,219,0.1); }
textarea.form-input { resize: vertical; min-height: 70px; line-height: 1.5; }
select.form-input { cursor: pointer; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,20,35,0.55);
  z-index: 200;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-sheet {
  background: white;
  border-radius: 18px 18px 0 0;
  padding: 0 20px 40px;
  width: 100%;
  max-width: 430px;
  max-height: 92vh;
  overflow-y: auto;
  animation: slideUp 0.22s ease;
}
@keyframes slideUp {
  from { transform: translateY(50px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.modal-handle { width: 36px; height: 4px; background: #dde1e7; border-radius: 2px; margin: 14px auto 16px; }
.modal-title  { font-size: 18px; font-weight: 800; margin-bottom: 16px; }
.modal-close-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-close-btn { background: #f0f2f5; border: none; border-radius: 50%; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); font-size: 16px; }

/* ── TOAST ── */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #1a1f2e;
  color: white;
  padding: 11px 20px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  z-index: 400;
  white-space: nowrap;
  opacity: 0;
  transition: all 0.28s;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── BANNER ── */
.info-banner {
  background: var(--primary-lt);
  border: 1px solid rgba(26,111,219,0.2);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.info-banner i { color: var(--primary); font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.info-banner p { font-size: 12px; color: #143a6e; line-height: 1.55; }
.warn-banner {
  background: var(--orange-lt);
  border: 1px solid rgba(224,123,16,0.25);
  border-radius: 10px;
  padding: 11px 14px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.warn-banner i { color: var(--orange); font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.warn-banner p { font-size: 12px; color: #6b3a00; line-height: 1.55; }

/* ── INVOICE ROWS ── */
.inv-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.inv-row:last-child { border-bottom: none; }
.inv-total { font-size: 18px; font-weight: 800; }

/* ── CUSTOMER ── */
.cust-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.cust-pts  { font-size: 12px; font-weight: 700; color: var(--primary); text-align: right; }
.cust-tier { font-size: 10px; color: var(--hint); text-align: right; margin-top: 1px; }

/* ── REWARDS ── */
.rewards-hero {
  background: linear-gradient(135deg, #1a6fdb 0%, #1044a0 100%);
  border-radius: var(--r-card);
  padding: 20px;
  color: white;
  margin-bottom: 14px;
}
.rewards-pts { font-size: 48px; font-weight: 900; line-height: 1; }
.rewards-pts-label { font-size: 12px; opacity: 0.85; margin-top: 3px; }
.progress-bar { background: rgba(255,255,255,0.25); border-radius: 100px; height: 8px; margin-top: 14px; overflow: hidden; }
.progress-fill { height: 100%; background: white; border-radius: 100px; transition: width 0.6s ease; }

/* ── SCHEDULE ── */
.sched-slot { display: flex; gap: 10px; margin-bottom: 6px; align-items: stretch; }
.sched-time { font-size: 11px; font-weight: 600; color: var(--muted); width: 44px; padding-top: 6px; text-align: right; flex-shrink: 0; }
.sched-bar  { flex: 1; border-radius: 8px; padding: 9px 12px; }
.week-strip { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.week-strip::-webkit-scrollbar { display: none; }
.day-chip {
  text-align: center;
  padding: 8px 10px;
  background: var(--card);
  border-radius: 10px;
  min-width: 46px;
  cursor: pointer;
  flex-shrink: 0;
  border: 1px solid var(--border);
  font-family: inherit;
  transition: all 0.15s;
}
.day-chip.selected { background: var(--primary); border-color: var(--primary); color: white; }
.day-chip .d-name { font-size: 10px; font-weight: 700; color: var(--hint); }
.day-chip .d-num  { font-size: 17px; font-weight: 800; color: var(--text); line-height: 1.2; }
.day-chip.selected .d-name { color: rgba(255,255,255,0.8); }
.day-chip.selected .d-num  { color: white; }

/* ── TIMELINE ── */
.timeline { padding-left: 22px; border-left: 2px solid var(--border); }
.tl-item  { position: relative; padding-bottom: 18px; }
.tl-dot   { position: absolute; left: -27px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid white; box-shadow: 0 0 0 2px var(--primary); }
.tl-dot.done    { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.tl-dot.pending { background: #ccc; box-shadow: 0 0 0 2px #ccc; }
.tl-time  { font-size: 10px; color: var(--hint); font-weight: 700; }
.tl-label { font-size: 13px; font-weight: 700; margin-top: 1px; }
.tl-sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }

/* ── SETTINGS ── */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; }
.setting-row .s-label { font-size: 14px; font-weight: 600; }
.setting-row .s-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
input[type=checkbox].toggle {
  width: 44px; height: 24px; border-radius: 12px;
  -webkit-appearance: none; appearance: none;
  background: #d0d5dd; cursor: pointer;
  position: relative; transition: background 0.2s; flex-shrink: 0;
}
input[type=checkbox].toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type=checkbox].toggle:checked { background: var(--primary); }
input[type=checkbox].toggle:checked::after { left: 22px; }

/* ── SEARCH ── */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--hint); font-size: 16px; pointer-events: none; }
.search-wrap .form-input { padding-left: 36px; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state i { font-size: 48px; color: #cdd2d8; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ── LEADERBOARD ── */
.lb-rank { font-size: 20px; font-weight: 900; width: 28px; }
.lb-rank.r1 { color: var(--primary); }
.lb-rank.r2 { color: #888; }
.lb-rank.r3 { color: var(--orange); }

/* ── QUICK ACTION GRID ── */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.quick-action-btn {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  transition: background 0.15s;
}
.quick-action-btn:active { background: var(--bg); }
.quick-action-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

/* ── DIVIDER ── */
.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* ── UTILS ── */
.flex         { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8  { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.text-muted   { color: var(--muted); }
.text-sm      { font-size: 12px; }
.text-right   { text-align: right; }
.font-bold    { font-weight: 700; }
.color-primary { color: var(--primary); }
.color-green   { color: var(--green); }
.screen-title  { font-size: 20px; font-weight: 800; margin-bottom: 2px; }
.screen-sub    { font-size: 12px; color: var(--muted); margin-bottom: 14px; }

@supports (padding: env(safe-area-inset-bottom)) {
  #bottom-nav { padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
}

.timer-val { color: var(--primary); }
.timer-paused { color: var(--muted); }

/* ─── Floating "+" Add button + speed-dial menu ─── */
#fab-add {
  position: fixed;
  bottom: calc(74px + env(safe-area-inset-bottom, 8px));
  right: max(16px, calc(50% - 199px));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none;
  font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(15,45,107,0.40);
  z-index: 80; cursor: pointer; transition: transform 0.2s;
}
#fab-add.open { transform: rotate(45deg); }
#fab-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.35);
  z-index: 79; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
#fab-backdrop.open { opacity: 1; pointer-events: auto; }
.fab-menu {
  position: fixed;
  bottom: calc(142px + env(safe-area-inset-bottom, 8px));
  right: max(16px, calc(50% - 199px));
  width: 224px; background: #fff; border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.18);
  padding: 8px; z-index: 81; display: none; transform-origin: bottom right;
}
.fab-menu.open { display: block; animation: fabIn 0.16s ease-out; }
@keyframes fabIn { from { opacity: 0; transform: translateY(8px) scale(0.96); } to { opacity: 1; transform: none; } }
.fab-menu-title { font-size: 11px; font-weight: 800; color: var(--hint); text-transform: uppercase; letter-spacing: 0.04em; padding: 6px 10px 8px; }
.fab-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: none; background: none; font-family: inherit;
  font-size: 14px; font-weight: 600; color: var(--text);
  cursor: pointer; border-radius: 9px; text-align: left;
}
.fab-item:active, .fab-item:hover { background: var(--primary-lt); }
.fab-ic { width: 32px; height: 32px; border-radius: 9px; background: #eef2ff; color: var(--primary); display: flex; align-items: center; justify-content: center; font-size: 17px; flex-shrink: 0; }
.fab-soon { color: var(--hint); }
.fab-soon .fab-ic { background: var(--bg); color: var(--hint); }
.fab-tag { margin-left: auto; font-size: 10px; font-weight: 700; color: var(--hint); background: var(--border); padding: 2px 8px; border-radius: 100px; }

/* ─── Modern date + time pickers ─── */
.picker-btn {
  text-align: left; cursor: pointer; background: var(--card);
  display: flex; align-items: center; gap: 8px;
}
.picker-btn i { color: var(--primary); font-size: 17px; }
.picker-btn .pk-val { font-weight: 600; color: var(--text); }

/* Calendar */
.dp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dp-head button { background: none; border: none; color: var(--primary); font-size: 26px; cursor: pointer; padding: 4px 14px; line-height: 1; font-family: inherit; }
.dp-month { font-size: 16px; font-weight: 800; color: var(--text); }
.dp-grid { display: grid; grid-template-columns: repeat(7,1fr); gap: 4px; }
.dp-dow { margin-bottom: 6px; }
.dp-dow div { text-align: center; font-size: 11px; font-weight: 700; color: var(--hint); text-transform: uppercase; }
.dp-day { aspect-ratio: 1; border: none; background: none; border-radius: 50%; font-size: 15px; font-weight: 600; color: var(--text); cursor: pointer; font-family: inherit; display: flex; align-items: center; justify-content: center; }
.dp-day:hover { background: var(--primary-lt); }
.dp-day.today { color: var(--primary); font-weight: 800; }
.dp-day.sel { background: var(--primary); color: #fff; }

/* Time spin wheel */
.tp-wheels { position: relative; display: flex; justify-content: center; gap: 6px; height: 200px; margin: 10px 0 4px; }
.tp-col { flex: 0 0 auto; width: 76px; height: 200px; overflow-y: scroll; scroll-snap-type: y mandatory; scrollbar-width: none; text-align: center; -webkit-overflow-scrolling: touch; position: relative; z-index: 1; }
.tp-col::-webkit-scrollbar { display: none; }
.tp-pad { height: 80px; }
.tp-item { height: 40px; line-height: 40px; scroll-snap-align: center; font-size: 22px; color: var(--hint); font-weight: 600; transition: color .1s; }
.tp-item.sel { color: var(--text); font-weight: 800; }
.tp-band { position: absolute; left: 50%; transform: translateX(-50%); width: 240px; top: 80px; height: 40px; background: var(--primary-lt); border-radius: 10px; pointer-events: none; z-index: 0; }
#modal-datepick, #modal-timepick, #modal-additem, #modal-job-pay { z-index: 210; }
#modal-take-payment { z-index: 220; }

/* ══════════════════════════════════════════════════════════════════
   DESKTOP DASHBOARD MODE
   Below this width: nothing here applies — the phone/tablet app above
   renders exactly as it always has. Above it: the phone chrome (header,
   screens-container, bottom-nav) is hidden and the desktop shell (sidebar +
   topbar + wide content) takes over. Same data, same functions — this is
   purely a different way of presenting them for office/admin use.
   ══════════════════════════════════════════════════════════════════ */
.desktop-only { display: none; }

@media (min-width: 1024px) {
  .mobile-shell { display: none !important; }
  .desktop-only { display: block; }

  html, body { max-width: none; margin: 0; overflow-x: visible; }
  body { background: #eef0f4; }

  #desktop-shell { display: flex; min-height: 100vh; }

  #dsk-sidebar {
    width: 208px; flex-shrink: 0; background: var(--primary);
    display: flex; flex-direction: column; gap: 2px; padding: 18px 12px;
    position: sticky; top: 0; height: 100vh;
  }
  .dsk-logo { color: #fff; font-weight: 800; font-size: 19px; padding: 4px 10px 20px; }
  .dsk-nav-item {
    display: flex; align-items: center; gap: 11px; background: none; border: none; cursor: pointer;
    color: #a9c0e8; font-family: inherit; font-size: 14px; font-weight: 600;
    padding: 10px 12px; border-radius: 9px; text-align: left; width: 100%;
  }
  .dsk-nav-item i { font-size: 18px; }
  .dsk-nav-item:hover { background: rgba(255,255,255,0.08); }
  .dsk-nav-item.active { background: rgba(255,255,255,0.16); color: #fff; }

  #dsk-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
  #dsk-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px; background: #fff; border-bottom: 1px solid var(--border);
  }
  #dsk-topbar-title { font-size: 18px; font-weight: 800; }
  #dsk-topbar-actions { display: flex; align-items: center; gap: 14px; }
  #dsk-content { flex: 1; padding: 22px 28px; max-width: 1400px; width: 100%; margin: 0 auto; }

  /* Metric cards + board layout used by the desktop Dashboard/Jobs board */
  .dsk-kpis { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 18px; }
  .dsk-kpi { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
  .dsk-kpi-label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
  .dsk-kpi-val { font-size: 22px; font-weight: 800; }
  .dsk-kpi-trend { display: block; font-size: 11px; font-weight: 700; margin-top: 6px; }
  .dsk-kpi-trend.up { color: var(--green); }
  .dsk-kpi-trend.down { color: #d03030; }
  .dsk-kpi-trend.flat { color: var(--hint); }
  .dsk-board { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; align-items: start; }
  .dsk-col-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; font-size: 13px; font-weight: 700; }
  .dsk-col-count { font-size: 12px; color: var(--muted); margin-left: auto; }
  .dsk-card {
    background: #fff; border: 1px solid var(--border); border-left: 3px solid var(--primary);
    border-radius: 0 8px 8px 0; padding: 10px 12px; margin-bottom: 8px; cursor: pointer;
  }
  .dsk-card:hover { border-color: var(--border-md); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
  .dsk-card-name { font-size: 13px; font-weight: 700; }
  .dsk-card-sub  { font-size: 12px; color: var(--muted); margin-top: 2px; }
  .dsk-empty-col { border: 1px dashed var(--border-md); border-radius: 8px; padding: 20px 10px; text-align: center; font-size: 12px; color: var(--hint); }

  /* Desktop still uses the phone's existing card-list screens for Schedule/Team/Reports for
     now (Phase 1) — just centered in a wider column instead of a 430px-wide phone column, so
     nothing about those screens' own code changes. */
  .dsk-wide-wrap { max-width: 720px; }

  /* Phase 2 — real desktop tables (Customers / Invoices) */
  .dsk-table-toolbar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
  .dsk-table-toolbar .form-input { height: 36px; }
  .dsk-filter-pills { display: flex; gap: 4px; background: var(--surface,#eef0f4); border-radius: 8px; padding: 3px; }
  .dsk-filter-pills button { border: none; background: none; font-family: inherit; font-size: 12px; font-weight: 700; padding: 6px 12px; border-radius: 6px; cursor: pointer; color: var(--muted); }
  .dsk-filter-pills button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
  .dsk-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .dsk-table thead th { text-align: left; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.3px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: #f7f8fa; white-space: nowrap; }
  .dsk-table tbody td { padding: 11px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
  .dsk-table tbody tr { cursor: pointer; }
  .dsk-table tbody tr:hover td { background: #f7f8fa; }
  .dsk-table tbody tr:last-child td { border-bottom: none; }
  .dsk-td-avatar { display: flex; align-items: center; gap: 9px; }
  .dsk-td-avatar .cust-avatar { flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; }
  .cust-action-item { display: flex; align-items: center; gap: 9px; width: 100%; background: none; border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; padding: 10px 14px; text-align: left; color: var(--text); }
  .cust-action-item:hover { background: #f7f8fa; }

  /* Merge customers form */
  .mg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
  .mg-field-label { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
  .mg-diff-tag { display: inline-block; background: var(--orange-lt,#fdf0e6); color: var(--orange,#e8520a); font-size: 9px; font-weight: 800; letter-spacing: 0.4px; text-transform: uppercase; border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
  .mg-field-static { font-size: 13px; font-weight: 600; padding: 10px 12px; background: #f7f8fa; border-radius: 8px; border: 1px solid var(--border); color: var(--text); }

  /* Phase 2 — real desktop week calendar (Schedule) */
  .dsk-cal-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
  .dsk-cal-range { font-size: 15px; font-weight: 800; min-width: 150px; text-align: center; }
  .dsk-cal-grid { background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .dsk-cal-row { display: grid; grid-template-columns: 68px repeat(7, 1fr); border-top: 1px solid var(--border); }
  .dsk-cal-row:first-child { border-top: none; }
  .dsk-cal-hour { padding: 8px 10px 0 0; font-size: 11px; color: var(--muted); text-align: right; }
  .dsk-cal-daysrow { border-top: none; background: #f7f8fa; }
  .dsk-cal-daycol { text-align: center; padding: 10px 4px; cursor: pointer; border-left: 1px solid var(--border); }
  .dsk-cal-daycol:first-child { border-left: none; }
  .dsk-cal-daycol.today .dsk-cal-daynum { background: var(--primary); color: #fff; }
  .dsk-cal-dayname { font-size: 10px; font-weight: 700; color: var(--muted); letter-spacing: 0.4px; }
  .dsk-cal-daynum { font-size: 15px; font-weight: 800; width: 26px; height: 26px; line-height: 26px; border-radius: 50%; margin: 3px auto 0; }
  .dsk-cal-cell { border-left: 1px solid var(--border); padding: 4px; min-height: 46px; display: flex; flex-direction: column; gap: 3px; }
  .dsk-cal-cell:first-of-type { border-left: none; }
  .dsk-cal-anyrow .dsk-cal-cell { min-height: 30px; }
  .dsk-cal-block { background: #f0f4fb; border-left: 3px solid var(--primary); border-radius: 0 6px 6px 0; padding: 4px 7px; cursor: pointer; overflow: hidden; }
  .dsk-cal-block:hover { background: #e6ecf9; }
  .dsk-cal-block-name { font-size: 11px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dsk-cal-block-time { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Phase 2 — desktop Team roster */
  .dsk-team-group-label { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: 0.5px; text-transform: uppercase; margin: 16px 0 8px; }
  .dsk-team-group-label:first-child { margin-top: 0; }
  .dsk-team-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin-bottom: 14px; }
  .dsk-team-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px; }
  .dsk-team-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
  .dsk-team-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-bottom: 10px; }
  .dsk-team-day { text-align: center; cursor: pointer; }
  .dsk-team-dayname { font-size: 9px; font-weight: 700; color: var(--hint); margin-bottom: 3px; }
  .dsk-team-bar { height: 30px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }
  .dsk-team-punches { border-top: 1px solid var(--border); padding-top: 8px; }
  .dsk-team-punch { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; font-size: 11px; color: var(--muted); cursor: pointer; }
  .dsk-team-seats { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }

  /* Phase 2 — desktop Reports */
  .dsk-rpt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .dsk-rpt-card { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
  .dsk-rpt-title { font-size: 13px; font-weight: 700; }

  /* Phase 2 — desktop Settings */
  .dsk-settings-layout { display: flex; gap: 24px; align-items: flex-start; }
  .dsk-settings-nav { width: 190px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; position: sticky; top: 22px; }
  .dsk-settings-nav-item { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--muted); padding: 9px 11px; border-radius: 7px; text-align: left; width: 100%; }
  .dsk-settings-nav-item i { font-size: 16px; }
  .dsk-settings-nav-item:hover { background: #f7f8fa; }
  .dsk-settings-nav-item.active { background: var(--primary-lt); color: var(--primary); }
  .dsk-settings-panel { flex: 1; min-width: 0; }
  .dsk-set-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
  .dsk-set-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }
  .dsk-set-subtitle { font-size: 12px; font-weight: 800; color: var(--hint); letter-spacing: 0.3px; margin-bottom: 8px; }

  /* Phase 2 — desktop Time Clock */
  .dsk-tc-layout { display: flex; gap: 20px; align-items: flex-start; }
  .dsk-tc-list { width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; position: sticky; top: 22px; }
  .dsk-tc-emp { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; font-family: inherit; padding: 9px 10px; border-radius: 7px; text-align: left; width: 100%; }
  .dsk-tc-emp:hover { background: #f7f8fa; }
  .dsk-tc-emp.active { background: var(--primary-lt); }
  .dsk-tc-emp-av { width: 28px; height: 28px; border-radius: 8px; color: #fff; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
  .dsk-tc-emp-name { flex: 1; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dsk-tc-emp-count { font-size: 11px; color: var(--muted); }
  .dsk-tc-detail { flex: 1; min-width: 0; }
  .dsk-tc-detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
  .dsk-tc-week-block { margin-bottom: 26px; }
  .dsk-tc-week-head { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 800; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 2px solid var(--primary); }
  .dsk-tc-week-total { color: var(--primary); margin-left: auto; }
  .dsk-tc-day-block { margin-bottom: 16px; margin-left: 4px; }
  .dsk-tc-day-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 800; margin-bottom: 8px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }
  .dsk-tc-day-total { color: var(--primary); }
  .dsk-tc-punch { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; }
  .dsk-tc-punch-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
  .dsk-tc-punch-time { font-weight: 700; font-size: 14px; }
  .dsk-tc-punch-dur { color: var(--primary); font-weight: 700; font-size: 13px; margin-left: auto; }

  /* Phase 2 — Dashboard: Pipeline + Today's Route map */
  .dsk-pipeline { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
  .dsk-pipe-stage { flex: 1; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px; text-align: center; cursor: pointer; }
  .dsk-pipe-stage:hover { border-color: var(--primary); }
  .dsk-pipe-stage i { font-size: 20px; color: var(--primary); }
  .dsk-pipe-count { font-size: 22px; font-weight: 800; margin-top: 4px; }
  .dsk-pipe-label { font-size: 11px; color: var(--muted); font-weight: 600; }
  .dsk-pipe-value { font-size: 12px; color: var(--primary); font-weight: 700; margin-top: 2px; }
  .dsk-pipe-arrow { color: var(--border-md); font-size: 16px; flex-shrink: 0; }

  /* Phase 2 — Messages */
  .dsk-msg-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
  .dsk-msg-row:last-child { border-bottom: none; }
  .dsk-msg-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--primary-lt); color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }

  /* Phase 2 — Messages two-pane conversation view */
  .dsk-msg-layout { display: flex; gap: 16px; height: calc(100vh - 180px); min-height: 420px; }
  .dsk-msg-convlist { width: 260px; flex-shrink: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; overflow-y: auto; padding: 4px; }
  .dsk-msg-conv { display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none; cursor: pointer; padding: 9px 8px; border-radius: 7px; text-align: left; }
  .dsk-msg-conv:hover { background: #f7f8fa; }
  .dsk-msg-conv.active { background: var(--primary-lt); }
  .dsk-msg-threadpane { flex: 1; min-width: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; }
  .dsk-msg-thread-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
  .dsk-msg-thread { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
  .dsk-bubble { max-width: 60%; padding: 9px 13px; border-radius: 12px; font-size: 13px; line-height: 1.4; }
  .dsk-bubble.out { align-self: flex-end; background: var(--primary); color: #fff; border-radius: 12px 12px 2px 12px; }
  .dsk-bubble.in  { align-self: flex-start; background: #f0f2f5; color: var(--text); border-radius: 12px 12px 12px 2px; }
  .dsk-bubble-time { font-size: 10px; opacity: 0.7; margin-top: 4px; }
  .dsk-bubble.clickable { cursor: pointer; }
  .dsk-bubble.clickable:hover { filter: brightness(0.95); }
  .dsk-msg-reply-row { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }
  .dsk-msg-reply-row .form-input { flex: 1; }

  /* The phone's floating round + button is mobile-only — the desktop topbar's own
     "+ Add New" button (below) replaces it. Its menu (.fab-menu) is reused by both;
     only its position changes here, from "floats above the bottom FAB" to "drops
     down from the topbar button." */
  #fab-add, #fab-backdrop { display: none !important; }
  .fab-menu { position: fixed; top: 60px; bottom: auto; right: 28px; transform-origin: top right; }

  /* Modals read better centered and a bit wider on a big screen, instead of a phone's
     bottom sheet — still the exact same modal HTML/content underneath. */
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: 16px; max-width: 520px; animation: none; }
}

/* ══════════════════════════════════════════════════════════════════
   AI SUPPORT CHAT — desktop only, bottom-right (mobile keeps its own FAB there,
   but doesn't need this widget at all per user request)
   ══════════════════════════════════════════════════════════════════ */
#support-bubble, #support-panel { display: none; }
#support-bubble {
  position: fixed; right: 28px; bottom: 28px;
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff; border: none; font-size: 22px;
  align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 4px 16px rgba(15,45,107,0.35); z-index: 90;
}
#support-panel {
  position: fixed; right: 28px; bottom: 92px;
  width: min(340px, calc(100vw - 40px)); height: min(460px, 65vh);
  background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,0.22);
  z-index: 91; flex-direction: column; overflow: hidden;
}
#support-panel.open { display: flex; }
#support-panel-head { background: var(--primary); color: #fff; padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; }
#support-panel-title { font-size: 14px; font-weight: 800; }
#support-panel-sub { font-size: 11px; opacity: 0.75; margin-top: 1px; }
#support-panel-head button { background: rgba(255,255,255,0.15); border: none; color: #fff; width: 26px; height: 26px; border-radius: 7px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#support-panel-msgs { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sup-msg { max-width: 84%; padding: 8px 12px; border-radius: 12px; font-size: 13px; line-height: 1.45; }
.sup-msg.user { align-self: flex-end; background: var(--primary); color: #fff; border-radius: 12px 12px 2px 12px; }
.sup-msg.bot  { align-self: flex-start; background: #f0f2f5; color: var(--text); border-radius: 12px 12px 12px 2px; }
.sup-msg.bot.err { background: #fdecea; color: #a32d2d; }
.sup-typing { align-self: flex-start; background: #f0f2f5; border-radius: 12px 12px 12px 2px; padding: 9px 13px; display: flex; gap: 4px; }
.sup-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--hint); animation: supBounce 1s infinite; }
.sup-typing span:nth-child(2) { animation-delay: 0.15s; }
.sup-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes supBounce { 0%,60%,100%{ transform: translateY(0); opacity:0.5; } 30%{ transform: translateY(-4px); opacity:1; } }
#support-panel-input-row { border-top: 1px solid var(--border); padding: 8px; display: flex; gap: 6px; }
#support-panel-input { flex: 1; border: 1px solid var(--border-md); border-radius: 9px; padding: 9px 11px; font-size: 13px; font-family: inherit; }
#support-panel-input-row button { width: 36px; height: 36px; border-radius: 9px; background: var(--primary); color: #fff; border: none; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
@media (min-width: 1024px) {
  #support-bubble { display: flex; }
}



