[hidden] { display: none !important; }
:root {
  --bg: #f4f5f2; --card: #fff; --ink: #1d232b; --mute: #6b7380; --line: #e2e5e9;
  --blue: #3d7bf5; --blue-d: #1f4fb3; --orange: #f5a623; --red: #d0021b; --gray: #5d6470; --ring: #e6007e; --green: #18a558;
  --tabs-h: 56px; --top-h: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
button, select, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

#top { position: fixed; top: 0; left: 0; right: 0; height: calc(var(--top-h) + var(--safe-t)); padding: var(--safe-t) 10px 0;
  display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); z-index: 20; }
#top .spacer { flex: 1; }
#zoneSel { font-weight: 700; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 28px 6px 10px; background: #fff; max-width: 60vw; }
.sync { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 5px 10px; font-size: 13px; color: var(--mute); }
.sync .dot { width: 9px; height: 9px; border-radius: 50%; background: #b9bec6; }
.sync.ok .dot { background: var(--green); } .sync.syncing .dot { background: var(--blue); animation: pulse 1s infinite; }
.sync.error .dot { background: var(--red); } .sync.offline .dot, .sync.pending .dot { background: var(--orange); }
@keyframes pulse { 50% { opacity: .3; } }

main { position: fixed; top: calc(var(--top-h) + var(--safe-t)); bottom: calc(var(--tabs-h) + var(--safe-b)); left: 0; right: 0; }
.view { position: absolute; inset: 0; display: none; }
.view.active { display: block; }
.view.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 12px 40px; }
#map { width: 100%; height: 100%; display: block; touch-action: none; }

#tabs { position: fixed; bottom: 0; left: 0; right: 0; height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: #fff; border-top: 1px solid var(--line); z-index: 20; }
#tabs button { flex: 1; border: 0; background: none; font-size: 11px; color: var(--mute); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 1px; position: relative; }
#tabs button .i { font-size: 20px; line-height: 1; filter: grayscale(1); opacity: .7; }
#tabs button.active { color: var(--blue-d); font-weight: 700; }
#tabs button.active .i { filter: none; opacity: 1; }
.badge { position: absolute; top: 4px; left: 52%; background: var(--ring); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 6px; min-width: 18px; line-height: 17px; }

.fabs { position: absolute; right: 10px; bottom: 14px; display: flex; flex-direction: column; gap: 10px; }
.fab { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 20px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,0,0,.15); color: var(--blue-d); }
.fab.on { background: var(--blue); color: #fff; }
.modebar { position: absolute; left: 10px; right: 10px; top: 10px; background: #1d232b; color: #fff; border-radius: 12px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.modebar .msg { flex: 1; font-size: 14px; }

/* bottom sheet */
.sheet { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + var(--safe-b)); max-height: 68%; background: #fff; z-index: 30;
  border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.18); display: flex; flex-direction: column; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: #d5d8dd; margin: 7px auto 2px; flex: none; }
.sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 14px 20px; }
.sheet.tall { max-height: 88%; }
.h-head { display: flex; align-items: flex-start; gap: 10px; }
.h-head h2 { margin: 0; font-size: 21px; flex: 1; }
.h-sub { color: var(--mute); font-size: 13px; margin-top: 2px; }
.x { border: 0; background: #eef0f3; width: 32px; height: 32px; border-radius: 50%; font-size: 18px; color: var(--mute); flex: none; }

.flag { border-radius: 10px; padding: 9px 11px; margin: 8px 0 0; font-weight: 600; border-left: 6px solid; }
.flag.l1 { background: #fff8d6; border-color: #f8d33a; } .flag.l2 { background: #ffeedd; border-color: #f5841f; } .flag.l3 { background: #ffe3e5; border-color: #e0222f; }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.outcomes button { border: 0; border-radius: 12px; padding: 14px 8px; font-weight: 700; font-size: 16px; color: #fff; min-height: 54px; }
.o-gave { background: var(--blue); } .o-come_back { background: #6e95e8; } .o-no_answer { background: var(--orange); color: #3b2600 !important; }
.o-no_thanks { background: var(--gray); } .o-dnr { background: var(--red); grid-column: span 2; padding: 10px !important; min-height: 44px !important; font-size: 14px !important; }
.toggles { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 13px; font-weight: 600; font-size: 14px; }
.chip.on { border-color: var(--blue); background: #e8f0ff; color: var(--blue-d); }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 6px 0 12px; }
.chips .chip { min-width: 46px; text-align: center; }
.step { background: #f6f8fb; border-radius: 14px; padding: 12px; margin-top: 12px; }
.step h3 { margin: 0 0 4px; font-size: 15px; }
.lbl { font-size: 13px; font-weight: 700; color: var(--mute); text-transform: uppercase; letter-spacing: .03em; margin-top: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.btn { border: 0; border-radius: 11px; padding: 11px 16px; font-weight: 700; background: var(--blue); color: #fff; }
.btn.small { padding: 7px 12px; font-size: 14px; }
.btn.ghost { background: #eef0f3; color: var(--ink); }
.btn.danger { background: #ffe3e5; color: var(--red); }
.btn.block { width: 100%; }
.sec { margin-top: 18px; }
.sec > h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--mute); margin: 0 0 6px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 14px; margin-top: 10px; color: #39414c; }
.facts b { color: var(--ink); }
.ret { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 9px 11px; background: #eef4ff; border-radius: 10px; font-weight: 600; }
.ret.due { background: #ffe6f3; color: #9b0057; }
.ret .grow { flex: 1; }
.note { display: flex; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.note .bar { width: 5px; border-radius: 3px; background: #e5e7eb; flex: none; }
.note .t { flex: 1; white-space: pre-wrap; }
.note .meta { font-size: 12px; color: var(--mute); }
.linkbtn { border: 0; background: none; color: var(--blue-d); font-weight: 600; padding: 2px 4px; }
textarea, input[type=text], input[type=email], input[type=password], input[type=url], input[type=date], input[type=number], select.input {
  width: 100%; border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 10px; background: #fff; }
textarea { min-height: 64px; resize: vertical; }
.visit { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; align-items: center; }
.visit .d { width: 86px; color: var(--mute); font-size: 13px; flex: none; }
.visit .o { flex: 1; }

/* symbols (legend, lists) */
.sym { display: inline-block; width: 18px; height: 18px; border: 1.5px solid; vertical-align: middle; flex: none; position: relative; }
.sym.circle { border-radius: 50%; } .sym.square { border-radius: 3px; }
.sym.dnr { border-radius: 3px; } .sym.dnr::after { content: '✕'; color: #fff; font-size: 12px; font-weight: 900; position: absolute; inset: 0; text-align: center; line-height: 15px; }
.sym.ring { box-shadow: 0 0 0 2px #fff, 0 0 0 4.5px var(--ring); }
.legend { display: grid; gap: 10px; }
.legend .li { display: flex; gap: 12px; align-items: center; }
.legend .tri { width: 0; height: 0; border-top: 11px solid; border-left: 11px solid transparent; flex: none; }

/* lists */
h2.title { font-size: 22px; margin: 4px 2px 10px; }
.card { background: #fff; border-radius: 14px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--line); }
.card h3 { margin: 0 0 8px; font-size: 16px; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .main { flex: 1; min-width: 0; }
.item .a { font-weight: 700; }
.item .s { font-size: 13px; color: var(--mute); }
.pill { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 10px; background: var(--ring); color: #fff; white-space: nowrap; }
.pill.soft { background: #eef0f3; color: var(--ink); }
.empty { color: var(--mute); padding: 14px 4px; text-align: center; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.kpi b { display: block; font-size: 22px; }
.kpi span { font-size: 12px; color: var(--mute); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--mute); text-transform: uppercase; cursor: pointer; user-select: none; }
td.n, th.n { text-align: right; }
.tablewrap { overflow-x: auto; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 110px; padding-top: 10px; }
.bars .b { flex: 1; background: var(--blue); border-radius: 4px 4px 0 0; position: relative; min-height: 2px; }
.bars .b span { position: absolute; top: -16px; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--mute); }
.barlbl { display: flex; gap: 4px; font-size: 10px; color: var(--mute); } .barlbl span { flex: 1; text-align: center; }
.field { margin-bottom: 10px; } .field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--mute); }
.hint { font-size: 13px; color: var(--mute); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 16px; padding: 16px; width: 100%; max-width: 420px; max-height: 85vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 10px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + var(--safe-b) + 14px); z-index: 60;
  background: #1d232b; color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; gap: 14px; align-items: center; box-shadow: 0 4px 14px rgba(0,0,0,.3); max-width: 92vw; min-width: 280px; justify-content: space-between; }
.toast button { border: 0; background: none; color: #8fb4ff; font-weight: 800; }
.sheet:not([hidden]) ~ .toast { bottom: 70%; }

/* laptop */
@media (min-width: 900px) {
  :root { --tabs-h: 0px; }
  #tabs { top: var(--top-h); bottom: 0; right: auto; width: 92px; height: auto; flex-direction: column; justify-content: flex-start; border-top: 0; border-right: 1px solid var(--line); padding-top: 8px; }
  #tabs button { flex: none; height: 66px; font-size: 12px; }
  main { left: 92px; bottom: 0; }
  .sheet { left: auto; right: 0; top: var(--top-h); bottom: 0; width: 400px; max-height: none !important; border-radius: 0; box-shadow: -6px 0 24px rgba(0,0,0,.12); }
  .sheet .grab { display: none; }
  .view.scroll { padding: 20px 28px 60px; }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .toast { bottom: 20px; }
  .sheet:not([hidden]) ~ .toast { bottom: 20px; }
  .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
}
