/* Doorway Field v1.0 — mobile-first, full-screen (100dvh). All styling lives here: zero inline styles. */
:root {
  --red: #e31b23; --ink: #1d1d1f; --muted: #6e6e73; --line: #e5e5ea; --bg: #ffffff; --soft: #f5f5f7;
  --nav-h: 64px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  --shadow: 0 6px 24px rgba(0, 0, 0, .18); --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overscroll-behavior: none; }
body { height: 100dvh; overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }

/* ---- views + nav ---- */
#app { position: fixed; inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0; }
.view { position: absolute; inset: 0; display: none; overflow-y: auto; padding: calc(16px + var(--safe-t)) 16px 24px; background: var(--bg); }
.view.active { display: block; }
#view-map { padding: 0; overflow: hidden; display: block; z-index: 0; }   /* never display:none: a hidden map collapses to 0x0 */
.view:not(#view-map) { z-index: 2; }
#map { position: absolute; inset: 0; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--bg); border-top: 1px solid var(--line); z-index: 30; }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; color: var(--muted); }
.tab i { font-style: normal; font-size: 20px; }
.tab.active { color: var(--red); font-weight: 600; }
.viewhead h1 { margin: 0 0 2px; font-size: 26px; }
.viewhead { margin-bottom: 12px; }
h3 { margin: 22px 0 8px; font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* ---- top bar + pills ---- */
.topbar { position: absolute; top: calc(10px + var(--safe-t)); left: 12px; right: 12px; display: flex; align-items: center; gap: 8px; z-index: 5; pointer-events: none; }
.brand { background: rgba(255, 255, 255, .94); padding: 6px 12px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); }
.brand b { color: var(--red); }
.sync, .queue, .me { background: rgba(255, 255, 255, .94); padding: 5px 10px; border-radius: 999px; font-size: 12px; box-shadow: var(--shadow); }
.queue:empty, .me:empty { display: none; }
.me { margin-left: auto; }
.sync-synced { color: #1e8e3e; } .sync-pending, .sync-syncing { color: #b06000; } .sync-offline { color: var(--muted); }
.pills { position: absolute; top: calc(64px + var(--safe-t)); display: flex; flex-direction: column; gap: 10px; z-index: 5; }
.pills.left { left: 12px; } .pills.right { right: 12px; }
.pill { width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .96); box-shadow: var(--shadow); font-size: 20px; font-weight: 700; }
.pill.active { background: var(--red); color: #fff; }
.pill.gps.active { background: #2f80ed; }

/* ---- floating bars ---- */
.floatbar { position: absolute; left: 70px; right: 70px; top: calc(64px + var(--safe-t)); z-index: 6; display: none; background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 8px; }
.floatbar.open { display: block; }
.actionbar { top: auto; bottom: 14px; left: 12px; right: 12px; z-index: 12; }   /* bottom edge, above the card: never over the 7 map pills or the map area being lassoed */
.actionbar.open { display: flex; align-items: center; gap: 8px; }
.actionbar span { flex: 1; font-size: 14px; }
#search-input { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
#search-results { list-style: none; margin: 6px 0 0; padding: 0; max-height: 40dvh; overflow-y: auto; }
#search-results li { padding: 10px 8px; border-top: 1px solid var(--line); display: flex; flex-direction: column; }
#search-results span { color: var(--muted); font-size: 13px; }

/* ---- buttons ---- */
.btn { border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: 9px 14px; font-weight: 600; font-size: 14px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger { color: var(--red); border-color: var(--red); }
.btn.wide { width: 100%; margin-top: 14px; padding: 13px; }
.pill-outline { border: 1.5px solid var(--red); color: var(--red); background: #fff; border-radius: 999px; padding: 5px 14px; font-weight: 600; font-size: 13px; }
.x { border: 0; background: var(--soft); width: 32px; height: 32px; border-radius: 50%; font-size: 20px; line-height: 1; }

/* ---- bottom card (slide-up) ---- */
.card { position: absolute; left: 0; right: 0; bottom: 0; z-index: 10; background: #fff; border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -6px 30px rgba(0, 0, 0, .2); padding: 6px 16px 14px; transform: translateY(110%); transition: transform .16s ease-out; will-change: transform; }
.card.open { transform: translateY(0); }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head h2 { margin: 0 0 4px; font-size: 20px; }
.card-head-actions { display: flex; gap: 8px; align-items: center; }
.address { margin: 8px 0 2px; color: var(--ink); font-size: 15px; }
.appt { margin: 2px 0; color: #00897b; font-size: 13px; font-weight: 600; }
.intel { margin: 2px 0; color: var(--muted); font-size: 12px; }
.appt:empty, .intel:empty { display: none; }
.card.bulk .card-actions, .card.bulk .note-bar, .card.bulk #card-details { display: none; }
.lead-menu { display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x proximity; padding: 10px 2px 8px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; scrollbar-width: none; }
.lead-menu::-webkit-scrollbar { display: none; }
.dispo { --c: #888; flex: 0 0 auto; scroll-snap-align: start; min-width: 58px; border: 2px solid var(--c); background: #fff; color: var(--c);
  border-radius: 14px; padding: 6px 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 700; font-size: 12px; touch-action: manipulation; }
.dispo i { font-style: normal; font-size: 16px; }
.dispo.on, .dispo:active { background: var(--c); color: #fff; }
.card-actions { display: flex; gap: 8px; margin: 4px 0 10px; }
.card-actions .btn { flex: 1; }
.note-bar { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.note-bar label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .06em; }
.note-bar input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; min-width: 0; }

/* ---- status colours (one per code; the pin icons use the same table in OfflineSync.STATUS) ---- */
.dispo-NEW, .chip-NEW { --c: #2f80ed; } .dispo-NH1, .chip-NH1 { --c: #c9a227; } .dispo-NH2, .chip-NH2 { --c: #f2994a; }
.dispo-NH3, .chip-NH3 { --c: #e2703a; } .dispo-GB, .chip-GB { --c: #9b51e0; } .dispo-P_GB, .chip-P_GB { --c: #bb6bd9; }
.dispo-SOLD, .chip-SOLD { --c: #27ae60; } .dispo-NI, .chip-NI { --c: #eb5757; } .dispo-APPT, .chip-APPT { --c: #00a3a3; }
.dispo-PVL, .chip-PVL { --c: #a68a64; }
.chip-CCI { --c: #2d9cdb; } .chip-CST { --c: #1b5e20; }
.status-chip { --c: #888; display: inline-block; background: var(--c); color: #fff; border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 600; }

/* ---- modals, drawer, details ---- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); display: none; align-items: flex-end; }
.modal.open { display: flex; }
.sheet { width: 100%; background: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 14px 16px calc(18px + var(--safe-b)); max-height: 92dvh; overflow-y: auto; }
.modal.full .sheet { height: 100dvh; max-height: 100dvh; border-radius: 0; padding-top: calc(14px + var(--safe-t)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 19px; }
.sheet label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; font-size: 13px; color: var(--muted); }
.sheet label input { border: 1px solid var(--line); border-radius: 10px; padding: 11px; color: var(--ink); font-size: 16px; }
.mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-card { border: 2px solid var(--line); background: #fff; border-radius: 14px; padding: 6px; display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
.mode-card.active { border-color: var(--red); color: var(--red); }
.thumb { display: block; height: 70px; border-radius: 10px; }
.thumb-street { background: linear-gradient(135deg, #f4f1ea 0 45%, #fff 45% 52%, #e8e4da 52% 100%), #f4f1ea; }
.thumb-satellite { background: radial-gradient(circle at 30% 40%, #5b7244 0 18%, transparent 19%), radial-gradient(circle at 70% 70%, #3e5530 0 22%, transparent 23%), linear-gradient(135deg, #4a5d3a, #6d7f55); }
.thumb-hybrid { background: linear-gradient(90deg, transparent 47%, rgba(255, 255, 255, .85) 47% 53%, transparent 53%), radial-gradient(circle at 70% 70%, #3e5530 0 22%, transparent 23%), linear-gradient(135deg, #4a5d3a, #6d7f55); }
.dtabs { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; margin-bottom: 12px; }
.dtab { flex: 1; border: 0; background: none; border-radius: 10px; padding: 8px; font-weight: 600; color: var(--muted); }
.dtab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.info { display: grid; grid-template-columns: 38% 62%; margin: 0; }
.info dt { color: var(--muted); font-size: 13px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.info dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); word-break: break-word; }
.status-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 16px 0; }
.status-grid .dispo { min-width: 0; }
.row-actions { display: flex; gap: 8px; }
.row-actions .btn { flex: 1; }
.note-form { display: flex; gap: 8px; }
.note-form input { flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-width: 0; }
.timeline { list-style: none; padding: 0; margin: 12px 0; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 12px 12px; }
.timeline time { color: var(--muted); font-size: 12px; }
.timeline p { margin: 2px 0 0; }
.empty { color: var(--muted); list-style: none; padding: 14px 0; }

/* ---- list, stats, admin ---- */
.filters { display: flex; gap: 8px; margin-bottom: 8px; }
.filters input, .filters select, .turf-form input, .turf-form select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.list li div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list li b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list small { color: var(--muted); }
.list .jump { padding: 7px 10px; font-size: 12px; white-space: nowrap; }
.ranges { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.range { flex: 1; border: 0; background: none; padding: 8px; border-radius: 10px; font-weight: 600; color: var(--muted); }
.range.active { background: #fff; color: var(--red); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--soft); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; }
.tile b { font-size: 28px; } .tile span { color: var(--muted); font-size: 13px; }
.board { list-style: none; padding: 0; margin: 0; }
.board li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.board li b { flex: 1; } .board li span:last-child { color: var(--muted); font-size: 13px; }
.rank { width: 28px; height: 28px; border-radius: 50%; background: var(--red); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.drop-zone { border: 2px dashed var(--line); border-radius: 14px; padding: 26px 14px; text-align: center; font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.drop-zone small { color: var(--muted); font-weight: 400; }
.drop-zone.hover { border-color: var(--red); background: #fff4f4; }
.report p { margin: 8px 0 2px; }
.link { color: var(--red); font-weight: 600; }
.preview { border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-top: 10px; }
.pv-tabs { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; margin: 6px 0 8px; }
.pv-tab { flex: 1; border: 0; background: none; padding: 7px; border-radius: 10px; font-weight: 600; color: var(--muted); font-size: 13px; }
.pv-tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.pv-scroll { overflow-x: auto; max-height: 45dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.grid { border-collapse: collapse; font-size: 12px; min-width: 100%; }
.grid th { position: sticky; top: 0; background: var(--soft); text-align: left; padding: 6px; white-space: nowrap; }
.grid td { padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid tr.bad td { background: #fff4f4; } .grid td.issues { color: var(--red); white-space: normal; min-width: 160px; }
.pv-actions { display: flex; gap: 8px; margin-top: 10px; } .pv-actions select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 9px; background: #fff; }
.btn:disabled { opacity: .45; }
.imp-status { border-radius: 999px; padding: 2px 8px; font-weight: 600; } .imp-ok { background: #e6f4ea; color: #1e8e3e; } .imp-warn { background: #fef7e0; color: #b06000; }
.rejects { color: var(--red); font-size: 13px; padding-left: 18px; }
.turf-form { display: flex; flex-wrap: wrap; gap: 8px; }
.progress table { width: 100%; border-collapse: collapse; font-size: 14px; }
.progress th, .progress td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.progress meter { width: 70px; vertical-align: middle; }

/* ---- toast ---- */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 12px); transform: translate(-50%, 140%); opacity: 0; z-index: 50;
  background: #1d1d1f; color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; transition: transform .16s, opacity .16s; max-width: calc(100% - 32px); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
#toast-action { border: 0; background: none; color: #ffd166; font-weight: 700; pointer-events: auto; }
.toast { pointer-events: none; }   /* taps go through to the map except on Undo */
.maplibregl-ctrl-bottom-left { bottom: 4px; }
.maplibregl-ctrl-attrib.df-attrib { background: rgba(255, 255, 255, .85); font-size: 10px; line-height: 1.3; max-width: calc(100vw - 24px); }   /* Esri / USGS / OpenStreetMap credits */
.maplibregl-ctrl-attrib.df-attrib .maplibregl-ctrl-attrib-button { display: none; }
@media (min-width: 720px) { .card, .sheet { max-width: 480px; margin: 0 auto; } .modal { justify-content: center; } }
