:root {
  --navy: #0f3d5e;
  --navy-2: #164f78;
  --teal: #2bb3a3;
  --offer: #e8811a;
  --offer-bg: #fff4e8;
  --pending: #8a6d00;
  --pending-bg: #fff8d6;
  --ie: #7b4fd6;
  --ie-bg: #f2ecff;
  --case: #1f6fd1;
  --case-bg: #e9f2fe;
  --danger: #c23b3b;
  --ink: #17212b;
  --ink-2: #4b5a68;
  --ink-3: #7c8a97;
  --line: #e2e7ec;
  --bg: #f4f6f8;
  --card: #fff;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
a { color: inherit; }

#app { height: 100dvh; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; background: var(--bg); position: relative; }

/* Header */
.top { background: var(--navy); color: #fff; padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 0; flex: none; }
.top-row { display: flex; align-items: center; gap: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.who { flex: 1; min-width: 0; }
.who b { display: block; font-size: 16px; }
.who span { font-size: 12.5px; opacity: .8; }
.icon-btn { background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.stats { display: flex; gap: 6px; margin: 10px 0 6px; }
.stat { flex: 1; background: rgba(255,255,255,.1); border-radius: 10px; padding: 6px 10px; text-align: left; border: 0; color: #fff; display: flex; align-items: baseline; gap: 6px; }
.stat b { font-size: 18px; line-height: 1.2; }
.stat span { font-size: 11.5px; opacity: .85; }
.stat.on { background: #fff; color: var(--navy); }
.tabs { display: flex; gap: 4px; }
.tab { flex: 1; background: none; border: 0; color: rgba(255,255,255,.75); padding: 8px 0 9px; font-weight: 600; font-size: 14px; border-bottom: 3px solid transparent; }
.tab.on { color: #fff; border-bottom-color: var(--teal); }

/* Body */
.body { flex: 1; min-height: 0; position: relative; }
.list { height: 100%; overflow-y: auto; padding: 12px 12px calc(24px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
.section-h { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin: 14px 4px 8px; display: flex; justify-content: space-between; }
.section-h:first-child { margin-top: 4px; }
.empty { text-align: center; color: var(--ink-3); padding: 48px 24px; font-size: 14.5px; line-height: 1.5; }
.empty b { display: block; color: var(--ink-2); font-size: 16px; margin-bottom: 4px; }

/* Cards */
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16,24,40,.06); border-left: 4px solid var(--case); }
.card.offer { border-left-color: var(--offer); }
.card.pending { border-left-color: #d9b100; }
.card.ie { border-left-color: var(--ie); }
.card.focus { box-shadow: 0 0 0 2px var(--navy); }
.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-title { flex: 1; min-width: 0; }
.card-title b { font-size: 16.5px; display: block; }
.card-title span { font-size: 13px; color: var(--ink-2); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #eef1f4; color: var(--ink-2); white-space: nowrap; }
.badge.offer { background: var(--offer-bg); color: #a85400; }
.badge.pending { background: var(--pending-bg); color: var(--pending); }
.badge.ie { background: var(--ie-bg); color: var(--ie); }
.badge.case { background: var(--case-bg); color: var(--case); }
.badge.disc { background: var(--navy); color: #fff; }
.badge.urgent { background: #fdeaea; color: var(--danger); }
.facts { margin: 10px 0 0; display: grid; grid-template-columns: 22px 1fr; gap: 6px 4px; font-size: 13.5px; color: var(--ink-2); }
.facts dt { text-align: center; }
.facts dd { margin: 0; }
.note { font-size: 12.5px; color: var(--ink-3); margin-top: 8px; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.btn { flex: 1; border: 0; border-radius: 11px; padding: 12px 10px; font-weight: 650; font-size: 15px; background: #eef1f4; color: var(--ink); text-align: center; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 46px; }
.btn.primary { background: var(--teal); color: #fff; }
.btn.accept { background: #1e9e5a; color: #fff; }
.btn.decline { background: #fff; color: var(--danger); box-shadow: inset 0 0 0 1.5px #efc7c7; }
.btn.ghost { background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.small { flex: none; min-height: 38px; padding: 8px 12px; font-size: 14px; }
.map-link { background: none; border: 0; padding: 0; color: var(--case); font-size: 13px; font-weight: 600; }

/* Map */
#map { position: absolute; inset: 0; }
.leaflet-container { font: inherit; background: #e9eef2; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3); display: grid; place-items: center; }
.pin i { transform: rotate(45deg); font-style: normal; font-weight: 800; font-size: 10.5px; color: #fff; letter-spacing: -.02em; }
.pin.offer { background: var(--offer); }
.pin.pending { background: #d9b100; }
.pin.ie { background: var(--ie); }
.pin.case { background: var(--case); }
.pin.sel { outline: 3px solid var(--navy); }
.legend { position: absolute; top: 10px; left: 10px; z-index: 500; background: rgba(255,255,255,.95); border-radius: 10px; padding: 6px 10px; font-size: 12px; display: flex; gap: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: 0; background: var(--c); }
.locate { position: absolute; right: 10px; top: 10px; z-index: 500; background: #fff; border: 0; border-radius: 10px; width: 40px; height: 40px; box-shadow: 0 1px 4px rgba(0,0,0,.2); font-size: 18px; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 600; padding: 0 10px calc(10px + var(--safe-bottom)); max-height: 72%; overflow-y: auto; }
.sheet .card { box-shadow: 0 6px 24px rgba(16,24,40,.22); margin: 0; }
.sheet-close { float: right; background: #eef1f4; border: 0; border-radius: 50%; width: 30px; height: 30px; font-size: 16px; line-height: 1; margin: -2px -2px 0 6px; }
.map-empty { position: absolute; inset: auto 16px 16px; z-index: 500; background: #fff; border-radius: 12px; padding: 12px 14px; font-size: 13.5px; color: var(--ink-2); box-shadow: 0 2px 10px rgba(0,0,0,.15); }

/* Dialog sheet */
.scrim { position: fixed; inset: 0; background: rgba(15,25,35,.45); z-index: 1000; display: flex; align-items: flex-end; justify-content: center; }
.dialog { background: #fff; width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px calc(16px + var(--safe-bottom)); }
.dialog h2 { margin: 0 0 4px; font-size: 18px; }
.dialog p { margin: 0 0 12px; color: var(--ink-2); font-size: 14px; line-height: 1.45; }
.dialog label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 10px 0 6px; }
.dialog textarea, .dialog input, .dialog select { width: 100%; font: inherit; font-size: 16px; padding: 11px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; }
.dialog textarea { min-height: 76px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 12px; font-size: 13.5px; }
.chip.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.err { color: var(--danger); font-size: 13.5px; margin-top: 8px; min-height: 1em; }

/* Sign-in */
.signin { flex: 1; overflow-y: auto; padding: calc(env(safe-area-inset-top, 0px) + 32px) 18px 32px; }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.brand img { width: 46px; height: 46px; }
.brand b { font-size: 21px; display: block; color: var(--navy); }
.brand span { font-size: 13.5px; color: var(--ink-2); }
.demo-note { background: var(--pending-bg); color: #5f4b00; border-radius: 12px; padding: 10px 12px; font-size: 13.5px; line-height: 1.45; margin-bottom: 16px; }
.person { display: flex; width: 100%; align-items: center; gap: 12px; background: #fff; border: 0; border-radius: 12px; padding: 12px; margin-bottom: 8px; text-align: left; box-shadow: 0 1px 2px rgba(16,24,40,.06); }
.person .avatar { background: var(--navy); color: #fff; }
.person b { display: block; font-size: 15.5px; }
.person span { font-size: 12.5px; color: var(--ink-3); }
.person em { margin-left: auto; font-style: normal; color: var(--ink-3); font-size: 20px; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; z-index: 2000; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
.loading { display: grid; place-items: center; height: 100%; color: var(--ink-3); font-size: 14px; }
