:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e3e8ef;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --primary: #0d9488;
  --primary-50: #ecfdf8;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --sidebar: #0b1f2a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.01em; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; background: var(--sidebar); color: #cbd5e1;
  position: fixed; top: 0; bottom: 0; left: 0;
  display: flex; flex-direction: column; z-index: 40;
  transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; color: #fff; }
.brand .bname { font-weight: 800; font-size: 17px; }
.brand small { display: block; color: #7f97a6; font-size: 12px; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #3b82f6);
  display: grid; place-items: center; color: #fff;
}
.brand-logo .icon { width: 20px; height: 20px; fill: #fff; stroke: none; }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; scrollbar-width: thin; scrollbar-color: #26404d transparent; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: #5d7584; padding: 16px 10px 6px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
  color: #c3d0d9; font-weight: 500; text-decoration: none; margin-bottom: 1px;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.active { background: rgba(45, 212, 191, .14); color: #5eead4; }
.nav .count { margin-left: auto; background: #ef4444; color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.sidebar-foot { padding: 14px 20px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; color: #5d7584; }

.main { flex: 1; margin-left: 248px; min-width: 0; }
.topbar {
  height: 60px; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .today { color: var(--muted); font-weight: 500; }
.spacer { flex: 1; }
.menu-btn { display: none !important; }
.content { padding: 24px; max-width: 1440px; margin: 0 auto; }
.nav-overlay { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; margin: 0 0 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 500; margin-bottom: 8px; }

/* ---------- Cards & grids ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-head h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.two-col.even { grid-template-columns: 1fr 1fr; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }

.kpi { padding: 18px; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 8px; }
.kpi .label .icon { width: 30px; height: 30px; padding: 7px; border-radius: 8px; background: var(--primary-50); color: var(--primary); }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 10px; letter-spacing: -.02em; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.up { color: var(--success); font-weight: 700; }
.down { color: var(--danger); font-weight: 700; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none !important; white-space: nowrap; line-height: 1.2;
  transition: background .12s, border-color .12s, filter .12s;
}
.btn:hover { background: var(--surface-2); border-color: #cfd8e3; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary); border-color: var(--primary); filter: brightness(.92); }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: var(--danger); filter: brightness(.92); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-lg { padding: 13px 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn .icon { width: 16px; height: 16px; }
.mr-auto { margin-right: auto; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }

.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; vertical-align: middle; }
.icon.xs { width: 12px; height: 12px; }
.icon.sm { width: 14px; height: 14px; }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border); }
.r { text-align: right !important; }
.c { text-align: center; }
.nowrap { white-space: nowrap; }

.li { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.li:last-child { border-bottom: 0; }
.li.clickable { cursor: pointer; }
.li.clickable:hover { background: var(--surface-2); }
.grow { flex: 1; min-width: 0; }
.time-col { display: flex; flex-direction: column; min-width: 74px; font-size: 13px; }
.strong { font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.big { font-size: 20px; font-weight: 800; }
.pre { white-space: pre-wrap; margin: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #475569; white-space: nowrap; line-height: 1.3; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.teal { background: #ccfbf1; color: #0f766e; }
.badge.purple { background: #ede9fe; color: #6d28d9; }
[data-seg="residential"] .com-only, [data-seg="commercial"] .res-only { display: none !important; }
.tag.seg { background: #e0f2fe; color: #0369a1; }
.seg-pick { display: flex; gap: 8px; margin-bottom: 16px; }
.seg-pick .check { flex: 1; justify-content: center; padding: 10px; font-weight: 600; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; background: #eef2ff; color: #4338ca; margin-left: 4px; }

.svc-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12px; color: var(--text-2); }
.svc-tag i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); display: inline-block; }

.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex-shrink: 0; vertical-align: middle; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
/* Company logo */
.logo-box { display: inline-flex; align-items: center; justify-content: flex-start; flex-shrink: 0; }
.logo-box img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-box.lg-side { background: #fff; border-radius: 10px; padding: 6px 10px; height: 52px; max-width: 100%; }
.logo-box.lg-doc { height: 64px; max-width: 220px; }
.logo-box.lg-public { height: 48px; max-width: 180px; }
.brand-with-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.logo-field .logo-preview { width: 180px; height: 80px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; padding: 8px; flex-shrink: 0; }
.logo-field .logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
img.avatar { object-fit: cover; background: var(--surface-2); }
.avatar.xl { width: 72px; height: 72px; font-size: 24px; }
.photo-field { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 12px; border: 1px dashed var(--border); border-radius: 12px; }
.photo-field .btn-row { margin: 6px 0 4px; }
.avatars { display: flex; padding-left: 6px; }
.avatars .avatar { margin-left: -6px; border: 2px solid #fff; }
.who { display: flex; align-items: center; gap: 8px; margin: 4px 0; }

.empty { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; color: #cbd5e1; margin-bottom: 8px; }

.bar { height: 8px; background: #eef2f6; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; }
.hbar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 12px; align-items: center; margin-bottom: 10px; font-size: 13px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; color: var(--text); width: 100%; min-width: 0;
}
input[type=color] { padding: 3px; height: 40px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--primary); }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: 3px solid color-mix(in srgb, var(--primary) 22%, transparent); border-color: var(--primary); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.inline { display: flex; gap: 6px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check { display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 500; background: #fff; user-select: none; }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-50); }
.radios { display: flex; flex-direction: column; gap: 8px; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 0 10px; display: flex; gap: 8px; align-items: center; }
.section-title:first-child { margin-top: 0; }
.price-hint { background: var(--primary-50); color: #115e59; border-radius: 8px; padding: 9px 12px; margin: -4px 0 14px; font-size: 13px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.price-hint:empty { display: none; }
.price-hint .icon { width: 14px; height: 14px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar select, .toolbar input { width: auto; }
.search { position: relative; }
.search input { padding-left: 34px; min-width: 240px; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 7px 13px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--primary-50); color: var(--primary); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tab { padding: 10px 14px; border: 0; background: none; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.dropdown .menu { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 30px rgba(15, 23, 42, .14); min-width: 210px; padding: 6px; display: none; z-index: 60; }
.dropdown.open .menu { display: block; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; font: inherit; text-align: left; border-radius: 6px; cursor: pointer; color: var(--text); font-weight: 500; }
.menu button:hover { background: var(--surface-2); }

/* ---------- Modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 100; animation: fade .15s; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 640px; box-shadow: 0 24px 60px rgba(0, 0, 0, .28); animation: pop .16s ease-out; }
.modal.lg { max-width: 900px; }
.modal.sm { max-width: 440px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }

#toast-root { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast { background: #0f172a; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: pop .2s; font-weight: 500; max-width: 360px; transition: opacity .3s; }
.toast.error { background: var(--danger); }
.toast.out { opacity: 0; }

/* ---------- Job detail ---------- */
.job-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.dl { margin-bottom: 14px; }
.dl > span:first-child { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.note-box { background: #f0f9ff; border: 1px solid #bae6fd; color: #075985; border-radius: 8px; padding: 8px 11px; margin-bottom: 8px; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.note-box.amber { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.note-box .icon { width: 15px; height: 15px; margin-top: 2px; }
.checklist { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; }
.ck { display: flex; gap: 9px; align-items: flex-start; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.ck input { margin-top: 2px; }
.ck:has(input:checked) span { text-decoration: line-through; color: var(--muted); }

/* ---------- Calendar ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(150px, 1fr)); gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.day-col { background: #fff; border: 1px solid var(--border); border-radius: 10px; min-height: 460px; display: flex; flex-direction: column; min-width: 0; }
.day-col.today { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 18%, transparent); }
.day-col.past { background: #fbfcfd; }
.day-head { padding: 10px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; }
.day-head .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: .05em; }
.day-head .dnum { font-size: 20px; font-weight: 800; }
.day-col.today .dnum { color: var(--primary); }
.day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; flex: 1; cursor: copy; }
.add-hint { color: #b6c2cf; text-align: center; font-size: 12px; padding: 6px; margin-top: auto; border: 1px dashed transparent; border-radius: 8px; }
.day-body:hover .add-hint { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.job-chip { border-left: 4px solid var(--c, var(--primary)); background: color-mix(in srgb, var(--c, #0d9488) 8%, #fff); border-radius: 7px; padding: 7px 9px; font-size: 12px; cursor: pointer; box-shadow: 0 1px 0 rgba(15, 23, 42, .04); }
.job-chip:hover { background: color-mix(in srgb, var(--c, #0d9488) 15%, #fff); }
.job-chip .t { font-weight: 700; display: flex; align-items: center; gap: 4px; }
.job-chip .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-chip .s { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-weight: 600; }
.job-chip.completed { opacity: .62; }
.job-chip.cancelled { opacity: .45; text-decoration: line-through; }
.job-chip.in_progress { box-shadow: 0 0 0 2px #f59e0b inset; }
.job-chip.unassigned { outline: 2px dashed #ef4444; outline-offset: -2px; }

.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--border); gap: 1px; }
.month .mh { background: var(--surface-2); padding: 8px; font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; }
.month .mc { background: #fff; min-height: 112px; padding: 6px; cursor: copy; min-width: 0; }
.month .mc.other { background: #fafbfc; }
.month .mc.other .mnum { color: #a3b1bf; }
.mtop { display: flex; justify-content: space-between; align-items: center; }
.mnum { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 12px; font-weight: 700; cursor: pointer; }
.mnum:hover { background: var(--surface-2); }
.mc.today .mnum { background: var(--primary); color: #fff; }
.mjob { font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-top: 3px; background: color-mix(in srgb, var(--c) 14%, #fff); border-left: 3px solid var(--c); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.mjob.cancelled { text-decoration: line-through; opacity: .5; }
.more { font-size: 11px; color: var(--primary); font-weight: 600; margin-top: 3px; cursor: pointer; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Estimate / quote ---------- */
.quote-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 20px; align-items: start; }
.estimate { background: linear-gradient(160deg, var(--primary-50), #f0f9ff); border: 1px solid color-mix(in srgb, var(--primary) 30%, transparent); border-radius: 12px; padding: 18px; }
.estimate .big { font-size: 32px; color: var(--primary); letter-spacing: -.02em; }
.est-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.mini { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.mini td { padding: 5px 0; border-bottom: 1px dashed #cfe3e0; }
.mini td:last-child { text-align: right; font-weight: 600; }
.sticky { position: sticky; top: 76px; }

/* ---------- Documents (invoice/quote) ---------- */
.doc { background: #fff; max-width: 860px; margin: 0 auto; padding: 48px; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 32px; }
.doc-co { display: flex; gap: 14px; }
.doc-co .brand-logo { width: 48px; height: 48px; }
.doc-title { font-size: 30px; font-weight: 800; letter-spacing: .04em; color: var(--primary); text-align: right; margin: 0; }
.doc-meta { text-align: right; color: var(--text-2); }
.doc-meta div { margin-top: 2px; }
.doc-to { margin-bottom: 26px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 2px solid var(--text); padding: 8px 6px; }
.doc td { padding: 11px 6px; border-bottom: 1px solid var(--border); }
.doc-totals { margin-left: auto; width: 300px; max-width: 100%; margin-top: 16px; }
.doc-totals div { display: flex; justify-content: space-between; padding: 5px 0; }
.doc-totals .grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 10px; font-size: 18px; font-weight: 800; }
.doc-foot { margin-top: 34px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.stamp { position: absolute; top: 230px; right: 56px; transform: rotate(-12deg); border: 4px solid var(--success); color: var(--success); font-size: 34px; font-weight: 900; padding: 4px 18px; border-radius: 10px; opacity: .25; letter-spacing: .1em; pointer-events: none; }
.doc-bar { max-width: 860px; margin: 0 auto 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Field app ---------- */
.field-app { max-width: 560px; margin: 0 auto; }
.fjob { margin-bottom: 14px; overflow: hidden; }
.fjob-head { padding: 14px 16px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--c, #0d9488) 7%, #fff); border-left: 5px solid var(--c, var(--primary)); }
.fjob-sec { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.fjob-sec:last-child { border-bottom: 0; }
.clock-btn { font-size: 16px; padding: 14px; }
.done-box { background: #dcfce7; color: #166534; border-radius: 10px; padding: 12px; text-align: center; font-weight: 600; }

/* ---------- Public booking ---------- */
.public { min-height: 100vh; background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 12%, #fff) 0, var(--bg) 340px); padding: 24px 16px 40px; }
.public-wrap { max-width: 1040px; margin: 0 auto; }
.public-head { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.public-head .brand-logo { width: 44px; height: 44px; }
.pname { font-size: 20px; font-weight: 800; }
.public h1 { margin: 0 0 4px; font-size: 26px; }
.public-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.center { text-align: center; }
.success-icon { width: 64px; height: 64px; border-radius: 50%; background: #dcfce7; color: var(--success); display: grid; place-items: center; margin: 0 auto 14px; }
.success-icon .icon { width: 32px; height: 32px; }

.link-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 12px; }
.link-box code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }

.emp-card { padding: 18px; }
.emp-top { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; background: var(--surface-2); border-radius: 10px; padding: 10px 4px; margin-bottom: 12px; }
.stat-row b { display: block; font-size: 17px; }
.stat-row span { font-size: 11px; color: var(--muted); }
.inactive { opacity: .55; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .two-col, .two-col.even { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35; }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex !important; }
  .content { padding: 16px; }
  .topbar { padding: 0 12px; }
  .topbar .today { display: none; }
  .quote-grid, .public-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .detail-grid { grid-template-columns: 1fr; }
  .search input { min-width: 0; width: 100%; }
  .search { flex: 1 1 200px; }
  .doc { padding: 24px; }
  .month .mc { min-height: 70px; }
  .mjob { display: none; }
  .modal-backdrop { padding: 12px 8px; }
  .hide-sm { display: none; }
}

/* ---------- Phones: app-like layout ---------- */
.bottom-nav { display: none; }
.install-banner { display: flex; align-items: center; gap: 10px; margin: 12px 16px 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.install-banner img { border-radius: 9px; }
.install-steps ol { padding-left: 20px; line-height: 1.7; }
@media (max-width: 900px) {
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 45; background: rgba(255, 255, 255, .97); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; color: var(--muted); font-size: 10.5px; font-weight: 600; text-decoration: none; border-radius: 10px; }
  .bottom-nav a .icon { width: 22px; height: 22px; }
  .bottom-nav a.active { color: var(--primary); }
  .content { padding-bottom: calc(90px + env(safe-area-inset-bottom)); }
  #toast-root { bottom: calc(80px + env(safe-area-inset-bottom)); right: 12px; left: 12px; align-items: stretch; }
  .topbar { padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
  .sidebar { z-index: 60; padding-top: env(safe-area-inset-top); }
  body.nav-open .nav-overlay { z-index: 55; }
}
@media (max-width: 700px) {
  /* Summary numbers: 2 per row, compact */
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .label { font-size: 12px; gap: 6px; }
  .kpi .label .icon { width: 24px; height: 24px; padding: 5px; }
  .kpi .value { font-size: 19px; margin-top: 6px; }
  .page-head h1 { font-size: 21px; }
  .page-head .actions { width: 100%; }
  .toolbar select, .toolbar input[type=date] { flex: 1 1 140px; }
  /* Schedule: days stacked vertically instead of 7 squeezed columns */
  .week { grid-template-columns: 1fr; overflow: visible; gap: 10px; }
  .day-col { min-height: 0; }
  .day-head { flex-direction: row; align-items: center; }
  .day-head > div:first-child { display: flex; align-items: baseline; gap: 8px; }
  .day-body { padding: 8px; }
  .day-body .add-hint { padding: 4px; }
  /* List tables become cards */
  .table-wrap:has(> .table.cardify) { overflow: visible; }
  .table.cardify thead { display: none; }
  .table.cardify, .table.cardify tbody, .table.cardify tfoot, .table.cardify tr { display: block; width: 100%; }
  .table.cardify tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table.cardify tbody tr:last-child { border-bottom: 0; }
  .table.cardify td { display: block; padding: 3px 0; border: 0; text-align: right !important; overflow: hidden; }
  .table.cardify td::before { content: attr(data-label); float: left; margin-right: 14px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding-top: 2px; }
  .table.cardify td .avatars, .table.cardify td .who { display: inline-flex; }
  .table.cardify td[data-label=""]::before { display: none; }
  .table.cardify td:first-child { display: block; text-align: left !important; font-size: 15px; padding-bottom: 6px; }
  .table.cardify td:first-child::before { display: none; }
  .table.cardify td:empty { display: none; }
  .table.cardify tr.clickable:hover td { background: transparent; }
  .table.cardify tr.clickable:active { background: var(--surface-2); }
  .table.cardify tfoot tr { background: var(--surface-2); }
  .table.cardify .avatars { justify-content: flex-end; }
  /* Modals: use the full width of the phone */
  /* bottom sheet: short forms sit at the bottom, tall ones scroll normally from the top.
     The top padding keeps the title and the close (X) button clear of the phone's status bar (time, battery). */
  /* the status-bar space is a border (outside the scroll area), so nothing can scroll above the window title */
  .modal-backdrop { padding: 0; border-top: env(safe-area-inset-top, 0px) solid transparent; align-items: flex-start; }
  .modal-head { position: sticky; top: 0; z-index: 2; background: #fff; border-radius: 16px 16px 0 0; }  .modal-head [data-close] { padding: 8px; }
  .modal-head [data-close] .icon { width: 22px; height: 22px; }
  .modal { border-radius: 16px 16px 0 0; max-width: none !important; margin-top: auto; animation: sheet-up .22s ease-out; }
  @keyframes sheet-up { from { opacity: 0; translate: 0 40px; } }
  .modal-foot { border-radius: 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .modal-foot .btn { flex: 1 1 auto; }
}

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .no-print, #toast-root, .nav-overlay, .bottom-nav, .install-banner { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  .card { box-shadow: none; }
  a { color: inherit; }
}

/* ---------- Login / sign up / admin ---------- */
.public { padding-top: calc(24px + env(safe-area-inset-top)); }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom)); background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 14%, #fff), var(--bg) 60%); }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }
.auth-card h2 { margin: 6px 0 8px; }
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-tabs { display: flex; width: 100%; margin-bottom: 18px; }
.auth-tabs button { flex: 1; }
.auth-error { color: var(--danger); font-weight: 600; margin-top: 10px; min-height: 1.2em; text-align: center; }
.btn:disabled { opacity: .6; cursor: wait; }
.save-state { font-size: 12px; color: var(--muted); opacity: 0; transition: opacity .2s; }
.save-state.on { opacity: 1; }
.trial-pill { background: rgba(45, 212, 191, .14); color: #5eead4; border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; font-weight: 600; }
.user-btn { padding: 4px; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.admin-wrap { min-height: 100vh; }
.admin-wrap .topbar .brand-logo { width: 30px; height: 30px; }

/* ---------- Properties (a client with several homes / locations) ---------- */
.place { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: #0369a1; background: #e0f2fe; border-radius: 5px; padding: 1px 6px; max-width: 100%; }
.job-chip .place { margin: 2px 0; font-size: 10.5px; }
.prop-item { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.prop-item:last-child { border-bottom: 0; }
.prop-item .note-box { margin: 0; }
.prop-head { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.prop-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); }
.prop-stats span { display: inline-flex; align-items: center; gap: 4px; }
/* ---------- Support mode (platform admin inside a company) ---------- */
.support-pill { display: inline-flex; align-items: center; gap: 8px; padding: 4px 4px 4px 10px; background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; border-radius: 999px; font-size: 13px; min-width: 0; }
.support-pill > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.support-pill .btn { border-radius: 999px; padding: 3px 10px; }
.support-status { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 12px; }
.support-status .icon { width: 22px; height: 22px; color: var(--muted); }
.support-status.on { background: #ecfdf5; border-color: #a7f3d0; }
.support-status.on .icon { color: var(--success); }

/* ---------- Language picker with flags ---------- */
.flag { width: 21px; height: 14px; border-radius: 2px; box-shadow: 0 0 0 1px rgba(15, 23, 42, .15); flex-shrink: 0; vertical-align: middle; }
.lang-btn { gap: 7px; padding: 7px 10px; }
.lang-btn .caret { font-size: 10px; color: var(--muted); }
.lang-pick .menu { min-width: 180px; }
.lang-pick .menu button.current { background: var(--primary-50); }
.check .flag { margin-right: 2px; }

/* ---------- Turnovers (Airbnb / on demand) ---------- */
.tv-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 10.5px; font-weight: 700; color: #9d174d; background: #fce7f3; border-radius: 5px; padding: 1px 6px; margin: 2px 4px 0 0; white-space: nowrap; }
.tv-badge.hot { color: #b91c1c; background: #fee2e2; }
.note-box.red { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.job-chip.alerted { outline: 2px solid #ef4444; outline-offset: -2px; }
.tv-panel { background: #fdf2f8; border: 1px solid #fbcfe8; border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.tv-line { font-size: 13px; }
.doc-to-wrap { display: flex; gap: 40px; flex-wrap: wrap; margin-bottom: 26px; }
.doc-to-wrap .doc-to { margin-bottom: 0; }
.mt-xs { margin-top: 6px; }
.doc-co:has(.logo-box) { flex-direction: column; gap: 10px; }

/* ---------- Address autocomplete ---------- */
.addr-ac { position: fixed; z-index: 3000; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(11, 31, 42, .18); overflow: hidden; max-height: 320px; overflow-y: auto; }
.addr-opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; cursor: pointer; }
.addr-opt + .addr-opt { border-top: 1px solid var(--border); }
.addr-opt:hover, .addr-opt.on { background: var(--primary-50); }
.addr-opt svg { flex: none; margin-top: 2px; color: var(--muted); }
.addr-opt b { display: block; font-weight: 600; font-size: 14px; }
.addr-opt span { display: block; font-size: 12.5px; color: var(--muted); }
.addr-msg { padding: 12px; font-size: 13px; color: var(--muted); }
.addr-src { padding: 4px 12px 6px; font-size: 10.5px; color: var(--muted); text-align: right; }
.field.f-state { max-width: 90px; }

/* ---------- Password field with strength meter ---------- */
.pw-wrap { display: flex; gap: 6px; align-items: center; }
.pw-in { position: relative; flex: 1; min-width: 0; }
.pw-in input { width: 100%; padding-right: 40px; }
.pw-eye { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: var(--muted); padding: 8px; cursor: pointer; display: flex; }
.pw-wrap > .btn { flex: none; white-space: nowrap; }
.pw-meter { height: 4px; border-radius: 4px; background: var(--border); margin-top: 6px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 4px; transition: width .2s, background .2s; }
.pw-meter[data-level="1"] span { width: 33%; background: var(--danger); }
.pw-meter[data-level="2"] span { width: 66%; background: var(--warning); }
.pw-meter[data-level="3"] span { width: 100%; background: var(--success); }
.pw-hint { margin-top: 4px; }

/* WhatsApp button (support) */
.btn-whatsapp { background: #25d366; border-color: #25d366; color: #fff; margin-top: 10px; }
.btn-whatsapp:hover { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
