/* Brand fonts, bundled so the wordmark looks the same everywhere (SIL Open Font Licence, see fonts/) */
@font-face { font-family: "Bebas Neue"; src: url("fonts/bebas-neue.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Kaushan Script"; src: url("fonts/kaushan-script.woff2") format("woff2"); font-display: swap; }
:root {
  /* KK Pest Control brand: logo green, logo black, termite gold */
  --bg: #f3f5f3;
  --surface: #ffffff;
  --surface-2: #f7f9f7;
  --border: #e0e6e1;
  --text: #141714;
  --muted: #5b655d;
  --primary: #237f47;
  --brand-green: #2f8c53;
  --brand-red: #c8373a;
  --font-brand: "Bebas Neue", "Oswald", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-script: "Kaushan Script", "Brush Script MT", cursive;
  --primary-ink: #ffffff;
  --primary-soft: #e4f4ea;
  --gold: #d99a14;
  --gold-ink: #2b1d00;
  --side: #161816;
  --side-ink: #cfd6d0;
  --side-active: #222a24;
  --ok: #15803d;      --ok-soft: #e7f6ec;
  --warn: #b45309;    --warn-soft: #fdf3e2;
  --bad: #b91c1c;     --bad-soft: #fdecec;
  --info: #1d4ed8;    --info-soft: #e8efff;
  --neutral-soft: #edf0ed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 20, .06), 0 2px 8px rgba(20, 24, 20, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f120f; --surface: #171b18; --surface-2: #1c211d; --border: #2a322c;
    --text: #e6ebe7; --muted: #9aa59d; --primary: #4cbf78; --primary-ink: #04210f; --primary-soft: #153020;
    --gold: #f2c14e; --gold-ink: #2b1d00;
    --side: #0b0d0b; --side-ink: #c3ccc5; --side-active: #1c241e;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270e;
    --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #18244a; --neutral-soft: #1f2621;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f120f; --surface: #171b18; --surface-2: #1c211d; --border: #2a322c;
    --text: #e6ebe7; --muted: #9aa59d; --primary: #4cbf78; --primary-ink: #04210f; --primary-soft: #153020;
    --gold: #f2c14e; --gold-ink: #2b1d00;
    --side: #0b0d0b; --side-ink: #c3ccc5; --side-active: #1c241e;
    --ok: #4ade80; --ok-soft: #12301f; --warn: #fbbf24; --warn-soft: #33270e;
    --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #18244a; --neutral-soft: #1f2621;
    color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Layout ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar { width: 236px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 30; transition: transform .2s; }
.brand { display: flex; flex-direction: column; gap: 8px; padding: 14px 12px 10px; }
.brand-plate { background: #fff; border-radius: 10px; padding: 10px 12px; overflow: hidden; }
.brand-plate .lockup { gap: 6px; }
.brand-plate .lockup-mark { width: 40px; height: 33px; }
.brand-plate .lockup-word { font-size: 20.5px; }
.brand-plate .lockup-tag { font-size: 10.5px; }
.brand-sub { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .6; padding-left: 4px; }

/* Brand lockup: mark + wordmark + tagline (as on the business card) */
.lockup { display: flex; align-items: center; gap: 8px; color: #161816; }
.lockup-mark { width: 52px; height: 43px; flex: none; display: block; }
.lockup-text { min-width: 0; line-height: 1; overflow: hidden; }
.lockup-word { font-family: var(--font-brand); font-size: 25px; letter-spacing: .02em; color: #2f8c53; white-space: nowrap; }
.lockup-tag { font-family: var(--font-script); font-size: 12px; color: #c8373a; margin-top: 3px; white-space: nowrap; }
.brand-mark { width: 52px; height: 44px; flex: none; display: block; border-radius: 8px; box-shadow: 0 0 0 1px rgba(255,255,255,.08); }
#nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--side-ink); text-decoration: none; font-weight: 500; margin-bottom: 2px; }
#nav a:hover { background: rgba(255,255,255,.06); }
#nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
#nav a.active svg { color: var(--primary); }
#nav .nav-sep { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: 14px 10px 6px; }
#nav .count { margin-left: auto; background: var(--gold); color: var(--gold-ink); font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 10px; }
.sidebar-foot { font-size: 11.5px; padding: 14px 16px; opacity: .65; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-foot a { color: var(--gold); }
#shell { flex: 1; margin-left: 236px; min-width: 0; }
#topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 12px 24px; min-height: 60px; }
#topbar h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#pageActions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.menu-btn { display: none; }
.top-logo { display: none; width: 40px; height: 33px; border-radius: 6px; box-shadow: 0 0 0 1px var(--border); }
#main { padding: 22px 24px 60px; max-width: 1280px; }
#scrim { display: none; }

@media (max-width: 900px) {
  #sidebar { transform: translateX(-100%); }
  body.nav-open #sidebar { transform: none; }
  body.nav-open #scrim { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; }
  #shell { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .top-logo { display: block; }
  #topbar { padding: 10px 16px; flex-wrap: wrap; }
  #topbar h1 { font-size: 16px; }
  #pageActions { width: 100%; justify-content: flex-start; }
  #pageActions:empty { display: none; }
  #main { padding: 16px 16px 60px; }
}

/* ---------- Components ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 12px; border-radius: 8px; font: inherit; font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-danger { color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { border: 0; background: transparent; color: inherit; padding: 6px; border-radius: 8px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 .sp { flex: 1; }
.card-flush { padding: 0; overflow: hidden; }
.card-flush > h3 { padding: 16px 18px 0; }
.grid { display: grid; gap: 18px; }
.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, 2fr) minmax(0, 1fr); }
@media (max-width: 1000px) { .g2, .g3, .g-side { grid-template-columns: minmax(0, 1fr); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: block; }
.kpi:hover { border-color: var(--primary); }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.kpi .val { font-size: 24px; font-weight: 750; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.warn .val { color: var(--warn); }
.kpi.bad .val { color: var(--bad); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .muted, .muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; font-weight: 650; background: var(--neutral-soft); color: var(--muted); white-space: nowrap; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-bad { background: var(--bad-soft); color: var(--bad); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-primary { background: var(--primary-soft); color: var(--primary); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .sp { flex: 1; }
.search { min-width: 220px; flex: 1; max-width: 360px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--primary-soft); color: var(--primary); }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
input[disabled], select[disabled], textarea[disabled] { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 650; color: var(--muted); }
.field small { color: var(--muted); font-size: 11.5px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { display: none; }
.chip span { display: inline-block; padding: 5px 10px; border: 1px solid var(--border); border-radius: 20px; font-size: 12.5px; cursor: pointer; user-select: none; }
.chip input:checked + span { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 650; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 12.5px; }
.dl dd { margin: 0; font-weight: 500; }

.modal { position: fixed; inset: 0; background: rgba(5, 20, 17, .5); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-card { background: var(--surface); border-radius: 12px; width: min(720px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 16px; margin: 0; flex: 1; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

#toasts { position: fixed; bottom: 18px; right: 18px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #10241f; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); max-width: 340px; animation: tin .2s; }
.toast.error { background: #7f1d1d; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }

.banner { background: var(--primary-soft); border: 1px solid var(--primary); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.banner h3 { margin: 0 0 6px; }
.banner p { margin: 0 0 12px; color: var(--muted); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.alert-warn { background: var(--warn-soft); color: var(--warn); }

/* ---------- Schedule ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 260px; display: flex; flex-direction: column; }
.day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.day.drop { background: var(--primary-soft); }
.day-head { padding: 8px 10px; border-bottom: 1px solid var(--border); display: flex; align-items: baseline; gap: 6px; }
.day-head b { font-size: 18px; }
.day-head span { font-size: 12px; color: var(--muted); }
.day-head .add { margin-left: auto; }
.day-body { padding: 6px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.job-card { border-left: 4px solid var(--tc, var(--primary)); background: var(--surface-2); border-radius: 6px; padding: 6px 8px; font-size: 12px; cursor: pointer; }
.job-card:hover { filter: brightness(.97); }
.job-card .t { font-weight: 700; }
.job-card .c { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.job-card.done { opacity: .6; }
.job-card.cancel { text-decoration: line-through; opacity: .5; }
@media (max-width: 900px) {
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- Job report ---------- */
.job-head { display: flex; flex-wrap: wrap; gap: 10px 24px; align-items: flex-start; }
.job-head .main { flex: 1; min-width: 240px; }
.job-head h2 { margin: 0 0 4px; font-size: 20px; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.station-row select { min-width: 150px; }
.station-row input.cnt { width: 70px; }
.pest-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.pest-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.pest-item b { flex: 1; font-size: 13px; }
.pest-item select { width: auto; }
.sig-wrap { border: 1px dashed var(--border); border-radius: 8px; background: #fff; touch-action: none; }
.sig-wrap canvas { width: 100%; height: 160px; display: block; cursor: crosshair; }
.sig-img { max-height: 120px; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photo { position: relative; }
.photo img { width: 110px; height: 110px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.photo button { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.6); color: #fff; border: 0; border-radius: 6px; padding: 2px 6px; cursor: pointer; }

/* ---------- Charts ---------- */
.chart { width: 100%; height: auto; max-height: 240px; display: block; stroke: none; }
.chart * { stroke: none; }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--primary); }
.chart .bar.alt { fill: var(--gold); }
.chart .grid line { stroke: var(--border); stroke-width: 1; }.chart .val { fill: var(--text); font-weight: 650; }

/* ---------- Line items ---------- */
.items td { padding: 6px 8px; }
.items input { padding: 6px 8px; }
.totals { margin-left: auto; width: min(320px, 100%); }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-size: 16px; font-weight: 750; border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }

/* ---------- Print documents ---------- */
#print { display: none; }
#print.show { display: block; position: fixed; inset: 0; z-index: 55; overflow-y: auto; background: rgba(5, 20, 17, .65); padding: 16px; }
#print.show .doc { max-width: 820px; margin: 0 auto 16px; padding: 28px; border-radius: 6px; overflow-x: auto; }
.print-bar { position: sticky; top: 0; z-index: 1; display: flex; gap: 8px; justify-content: flex-end; max-width: 820px; margin: 0 auto 10px; }
@media (max-width: 600px) { #print.show { padding: 8px; } #print.show .doc { padding: 14px; } #print.show .doc-head { flex-direction: column; } #print.show .doc-title { text-align: left; } #print.show .doc .meta, #print.show .doc .sign { grid-template-columns: 1fr; } }
.doc { font-family: "Helvetica Neue", Arial, sans-serif; color: #111; font-size: 12px; line-height: 1.45; background: #fff; }
.doc-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 3px solid #2f8c53; padding-bottom: 12px; margin-bottom: 14px; }
.doc-co { display: flex; gap: 12px; }
.doc-co { flex-direction: column; gap: 6px; }
.doc-co .lockup-mark { width: 70px; height: 58px; }
.doc-co .lockup-word { font-size: 34px; }
.doc-co .lockup-tag { font-size: 15px; }
.doc-co p { margin: 2px 0 0; color: #555; font-size: 11px; }
.doc-title { text-align: right; }
.doc-title h2 { margin: 0; font-size: 20px; color: #237f47; letter-spacing: .03em; text-transform: uppercase; }
.doc-title p { margin: 2px 0; }
.doc h4 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #237f47; border-bottom: 1px solid #ddd; padding-bottom: 3px; }
.doc table { width: 100%; border-collapse: collapse; }
.doc th, .doc td { border: 1px solid #d5d5d5; padding: 5px 7px; font-size: 11px; text-align: left; background: none; color: #111; text-transform: none; letter-spacing: 0; }
.doc th { background: #eaf6ee; font-weight: 700; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
.doc .meta div { display: flex; gap: 8px; }
.doc .meta b { min-width: 110px; color: #444; font-weight: 600; }
.doc .sign { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 24px; }
.doc .sign div { border-top: 1px solid #333; padding-top: 4px; min-height: 30px; }
.doc .sign img { max-height: 70px; display: block; margin-bottom: 4px; }
.doc .totals { width: 260px; }
.doc .note { white-space: pre-wrap; }
.doc .foot { margin-top: 26px; font-size: 10px; color: #777; text-align: center; border-top: 1px solid #ddd; padding-top: 6px; }
.doc .chart { max-height: 200px; }
.doc .chart text { fill: #555; }
.doc .chart .bar { fill: #2f8c53; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.doc .chart .val { fill: #111; }
.doc .chart .grid line { stroke: #ddd; }
.doc .photos img { width: 150px; height: 110px; object-fit: cover; border: 1px solid #ccc; }
.doc .pill { display: inline-block; padding: 1px 6px; border-radius: 8px; border: 1px solid #ccc; font-size: 10px; }

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; }
  #app, #modal, #toasts { display: none !important; }
  #print, #print.show { display: block; position: static; padding: 0; background: none; overflow: visible; }
  #print.show .doc { padding: 0; max-width: none; margin: 0; }
  .print-bar { display: none !important; }
  .doc { page-break-after: always; }
  .doc:last-child { page-break-after: auto; }
  .doc tr { page-break-inside: avoid; }
}

/* ---------- Cloud: sign-in, sync status, live map ---------- */
#gate { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
#gate[hidden] { display: none; }
.gate-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: 28px; width: min(400px, 100%); display: grid; gap: 10px; }
.gate-card .lockup { background: #fff; border-radius: 10px; padding: 10px 12px; justify-self: start; }
.gate-card h2 { margin: 8px 0 0; font-size: 20px; }
.gate-card p { margin: 0; }
.gate-form { display: grid; gap: 10px; }
.gate-err { color: var(--bad); font-size: 13px; min-height: 18px; }
.sync { font-weight: 650; margin-bottom: 4px; }
.sync::before { content: "●"; margin-right: 6px; }
.sync-idle::before { color: #4ade80; }
.sync-pending::before, .sync-saving::before { color: var(--gold); }
.sync-error { color: #fca5a5; }
.sync-error::before { color: #f87171; }
.livewrap { position: relative; height: calc(100vh - 290px); min-height: 420px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); }
.live-detail { position: absolute; left: 12px; bottom: 12px; z-index: 800; width: min(360px, calc(100% - 24px)); background: var(--surface); color: var(--text); border-radius: 12px; padding: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.ld-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ld-grid span { display: block; color: var(--muted); font-size: 11px; }
.ld-grid b { font-size: 14px; }
#map { height: 100%; width: 100%; }
/* Map drawings (routes, job areas) must not pick up the icon sizing used elsewhere */
.leaflet-container svg { width: auto; height: auto; max-width: none; }
.live-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.live-dock { display: flex; gap: 10px; overflow-x: auto; padding: 12px 0 4px; }
.tcard { flex: none; display: flex; gap: 10px; align-items: center; text-align: left; min-width: 230px; background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: 10px 12px; font: inherit; color: inherit; cursor: pointer; }
.tcard.sel { border-color: var(--primary); }
.avi { width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 800; display: grid; place-items: center; flex: none; font-size: 14px; }
.map-av { text-align: center; width: 64px; }
.map-av .avi { margin: 0 auto; }
.map-name, .map-site { display: inline-block; background: #fff; color: #111; border-radius: 8px; padding: 1px 7px; font-size: 11px; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.3); white-space: nowrap; margin-top: 3px; }
.map-site { transform: translate(-50%, -120%); }
.att-img { width: 54px; height: 54px; object-fit: cover; border-radius: 8px; display: block; }

/* ---------- Quotation editor ---------- */
.qt-start { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.qt-start .muted { flex: 1; min-width: 200px; }
.qt-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-top: 12px; }
.qt-photo { border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: grid; gap: 6px; background: var(--surface-2); }
.qt-img { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: var(--neutral-soft); display: grid; place-items: center; }
.qt-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.qt-photo-tools { display: flex; align-items: center; gap: 2px; }
.qt-photo-tools .sp { flex: 1; }
.qt-add { min-height: 160px; border: 2px dashed var(--border); border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); font-weight: 600; cursor: pointer; }
.qt-add:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Printed quotation (company letterhead format) ---------- */
.qdoc { --qn: #1d3a66; font-family: Helvetica, Arial, "Liberation Sans", Arimo, FreeSans, sans-serif; color: #111; font-size: 9pt; line-height: 1.35; background: #fff; }
#print.show .qdoc { max-width: 820px; margin: 0 auto 16px; padding: 36px 42px; border-radius: 6px; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; border-bottom: 3px solid var(--qn); padding-bottom: 14px; }
.q-co { color: var(--qn); font-weight: 700; font-size: 16pt; }
.q-tag { color: #555; font-size: 7.5pt; margin-top: 1px; }
.q-addr { color: #444; font-size: 7.5pt; margin-top: 8px; line-height: 1.45; }
.q-title { color: var(--qn); font-weight: 700; font-size: 21pt; line-height: 1; padding-top: 4px; }
.q-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin: 18px 0 10px; }
.q-label { font-weight: 700; color: #555; font-size: 7.5pt; border-bottom: 1px solid #ddd; padding-bottom: 4px; margin-bottom: 6px; }
.q-to div { margin-top: 5px; }
.q-details { width: 100%; border-collapse: collapse; }
.q-details td { padding: 2px 0 3px; border: 0; font-size: 9pt; background: none; text-transform: none; letter-spacing: 0; }
.q-details td:first-child { color: #666; width: 42%; }
.q-subject { font-weight: 700; margin: 10px 0 8px; }
.q-items { width: 100%; border-collapse: collapse; }
.q-items th { background: #eef1f6; color: #111; text-align: left; text-transform: none; letter-spacing: 0; font-weight: 700; padding: 6px 10px; border-bottom: 2px solid var(--qn); font-size: 9pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.q-items td { padding: 7px 10px; border-bottom: 1px solid #ddd; vertical-align: top; }
.q-items .r { text-align: right; white-space: nowrap; }
.q-items tr { page-break-inside: avoid; }
.q-sub td { padding-top: 6px; padding-bottom: 6px; color: #333; }
.q-total td { background: #eef1f6; font-weight: 700; border-top: 2px solid var(--qn); border-bottom: 0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.q-words { color: #555; font-size: 7.5pt; margin: 5px 10px 4px; }
.qdoc h3 { color: var(--qn); font-size: 11pt; margin: 10px 0 3px; }
.qdoc ul { margin: 0; padding-left: 18px; }
.qdoc li { margin: 1px 0; }
.q-bottom { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 6px; page-break-inside: avoid; }
.q-bank { line-height: 1.5; }
.q-acc-title { font-weight: 700; margin: 12px 0 4px; }
.q-acc { display: flex; align-items: flex-end; gap: 10px; margin: 13px 0; color: #666; font-size: 8pt; }
.q-acc span { flex: 1; }
.q-acc i { flex: 0 0 46%; border-bottom: 1px solid #333; }
.q-thanks { color: #555; font-size: 7.5pt; margin: 18px 10px 4px; }
.q-sign { font-weight: 700; margin: 10px; }
.q-foot { text-align: center; color: #777; font-size: 7.5pt; border-top: 1px solid #eee; margin-top: 26px; padding-top: 6px; }
.q-photos-page h2 { color: var(--qn); font-size: 17pt; margin: 0; }
.q-psub { color: #555; font-size: 8pt; margin: 2px 0 12px; }
.q-prow { display: grid; gap: 8px; margin-bottom: 12px; page-break-inside: avoid; }
.q-prow.n1, .q-prow.wide { grid-template-columns: 1fr; }
.q-prow.n2 { grid-template-columns: 1fr 1fr; }
.q-prow.n3 { grid-template-columns: repeat(3, 1fr); }
.q-prow figure { margin: 0; }
.q-prow img { width: 100%; height: 395px; object-fit: cover; display: block; }
.q-prow.n2 img { height: 330px; }
.q-prow.n1 img, .q-prow.wide img { height: 395px; }
.q-prow figcaption { text-align: center; font-size: 7.5pt; color: #444; margin-top: 5px; line-height: 1.35; }
.q-pnote { font-size: 7.5pt; color: #444; margin-top: 4px; }
@media (max-width: 640px) {
  #print.show .qdoc { padding: 18px 16px; }
  .q-head, .q-meta, .q-bottom { display: block; }
  .q-title { margin-top: 10px; }
  .q-items { font-size: 9pt; }
  .q-items th, .q-items td { padding: 6px 4px; }
  .q-prow.n3 { grid-template-columns: 1fr 1fr; }
  .q-prow img { height: 180px; }
}
@media print {
  #print.show .qdoc { max-width: none; margin: 0; padding: 0; border-radius: 0; }
  .qdoc { page-break-after: always; }
  .qdoc:last-child { page-break-after: auto; }
}

/* ---------- Location search ---------- */
.place { display: grid; gap: 6px; }
.place-search { position: relative; }
.place-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.15); overflow: hidden; max-height: 280px; overflow-y: auto; }
.place-opt { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; font: inherit; color: var(--text); cursor: pointer; border-bottom: 1px solid var(--border); }
.place-opt:last-child { border-bottom: 0; }
.place-opt:hover, .place-opt:focus { background: var(--primary-soft); }
.place-opt b { display: block; font-size: 13.5px; }
.place-opt span { display: block; font-size: 12px; color: var(--muted); }
.place-msg { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.place-status { font-size: 12.5px; }
.place-set { font-weight: 600; }
.place-here { justify-self: start; }

.review-bonus { display: flex; align-items: center; gap: 12px; padding: 12px 18px 16px; border-top: 1px solid var(--border); }
.review-bonus > div { flex: 1; }

.doc .borang img { display: block; width: 100%; max-height: 240mm; object-fit: contain; margin: 0 0 8px; border: 1px solid #ccc; page-break-inside: avoid; }
