body { font-size: 16px; }
.small { font-size: 13px; }
#main { min-height: 100%; display: flex; flex-direction: column; padding-bottom: calc(150px + env(safe-area-inset-bottom)); }

.top {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5;
}
.top .grow { flex: 1; min-width: 0; }
.me-name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conn { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

.content { padding: 16px; display: grid; gap: 16px; width: 100%; max-width: 560px; margin: 0 auto; }
.top { max-width: none; }
#warnings, .panic-banner { max-width: 528px; margin-left: auto !important; margin-right: auto !important; }
@media (max-width: 560px) { #warnings, .panic-banner { margin-left: 16px !important; margin-right: 16px !important; } }

/* Driver map + day summary */
.map-card { padding: 0; overflow: hidden; position: relative; }
.dmap { height: 260px; background: var(--surface-2); }
.dmap .leaflet-tile-pane { filter: brightness(.85) saturate(.9); }
.map-btn { position: absolute; right: 10px; top: 10px; z-index: 500; background: var(--surface); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: #2f7bff; border: 3px solid #fff; box-shadow: 0 0 0 6px rgb(47 123 255 / .25); transform: translate(-9px, -9px); }
.pickup-pin { font-size: 28px; line-height: 1; transform: translate(-14px, -28px); filter: drop-shadow(0 1px 2px rgb(0 0 0 / .6)); }
.day-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.day-stats div { background: var(--surface-2); border-radius: 10px; padding: 10px 4px; }
.day-stats b { display: block; font-size: 24px; }
.day-stats span { font-size: 12px; color: var(--muted); }
.day-trip { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 14px; }
.day-trip:first-child { margin-top: 10px; }
.day-trip time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.day-trip .grow { flex: 1; min-width: 0; }
.day-trip .badge { align-self: flex-start; }
.day-empty { margin: 10px 0 0; }
.warn-line { margin: 8px 16px 0; padding: 10px 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, var(--warn) 20%, var(--surface)); border: 1px solid var(--warn); }
.warn-line.demo { background: color-mix(in srgb, var(--info) 22%, var(--surface)); border-color: var(--info); }
.warn-line.danger { background: color-mix(in srgb, var(--danger) 22%, var(--surface)); border-color: var(--danger); }

.status-card { text-align: center; }
.status-label { font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.status-label.on { color: var(--ok); }
.status-btn { width: 100%; min-height: 64px; font-size: 20px; border-radius: 14px; }
.status-btn.go { background: var(--ok); border-color: var(--ok); color: #fff; }

.kv { display: grid; gap: 2px; margin-top: 10px; }
.kv strong { font-size: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.wide { width: 100%; margin-top: 10px; min-height: 52px; }
.big { min-height: 64px; font-size: 20px; }

/* Panic */
.panic-banner { margin: 8px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--danger); color: #fff;
  display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.panic-banner button { background: #fff; color: #000; border: 0; }

.sos-wrap { position: fixed; left: 0; right: 0; bottom: 0; display: grid; place-items: center;
  padding: 12px 0 calc(16px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 35%); z-index: 6; }
.sos {
  position: relative; width: 112px; height: 112px; border-radius: 50%; border: 0; background: var(--danger); color: #fff;
  display: grid; place-items: center; align-content: center; gap: 0; box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 30%, transparent);
  user-select: none; -webkit-user-select: none; touch-action: none; -webkit-touch-callout: none;
}
.sos-text { font-size: 28px; font-weight: 900; letter-spacing: 1px; }
.sos-hint { font-size: 11px; opacity: .85; }
.sos-ring { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); transform: rotate(-90deg); pointer-events: none; }
.sos-ring circle { fill: none; stroke: #fff; stroke-width: 5; stroke-dasharray: 289; stroke-dashoffset: 289; }
.sos.holding .sos-ring circle { transition: stroke-dashoffset 2s linear; stroke-dashoffset: 0; }
.sos.sent { background: #7a0d14; }

/* Overlays */
.overlay { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / .7); display: grid; place-items: end center; }
.offer { width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
.offer h2 { font-size: 24px; }
.offer-distance { font-size: 34px; font-weight: 900; color: var(--accent); margin-top: 6px; }
.countdown { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 16px; }
.countdown div { height: 100%; background: var(--accent); width: 100%; }

.scan { background: #000; place-items: stretch; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto; overflow: auto; }
.grid2 > * { min-width: 0; }
.scan-head { padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); color: #fff; }
.scan-cam { position: relative; overflow: hidden; min-height: 240px; }
.scan-cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 6%; right: 6%; top: 32%; height: 28%; border: 3px solid var(--accent); border-radius: 10px;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / .35); }
.scan-hint { position: absolute; left: 16px; right: 16px; bottom: 12px; color: #fff; text-align: center; font-weight: 600; margin: 0;
  text-shadow: 0 1px 3px #000; }
.scan-actions { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.scan-form { margin: 0 12px 12px; align-self: start; }
.scan-form img { width: 100%; border-radius: 8px; margin-bottom: 8px; }
.photo-btn { width: 100%; margin: 0; color: var(--text); font-size: 15px; }
.result { margin-top: 12px; padding: 12px; border-radius: 10px; font-weight: 700; }
.result.ok { background: color-mix(in srgb, var(--ok) 22%, var(--surface)); border: 1px solid var(--ok); }
.result.bad { background: var(--danger); color: #fff; font-size: 18px; }
.result.warn { background: color-mix(in srgb, var(--warn) 22%, var(--surface)); border: 1px solid var(--warn); }
