:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --ink: #111827;
  --muted: #5b6577;
  --line: #e2e7ef;
  --brand: #0f3d91;
  --brand-2: #1d5fd6;
  --red: #c8102e;
  --ok: #0f8a4b;
  --warn: #b45309;
  --shadow: 0 10px 30px rgba(15, 30, 60, .16), 0 2px 6px rgba(15, 30, 60, .08);
  --r: 16px;
  --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.45 Inter, system-ui, -apple-system, sans-serif; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
#map { position: fixed; inset: 0; }
[hidden] { display: none !important; }

/* Barra superior */
.top { position: fixed; left: 12px; right: 12px; top: calc(10px + var(--safe-t)); display: flex; align-items: center; gap: 10px; z-index: 5; pointer-events: none; }
.top > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,.94); backdrop-filter: blur(10px); padding: 7px 14px 7px 8px; border-radius: 999px; box-shadow: var(--shadow); min-width: 0; }
.brand img { border-radius: 10px; }
.brand h1 { font-size: 15px; margin: 0; font-weight: 750; letter-spacing: -.01em; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net { background: var(--warn); color: #fff; font-size: 12px; font-weight: 650; padding: 5px 10px; border-radius: 999px; box-shadow: var(--shadow); }
.icon-btn { margin-left: auto; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.94); box-shadow: var(--shadow); display: grid; place-items: center; color: var(--brand); }

/* Barra inferior */
.dock { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(14px + var(--safe-b)); display: flex; align-items: center; gap: 14px; z-index: 5; }
.dock-btn { width: 72px; height: 62px; border: 0; border-radius: 18px; background: rgba(255,255,255,.96); box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--brand); font-size: 11px; font-weight: 650; }
.shutter { height: 72px; padding: 0 26px; border: 0; border-radius: 999px; background: linear-gradient(135deg, var(--brand-2), var(--brand)); color: #fff; display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; box-shadow: 0 12px 28px rgba(15, 61, 145, .45); }
.shutter svg { width: 28px; height: 28px; }
.shutter:active, .dock-btn:active, .btn:active { transform: scale(.97); }

.pick-bar { position: fixed; left: 12px; right: 12px; top: calc(68px + var(--safe-t)); z-index: 6; background: var(--ink); color: #fff; border-radius: 14px; padding: 10px 10px 10px 14px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); font-size: 14px; }
.pick-bar span { flex: 1; }

/* Hoja inferior */
.scrim { position: fixed; inset: 0; background: rgba(10, 20, 40, .35); z-index: 9; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--bg); border-radius: 22px 22px 0 0; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; box-shadow: 0 -10px 40px rgba(0,0,0,.25); padding: 6px 16px calc(18px + var(--safe-b)); animation: up .22s ease-out; }
@media (min-width: 760px) { .sheet { left: auto; right: 16px; top: 16px; bottom: 16px; width: 440px; border-radius: 22px; max-height: none; } }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.grip { width: 42px; height: 5px; border-radius: 9px; background: #c9d1de; margin: 4px auto 10px; }
.sheet h2 { font-size: 19px; margin: 2px 0 12px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.sheet h2 .x { margin-left: auto; width: 36px; height: 36px; border: 0; border-radius: 50%; background: #e7ebf2; font-size: 20px; line-height: 1; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; }
.card h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.photo { position: relative; border-radius: var(--r); overflow: hidden; background: #dde3ec; margin-bottom: 12px; aspect-ratio: 4 / 3; }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .retake { position: absolute; right: 10px; bottom: 10px; }

.terr { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 0; }
.terr dt { color: var(--muted); font-size: 13px; }
.terr dd { margin: 0; font-weight: 650; }
.terr dd small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.coords { font-variant-numeric: tabular-nums; font-size: 13.5px; color: var(--muted); }
.coords b { color: var(--ink); font-weight: 650; }
.gps { text-transform: none; letter-spacing: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 650; padding: 3px 9px; border-radius: 999px; background: #e8eefb; color: var(--brand); }
.gps.ok { background: #e3f5ea; color: var(--ok); }
.gps.warn { background: #fdf0e0; color: var(--warn); }
.gps i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.gps.wait i { animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; font-weight: 650; margin-bottom: 5px; }
label.f > span em { color: var(--red); font-style: normal; }
.in { width: 100%; border: 1px solid #cfd7e4; background: #fff; border-radius: 12px; padding: 12px 13px; font-size: 16px; outline: none; }
.in:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(29, 95, 214, .18); }
textarea.in { min-height: 96px; resize: vertical; }

.btn { border: 1px solid #cfd7e4; background: #fff; border-radius: 12px; padding: 11px 16px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.danger { color: var(--red); }
.btn.sm { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.actions { display: flex; gap: 10px; position: sticky; bottom: calc(-18px - var(--safe-b)); background: var(--bg); padding: 10px 0 4px; }
.actions .btn { flex: 1; padding: 14px; }

/* Lista */
.search { position: relative; margin-bottom: 10px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; gap: 12px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 8px; text-align: left; width: 100%; }
.item img, .item .ph { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #dde3ec; flex: none; }
.item b { display: block; font-size: 15px; }
.item small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.muted { color: var(--muted); font-size: 13px; }
.obs-text { white-space: pre-wrap; margin: 0; }
.seg { display: flex; background: #e7ebf2; border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 9px 6px; font-weight: 650; font-size: 14px; color: var(--muted); }
.seg button.on { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.bar { height: 6px; background: #e7ebf2; border-radius: 9px; overflow: hidden; margin-top: 8px; }
.bar b { display: block; height: 100%; width: 0; background: var(--brand-2); transition: width .2s; }
.chk { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.chk input { width: 20px; height: 20px; accent-color: var(--brand); }

.toast { position: fixed; left: 50%; bottom: calc(104px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: calc(100vw - 32px); box-shadow: var(--shadow); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

.maplibregl-ctrl-bottom-right { bottom: calc(96px + var(--safe-b)); }
.maplibregl-ctrl-attrib { font-size: 10px; }
.pin { width: 30px; height: 30px; border-radius: 50% 50% 50% 0; background: var(--red); transform: rotate(-45deg); border: 3px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,.35); }
.me-dot { width: 18px; height: 18px; border-radius: 50%; background: var(--brand-2); border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(29,95,214,.25); }
