/* ═══════════════════════════════════════════════════════════════════════════
   THEME TOKENS  — single source of truth. Dark + Light via data-theme.
   Brand colours (--primary = brown, --primary-2 = gold) and the heading/body
   font pairing are pulled straight from royalfloors.com.au's own stylesheet,
   not invented — see the "Design" notes for where each value comes from.
   ═══════════════════════════════════════════════════════════════════════════ */
:root, [data-theme="dark"]{
  --bg:#0b0e1a; --surface:#14172a; --surface-2:#1b1f36; --surface-3:#232842;
  --border:rgba(255,255,255,0.08); --border-2:rgba(255,255,255,0.14);
  --text:#e7ecf5; --text-dim:#9aa6c0; --text-muted:#5b6580;
  --primary:#8a5a2e; --primary-2:#c5853a; --primary-soft:rgba(197,133,58,0.16);
  --success:#10b981; --success-soft:rgba(16,185,129,0.14);
  --danger:#ef4444;  --danger-soft:rgba(239,68,68,0.14);
  --warning:#f59e0b; --warning-soft:rgba(245,158,11,0.14);
  --info:#3b82f6;    --info-soft:rgba(59,130,246,0.14);
  --shadow:0 10px 30px rgba(0,0,0,0.45); --shadow-sm:0 4px 12px rgba(0,0,0,0.3);
  --input-bg:rgba(255,255,255,0.05);
  --font-heading:'Abhaya Libre',Georgia,serif; --font-body:'Albert Sans',system-ui,sans-serif;
  /* Appointment-type colours (Calendar) - one hue per type, independent of
     theme/status, same "solid text/border + rgba-soft background" convention
     as --success/--success-soft above. */
  --type-measurement:#f97316; --type-measurement-soft:rgba(249,115,22,.14);
  --type-quote:#8b5cf6; --type-quote-soft:rgba(139,92,246,.14);
  --type-carpet:#10b981; --type-carpet-soft:rgba(16,185,129,.14);
  --type-hardfloor:#3b82f6; --type-hardfloor-soft:rgba(59,130,246,.14);
  --type-pickup:#eab308; --type-pickup-soft:rgba(234,179,8,.14);
  --type-followup:#ec4899; --type-followup-soft:rgba(236,72,153,.14);
  --type-invoice:#64748b; --type-invoice-soft:rgba(100,116,139,.14);
  --type-default:#94a3b8; --type-default-soft:rgba(148,163,184,.14);
}
[data-theme="light"]{
  --bg:#f7f4ef; --surface:#ffffff; --surface-2:#faf8f4; --surface-3:#f2ede3;
  --border:#e7e0d3; --border-2:#dcd2bf;
  --text:#241705; --text-dim:#5c4a2f; --text-muted:#9c8b6f;
  --primary:#452205; --primary-2:#c5853a; --primary-soft:rgba(69,34,5,0.09);
  --success:#059669; --success-soft:rgba(16,185,129,0.12);
  --danger:#dc2626;  --danger-soft:rgba(239,68,68,0.10);
  --warning:#d97706; --warning-soft:rgba(245,158,11,0.14);
  --info:#2563eb;    --info-soft:rgba(59,130,246,0.12);
  --shadow:0 10px 30px rgba(36,23,5,0.10); --shadow-sm:0 4px 12px rgba(36,23,5,0.07);
  --input-bg:#f4f0e8;
}
@import url('https://fonts.googleapis.com/css2?family=Abhaya+Libre:wght@500;600;700;800&family=Albert+Sans:wght@400;500;600;700;800&display=swap');
*{box-sizing:border-box;margin:0;padding:0}
html,body,#root{height:100%}
body{font-family:var(--font-body);background:var(--bg);color:var(--text);overflow:hidden}
h1,h2,h3,h4,h5,h6,.card-h,.modal-h,.stat-val,.top-title,.login-brand{font-family:var(--font-heading)}
::-webkit-scrollbar{width:10px;height:10px}
::-webkit-scrollbar-thumb{background:var(--border-2);border-radius:8px}
::-webkit-scrollbar-track{background:transparent}

.app{display:flex;height:100vh;overflow:hidden}

/* ── SIDEBAR NAV ── */
.nav{width:250px;flex-shrink:0;background:var(--surface);border-right:1px solid var(--border);display:flex;flex-direction:column;overflow:hidden}
.nav-brand{display:flex;align-items:center;justify-content:center;padding:20px 16px 16px}
.nav-scroll{flex:1;overflow-y:auto;padding:6px 12px}
.nav-section{font-size:10.5px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.1em;padding:16px 12px 7px}
.nav-item{display:flex;align-items:center;gap:12px;padding:11px 13px;border-radius:10px;cursor:pointer;font-size:14px;font-weight:500;color:var(--text-dim);transition:.12s;user-select:none;margin-bottom:2px}
.nav-item:hover{background:var(--surface-2);color:var(--text)}
/* Active page: soft beige pill with a gold accent bar on its left edge (an
   inset shadow, not a border, so the row's text never shifts sideways). */
.nav-item.on{background:var(--primary-soft);color:var(--primary);font-weight:700;box-shadow:inset 3px 0 0 var(--primary-2)}
.nav-ico{width:19px;display:flex;align-items:center;justify-content:center;flex-shrink:0}
.nav-badge{margin-left:auto;font-size:11px;font-weight:700;background:var(--surface-3);color:var(--text-dim);padding:2px 9px;border-radius:12px}
/* Footer: round avatar + stacked name/role + logout button on the right */
.nav-foot{padding:12px;border-top:1px solid var(--border);display:flex;align-items:center;gap:10px}
.nav-foot-avatar{border-radius:50%}
.nav-foot-id{flex:1;min-width:0}
.nav-foot-name{font-size:13px;font-weight:700;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.nav-foot-role{font-size:11px;color:var(--text-muted)}
/* Mobile drawer controls: the hamburger lives in the topbar and the backdrop
   dims/closes the off-canvas nav. Both are inert on desktop (see @media). */
.topbar .nav-toggle{display:none}   /* .topbar prefix beats .icon-btn's own display:flex */
.bottom-nav{display:none}           /* mobile-only; shown in the 820px media query */
.nav-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.45);z-index:490;animation:fadein .15s ease}
@keyframes fadein{from{opacity:0}to{opacity:1}}

/* ── MAIN ── */
.main{flex:1;display:flex;flex-direction:column;overflow:hidden;min-width:0}
.topbar{height:56px;flex-shrink:0;border-bottom:1px solid var(--border);background:var(--surface);display:flex;align-items:center;gap:12px;padding:0 18px}
.top-title{font-size:15px;font-weight:700}
.top-search{flex:1;max-width:440px;position:relative}
.top-search input{width:100%;background:var(--input-bg);border:1px solid var(--border);border-radius:9px;padding:8px 12px 8px 32px;color:var(--text);font-size:13px;outline:none;font-family:inherit}
.top-search input:focus{border-color:var(--primary)}
.top-search .si{position:absolute;left:10px;top:50%;transform:translateY(-50%);color:var(--text-muted);font-size:13px}
.top-search .kbd{position:absolute;right:8px;top:50%;transform:translateY(-50%);font-size:10px;color:var(--text-muted);border:1px solid var(--border);border-radius:5px;padding:1px 6px}
.top-right{margin-left:auto;display:flex;align-items:center;gap:8px}
.icon-btn{width:34px;height:34px;border-radius:7px;border:1px solid var(--border);background:var(--surface-2);color:var(--text-dim);cursor:pointer;font-size:15px;display:flex;align-items:center;justify-content:center;transition:.12s}
.icon-btn:hover{background:var(--surface-3);color:var(--text)}
.page{flex:1;overflow-y:auto;overflow-x:hidden;padding:22px 26px}
.page-narrow{max-width:1100px;margin:0 auto}

/* ── PAGE HEADER (PageHead primitive): title + subtitle + right-aligned action ── */
.page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:18px}
.page-head-title{font-size:22px;font-weight:800;letter-spacing:-.4px;display:flex;align-items:center;gap:9px;line-height:1.15}
.page-head-title svg{color:var(--primary-2)}
.page-head-sub{font-size:13px;color:var(--text-muted);margin-top:4px}
.page-head-actions{display:flex;align-items:center;gap:9px;flex-wrap:wrap}

/* ── LOADING STATE (Loading primitive) ── */
.spinner{width:18px;height:18px;border:2.5px solid var(--border-2);border-top-color:var(--primary-2);border-radius:50%;animation:spin .7s linear infinite;display:inline-block;flex-shrink:0}
.loading-state{display:flex;align-items:center;justify-content:center;gap:10px;color:var(--text-muted);font-size:13.5px;font-weight:500}

/* ── BUTTONS ── */
.btn{display:inline-flex;align-items:center;gap:6px;padding:8px 14px;border-radius:8px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid transparent;transition:.13s;font-family:inherit;white-space:nowrap}
.btn:disabled{opacity:.45;cursor:default}
.btn-primary{background:linear-gradient(135deg,var(--primary),var(--primary-2));color:#fff;box-shadow:0 2px 8px rgba(0,0,0,0.14)}
.btn-primary:hover:not(:disabled){filter:brightness(1.08)}
.btn-ghost{background:var(--surface-2);color:var(--text-dim);border-color:var(--border)}
.btn-ghost:hover{background:var(--surface-3);color:var(--text)}
.btn-danger{background:var(--danger-soft);color:var(--danger);border-color:transparent}
.btn-danger:hover{background:var(--danger);color:#fff}
.btn-success{background:var(--success-soft);color:var(--success)}
.btn-success:hover{background:var(--success);color:#fff}
.btn-sm{padding:6px 11px;font-size:12px;border-radius:7px}
.btn-block{width:100%;justify-content:center}
.btn:active:not(:disabled){transform:translateY(1px)}
/* Keyboard-only focus rings (a11y) — mouse clicks stay clean, Tab shows a ring. */
.btn:focus-visible,.icon-btn:focus-visible,.tab:focus-visible,.stab:focus-visible,.nav-item:focus-visible,.chk:focus-visible,.sel-plain:focus-visible{outline:2px solid var(--primary-2);outline-offset:2px}
.inp:focus-visible,.sel:focus-visible,.ta:focus-visible{box-shadow:0 0 0 3px var(--primary-soft)}

/* ── SAVE BAR (explicit Save button + unsaved-changes indicator) ── */
.save-bar{position:sticky;top:0;z-index:60;display:flex;align-items:center;justify-content:space-between;gap:14px;background:var(--surface);border:1px solid var(--border-2);border-radius:14px;padding:11px 16px;margin-bottom:16px;box-shadow:var(--shadow-sm)}
.save-status{display:flex;align-items:center;gap:8px;font-size:12.5px;font-weight:600;color:var(--text-dim)}
.save-status .dot{width:8px;height:8px;border-radius:50%;background:var(--success);flex-shrink:0}
.save-status.dirty{color:var(--warning)}
.save-status.dirty .dot{background:var(--warning)}
.save-status.error{color:var(--danger)}
.save-status.error .dot{background:var(--danger)}

/* ── CARDS / LAYOUT ── */
.card{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:20px;margin-bottom:16px;box-shadow:var(--shadow-sm)}
.card-h{font-size:13.5px;font-weight:700;margin-bottom:16px;display:flex;align-items:center;gap:8px;letter-spacing:-.1px}
.sec-hd{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:14px;flex-wrap:wrap}
.grid{display:grid;gap:14px}
.g2{grid-template-columns:repeat(auto-fit,minmax(220px,1fr))}
.g3{grid-template-columns:repeat(auto-fit,minmax(180px,1fr))}
.g4{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
.row{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.spread{display:flex;align-items:center;justify-content:space-between;gap:10px}
.muted{color:var(--text-muted)} .dim{color:var(--text-dim)}
.hr{border:none;border-top:1px solid var(--border);margin:16px 0}

/* ── FORM FIELDS ── */
.field{display:flex;flex-direction:column;gap:5px}
.field.full{grid-column:1/-1}
.lbl{font-size:10.5px;font-weight:700;color:var(--text-muted);text-transform:uppercase;letter-spacing:.06em}
.inp,.sel,.ta{background:var(--input-bg);border:1px solid var(--border);border-radius:6px;padding:9px 11px;color:var(--text);font-size:13px;font-family:inherit;outline:none;transition:.13s;width:100%}
.inp:focus,.sel:focus,.ta:focus{border-color:var(--primary);background:transparent}
.inp::placeholder,.ta::placeholder{color:var(--text-muted)}
.inp:read-only{opacity:.7}
.ta{resize:vertical;min-height:72px;line-height:1.5}
.sel{cursor:pointer;appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2394a3b8' d='M5 7L1 3h8z'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 10px center;padding-right:28px}
.inp.invalid,.sel.invalid{border-color:var(--danger)!important;background:var(--danger-soft)!important}
.inp.valid,.sel.valid{border-color:var(--success)!important}
.field-err{color:var(--danger);font-size:11px;font-weight:600}

/* ── CUSTOMER PAGE CONTROLS (search + filter + sort) ──
   Uses the app's own theme tokens (not literal hex) so this still looks right
   in dark mode - the light theme's --surface/--border/--text already ARE the
   warm white/beige/dark-brown palette this was designed to match. */
.customer-controls{display:flex;align-items:center;gap:14px;padding:16px;background:var(--surface);border:1px solid var(--border);border-radius:16px;box-shadow:var(--shadow-sm);margin-bottom:16px;flex-wrap:wrap}
.customer-filter-control,.customer-sort-control{height:48px;min-width:210px;display:flex;align-items:center;gap:10px;border:1px solid var(--border);border-radius:11px;background:var(--surface-2);color:var(--text);padding:0 14px;font-size:13.5px;font-weight:600}
.customer-filter-control svg,.customer-sort-control svg{color:var(--primary-2);flex-shrink:0}
.customer-filter-control .chevron,.customer-sort-control .chevron{margin-left:auto;color:var(--text-muted)}
.customer-filter-control:focus-within,.customer-sort-control:focus-within{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft)}
.sel-plain{border:none;background:transparent;color:inherit;font:inherit;font-weight:inherit;outline:none;cursor:pointer;appearance:none;flex:1;padding:0}
@media (max-width:768px){
  .customer-controls{flex-direction:column;align-items:stretch}
  .customer-filter-control,.customer-sort-control{width:100%;min-width:0}
}

/* ── JOB DESCRIPTION CHECKLIST (Job Sheet) ── */
.jd-list{border:1px solid var(--border);border-radius:12px;background:var(--surface-2);padding:2px 14px}
.jd-item{padding:12px 0;border-bottom:1px solid var(--border)}
.jd-item:last-child{border-bottom:none}
.jd-q{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;font-size:13.5px;font-weight:600;color:var(--text)}
.jd-detail{margin-top:11px;display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(190px,1fr))}

/* ── TAGS ── */
.tags{display:flex;flex-wrap:wrap;gap:5px;align-items:center}
.tag{display:inline-flex;align-items:center;gap:5px;padding:2px 9px;border-radius:20px;font-size:11px;font-weight:600;background:var(--primary-soft);color:var(--primary)}
.tag x{cursor:pointer;font-weight:800;opacity:.7}
.tag x:hover{opacity:1}
.tag-add{border:1px dashed var(--border-2);background:transparent;color:var(--text-muted);border-radius:20px;padding:2px 9px;font-size:11px;cursor:pointer;font-family:inherit}

/* ── BADGES / STATUS ── */
.badge{display:inline-flex;align-items:center;gap:5px;padding:3px 10px;border-radius:20px;font-size:11px;font-weight:700}
.b-lead{background:var(--primary-soft);color:var(--primary)}
.b-quoted{background:var(--warning-soft);color:var(--warning)}
.b-ordered{background:var(--info-soft);color:var(--info)}
.b-jobsheetsent{background:rgba(20,184,166,0.16);color:#0d9488}
.b-installed{background:rgba(139,92,246,0.16);color:var(--primary-2)}
.b-complete{background:var(--success-soft);color:var(--success)}
.b-lost{background:var(--danger-soft);color:var(--danger)}
.dot{width:8px;height:8px;border-radius:50%;display:inline-block}

/* ── STATS ── */
.stat{background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:18px 20px;box-shadow:var(--shadow-sm)}
.stat-lbl{font-size:11px;color:var(--text-muted);font-weight:600;margin-bottom:6px;display:flex;align-items:center;gap:6px}
.stat-val{font-size:26px;font-weight:800;letter-spacing:-.5px}
.stat-sub{font-size:11px;color:var(--text-dim);margin-top:4px}

/* ── TABLES ── */
.tw{overflow-x:auto;-webkit-overflow-scrolling:touch;border:1px solid var(--border);border-radius:12px}
.tbl{width:100%;border-collapse:collapse;font-size:12.5px}
.tbl th{background:var(--surface-2);color:var(--text-muted);font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;padding:11px 14px;text-align:left;border-bottom:1px solid var(--border);white-space:nowrap}
.tbl td{padding:10px 14px;border-bottom:1px solid var(--border);vertical-align:middle}
.tbl tr:last-child td{border-bottom:none}
.tbl tbody tr{cursor:default}
.tbl tr.clickable{cursor:pointer}
.tbl tr.clickable:hover td{background:var(--surface-2)}
.tbl td .inp,.tbl td .sel{padding:6px 8px;font-size:12px}
.tbl-empty{text-align:center;padding:26px;color:var(--text-muted)}
.rt{font-weight:700;color:var(--primary);white-space:nowrap}

/* ── LIST ROWS (customers/jobs) ── */
.lrow{display:flex;align-items:center;gap:14px;padding:14px 16px;border:1px solid var(--border);border-radius:12px;background:var(--surface);margin-bottom:9px;cursor:pointer;transition:.12s}
.lrow:hover{border-color:var(--border-2);background:var(--surface-2);box-shadow:var(--shadow-sm)}
.avatar{width:40px;height:40px;border-radius:11px;background:linear-gradient(135deg,var(--primary),var(--primary-2));display:flex;align-items:center;justify-content:center;font-weight:700;color:#fff;font-size:14px;flex-shrink:0}
.avatar.sm{width:30px;height:30px;font-size:12px;border-radius:9px}

/* ── TABS ── */
.tabs{display:flex;gap:3px;border-bottom:1px solid var(--border);margin-bottom:18px;overflow-x:auto}
.tab{padding:10px 15px;font-size:13px;font-weight:600;color:var(--text-muted);cursor:pointer;background:none;border:none;border-bottom:2px solid transparent;font-family:inherit;white-space:nowrap;display:flex;align-items:center;gap:6px}
.tab:hover{color:var(--text-dim)}
.tab.on{color:var(--primary);border-bottom-color:var(--primary)}
.tab-dot{width:8px;height:8px;border-radius:50%;background:var(--danger);display:inline-block;box-shadow:0 0 0 2px var(--surface)}
/* Two-column tab layout: left group hugs the left edge, right group the right. */
.tabs-split{justify-content:space-between;gap:16px}
.tab-group{display:flex;gap:3px}
/* Small "new from installer" flag on a jobs-list card */
.kcard-flag{display:inline-flex;align-items:center;gap:4px;font-size:10.5px;font-weight:700;color:var(--danger);background:var(--danger-soft);border-radius:20px;padding:1px 8px}
.subtabs{display:flex;gap:7px;margin-bottom:16px}
.stab{padding:8px 16px;border-radius:9px;font-size:13px;font-weight:600;cursor:pointer;border:1px solid var(--border);background:var(--surface-2);color:var(--text-dim);font-family:inherit;display:inline-flex;align-items:center;gap:6px}
.stab.on{background:var(--primary-soft);color:var(--primary);border-color:var(--border-2);font-weight:700}

/* ── KANBAN ── */
.kanban{display:flex;gap:14px;overflow-x:auto;padding-bottom:8px;align-items:flex-start}
.kcol{flex:0 0 260px;background:var(--surface-2);border:1px solid var(--border);border-radius:14px;padding:12px;min-height:120px}
.kcol.drag{border-color:var(--primary);background:var(--primary-soft)}
.kcol-h{display:flex;align-items:center;justify-content:space-between;font-size:12px;font-weight:700;margin-bottom:10px;padding:0 3px}
.kcard{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:11px 12px;margin-bottom:8px;cursor:grab;box-shadow:var(--shadow-sm)}
.kcard:hover{border-color:var(--border-2)}
.kcard:active{cursor:grabbing}
.kcard-t{font-size:13px;font-weight:600;margin-bottom:3px}
.kcard-m{font-size:11px;color:var(--text-muted)}

/* ── SCHEDULER ── */
.sched-toolbar{display:flex;align-items:center;justify-content:space-between;gap:14px;flex-wrap:wrap;margin-bottom:14px}
.sched-filters{margin-bottom:16px}
.sched-filters .sel,.sched-filters .inp{width:auto;min-width:150px}
.sched-dow-row{display:grid;grid-template-columns:repeat(7,1fr);border-bottom:1px solid var(--border);margin-bottom:2px}
.sched-dow{padding:6px 8px;font-size:10.5px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;color:var(--text-muted);text-align:center}
.sched-month-grid{display:grid;grid-template-columns:repeat(7,1fr);grid-auto-rows:1fr;gap:1px;background:var(--border)}
.sched-cell{background:var(--surface);min-height:96px;padding:6px;cursor:pointer;transition:.12s;display:flex;flex-direction:column;gap:4px}
.sched-cell:hover{background:var(--surface-2)}
.sched-cell.dim{background:var(--bg);opacity:.55}
.sched-cell.today .sched-cell-num{background:var(--primary);color:#fff;border-radius:20px}
.sched-cell-num{font-size:12px;font-weight:700;width:22px;height:22px;display:flex;align-items:center;justify-content:center}
.sched-cell-appts{display:flex;flex-direction:column;gap:3px;overflow:hidden}
.sched-chip{font-size:10.5px;padding:2px 6px;border-radius:5px;background:var(--info-soft);color:var(--info);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
.sched-more{font-size:10.5px;color:var(--text-muted);padding:0 2px}

/* ── APPOINTMENT TYPE COLOURS ── one hue per type. On the small Month-view
   chips (.sched-chip) the whole tag is tinted; on the larger Week/Day/List
   cards (.appt-card) only a left accent bar is tinted, so the card's own
   text stays fully readable at normal contrast. .is-cancelled/.is-completed
   layer on top of any type without changing its hue. */
.sched-chip.appt-type-measurement{background:var(--type-measurement-soft);color:var(--type-measurement)}
.sched-chip.appt-type-quote{background:var(--type-quote-soft);color:var(--type-quote)}
.sched-chip.appt-type-carpet{background:var(--type-carpet-soft);color:var(--type-carpet)}
.sched-chip.appt-type-hardfloor{background:var(--type-hardfloor-soft);color:var(--type-hardfloor)}
.sched-chip.appt-type-pickup{background:var(--type-pickup-soft);color:var(--type-pickup)}
.sched-chip.appt-type-followup{background:var(--type-followup-soft);color:var(--type-followup)}
.sched-chip.appt-type-invoice{background:var(--type-invoice-soft);color:var(--type-invoice)}
.sched-chip.appt-type-default{background:var(--type-default-soft);color:var(--type-default)}
.appt-card.appt-type-measurement{border-left:3px solid var(--type-measurement)}
.appt-card.appt-type-quote{border-left:3px solid var(--type-quote)}
.appt-card.appt-type-carpet{border-left:3px solid var(--type-carpet)}
.appt-card.appt-type-hardfloor{border-left:3px solid var(--type-hardfloor)}
.appt-card.appt-type-pickup{border-left:3px solid var(--type-pickup)}
.appt-card.appt-type-followup{border-left:3px solid var(--type-followup)}
.appt-card.appt-type-invoice{border-left:3px solid var(--type-invoice)}
.appt-card.appt-type-default{border-left:3px solid var(--type-default)}
.is-cancelled{text-decoration:line-through;opacity:.55}
.is-completed{opacity:.82}
.sched-week-grid{display:grid;grid-template-columns:repeat(7,1fr);gap:10px}
.sched-week-col{background:var(--surface);border:1px solid var(--border);border-radius:12px;padding:10px;min-height:220px}
.sched-week-hd{font-size:12px;font-weight:700;margin-bottom:8px;cursor:pointer;padding-bottom:6px;border-bottom:1px solid var(--border)}
.appt-card{background:var(--surface-2);border:1px solid var(--border);border-radius:10px;padding:9px 10px;margin-bottom:7px;cursor:pointer;transition:.12s}
.appt-card:hover{border-color:var(--border-2);background:var(--surface-3)}
.appt-card-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:4px}
.appt-card-time{font-size:11px;font-weight:700;color:var(--text-dim)}
.appt-card-title{font-size:13px;font-weight:600;margin-bottom:2px}
.appt-card-sub{font-size:11.5px;color:var(--text-muted)}

/* ── TOTALS BOX ── */
.totals{background:var(--surface-2);border:1px solid var(--border);border-radius:12px;padding:16px;margin-top:12px}
.trow{display:flex;justify-content:space-between;padding:5px 0;font-size:13px;color:var(--text-dim);border-bottom:1px solid var(--border)}
.trow:last-child{border-bottom:none}
.tgrand{display:flex;justify-content:space-between;font-size:18px;font-weight:800;margin-top:8px;padding-top:10px;border-top:1px solid var(--border-2)}
.tgrand b{color:var(--primary)}

/* ── ADDRESS AUTOCOMPLETE ── */
.addr-wrap{position:relative}
.addr-sug{position:absolute;top:calc(100% + 4px);left:0;right:0;background:var(--surface);border:1px solid var(--border-2);border-radius:10px;z-index:300;overflow:hidden;box-shadow:var(--shadow)}
.addr-item{padding:10px 13px;cursor:pointer;font-size:12.5px;border-bottom:1px solid var(--border)}
.addr-item:last-child{border-bottom:none}
.addr-item:hover{background:var(--primary-soft)}
.addr-main{font-weight:600}
.addr-sub{font-size:11px;color:var(--text-muted);margin-top:1px}
.addr-loading{padding:11px 13px;font-size:12px;color:var(--text-muted);display:flex;gap:8px;align-items:center}
.gps-btn{display:inline-flex;align-items:center;gap:6px;padding:7px 12px;background:var(--success-soft);border:none;border-radius:8px;color:var(--success);font-size:12px;font-weight:600;cursor:pointer;font-family:inherit}
.gps-btn:disabled{opacity:.5}
.spin{width:11px;height:11px;border:2px solid var(--text-muted);border-top-color:var(--primary);border-radius:50%;animation:spin .7s linear infinite;display:inline-block}
@keyframes spin{to{transform:rotate(360deg)}}

/* ── MODAL ── */
.overlay{position:fixed;inset:0;background:rgba(0,0,0,0.6);backdrop-filter:blur(4px);display:flex;align-items:flex-start;justify-content:center;z-index:400;padding:40px 16px;overflow-y:auto}
.modal{background:var(--surface);border:1px solid var(--border-2);border-radius:16px;box-shadow:var(--shadow);width:100%;max-width:540px;padding:26px}
.modal.wide{max-width:720px}
.modal-h{font-size:17px;font-weight:800;margin-bottom:4px}
.modal-sub{font-size:12.5px;color:var(--text-muted);margin-bottom:18px}
.modal-acts{display:flex;gap:9px;justify-content:flex-end;margin-top:20px}

/* ── TOASTS ── */
.toasts{position:fixed;bottom:20px;right:20px;z-index:600;display:flex;flex-direction:column;gap:9px}
.toast{background:var(--surface);border:1px solid var(--border-2);border-left:3px solid var(--primary);border-radius:12px;padding:12px 16px;font-size:13px;font-weight:500;box-shadow:var(--shadow);min-width:230px;animation:slidein .2s ease}
.toast.success{border-left-color:var(--success)} .toast.error{border-left-color:var(--danger)} .toast.warning{border-left-color:var(--warning)}
@keyframes slidein{from{transform:translateX(30px);opacity:0}to{transform:none;opacity:1}}

/* ── MISC ── */
.empty{text-align:center;padding:60px 20px;color:var(--text-muted)}
.empty .ico{font-size:46px;opacity:.4;margin-bottom:12px}
.empty .t{font-size:16px;font-weight:600;color:var(--text-dim);margin-bottom:5px}
.pill{padding:2px 9px;border-radius:20px;font-size:11px;font-weight:600;background:var(--surface-3);color:var(--text-dim)}
.chk{display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:13px;color:var(--text-dim)}
.chk input{accent-color:var(--primary);width:15px;height:15px;cursor:pointer}
.timeline-item{display:flex;gap:11px;padding:9px 0;border-bottom:1px solid var(--border)}
.timeline-item:last-child{border-bottom:none}
.tl-dot{width:9px;height:9px;border-radius:50%;background:var(--primary);margin-top:5px;flex-shrink:0}
.tl-txt{font-size:13px} .tl-time{font-size:11px;color:var(--text-muted);margin-top:2px}
/* Photo tile: square media area with the caption in its own readable strip
   BELOW the image (normal text on a surface background), never overlaid in
   white on top of the photo. */
.photo{position:relative;border-radius:10px;overflow:hidden;border:1px solid var(--border);background:var(--surface-2);display:flex;flex-direction:column}
.photo img,.photo video{width:100%;aspect-ratio:1;object-fit:cover;display:block;background:#000;flex-shrink:0}
.photo .rm{position:absolute;top:5px;right:5px;background:rgba(0,0,0,.6);color:#fff;border:none;border-radius:6px;width:24px;height:24px;cursor:pointer}
.photo-caption{color:var(--text);font-size:12px;font-weight:500;padding:7px 9px;line-height:1.45;border-top:1px solid var(--border);background:var(--surface-2);word-break:break-word;flex:1}
.progress-steps{display:flex;gap:5px;align-items:center;flex-wrap:wrap;margin-top:6px}
.pstep{font-size:10px;padding:2px 9px;border-radius:5px;border:1px solid var(--border);color:var(--text-muted)}
.pstep.done{background:var(--primary-soft);border-color:var(--border-2);color:var(--primary)}
.parrow{font-size:9px;color:var(--text-muted)}
.bar-track{height:9px;background:var(--surface-3);border-radius:6px;overflow:hidden}
.bar-fill{height:100%;background:linear-gradient(90deg,var(--primary),var(--primary-2))}

/* ── LOGIN SCREEN ── premium light look: soft beige/gold radial shapes behind
   a centred white card. Deliberately fixed light tones (not theme vars) for
   the background blobs specifically, same reasoning as the print/document
   preview above - a sign-in page should look the same regardless of which
   in-app theme is currently selected. */
.login-wrap{height:100vh;display:flex;align-items:center;justify-content:center;background:
  radial-gradient(600px 400px at 12% 8%, rgba(197,133,58,0.16), transparent 60%),
  radial-gradient(700px 500px at 88% 92%, rgba(69,34,5,0.10), transparent 60%),
  linear-gradient(180deg, #faf8f4, #f4efe6)}
.login-card{width:100%;max-width:400px;background:var(--surface);border:1px solid var(--border);border-radius:20px;padding:36px 34px;box-shadow:0 20px 50px rgba(36,23,5,0.14)}
.login-brand{display:flex;align-items:center;justify-content:center;margin-bottom:18px}
.login-title{text-align:center;font-size:22px;font-weight:800;margin-bottom:6px;color:var(--text)}
.login-sub{text-align:center;color:var(--text-muted);font-size:12.5px;margin-bottom:24px}
.login-err{background:var(--danger-soft);color:var(--danger);border-radius:8px;padding:9px 12px;font-size:12.5px;margin-bottom:14px}
.login-input-wrap{position:relative}
.login-input-wrap .inp{padding-left:38px}
.login-input-icon{position:absolute;left:12px;top:50%;transform:translateY(-50%);color:var(--text-muted);display:flex;pointer-events:none}
.login-eye-btn{position:absolute;right:10px;top:50%;transform:translateY(-50%);background:none;border:none;color:var(--text-muted);cursor:pointer;padding:4px;display:flex}
.login-eye-btn:hover{color:var(--text)}
.login-row-between{display:flex;align-items:center;justify-content:space-between;margin:2px 0 18px;font-size:12.5px}
.login-row-between .chk{font-size:12.5px}
.login-forgot{color:var(--primary-2);font-weight:600;cursor:pointer;background:none;border:none;font-family:inherit;font-size:12.5px;padding:0}
.login-forgot:hover{text-decoration:underline}
.login-help{text-align:center;margin-top:20px;font-size:11.5px;color:var(--text-muted);line-height:1.6}

/* ── COMPANY LOGO (reusable everywhere: login, sidebar, print/PDF headers, previews) ──
   Always sized with object-fit:contain so the full logo shows — never cropped,
   stretched or recoloured. A white "plate" sits behind it so the logo's own
   colours stay accurate even when the surrounding UI is in dark mode. ── */
.logo-plate{background:#fff;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;box-shadow:0 1px 3px rgba(0,0,0,0.12)}
.logo-plate.login{padding:14px 20px;margin-bottom:2px}
.logo-plate.nav{padding:12px 18px;border:1px solid var(--border);border-radius:14px}
.company-logo{max-width:180px;max-height:80px;width:auto;height:auto;object-fit:contain;display:block}
.login-logo{max-width:200px;max-height:110px;width:auto;height:auto;object-fit:contain;display:block}
.nav-logo{max-width:160px;max-height:62px;width:auto;height:auto;object-fit:contain;display:block}
/* ── DOCUMENT / PRINT PREVIEW  ──────────────────────────────────────────────
   Used by every in-app "this is exactly what prints" preview (Invoice
   preview, Job Sheet, etc). Deliberately fixed light "paper" colours instead
   of the app's dark/light theme variables — a printed document always looks
   like white paper with the brand's own brown/gold palette, regardless of
   which theme the office is using inside the app, so preview always matches
   the actual PDF/print output exactly. The same class names + look are
   mirrored in the print template's own stylesheet (see 06-print.js). ── */
.document-header{display:flex;align-items:center;gap:16px;padding-bottom:18px;margin-bottom:20px;border-bottom:2px solid #c5853a}
.document-header .brand-divider{width:1px;align-self:stretch;background:#e7e0d3}
.document-header .company-details{font-size:12.5px;color:#5c4a2f;line-height:1.9}
.document-header .company-details .abn{color:#9c8b6f}
.document-header .company-details b{color:#241705;font-size:14px}

/* Two-column "Customer Details / Job Details" style block used by every
   preview & print document - replaces the old text-align:right column,
   which pushed labels/values to the far edge and mangled long values (like
   a warehouse pickup address) into one unreadable line. */
.document-details-grid{display:grid;grid-template-columns:1fr 1fr;gap:28px;align-items:start;margin-bottom:20px}
.document-detail-card{border:1px solid #e7e0d3;border-radius:8px;padding:14px 16px;background:#fffdfa}
.document-detail-title{font-size:11px;font-weight:700;letter-spacing:.05em;text-transform:uppercase;color:#9b6a2f;margin-bottom:10px}
.document-detail-row{display:grid;grid-template-columns:96px 1fr;gap:8px;margin-bottom:6px;line-height:1.4;font-size:12.5px}
.document-detail-row:last-child{margin-bottom:0}
.document-detail-label{font-weight:700;color:#241705}
.document-detail-value{color:#3a2c17;word-break:break-word;overflow-wrap:anywhere;white-space:normal}
.document-detail-value.multiline{white-space:pre-line}
@media (max-width:720px){ .document-details-grid{grid-template-columns:1fr} }

/* ── ROLE BADGES ── */
.role-admin{background:var(--danger-soft);color:var(--danger)}
.role-office{background:var(--info-soft);color:var(--info)}
.role-installer{background:var(--warning-soft);color:var(--warning)}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE / TABLET  — the whole app must be usable in a phone browser (installers
   on site, staff on the go). Off-canvas nav, everything wide scrolls INSIDE its
   own container (the page body never scrolls sideways), modals fit and scroll,
   and tap targets are finger-sized. Purely presentational — no JS/logic touched.
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width:820px){
  /* Off-canvas drawer + the topbar hamburger that opens it */
  .nav{position:fixed;z-index:500;height:100%;width:min(84vw,300px);transform:translateX(-100%);transition:transform .2s ease;box-shadow:var(--shadow)}
  .nav.open{transform:none}
  .topbar .nav-toggle{display:inline-flex}
  .nav-item{min-height:44px}

  /* Topbar: keep it from overflowing — drop the ⌘K hint, let search shrink */
  .topbar{padding:0 12px;gap:8px}
  .top-search{max-width:none}
  .top-search .kbd{display:none}
  .top-title{font-size:14px}

  /* Comfortable page gutters + clearance for the fixed bottom nav */
  .page{padding:16px 14px calc(80px + env(safe-area-inset-bottom))}

  /* Bottom nav: the everyday pages within thumb reach. Sits below the
     drawer's backdrop (z 490) so opening the menu dims it too. */
  .bottom-nav{display:flex;position:fixed;left:0;right:0;bottom:0;z-index:480;background:var(--surface);border-top:1px solid var(--border);padding-bottom:env(safe-area-inset-bottom);box-shadow:0 -4px 16px rgba(36,23,5,0.07)}
  .bn-item{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:58px;padding:8px 2px;background:none;border:none;font-family:inherit;font-size:10.5px;font-weight:600;color:var(--text-muted);cursor:pointer}
  .bn-item span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
  .bn-item.on{color:var(--primary-2)}
  .bn-item:active{background:var(--surface-2)}

  /* Kanban boards: swipe one column at a time instead of free-scrolling */
  .kanban{scroll-snap-type:x proximity;scroll-padding-left:14px}
  .kcol{scroll-snap-align:start;flex:0 0 84%}

  /* Tap targets: finger-sized inputs/buttons/tabs */
  .btn{min-height:40px}
  .btn-sm{min-height:34px}
  .inp,.sel,.ta{min-height:42px;font-size:16px}   /* 16px stops iOS zoom-on-focus */
  .tab,.stab{min-height:40px}

  /* Wide surfaces scroll within themselves, never the page */
  .tabs,.subtabs{overflow-x:auto;-webkit-overflow-scrolling:touch;flex-wrap:nowrap}
  .subtabs{padding-bottom:2px}
  .kanban{-webkit-overflow-scrolling:touch}
  .tbl th,.tbl td{padding:9px 11px}

  /* Modals fill the screen sensibly and scroll internally */
  .overlay{padding:12px;align-items:flex-start}
  .modal,.modal.wide{max-width:100%;max-height:calc(100dvh - 24px);overflow-y:auto;padding:18px}
  .modal-acts{flex-wrap:wrap}

  /* Calendar month grid stays legible: give it a min width and let it scroll */
  .sched-toolbar{gap:8px}
  .sched-dow-row,.sched-month-grid{min-width:640px}
  .sched-month-wrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:12px}
  .sched-week-grid{grid-template-columns:repeat(7,minmax(160px,1fr));overflow-x:auto;-webkit-overflow-scrolling:touch}

  /* Toasts span the width and sit above the bottom nav */
  .toasts{left:12px;right:12px;bottom:calc(70px + env(safe-area-inset-bottom))}
  .toast{min-width:0}
}
@media (max-width:560px){
  .page{padding:13px 11px calc(80px + env(safe-area-inset-bottom))}
  .card{padding:15px;border-radius:12px}
  .page-head-title{font-size:19px}
  .stat-val{font-size:22px}
  /* Stack every auto-fit grid into a single column so nothing gets squeezed */
  .g2,.g3,.g4{grid-template-columns:1fr}
  /* Action rows: let buttons wrap instead of overflowing; modal actions
     become full-width stacked buttons that are easy to hit */
  .sec-hd,.modal-acts,.save-bar{flex-wrap:wrap}
  .modal-acts .btn{flex:1 1 auto;justify-content:center}
  .save-bar{padding:10px 12px}
  /* Full-width primary actions read better on a narrow screen */
  .page-head-actions{width:100%}
  .page-head-actions .btn{flex:1;justify-content:center}
}
