:root {
  --navy: #0a3162;
  --navy2: #12417f;
  --bg: #f1f5fb;
  --card: #ffffff;
  --surface: #ffffff;
  --line: #e2e9f3;
  --ink: #0b2447;
  --muted: #5f6f8a;
  --green: #5bcba0;
  --ok: #0b7a52;
  --warn: #9a5b00;
  --sos: #d92d3a;
  --radius: 18px;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--navy); color: var(--ink); font: 16px/1.45 var(--body); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 0.9rem; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ico { width: 22px; height: 22px; flex: none; }
:focus-visible { outline: 3px solid var(--navy); outline-offset: 2px; }
.logo-sm { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.logo-lg { width: 150px; height: 150px; display: block; margin: 0 auto; }
.hero .logo-lg { width: 104px; height: 104px; margin: -4px auto -6px; }

/* Estructura: cabecera azul + hoja clara */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.app-head { color: #fff; padding: calc(16px + env(safe-area-inset-top)) 20px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-head h1 { font-size: 1.4rem; }
.app-head.hero { flex-direction: column; text-align: center; padding-bottom: 20px; gap: 6px; position: relative; }
.hero .slogan { font-size: 1.02rem; line-height: 1.35; max-width: 280px; }
.hero .hi { opacity: 0.85; font-size: 0.9rem; }
.hero .pill { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; }
.phead { gap: 14px; justify-content: flex-start; padding-bottom: 28px; }
.phead .avatar { width: 66px; height: 66px; background: #fff; color: var(--navy); }
.phead b { font-size: 1.2rem; display: block; }
.phead small { opacity: 0.8; }
.page {
  flex: 1; background: var(--bg); border-radius: 28px 28px 0 0; padding: 18px 16px calc(104px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 14px;
}
.pill { font-size: 0.74rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--green); color: var(--navy); }
.pill.none { background: #e8edf5; color: var(--muted); display: inline-block; width: fit-content; }
.section-title { font-size: 1rem; font-weight: 700; margin: 8px 2px -4px; }

/* Barra inferior */
.tabbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr); background: #fff; border-top: 1px solid var(--line);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tab { appearance: none; border: 0; background: none; color: #6b7a94; font: 600 0.68rem var(--body); display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0 8px; cursor: pointer; position: relative; }
.tab.on { color: var(--navy); font-weight: 800; }
.tab.on::after { content: ""; position: absolute; bottom: 0; width: 26px; height: 3px; border-radius: 3px; background: var(--navy); }

/* Tarjetas base */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(11, 36, 71, 0.04); }
.card.stack > h2 + .muted { margin-top: -8px; }
.empty { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.iconbox { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; color: #fff; flex: none; background: var(--navy); }
.iconbox.lt { background: #e5eefb; color: var(--navy); }
.c-navy { background: var(--navy); } .c-red { background: var(--sos); }

/* Emergencia (siempre en rojo) */
.sos-card { background: var(--sos); color: #fff; border-radius: 22px; padding: 18px; }
.sos-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.sos-head p { font-size: 0.88rem; opacity: 0.92; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.sos-head p .ico { width: 18px; height: 18px; }
.sos-head h2 { font-size: 1.55rem; word-break: break-word; }
.blood { background: #fff; color: var(--sos); border-radius: 16px; padding: 8px 14px; text-align: center; flex: none; min-width: 82px; }
.blood small { display: block; font-size: 0.72rem; color: #7a1d26; }
.blood b { font: 800 2.3rem/1 var(--body); letter-spacing: -0.02em; }
.facts { margin: 14px 0 0; display: grid; gap: 8px; }
.facts div { background: rgba(0, 0, 0, 0.16); border-radius: 14px; padding: 10px 12px; }
.facts dt { font-size: 0.8rem; opacity: 0.88; }
.facts dd { margin: 2px 0 0; font-size: 1.05rem; font-weight: 600; white-space: pre-wrap; word-break: break-word; }
.callbtn { display: flex; align-items: center; gap: 12px; margin-top: 12px; background: #fff; color: var(--ink); text-decoration: none; border-radius: 14px; padding: 12px 16px; }
.callbtn .ico { color: var(--sos); width: 26px; height: 26px; }
.callbtn span { display: block; font-size: 0.82rem; color: var(--muted); }
.callbtn b { font-size: 1.15rem; }
.alertbar { background: var(--sos); color: #fff; border-radius: 16px; padding: 14px 16px; display: flex; gap: 12px; align-items: center; font-weight: 600; }
.alertbar .ico { width: 30px; height: 30px; }
.steps { background: #e8f0fb; border-radius: var(--radius); padding: 16px; }
.steps h2 { color: var(--navy); margin-bottom: 10px; }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: s; }
.steps li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; font-size: 0.95rem; }
.steps li::before { content: counter(s); background: var(--navy); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.8rem; font-weight: 700; flex: none; }
.phones { display: flex; flex-direction: column; }
.phones a { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); color: var(--ink); text-decoration: none; font-weight: 600; }
.phones a:first-of-type { border-top: 0; }
.phones a b { margin-left: auto; font-size: 1.05rem; }
.phones .ico { color: var(--navy); }

/* Inicio */
.vcard, .dcard .dmain, .tilec, .mrow {
  appearance: none; font: inherit; color: inherit; text-align: left; cursor: pointer; text-decoration: none;
}
.vcard { width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; align-items: center; gap: 14px; }
.vcard .rt b, .tilec b { font-size: 1.02rem; }
.rt { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.rt small { color: var(--muted); font-size: 0.84rem; font-weight: 400; }
.chev { color: #8a98b2; width: 20px; height: 20px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tilec { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; position: relative; min-height: 118px; }
.tilec .chev { position: absolute; right: 10px; top: 50%; margin-top: -6px; }
.tilec small { color: var(--muted); font-size: 0.78rem; line-height: 1.25; display: block; }
.tilec.sosc { background: #fdecee; border-color: #f4b3ba; }
.tilec.sosc b { color: var(--sos); }
.driver { display: flex; align-items: center; gap: 14px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; background: #e5eefb; color: var(--navy); display: grid; place-items: center; overflow: hidden; font-weight: 800; font-size: 1.15rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.plate { display: inline-block; background: #fff; color: #111; border: 3px solid #111; border-radius: 10px; padding: 2px 14px; font: 800 1.7rem/1.25 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0.12em; }
.plate.sm { font-size: 1rem; border-width: 2px; padding: 0 8px; border-radius: 7px; }

/* Documentos */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #e4ebf5; border-radius: 14px; padding: 4px; gap: 2px; }
.seg button { appearance: none; border: 0; background: none; color: var(--muted); font: 600 0.8rem var(--body); padding: 9px 4px; border-radius: 11px; cursor: pointer; }
.seg button.on { background: var(--navy); color: #fff; }
.dcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(11, 36, 71, 0.04); overflow: hidden; }
.dcard .dmain { width: 100%; border: 0; background: none; padding: 14px; display: flex; align-items: center; gap: 14px; }
.dcard .iconbox { width: 54px; height: 54px; border-radius: 16px; }
.dcard .rt b { font-size: 1rem; }
.dcard .rt .chip { align-self: flex-start; margin: 4px 0 2px; }
.dact { display: flex; gap: 6px; padding: 0 14px 12px 82px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 0.74rem; font-weight: 700; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.chip.ok { background: #dcf4ea; color: var(--ok); }
.chip.warn { background: #fff0d1; color: var(--warn); }
.chip.bad { background: #fde1e3; color: #b4232f; }
.chip.none { background: #e8edf5; color: #51607a; }

/* Vehículo, listas y menú */
.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn { appearance: none; border: 1.5px solid #cbd6e6; background: #fff; color: var(--ink); border-radius: 999px; padding: 7px 16px; font: 700 0.92rem ui-monospace, Menlo, Consolas, monospace; cursor: pointer; }
.pill-btn.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.drow { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.drow:first-of-type { border-top: 0; }
.drow .ico { color: var(--navy); width: 20px; height: 20px; }
.drow span { color: var(--muted); font-size: 0.92rem; }
.drow b { margin-left: auto; text-align: right; word-break: break-all; font-size: 0.95rem; }
.arow { width: 100%; appearance: none; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.arow:first-of-type { border-top: 0; }
.arow .iconbox { width: 38px; height: 38px; border-radius: 11px; }
.arow .iconbox .ico { width: 20px; height: 20px; }
.arow .rt b { font-size: 0.96rem; }
.menu { padding: 4px 16px; }
.mrow { width: 100%; border: 0; border-top: 1px solid var(--line); background: none; display: flex; align-items: center; gap: 14px; padding: 15px 0; font-weight: 600; font-size: 1rem; }
.mrow:first-child { border-top: 0; }
.mrow .ico:first-child { color: var(--navy); }
.mrow .chev { margin-left: auto; }
.brandfoot { text-align: center; color: var(--muted); padding: 12px 0; font-size: 0.85rem; }
.brandfoot img { width: 72px; height: 72px; display: block; margin: 0 auto 6px; border-radius: 18px; }

/* Formularios y botones */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.9rem; }
.field input, .field select, .field textarea { font: 400 1rem var(--body); color: var(--ink); background: #fff; border: 1.5px solid #cbd6e6; border-radius: 12px; padding: 12px 14px; width: 100%; }
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(91, 203, 160, 0.35); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 0.92rem; font-weight: 500; }
.check input { width: 22px; height: 22px; flex: none; margin-top: 1px; accent-color: var(--navy); }
.pw { display: flex; gap: 8px; align-items: center; }
.pw input { flex: 1; min-width: 0; }
.btn {
  appearance: none; cursor: pointer; font: 700 1rem var(--body); text-decoration: none; text-align: center; gap: 8px;
  border: 1.5px solid #cbd6e6; background: #fff; color: var(--navy); border-radius: 14px; padding: 12px 20px; min-height: 46px;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn .ico { width: 20px; height: 20px; }
.btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.block { width: 100%; }
.btn.small { padding: 7px 14px; min-height: 36px; font-size: 0.86rem; border-radius: 11px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.danger { color: var(--sos); border-color: #f0a9b0; background: #fff; }
.btn.ghost.danger { border-color: transparent; background: none; }
.btn.link { border: 0; background: none; text-decoration: underline; min-height: 0; padding: 6px; color: #fff; font-weight: 500; }
.btn:disabled { opacity: 0.55; cursor: progress; }
.danger-zone { border-color: #f0a9b0; background: #fff7f8; }
.danger-zone h2 { color: var(--sos); }
.notice { background: #fff3cf; border: 1px solid #ecd27a; color: #6b4d00; border-radius: 12px; padding: 10px 12px; font-size: 0.92rem; }
.linkbox { background: var(--bg); border: 1px dashed #9fb0c7; border-radius: 12px; padding: 10px 12px; overflow-wrap: anywhere; font-size: 0.86rem; }

/* Acceso (pantalla azul con logo) */
.auth { max-width: 420px; margin: 0 auto; padding: calc(36px + env(safe-area-inset-top)) 18px 40px; display: flex; flex-direction: column; gap: 16px; color: #fff; }
.auth .tagline { text-align: center; line-height: 1.35; }
.auth .card { color: var(--ink); }
.brand { display: flex; align-items: center; gap: 10px; font: 800 1.3rem var(--body); }

/* Modal, visor y avisos */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(10, 49, 98, 0.55); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; border-radius: 26px 26px 0 0; padding: 22px 18px calc(24px + env(safe-area-inset-bottom)); }
.viewer { position: fixed; inset: 0; z-index: 30; background: #061d3d; display: flex; flex-direction: column; color: #fff; }
.viewer-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; }
.viewer-bar .btn { color: #fff; border-color: rgba(255, 255, 255, 0.6); background: none; }
.viewer-body { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 10px calc(14px + env(safe-area-inset-bottom)); align-items: center; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; margin: auto; touch-action: pinch-zoom; }
.viewer-body iframe { width: 100%; flex: 1; min-height: 60vh; border: 0; background: #fff; border-radius: 12px; }
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(12px); z-index: 40;
  background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; max-width: 90vw; border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; font-weight: 600; font-size: 0.93rem; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.app-head .pill { margin-left: auto; }
.card .btn.link { color: var(--navy); }
.tilec > span:nth-child(2) { padding-right: 14px; }
.vcard .rt b { font-size: 1rem; }

.cblock { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 12px; background: #f8fafd; }
.cb-head { display: flex; justify-content: space-between; align-items: center; }
.cblock .grid2 { grid-template-columns: 1.6fr 1fr; }
.auth .privacy { font-size: 0.82rem; opacity: 0.85; text-align: center; line-height: 1.4; }
.notice-info { background: #e8f0fb; color: var(--navy); border-radius: 12px; padding: 10px 12px; font-size: 0.84rem; line-height: 1.4; }

.pushbanner { display: flex; align-items: center; gap: 10px; padding: 12px; }

/* v2 */
.auth .privacy a, .auth .tagline a { color: #fff; }
.notice-info a, .check a { color: var(--navy); font-weight: 600; }
.check.consent { background: #fff7f8; border: 1px solid #f0a9b0; border-radius: 12px; padding: 10px 12px; }
.check input:disabled + span { opacity: 0.6; }
.notice-card { border-color: #ecd27a; background: #fffbea; }
a.mrow { color: inherit; }
.section-title { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.section-title .ico { color: var(--navy); width: 20px; height: 20px; }
.pay-card { border-color: #ecd27a; background: #fffbea; }
.pay-card.bad { border-color: #f0a9b0; background: #fff7f8; }
.pay-card.bad h2 { color: var(--sos); }
.pay-card a, .card .muted a { color: var(--navy); font-weight: 600; }
.xbtn { appearance: none; border: 0; background: none; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 2px 6px; align-self: flex-start; }

/* Chat con Soporte */
.chat-bubble { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 15; width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--navy); color: #fff; display: grid; place-items: center; box-shadow: 0 6px 18px rgba(10, 49, 98, 0.35); cursor: pointer; }
.chat-bubble .ico { width: 28px; height: 28px; }
.chat-badge { position: absolute; top: -2px; right: -2px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--sos); color: #fff; font: 800 0.75rem/22px var(--body); border: 2px solid #fff; }
@media (min-width: 600px) { .chat-bubble { right: max(16px, calc(50vw - 280px - 76px)); } }
.chat-popup { position: fixed; right: 16px; bottom: calc(152px + env(safe-area-inset-bottom)); z-index: 16; width: min(320px, calc(100vw - 32px)); background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--navy); border-radius: 16px; padding: 12px 14px; box-shadow: 0 10px 28px rgba(11, 36, 71, 0.22); display: flex; flex-direction: column; gap: 8px; }
.chat-popup .cp-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.chat-popup .cp-head b { display: flex; align-items: center; gap: 6px; color: var(--navy); font-size: 0.95rem; }
.chat-popup .cp-head .ico { width: 18px; height: 18px; }
.chat-popup p { font-size: 0.92rem; white-space: pre-wrap; word-break: break-word; }
.chat-popup .btn { align-self: flex-start; }
.chat-panel { position: fixed; right: 8px; left: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 18; height: min(78vh, 620px); background: var(--bg); border-radius: 22px; box-shadow: 0 16px 40px rgba(11, 36, 71, 0.35); display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); }
@media (min-width: 600px) { .chat-panel { left: auto; right: 16px; bottom: 16px; width: 390px; } }
.chat-panel[hidden] { display: none !important; }
.cp-top { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.cp-top .iconbox { width: 40px; height: 40px; border-radius: 12px; }
.cp-top small { color: rgba(255, 255, 255, 0.8) !important; }
.cp-top .xbtn { color: #fff; }
.cp-list { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; }
.cm { max-width: 84%; border-radius: 16px; padding: 9px 12px; }
.cm p { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 0.95rem; }
.cm small { display: flex; align-items: center; gap: 4px; font-size: 0.72rem; margin-top: 4px; opacity: 0.75; }
.cm small .ico { width: 14px; height: 14px; }
.cm.me { align-self: flex-end; background: var(--navy); color: #fff; border-bottom-right-radius: 6px; }
.cm.me small { justify-content: flex-end; }
.cm.sup { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.cm.ann { align-self: stretch; max-width: none; background: #fff7e0; border: 1px solid #ecd27a; color: #5a4300; }
.cm.ann small { font-weight: 700; opacity: 1; margin: 0 0 4px; }
.cm-empty { text-align: center; padding: 24px 12px; }
.cp-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 12px 4px; background: #fff; border-top: 1px solid var(--line); align-items: end; }
.cp-form textarea { font: 400 1rem var(--body); border: 1.5px solid #cbd6e6; border-radius: 14px; padding: 10px 12px; resize: none; max-height: 140px; width: 100%; }
.cp-form textarea:focus { border-color: var(--navy); outline: none; }
.cp-form .btn { min-height: 46px; padding: 10px 14px; }
.cp-form #form-msg { grid-column: 1 / -1; }
.cp-form #form-msg:empty { display: none; }
.cp-foot { background: #fff; margin: 0; padding: 4px 14px 10px; font-size: 0.78rem; color: var(--muted); }
.cp-foot a { color: var(--navy); font-weight: 600; }
.install-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 0.93rem; }
/* Errores de formulario bien visibles */
#form-msg.form-error { background: #fde1e3; color: #9b1c27; border: 1px solid #f0a9b0; border-radius: 12px; padding: 10px 12px; font-size: 0.92rem; font-weight: 600; }
