[hidden] { display: none !important; }
/* Admin portal */
:root {
  --ink: #17221c; --ink-2: #44514a; --muted: #6b7770; --line: #dfe5e0; --panel: #f3f6f3; --bg: #fafbfa;
  --side: #17221c; --side-2: #24332b; --brand: #1f6f4a; --brand-dark: #144a31; --brand-tint: #e3f0e8; --accent: #e8a33d; --accent-tint: #fbefd9;
  --ok: #1d7a43; --warn: #b26b00; --err: #b42318; --err-tint: #fbe4e1; --radius: 6px;
  --f: 'Archivo', system-ui, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
/* Phones (1.0.3): iOS zooms the page in when a field's text is under 16px, and on a quick double tap. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: manipulation; }
a, button, input, select, textarea, label, summary, [role=button], [data-tab], .click, .kcard { touch-action: manipulation; }
@media (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { font-size: 16px !important; }
}
body { margin: 0; font: 400 15px/1.5 var(--f); color: var(--ink); background: var(--bg); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.boot { padding: 40px; color: var(--muted); }
h1, h2, h3 { font-stretch: 78%; font-weight: 850; line-height: 1.1; margin: 0; letter-spacing: -0.005em; }
h1 { font-size: 32px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; font-stretch: 85%; font-weight: 750; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* Shell */
.shell { display: grid; grid-template-columns: 228px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: #c8d2cb; padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side-brand { color: #fff; font-weight: 850; font-stretch: 75%; font-size: 21px; line-height: 1.1; padding: 4px 10px 18px; text-decoration: none; display: block; }
.side-brand small { display: block; font-size: 12px; font-weight: 500; font-stretch: 100%; color: #8d9a92; margin-top: 4px; }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; color: #c8d2cb; text-decoration: none; border-radius: var(--radius); font-weight: 500; }
.side nav a:hover { background: var(--side-2); color: #fff; }
.side nav a.on { background: var(--side-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.side nav .grp { font-size: 12px; color: #7d8b83; padding: 16px 10px 4px; }
.side .badge { background: var(--accent); color: var(--ink); font-size: 12px; font-weight: 800; border-radius: 99px; padding: 0 7px; }
.side-foot { margin-top: auto; padding: 16px 10px 0; border-top: 1px solid var(--side-2); font-size: 13px; }
.side-foot a { color: #c8d2cb; }
.main { min-width: 0; }
.topline { display: none; }
.page { padding: 24px 28px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }
.page-head:has(> h1 + .pill, > h1 + .status-select) h1 { margin-right: 0; }
.page-head > h1 + .pill, .page-head > h1 + .status-select { margin-right: auto; }
.crumb { font-size: 14px; margin-bottom: 6px; display: inline-block; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 60; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topline { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--side); color: #fff; position: sticky; top: 0; z-index: 40; }
  .topline button { background: var(--side-2); border: 0; color: #fff; padding: 8px 12px; border-radius: var(--radius); }
  .page { padding: 18px 14px 60px; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 650; font-size: 14px; padding: 8px 14px; border-radius: var(--radius); border: 1.5px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: progress; }
.btn-p { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-p:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-a { background: var(--accent); border-color: var(--accent); color: var(--ink); }
.btn-d { color: var(--err); }
.btn-d:hover { border-color: var(--err); }
.btn-sm { padding: 4px 9px; font-size: 13px; }
.btn-link { border: 0; background: none; padding: 4px; color: var(--brand); text-decoration: underline; font-weight: 500; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Panels / grid */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .g-side { grid-template-columns: minmax(0, 1fr); } .g3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin-bottom: 16px; }
.stat { padding: 14px 18px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-size: 28px; font-weight: 850; font-stretch: 72%; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
.stat.warn b { color: var(--warn); }
.stat a { color: inherit; text-decoration: none; }

/* Tables */
.tbl-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 650; color: var(--muted); font-size: 13px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--panel); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: #f7faf7; }
.tbl td.r, .tbl th.r { text-align: right; }
.panel .tbl th { background: none; padding-left: 0; }
.panel .tbl td { padding-left: 0; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* Pills */
.pill { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; background: var(--panel); color: var(--ink-2); white-space: nowrap; }
.pill.dot::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: 1px; }
.p-ok { background: var(--brand-tint); color: var(--brand-dark); }
.p-warn { background: var(--accent-tint); color: #7a4a00; }
.p-err { background: var(--err-tint); color: var(--err); }
.p-blue { background: #e3ecfb; color: #1e4fa8; }
.p-purple { background: #efe5fb; color: #6b21a8; }

/* Forms */
.fld { display: block; font-size: 13px; font-weight: 650; color: var(--ink-2); }
.fld > input, .fld > select, .fld > textarea, .inp { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1.5px solid #cbd4ce; border-radius: var(--radius); background: #fff; font-size: 15px; font-weight: 400; color: var(--ink); }
.fld > input[type=checkbox] { display: inline; width: auto; margin: 0 6px 0 0; }
.fld > input[type=color] { padding: 2px; height: 38px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.chk { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; color: var(--ink); }
.chk input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.f3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.f4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 700px) { .f2, .f3, .f4 { grid-template-columns: minmax(0, 1fr) !important; } } /* !important: some forms set columns inline */
.help { font-size: 13px; color: var(--muted); font-weight: 400; margin: 2px 0 0; }
.search { min-width: 240px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 12px; font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-2); }
.seg button + button { border-left: 1.5px solid var(--line); }
.seg button.on { background: var(--ink); color: #fff; }

/* Toggle switch */
.switch { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.switch input { appearance: none; width: 40px; height: 22px; background: #c7d0ca; border-radius: 99px; position: relative; flex: none; cursor: pointer; transition: background .15s; margin-top: 2px; }
.switch input::after { content: ''; position: absolute; width: 18px; height: 18px; background: #fff; border-radius: 50%; top: 2px; left: 2px; transition: left .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { left: 20px; }
.switch b { display: block; font-size: 15px; }
.switch span { font-size: 13px; color: var(--muted); }

/* Mode cards (quote toggle) */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 700px) { .modes { grid-template-columns: 1fr; } }
.mode { border: 2px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: pointer; display: block; }
.mode:has(input:checked) { border-color: var(--brand); background: var(--brand-tint); }
.mode input { accent-color: var(--brand); }
.mode b { font-size: 16px; }
.mode p { margin: 4px 0 0; font-size: 13px; color: var(--ink-2); }

/* Modal */
dialog#modal { border: 0; border-radius: 8px; padding: 0; width: min(680px, 100% - 20px); max-height: 92vh; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog#modal.wide { width: min(980px, 100% - 20px); }
dialog::backdrop { background: rgba(23,34,28,.45); }
.modal-in { display: flex; flex-direction: column; max-height: 92vh; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-b { padding: 18px 20px; overflow-y: auto; }
.modal-f { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: var(--panel); }
.modal-f .left { margin-right: auto; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); padding: 4px 8px; }

/* Toasts */
#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,.2); font-weight: 600; max-width: 360px; }
.toast.err { background: var(--err); }

/* Pipeline board */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: var(--panel); border-radius: var(--radius); padding: 10px; min-height: 200px; border-top: 4px solid var(--c, var(--line)); }
.col.drop { outline: 2px dashed var(--brand); }
.col-h { display: flex; justify-content: space-between; font-weight: 750; font-size: 14px; margin-bottom: 8px; }
.kcard { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; cursor: grab; font-size: 14px; }
.kcard:hover { border-color: var(--ink-2); }
.kcard b { display: block; }
.kcard .small { color: var(--muted); }

/* Client detail */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 14px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 14px 1fr; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--line); margin-top: 6px; }
.timeline li.t-note::before { background: var(--accent); }
.timeline li.t-status::before { background: var(--brand); }
.timeline li.t-payment::before { background: var(--ok); }
.timeline .when { font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1.5px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 9px 14px; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1.5px; white-space: nowrap; }
.tabs button.on { color: var(--ink); border-color: var(--brand); }
.status-select { font-weight: 700; padding: 6px 10px; border-radius: var(--radius); border: 1.5px solid var(--c); color: var(--c); background: #fff; }

/* Calendar */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--line); gap: 1px; }
.cal-h { background: var(--panel); padding: 6px 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.cal-d { background: #fff; min-height: 116px; padding: 6px; font-size: 12px; cursor: pointer; }
.cal-d:hover { background: #f7faf7; }
.cal-d.out { background: #fafbfa; color: #a5aea8; }
.cal-d.today .dn { background: var(--accent); color: var(--ink); }
.cal-d.blackout { background: repeating-linear-gradient(-45deg, #fff, #fff 6px, #f3f0ea 6px, #f3f0ea 12px); }
.dn { display: inline-block; font-weight: 750; font-size: 13px; padding: 0 6px; border-radius: 4px; margin-bottom: 4px; }
.ev { display: block; padding: 2px 6px; border-radius: 3px; margin-bottom: 2px; background: var(--brand-tint); color: var(--brand-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-left: 3px solid var(--tc, var(--brand)); font-weight: 500; }
.ev.requested { background: var(--accent-tint); color: #7a4a00; border-left-color: var(--accent); }
.ev.completed { background: #eef0ee; color: var(--muted); text-decoration: line-through; }
.ev.inspection { font-style: italic; }
.more { color: var(--muted); font-weight: 600; padding-left: 6px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(140px, 1fr)); gap: 8px; overflow-x: auto; }
.wcol { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; min-height: 300px; }
.wcol h3 { font-size: 15px; margin-bottom: 8px; }
.wcol.today { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.wev { border-left: 3px solid var(--tc, var(--brand)); background: var(--panel); padding: 6px 8px; border-radius: 4px; margin-bottom: 6px; font-size: 13px; cursor: pointer; }
.wev.requested { background: var(--accent-tint); }
.wev.completed { opacity: .55; }
@media (max-width: 760px) { .cal-d { min-height: 70px; } .ev { font-size: 0; height: 6px; padding: 0; margin-bottom: 2px; } }

/* Route */
.route { list-style: none; margin: 0; padding: 0; }
.route li { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.route .n { width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.route li.completed .n { background: var(--ok); }
.map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); z-index: 1; }
.map-tall { height: 560px; }
.pin { background: var(--ink); color: #fff; border-radius: 50%; width: 26px !important; height: 26px !important; display: grid; place-items: center; font: 800 13px var(--f); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.vtx { background: #fff; border: 2px solid var(--ink); border-radius: 50%; width: 12px !important; height: 12px !important; margin: -6px 0 0 -6px !important; }

/* Line items */
.items { width: 100%; border-collapse: collapse; }
.items th { font-size: 12px; color: var(--muted); text-align: left; padding: 4px 6px 4px 0; font-weight: 650; }
.items td { padding: 4px 6px 4px 0; vertical-align: top; }
.items input, .items select { width: 100%; padding: 7px 8px; border: 1.5px solid #cbd4ce; border-radius: var(--radius); font-size: 14px; }
.totals { margin-left: auto; width: min(320px, 100%); margin-top: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .t { font-weight: 850; font-size: 20px; font-stretch: 80%; border-top: 2px solid var(--ink); padding-top: 8px; margin-top: 4px; }

/* Bars (reports) */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 200px; padding-top: 18px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 46px; background: var(--brand); border-radius: 3px 3px 0 0; position: relative; min-height: 2px; }
.bar i span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; font-style: normal; color: var(--ink-2); white-space: nowrap; font-weight: 650; }
.bar small { font-size: 11px; color: var(--muted); margin-top: 4px; }
.hbar { display: grid; grid-template-columns: 150px minmax(0, 1fr) 90px; gap: 10px; align-items: center; font-size: 14px; padding: 4px 0; }
.hbar .track { height: 12px; background: var(--panel); border-radius: 3px; overflow: hidden; }
.hbar .track i { display: block; height: 100%; background: var(--brand); }

.login { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 20px; }
.login form { background: #fff; padding: 28px; border-radius: 8px; width: min(380px, 100%); display: grid; gap: 14px; }
.login h1 { font-size: 28px; }
.err-msg { color: var(--err); font-weight: 600; font-size: 14px; min-height: 1em; margin: 0; }
.notice { background: var(--accent-tint); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: var(--radius); font-size: 14px; margin-bottom: 14px; }
.notice.ok { background: var(--brand-tint); border-color: var(--brand); }
.sig { max-width: 260px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-grid img { aspect-ratio: 1; object-fit: cover; border-radius: var(--radius); width: 100%; }
.months-pick { display: flex; flex-wrap: wrap; gap: 4px; }
.months-pick label { font-size: 12px; border: 1.5px solid var(--line); border-radius: 4px; padding: 3px 6px; cursor: pointer; }
.months-pick label:has(input:checked) { background: var(--brand); color: #fff; border-color: var(--brand); }
.months-pick input { display: none; }
.drag { cursor: grab; color: var(--muted); padding: 0 6px; user-select: none; }

/* Installed app (public/js/pwa.js): offline bar, update prompt */
.net-bar { background: var(--warn); color: #fff; padding: calc(8px + env(safe-area-inset-top)) 14px 8px; font-size: 14px; font-weight: 600; text-align: center; }
.update-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 90; background: var(--ink); color: #fff; padding: 10px 12px 10px 16px; border-radius: 8px; display: flex; gap: 12px; align-items: center; box-shadow: 0 6px 24px rgba(0,0,0,.25); width: max-content; max-width: calc(100vw - 24px); }
.update-bar button { background: var(--accent); color: var(--ink); border: 0; border-radius: var(--radius); padding: 8px 12px; font-weight: 700; cursor: pointer; }

/* Office / Field switch (admin sidebar and mobile top bar) */
.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; background: var(--side-2); border-radius: 8px; padding: 3px; margin: 0 4px 14px; }
.view-switch a { text-align: center; padding: 7px 6px; border-radius: 6px; color: #c8d2cb; text-decoration: none; font-weight: 650; font-size: 14px; }
.view-switch a.on { background: #fff; color: var(--ink); }
.view-switch a:not(.on):hover { color: #fff; background: rgba(255,255,255,.08); }
.topline .t-field { margin-left: auto; background: var(--accent); color: var(--ink); text-decoration: none; font-weight: 700; padding: 8px 12px; border-radius: var(--radius); font-size: 14px; }
@media (max-width: 860px) { .topline { padding-top: calc(10px + env(safe-area-inset-top)); } }
