:root {
  --navy: #1a1a1a; --navy-deep: #0a0a0a; --teal: #c4161c; --teal-d: #8d1015; --cta-ink: #0a0a0a;
  --cream: #f4f1ec; --paper: #fffcf8; --paper-2: #ece7df; --line: #e4ddd3; --ink: #262626; --muted: #69727d;
  --c-no_answer: #8a939e; --c-not_interested: #d64545; --c-callback: #f0a202; --c-lead: #2f6fd6; --c-appointment: #1e9e5a;
  --danger: #d64545; --ok: #1e9e5a; --warn: #f0a202;
  --r: 14px; --r-sm: 10px;
  --shadow: 0 6px 24px rgba(10, 10, 10, .12); --shadow-sm: 0 1px 3px rgba(10, 10, 10, .08);
  --head: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: Roboto, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --top-h: 56px; --tab-h: 64px;
  --sab: env(safe-area-inset-bottom, 0px); --sat: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--cream); color: var(--ink); font: 16px/1.45 var(--body); -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
h1, h2, h3, h4 { font-family: var(--head); color: var(--navy-deep); margin: 0 0 .4em; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
a { color: var(--navy); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .tiny { font-size: .75rem; }
.hidden { display: none !important; }
.boot { height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--paper-2); border-top-color: var(--teal); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.shell { height: 100dvh; display: flex; flex-direction: column; }
.topbar { flex: 0 0 auto; height: calc(var(--top-h) + var(--sat)); padding: var(--sat) 12px 0 14px; display: flex; align-items: center; gap: 10px; background: var(--paper); border-bottom: 1px solid var(--line); z-index: 500; }
.topbar .logo { height: 34px; width: auto; display: block; }
.topbar .title { font: 700 1.05rem var(--head); color: var(--navy-deep); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.iconbtn { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; cursor: pointer; color: var(--navy); }
.iconbtn:active { background: var(--paper-2); }
.iconbtn svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 4px; right: 3px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font: 700 11px/18px var(--body); text-align: center; }
.pending-pill { font: 600 12px var(--body); background: #fff4dc; color: #7a5200; border: 1px solid #f3d38a; padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.offline-pill { font: 600 12px var(--body); background: var(--paper-2); color: var(--muted); padding: 4px 9px; border-radius: 999px; }
main.view { flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch; position: relative; }
main.view.pad { padding: 16px 16px calc(24px + var(--sab)); }
main.view.mapview { overflow: hidden; }
.tabbar { flex: 0 0 auto; display: flex; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: var(--sab); z-index: 500; }
.tabbar a { flex: 1; height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; text-decoration: none; color: var(--muted); font: 600 11.5px var(--body); position: relative; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a.active { color: var(--navy); }
.tabbar a.active::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--teal); }
.tabbar .badge { top: 6px; right: calc(50% - 22px); }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid transparent; font: 700 15px var(--body); cursor: pointer; text-decoration: none; user-select: none; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn-cta { background: var(--teal); color: var(--cta-ink); }
.btn-cta:active { background: var(--teal-d); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-ghost { background: var(--paper); color: var(--navy); border-color: var(--line); }
.btn-danger { background: #fff; color: var(--danger); border-color: #f1c4c4; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 17px; border-radius: 14px; }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn svg { width: 20px; height: 20px; }
.row { display: flex; gap: 10px; align-items: center; } .row > * { min-width: 0; }
.row.wrap { flex-wrap: wrap; } .grow { flex: 1; }
.stack > * + * { margin-top: 12px; }
label.field { display: block; }
label.field > span { display: block; font: 600 13px var(--body); color: var(--navy-deep); margin-bottom: 6px; }
.input, select.input, textarea.input { width: 100%; min-height: 48px; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); outline: none; }
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(25, 168, 184, .18); }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font-size: 14.5px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--teal); flex: 0 0 auto; margin: 0; }
.check:has(input:checked) { border-color: var(--teal); background: #e9f7f9; }
.consent { align-items: flex-start; font-size: 14px; line-height: 1.35; }
.consent input { margin-top: 1px; }
.seg { display: flex; background: var(--paper-2); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: transparent; font: 600 14px var(--body); color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--paper); color: var(--navy-deep); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); font: 600 13px var(--body); cursor: pointer; color: var(--ink); }
.chip.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* ---------- cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 12px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; }
.section-title h2 { margin: 0; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.kpi .v { font: 800 1.9rem/1.1 var(--head); color: var(--navy-deep); }
.kpi .l { font: 600 12.5px var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px; }
.kpi.accent { background: var(--navy); border-color: var(--navy); }
.kpi.accent .v { color: #fff; } .kpi.accent .l { color: #b9c6da; }
.kpi.teal .v { color: var(--teal-d); }
.mixbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--paper-2); margin: 10px 0 8px; }
.mixbar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.list { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-bottom: 1px solid var(--paper-2); }
.item:last-child { border-bottom: 0; }
.item .grow { min-width: 0; }
.item .t { font-weight: 700; color: var(--navy-deep); }
.item .s { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.item .time { font: 700 15px var(--head); color: var(--navy); min-width: 52px; }
.item.overdue .time { color: var(--danger); }
.item .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; background: var(--paper-2); color: var(--navy); }
.item .ic svg { width: 20px; height: 20px; }
.item.unread { background: #f1fafb; }
.item .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.item .actions.three { display: grid; grid-template-columns: 1fr 1.25fr 1fr; }
.item .actions.three .btn { padding: 0 8px; }
.empty { text-align: center; padding: 26px 16px; color: var(--muted); font-size: 14.5px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font: 700 11.5px var(--body); background: var(--paper-2); color: var(--navy); vertical-align: middle; }
.tag.lead { background: #e2f5f7; color: #0d6d78; } .tag.appointment { background: #e3f4ea; color: #146c3d; }
.tag.s-New { background: #e2f5f7; color: #0d6d78; } .tag.s-Contacted { background: #eef1f5; color: var(--navy); } .tag.s-Survey { background: #e3f4ea; color: #146c3d; } .tag.s-Sold { background: var(--navy); color: #fff; } .tag.s-Dead { background: #fbe9e9; color: #a12d2d; }
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: var(--r); background: #e9f3fb; border: 1px solid #c8dcf0; color: var(--navy-deep); font-size: 14.5px; }
.banner.warn { background: #fff6e2; border-color: #f3d38a; }
.banner.danger { background: #fdeceb; border-color: #f2b8b5; color: #7c1d1d; }
.banner svg { width: 22px; height: 22px; flex: 0 0 auto; margin-top: 1px; }
.banner b { color: inherit; }
.banner .row { margin-top: 10px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--paper); }
table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
table.t th, table.t td { padding: 10px 10px; text-align: right; border-bottom: 1px solid var(--paper-2); white-space: nowrap; }
table.t th:first-child, table.t td:first-child { text-align: left; position: sticky; left: 0; background: var(--paper); }
table.t th { font: 700 12px var(--body); color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
table.t tr:last-child td { border-bottom: 0; }
.lb { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--paper-2); }
.lb:last-child { border-bottom: 0; }
.lb .rank { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font: 800 14px var(--head); background: var(--paper-2); color: var(--navy); flex: 0 0 auto; }
.lb:nth-child(1) .rank { background: #f7c948; color: #4a3500; }
.lb:nth-child(2) .rank { background: #d9dee6; } .lb:nth-child(3) .rank { background: #e7b98c; color: #4d2c0c; }
.lb .pts { font: 800 18px var(--head); color: var(--navy-deep); text-align: right; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; padding-top: 6px; }
.bars div { flex: 1; background: var(--teal); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars div span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font: 700 11px var(--body); color: var(--navy-deep); }
.bars { padding-top: 20px; height: 110px; }
.bar-labels { display: flex; gap: 4px; margin-top: 4px; } .bar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--muted); }
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); flex: 0 0 auto; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: calc(24px + var(--sat)) 22px calc(24px + var(--sab)); background: linear-gradient(180deg, var(--paper) 0%, var(--paper) 46%, var(--cream) 46%); }
.login .brand { text-align: center; margin-bottom: 26px; }
.login .brand img { width: 240px; max-width: 72%; height: auto; }
.login .brand p { margin: 12px 0 0; font: 700 13px var(--head); letter-spacing: .14em; text-transform: uppercase; color: var(--teal-d); }
.login .card { padding: 22px 18px; box-shadow: var(--shadow); max-width: 420px; width: 100%; margin: 0 auto; }
.login .err { color: var(--danger); font-size: 14px; min-height: 20px; }
.login .foot { text-align: center; margin-top: 18px; font-size: 12.5px; color: var(--muted); }

/* ---------- map ---------- */
#map, .map { position: absolute; inset: 0; background: #e8ecef; }
.leaflet-container { font: inherit; }
.map-fab { position: absolute; left: 14px; right: 14px; bottom: calc(14px); z-index: 450; display: flex; gap: 10px; }
.map-fab .btn-cta { flex: 1; box-shadow: var(--shadow); min-height: 58px; font-size: 18px; border-radius: 16px; }
.map-round { width: 58px; height: 58px; border-radius: 16px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--navy); cursor: pointer; flex: 0 0 auto; }
.map-round svg { width: 26px; height: 26px; }
.map-top { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 450; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-chip { background: rgba(255, 255, 255, .96); border: 1px solid var(--line); border-radius: 12px; padding: 8px 11px; font-size: 13px; box-shadow: var(--shadow-sm); max-width: 100%; }
.map-chip b { color: var(--navy-deep); font-family: var(--head); }
.map-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--ink); }
.map-legend span { display: inline-flex; align-items: center; gap: 5px; }
.gps-dot { width: 18px; height: 18px; border-radius: 50%; background: #2b7bf3; border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(43, 123, 243, .35), 0 2px 6px rgba(0, 0, 0, .3); }
.crosshair { position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px; z-index: 440; pointer-events: none; }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.4; }
.leaflet-popup-content b { color: var(--navy-deep); }
.leaflet-popup-content .btn { margin-top: 8px; }
.leaflet-control-attribution { font-size: 10px; }
.map-filter { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 450; background: rgba(255, 255, 255, .97); border: 1px solid var(--line); border-radius: 14px; padding: 10px; box-shadow: var(--shadow-sm); }
.map-filter .chips { gap: 6px; flex-wrap: nowrap; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
.map-filter .chip { min-height: 32px; padding: 0 10px; font-size: 12.5px; white-space: nowrap; }
.map-filter .chip.off { opacity: .45; }
.draw-bar { position: absolute; left: 12px; right: 12px; bottom: 14px; z-index: 450; display: flex; gap: 8px; }
.draw-hint { position: absolute; top: 10px; left: 12px; right: 12px; z-index: 450; }

/* ---------- sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(10, 10, 10, .45); z-index: 1000; opacity: 0; transition: opacity .2s; }
.sheet-back.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1001; background: var(--paper); border-radius: 22px 22px 0 0; max-height: 92dvh; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .24s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -10px 40px rgba(10, 10, 10, .2); max-width: 640px; margin: 0 auto; }
.sheet.show { transform: translateY(0); }
.sheet.full { top: 0; max-height: none; border-radius: 0; }
.sheet .grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line); margin: 9px auto 2px; flex: 0 0 auto; }
.sheet .sh-head { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 18px; flex: 0 0 auto; }
.sheet.full .sh-head { padding-top: calc(10px + var(--sat)); border-bottom: 1px solid var(--line); }
.sheet .sh-head h2 { flex: 1; margin: 0; font-size: 1.15rem; }
.sheet .sh-body { overflow-y: auto; padding: 8px 18px 18px; -webkit-overflow-scrolling: touch; flex: 1 1 auto; }
.sheet .sh-foot { padding: 10px 18px calc(12px + var(--sab)); border-top: 1px solid var(--line); flex: 0 0 auto; background: var(--paper); }
.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.oc { min-height: 66px; border-radius: 14px; border: 0; font: 700 16px var(--body); display: flex; align-items: center; gap: 10px; padding: 0 14px; cursor: pointer; text-align: left; }
.oc:active { transform: scale(.98); filter: brightness(.95); }
.oc .ocd { width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .25); display: grid; place-items: center; flex: 0 0 auto; }
.oc .ocd svg { width: 20px; height: 20px; }
.oc.no_answer { background: #eceff2; color: #3d454f; } .oc.no_answer .ocd { background: var(--c-no_answer); color: #fff; }
.oc.not_interested { background: #fbe7e7; color: #8f2424; } .oc.not_interested .ocd { background: var(--c-not_interested); color: #fff; }
.oc.callback { background: #fff2d6; color: #6e4b00; } .oc.callback .ocd { background: var(--c-callback); color: #fff; }
.oc.lead { background: var(--teal); color: var(--cta-ink); } .oc.lead .ocd { background: rgba(10, 10, 10, .14); }
.oc.appointment { background: var(--navy); color: #fff; grid-column: span 2; } .oc.appointment .ocd { background: var(--c-appointment); }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick .chip { justify-content: center; min-height: 44px; border-radius: 12px; }
.addr-row { display: flex; gap: 8px; }
.addr-row .input { flex: 1; }
.linkbtn { background: none; border: 0; color: var(--navy); font: 600 14px var(--body); text-decoration: underline; padding: 8px 0; cursor: pointer; }
.photo-prev { display: flex; gap: 10px; align-items: center; }

#toast { position: fixed; left: 50%; top: calc(66px + var(--sat)); transform: translateX(-50%) translateY(-12px); background: var(--navy-deep); color: #fff; padding: 12px 18px; border-radius: 12px; font: 600 14.5px var(--body); opacity: 0; transition: all .2s; z-index: 2000; max-width: 90vw; text-align: center; pointer-events: none; box-shadow: var(--shadow); }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }
.menu .item { cursor: pointer; align-items: center; }
.menu .item .chev { color: var(--line); }
.pin-reveal { font: 800 2rem var(--head); letter-spacing: .2em; color: var(--navy-deep); text-align: center; padding: 14px; background: var(--paper-2); border-radius: 12px; margin: 10px 0; user-select: all; }
@media (min-width: 760px) { main.view.pad { padding: 24px; } .pad-inner { max-width: 900px; margin: 0 auto; } .kpis { grid-template-columns: repeat(4, 1fr); } }
