:root {
  --primary: #1B4BA8; --primary-dark: #142F6B; --primary-light: #EBF0FA;
  --accent: #16A34A; --accent-light: #DCFCE7;
  --gold: #B8962E; --gold-light: #F5E6B8; --gold-dark: #7A6220;
  --bg: #F4F6FB; --surface: #FFFFFF; --border: #D1D9E6;
  --text: #0F172A; --text-2: #3D4E6B; --text-3: #8496B0;
  --danger: #DC2626; --radius: 10px; --radius-sm: 6px;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; padding-bottom: 48px; font-size: 15px; }

/* HEADER */
.header { background: #0D2050; padding: 18px 16px 14px; position: sticky; top: 0; z-index: 100; border-bottom: 3px solid var(--primary); }
.header-inner { max-width: 500px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.hlogo { width: 44px; height: 44px; border-radius: 8px; overflow: hidden; border: 1.5px solid rgba(184,150,46,0.5); background: #142F6B; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.hlogo img { width: 38px; height: 38px; object-fit: contain; }
.hlogo-fallback { display: none; width: 22px; height: 22px; fill: white; }
.htxt h1 { font-size: 15px; font-weight: 700; color: white; letter-spacing: 0.05em; }
.htxt p { font-size: 11px; color: #93C5FD; margin-top: 1px; }
.hdate { margin-left: auto; text-align: right; flex-shrink: 0; }
.hdate .dv { font-size: 13px; font-weight: 600; color: white; }
.hdate .dl { font-size: 10px; color: #B8962E; text-transform: uppercase; letter-spacing: 0.05em; }
.pbar { height: 3px; background: rgba(255,255,255,0.15); margin-top: 10px; }
.gold-bar { height: 3px; background: #B8962E; }
.pfill { height: 100%; background: #5B8DEF; transition: width 0.3s ease; width: 0%; }

/* LAYOUT */
.wrap { max-width: 500px; margin: 0 auto; padding: 16px 14px 0; }
.card { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 10px; overflow: hidden; }
.card-head { padding: 11px 14px 9px; border-bottom: 1px solid #F1F5F9; display: flex; align-items: center; gap: 8px; }
.cicon { width: 26px; height: 26px; border-radius: 6px; background: var(--primary-light); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cicon svg { width: 14px; height: 14px; stroke: #1B4BA8; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctitle { font-size: 11px; font-weight: 600; color: var(--text-2); letter-spacing: 0.07em; text-transform: uppercase; }
.cbody { padding: 14px; }

/* FIELDS */
.field { margin-bottom: 13px; }
.field:last-child { margin-bottom: 0; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label { display: block; font-size: 11px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; letter-spacing: 0.03em; text-transform: uppercase; }
.req { color: var(--danger); margin-left: 2px; }
input[type=text], input[type=time], input[type=tel], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; font-family: inherit; color: var(--text); background: #FAFCFF;
  outline: none; transition: border-color 0.15s, box-shadow 0.15s; -webkit-appearance: none; appearance: none; min-height: 44px;
}
input:focus, textarea:focus, select:focus { border-color: #1B4BA8; box-shadow: 0 0 0 3px rgba(3,105,161,0.1); background: white; }
textarea { resize: none; line-height: 1.5; }
.sw { position: relative; }
.sw::after { content:''; position:absolute; right:12px; top:50%; transform:translateY(-50%); width:0; height:0; border-left:5px solid transparent; border-right:5px solid transparent; border-top:6px solid var(--text-3); pointer-events:none; }
.helper { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* AUTOCOMPLETE */
.ac-wrap { position: relative; }
/* Tarjetas con autocompletado dejan salir el dropdown (sin recortar) y lo ponen por encima */
.card-store { overflow: visible; position: relative; z-index: 50; }
.card-patrol { overflow: visible; position: relative; z-index: 60; }
.ac-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: white; border: 1.5px solid #1B4BA8; border-radius: var(--radius-sm); z-index: 200; box-shadow: 0 8px 24px rgba(15,23,42,0.18); display: none; max-height: 330px; overflow-y: auto; }
.ac-list.show { display: block; }
.ac-item { padding: 10px 12px; font-size: 14px; color: var(--text); cursor: pointer; border-bottom: 1px solid #F1F5F9; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item:active { background: var(--primary-light); color: var(--primary-dark); }
.ztag { font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 99px; flex-shrink: 0; text-transform: uppercase; letter-spacing: 0.03em; }
.zt-n { background:#EBF0FA; color:#1B4BA8; }
.zt-s { background:#FEF2F2; color:#DC2626; }
.ac-empty { padding: 11px 12px; font-size: 13px; color: var(--text-3); }

/* EVENT CHIPS */
.egrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.chip { border: 2px solid var(--border); border-radius: var(--radius); padding: 12px 6px 10px; text-align: center; cursor: pointer; background: #FAFCFF; transition: all 0.18s; user-select: none; display: flex; flex-direction: column; align-items: center; gap: 5px; min-height: 78px; justify-content: center; }
.chip:active { transform: scale(0.97); }
.cico { width: 32px; height: 32px; border-radius: 7px; display: flex; align-items: center; justify-content: center; }
.cico svg { width: 17px; height: 17px; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.clbl { font-size: 12px; font-weight: 600; color: var(--text-2); line-height: 1.2; }
.chip-otro { grid-column: 2 / 4; flex-direction: row; justify-content: center; min-height: 52px; padding: 12px 16px; gap: 10px; }
.chip-otro .cico { width: 28px; height: 28px; flex-shrink: 0; }
.chip-otro .clbl { font-size: 14px; }

.chip-r .cico { background:#FEF2F2; } .chip-r .cico svg { stroke:#DC2626; }
.chip-a .cico { background:#FFF7ED; } .chip-a .cico svg { stroke:#EA580C; }
.chip-i .cico { background:#F0FDF4; } .chip-i .cico svg { stroke:#16A34A; }
.chip-v .cico { background:#FFF1F2; } .chip-v .cico svg { stroke:#9F1239; }
.chip-otro .cico { background:#F1F5F9; } .chip-otro .cico svg { stroke:#475569; }

.chip-r.on  { border-color:#DC2626; background:#FEF2F2; } .chip-r.on .clbl { color:#991B1B; }
.chip-a.on  { border-color:#EA580C; background:#FFF7ED; } .chip-a.on .clbl { color:#9A3412; }
.chip-i.on  { border-color:var(--accent); background:var(--accent-light); } .chip-i.on .clbl { color:#14532D; }
.chip-v.on  { border-color:#9F1239; background:#FFF1F2; } .chip-v.on .clbl { color:#881337; }
.chip-otro.on { border-color:#475569; background:#F1F5F9; } .chip-otro.on .clbl { color:#1E293B; }

/* INDIGENTE SUB-CHIPS */
.indiv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 13px; }
.indiv-chip { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 9px 8px; text-align: center; cursor: pointer; background: #FAFCFF; font-size: 12px; font-weight: 600; color: var(--text-2); transition: all 0.15s; min-height: 44px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.indiv-chip.on { border-color: #1B4BA8; background: #EBF0FA; color: #142F6B; }
.indiv-chip svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* NIVEL 1 — Incidencias / Hallazgos */
.chip-inc .cico { background:#FEF2F2; } .chip-inc .cico svg { stroke:#DC2626; }
.chip-hal .cico { background:#EBF0FA; } .chip-hal .cico svg { stroke:#1B4BA8; }
.chip-inc.on { border-color:#DC2626; background:#FEF2F2; } .chip-inc.on .clbl { color:#991B1B; }
.chip-hal.on { border-color:#1B4BA8; background:#EBF0FA; } .chip-hal.on .clbl { color:#142F6B; }

/* NIVEL 2 — chips de subtipo (pills que envuelven) */
.n2grid { display: flex; flex-wrap: wrap; gap: 7px; }
.n2chip { border: 1.5px solid var(--border); border-radius: 99px; padding: 8px 13px; cursor: pointer; background: #FAFCFF; font-size: 12.5px; font-weight: 600; color: var(--text-2); transition: all 0.15s; user-select: none; line-height: 1.2; }
.n2chip:active { transform: scale(0.97); }
.n2chip.on { border-color: #1B4BA8; background: #1B4BA8; color: #fff; box-shadow: 0 2px 6px rgba(27,75,168,0.25); }

/* CHECKBOXES (selección múltiple) */
.chkrow { display: flex; flex-wrap: wrap; gap: 7px; }
.chk { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; cursor: pointer; background: #FAFCFF; font-size: 13px; font-weight: 500; color: var(--text-2); user-select: none; min-height: 40px; }
.chk input { width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: #1B4BA8; }
.chk.on { border-color: #1B4BA8; background: #EBF0FA; color: #142F6B; }

/* DYNAMIC SECTIONS */
.dyn { display: none; animation: si 0.2s ease-out; }
.dyn.show { display: block; }
@keyframes si { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }

/* OPT FIELDS (Otro) */
.opt-field { border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 8px; }
.opt-field:last-child { margin-bottom: 0; }
.opt-toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; background: #F8FAFC; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; user-select: none; font-size: 13px; font-weight: 500; color: var(--text-2); transition: background 0.15s; }
.opt-toggle:active { background: #EFF6FF; }
.opt-toggle .ot-label { display: flex; align-items: center; gap: 8px; }
.opt-toggle svg { width: 14px; height: 14px; stroke: var(--text-3); fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s; flex-shrink: 0; }
.opt-toggle.open svg.arr { transform: rotate(180deg); }
.opt-toggle.open { background: var(--primary-light); color: var(--primary-dark); border-color: var(--primary); }
.opt-toggle.open svg { stroke: #1B4BA8; }
.opt-body { display: none; padding: 12px; border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); background: white; }
.opt-body.open { display: block; animation: si 0.18s ease-out; }
.opt-body .field:last-child { margin-bottom: 0; }

/* TIME ROW */
.trow { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 8px; }
.tsep { font-size: 13px; color: var(--text-3); padding-bottom: 11px; text-align: center; font-weight: 500; }

/* UPLOAD */
.upload { border: 2px dashed var(--border); border-radius: var(--radius); padding: 20px 14px; text-align: center; cursor: pointer; background: #FAFCFF; transition: border-color 0.15s; }
.geo-ok { border-color: #16A34A; border-style: solid; background: #DCFCE7; }
.geo-ok .utxt, .geo-ok .usub { color: #14532D; }
.geo-ok .uiw { background: #BBF7D0; }
.geo-ok .uiw svg { stroke: #16A34A; }
.geo-err { border-color: #DC2626; border-style: solid; background: #FEF2F2; }
.geo-err .utxt { color: #991B1B; }
.geo-err .uiw { background: #FECACA; }
.geo-err .uiw svg { stroke: #DC2626; }
.upload:active { border-color: #1B4BA8; background: #EBF0FA; }
.uiw { width: 42px; height: 42px; background: #EBF0FA; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin: 0 auto 9px; }
.uiw svg { width: 20px; height: 20px; stroke: #1B4BA8; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.utxt { font-size: 14px; font-weight: 600; color: #1B4BA8; }
.usub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.fprev { display: none; margin-top: 9px; padding: 9px 12px; background: var(--accent-light); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; color: #14532D; align-items: center; gap: 7px; }
.fprev svg { width: 15px; height: 15px; stroke: var(--accent); fill: none; stroke-width: 2.5; flex-shrink: 0; }

/* BUTTONS */
.actions { max-width: 500px; margin: 12px auto 0; padding: 0 14px; display: flex; flex-direction: column; gap: 9px; }
.btn { width: 100%; padding: 14px; border-radius: var(--radius); font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.15s; min-height: 50px; border: none; }
.btn:active { transform: scale(0.985); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-p { background: #1B4BA8; color: white; box-shadow: 0 2px 8px rgba(27,75,168,0.25); }
.btn-p:active:not(:disabled) { background: #142F6B; }
.btn-s { background: white; color: var(--primary-dark); border: 2px solid var(--border); }
.btn-s:active:not(:disabled) { background: #F1F5F9; }
.btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.ordiv { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); }
.ordiv::before, .ordiv::after { content:''; flex:1; height:1px; background:var(--border); }
.badge { display:inline-flex; align-items:center; font-size:10px; font-weight:600; padding:2px 8px; border-radius:99px; background:#F1F5F9; color:var(--text-3); border:1px solid var(--border); margin-left:6px; text-transform:uppercase; letter-spacing:0.04em; }

/* TOAST */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); background: #0F172A; color: white; padding: 12px 20px; border-radius: var(--radius); font-size: 14px; font-weight: 500; z-index: 999; transition: transform 0.3s ease; white-space: nowrap; max-width: 90vw; text-align: center; box-shadow: 0 4px 20px rgba(0,0,0,0.3); }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: #14532D; border-left: 4px solid #16A34A; }
.toast.error { background: #7F1D1D; border-left: 4px solid #DC2626; }

/* SPINNER */
.spin { width: 17px; height: 17px; border: 2.5px solid rgba(255,255,255,0.3); border-top-color: white; border-radius: 50%; animation: sp 0.7s linear infinite; flex-shrink: 0; }
@keyframes sp { to { transform: rotate(360deg); } }
