/* Salud en Orden — estilo claro, alto contraste y botones grandes (pensado para gente grande). Base de diseño de Técnico Frío. */
:root {
  --bg: #EEF3F6; --card: #FFFFFF; --text: #13232E; --muted: #4F6170; --line: #D6E0E7;
  --brand: #0E5E6F; --brand2: #0A4654; --brandL: #E3F1F3; --accent: #F2652E; --accent2: #D9531F;
  --ok: #1E8E5A; --okL: #E2F5EB; --warn: #C76A00; --warnL: #FFF2DE; --bad: #C8322C; --badL: #FDE7E6;
  --fd: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif; --fb: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 18px; --sh: 0 1px 2px rgba(16,40,52,.06), 0 6px 18px rgba(16,40,52,.07);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 500 1.0625rem/1.45 var(--fb); padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
body.nonav { padding-bottom: 0; } body.nonav .nav { display: none; }
body.noscroll { overflow: hidden; }
h1, h2, h3 { font-family: var(--fd); letter-spacing: .1px; margin: 0; line-height: 1.08; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
.ic { width: 1.35em; height: 1.35em; flex: none; }
.ic.xl { width: 54px; height: 54px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 28px; display: flex; flex-direction: column; gap: 14px; }
.muted { color: var(--muted); } .small { font-size: .9rem; }

/* Encabezados */
.top { background: var(--brand); color: #fff; padding: calc(14px + env(safe-area-inset-top)) 16px 18px; }
.top-in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 1.85rem; font-weight: 800; }
.top p { margin: 2px 0 0; color: #CFE6EA; font-size: .98rem; }
.iconbtn { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.14); color: #fff; flex: none; }
.wrap .iconbtn { background: var(--brandL); color: var(--brand); }

/* Inicio */
.hero { background: linear-gradient(160deg, var(--brand) 0%, var(--brand2) 100%); color: #fff; padding: calc(16px + env(safe-area-inset-top)) 16px 22px; border-radius: 0 0 28px 28px; }
.hero-in { max-width: 640px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hi { margin: 0; color: #CFE6EA; font-size: 1.05rem; }
.hero h1 { font-size: 2.3rem; font-weight: 800; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px; }
.stats b { display: block; font: 800 1.9rem/1 var(--fd); }
.stats b.warn { color: #FFC59E; }
.stats span { font-size: .86rem; color: #DCEDF0; line-height: 1.2; display: block; margin-top: 3px; }
.sbox { display: flex; align-items: center; gap: 6px; background: #fff; border-radius: 16px; padding: 6px 6px 6px 14px; box-shadow: var(--sh); }
.sbox.light { border: 2px solid var(--line); box-shadow: none; }
.sbox .sic { color: var(--muted); display: flex; }
.sbox input { flex: 1; min-width: 0; border: 0; outline: 0; font: 600 1.1rem var(--fb); color: var(--text); padding: 10px 4px; background: none; }
.micbtn { width: 48px; height: 48px; border-radius: 12px; background: var(--brandL); color: var(--brand); display: grid; place-items: center; flex: none; }
.micbtn.rec { background: var(--accent); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.pchip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.16); color: #fff; border-radius: 99px; padding: 5px 12px 5px 5px; font-weight: 700; font-size: .98rem; align-self: flex-start; }
.wrap .pchip { background: #fff; color: var(--text); border: 2px solid var(--line); }
.pchip small { opacity: .8; font-weight: 600; }
.av { width: 32px; height: 32px; border-radius: 50%; background: var(--pc, var(--brand)); color: #fff; display: grid; place-items: center; font: 800 1rem var(--fd); flex: none; }
.hero .pchip .av { box-shadow: 0 0 0 2px rgba(255,255,255,.5); }

.bigadd { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--accent); color: #fff; border-radius: 20px; padding: 18px; text-align: left; box-shadow: 0 8px 20px rgba(242,101,46,.32); margin-top: -2px; }
.bigadd > .ic:first-child { width: 44px; height: 44px; background: rgba(255,255,255,.2); border-radius: 12px; padding: 8px; }
.bigadd b { display: block; font: 800 1.45rem var(--fd); }
.bigadd small { font-size: .98rem; color: #FFE7DC; }
.bigadd span { flex: 1; }
.chev { opacity: .7; }

.alertbox { display: flex; align-items: center; gap: 12px; background: var(--warnL); border: 2px solid #F3C98C; border-radius: var(--r); padding: 14px; color: #6B3A00; }
.alertbox > .ic { color: var(--warn); width: 30px; height: 30px; }
.alertbox div { flex: 1; } .alertbox b { display: block; font-size: 1.05rem; } .alertbox small { font-size: .92rem; }

.sechd { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
.sechd h2 { font-size: 1.5rem; font-weight: 800; }
.sechd a { color: var(--brand); font-weight: 700; font-size: .98rem; }
.cnt { font-style: normal; background: var(--brandL); color: var(--brand); border-radius: 99px; padding: 0 9px; font: 700 1rem var(--fb); }

/* Áreas */
.aic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--ac) 13%, #fff); color: var(--ac); flex: none; }
.aic .ic { width: 27px; height: 27px; }
.aic.sm { width: 40px; height: 40px; border-radius: 12px; } .aic.sm .ic { width: 23px; height: 23px; }
.aic.xs { width: 28px; height: 28px; border-radius: 8px; } .aic.xs .ic { width: 17px; height: 17px; }
.aic.xl { width: 76px; height: 76px; border-radius: 22px; } .aic.xl .ic { width: 42px; height: 42px; }
.agrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.acard { background: var(--card); border-radius: var(--r); padding: 14px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--sh); border: 1px solid var(--line); }
.acard b { font-size: 1.05rem; line-height: 1.2; } .acard small { color: var(--muted); font-size: .92rem; }

/* Listas de estudios */
.elist { display: flex; flex-direction: column; background: var(--card); border-radius: var(--r); box-shadow: var(--sh); border: 1px solid var(--line); overflow: hidden; }
.erow { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 84px; }
.erow:last-child { border-bottom: 0; }
.eth { width: 60px; height: 60px; border-radius: 12px; overflow: hidden; background: var(--bg); display: grid; place-items: center; flex: none; }
.eth img { width: 100%; height: 100%; object-fit: cover; }
.etx { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.etx b { font-size: 1.1rem; line-height: 1.2; } .etx small { color: var(--muted); font-size: .95rem; }
.tag { font-style: normal; align-self: flex-start; font-size: .82rem; font-weight: 700; color: var(--ac); background: color-mix(in srgb, var(--ac) 12%, #fff); border-radius: 99px; padding: 2px 10px; }
.ck2 input { width: 26px; height: 26px; accent-color: var(--brand); flex: none; }

/* Controles */
.clist { display: flex; flex-direction: column; gap: 10px; }
.ccard { background: var(--card); border-radius: var(--r); padding: 14px; box-shadow: var(--sh); border: 1px solid var(--line); border-left: 6px solid var(--ok); display: grid; grid-template-columns: auto 1fr; gap: 10px 12px; cursor: pointer; }
.ccard.turno { border-left-color: var(--warn); } .ccard.vencido { border-left-color: var(--bad); }
.cc-tx b { display: block; font-size: 1.12rem; line-height: 1.2; } .cc-tx small { color: var(--muted); font-size: .92rem; display: block; }
.sem { display: inline-block; margin-top: 6px; font-weight: 700; font-size: .92rem; border-radius: 8px; padding: 3px 9px; background: var(--okL); color: var(--ok); }
.turno .sem { background: var(--warnL); color: #8A4A00; } .vencido .sem { background: var(--badL); color: var(--bad); }
.cc-act { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Botones */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px; font-weight: 700; font-size: 1.05rem; text-align: center; }
.btn.full { width: 100%; } .btn.big { min-height: 60px; font-size: 1.15rem; }
.btn.sm { min-height: 44px; padding: 0 12px; font-size: .98rem; border-radius: 12px; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(242,101,46,.25); }
.btn.primary:disabled { opacity: .45; box-shadow: none; }
.btn.ghost { background: #fff; color: var(--brand); border: 2px solid var(--brand); }
.btn.ok { background: var(--okL); color: var(--ok); border: 2px solid #A8DCC0; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.link { background: none; color: var(--brand); min-height: 48px; text-decoration: underline; }
.btn.link.danger { color: var(--bad); background: none; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.tiles2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--sh); border: 1px solid var(--line); }
.tile > .ic { width: 34px; height: 34px; color: var(--brand); }
.tile:first-child > .ic { color: var(--bad); }
.tile b { font-size: 1.1rem; line-height: 1.2; } .tile small { color: var(--muted); font-size: .92rem; }
.privacy { display: flex; align-items: center; gap: 8px; justify-content: center; color: var(--muted); font-size: .92rem; margin: 6px 0 0; text-align: center; }
.tipbox { display: flex; gap: 10px; background: var(--brandL); border-radius: var(--r); padding: 14px; color: #0B3E49; }
.tipbox > .ic { color: var(--brand); margin-top: 2px; } .tipbox p { margin: 0; font-size: .98rem; }

.empty { background: var(--card); border-radius: var(--r); padding: 26px 18px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; border: 2px dashed var(--line); }
.empty.sm { padding: 18px; } .empty > .ic { color: var(--brand); }
.empty p { margin: 0; font-size: 1.05rem; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip { white-space: nowrap; background: #fff; border: 2px solid var(--line); border-radius: 99px; padding: 8px 14px; font-weight: 700; font-size: .98rem; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip i { font-style: normal; opacity: .7; }

/* Formularios */
.form { gap: 8px; }
.lbl { font-weight: 700; font-size: 1.02rem; margin-top: 10px; display: block; }
.lbl small { font-weight: 500; color: var(--muted); }
.inp { width: 100%; border: 2px solid var(--line); border-radius: 14px; padding: 12px 14px; font: 600 1.08rem var(--fb); color: var(--text); background: #fff; outline: none; }
.inp:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brandL); }
.inp.big { min-height: 56px; }
textarea.inp { resize: vertical; }
.cap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.capbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: #fff; border: 2px solid var(--brand); color: var(--brand); border-radius: var(--r); padding: 18px 10px; cursor: pointer; }
.capbtn .ic { width: 38px; height: 38px; }
.capbtn b { font-size: 1.08rem; } .capbtn small { color: var(--muted); font-size: .86rem; }
.capbtn.main { background: var(--accent); border-color: var(--accent); color: #fff; } .capbtn.main small { color: #FFE7DC; }
.prev { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pv { position: relative; width: 84px; height: 104px; border-radius: 12px; overflow: hidden; background: #fff; border: 2px solid var(--line); }
.pv img { width: 100%; height: 100%; object-fit: cover; }
.pv button { position: absolute; top: 4px; right: 4px; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.pv button .ic { width: 16px; height: 16px; }
.pdf { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--bad); font-weight: 800; }
.ac { position: relative; }
.acl { display: flex; flex-direction: column; background: #fff; border-radius: 14px; box-shadow: var(--sh); overflow: hidden; margin-top: 4px; }
.acl:empty { display: none; }
.acl button { display: flex; align-items: center; gap: 10px; padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); font-weight: 700; }
.acl button small { color: var(--muted); font-weight: 500; }
.apick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.apick button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px; border-radius: 14px; background: #fff; border: 2px solid var(--line); color: var(--ac); font-size: .86rem; line-height: 1.15; }
.apick button span { color: var(--text); font-weight: 600; text-align: center; }
.apick button.on { border-color: var(--ac); background: color-mix(in srgb, var(--ac) 12%, #fff); box-shadow: 0 0 0 2px var(--ac); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 4px; }
.seg button { min-height: 48px; border-radius: 10px; font-weight: 700; font-size: .98rem; }
.seg button.on { background: var(--brand); color: #fff; }
.cklist { display: flex; flex-direction: column; background: #fff; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.ck { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ck:last-child { border-bottom: 0; }
.ck input { width: 26px; height: 26px; accent-color: var(--brand); flex: none; }
.ck span { display: flex; flex-direction: column; } .ck b { font-size: 1.05rem; } .ck small { color: var(--muted); }

/* Detalle */
.detail-meta { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.detail-meta span { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 600; }
.note { background: #FFFBEA; border: 1px solid #F1E2A8; border-radius: 14px; padding: 12px 14px; font-size: 1.02rem; }
.acts3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.act { background: #fff; border: 1px solid var(--line); box-shadow: var(--sh); border-radius: 16px; padding: 12px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--brand); font-weight: 700; font-size: .9rem; line-height: 1.15; text-align: center; }
.act span { color: var(--text); }
.act:first-child { background: var(--brand); color: #fff; border-color: var(--brand); } .act:first-child span { color: #fff; }
.pages { display: flex; flex-direction: column; gap: 10px; }
.page { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.pdfcard { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 16px; }
.pdfcard .ic { width: 40px; height: 40px; color: var(--bad); }
.pdfcard b { display: block; } .pdfcard small { color: var(--muted); }

/* Pantalla completa (mostrar al médico / ficha) */
#show { position: fixed; inset: 0; z-index: 60; background: #0D1418; overflow: auto; display: none; padding-bottom: 30px; }
#show.on { display: block; } #show.light { background: #fff; }
.show-top { position: sticky; top: 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: rgba(13,20,24,.92); color: #fff; }
.show-top b { display: flex; align-items: center; gap: 8px; font-size: 1.15rem; } .show-top small { color: #B9C7CF; }
.show-top.sos { background: var(--bad); } .show-top.sos small { color: #FFE0DE; }
#show > img { display: block; width: 100%; margin: 0 0 8px; background: #fff; }
.show-empty { color: #fff; padding: 30px 16px; }
.fg { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; }
.fg-r { border-bottom: 2px solid #EEE; padding-bottom: 10px; }
.fg-r small { display: block; color: #5A6B77; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; font-size: .85rem; }
.fg-r b { font-size: 1.55rem; line-height: 1.25; }

/* Familia / más */
.plist { display: flex; flex-direction: column; gap: 8px; }
.prow { display: flex; align-items: center; gap: 12px; background: #fff; border: 2px solid var(--line); border-radius: var(--r); padding: 12px; text-align: left; width: 100%; }
.prow.on { border-color: var(--pc); box-shadow: 0 0 0 2px var(--pc); }
.prow .av { width: 44px; height: 44px; font-size: 1.3rem; }
.prow b { font-size: 1.12rem; } .prow small { color: var(--muted); display: block; } .prow em { color: var(--warn); font-style: normal; font-weight: 700; }
.pinfo { flex: 1; min-width: 0; } .pact { display: flex; gap: 6px; align-items: center; }
.mcard { background: #fff; border-radius: var(--r); padding: 16px; border: 1px solid var(--line); box-shadow: var(--sh); display: flex; flex-direction: column; gap: 10px; }
.mcard h3 { font-size: 1.35rem; display: flex; align-items: center; gap: 8px; color: var(--brand2); }
.mcard p { margin: 0; }
.mcard label.btn { cursor: pointer; }

/* Acceso y bienvenida */
.gate, .wiz { max-width: 520px; margin: 0 auto; padding: calc(36px + env(safe-area-inset-top)) 20px 40px; display: flex; flex-direction: column; gap: 10px; }
.gate { text-align: center; }
.logo-big { width: 84px; height: 84px; border-radius: 24px; background: var(--brand); color: #fff; display: grid; place-items: center; margin: 0 auto 6px; box-shadow: 0 10px 24px rgba(14,94,111,.3); }
.logo-big .ic { width: 46px; height: 46px; }
.gate h1, .wiz h1 { font-size: 2.2rem; font-weight: 800; color: var(--brand2); }
.wiz h1 { text-align: center; }
.lead { font-size: 1.12rem; color: var(--muted); margin: 0 0 6px; text-align: center; }
.gate .lbl { text-align: left; }

/* Hoja inferior */
#sheet { position: fixed; inset: 0; z-index: 50; display: none; }
#sheet.on { display: block; }
.sh-bg { position: absolute; inset: 0; background: rgba(8,20,26,.5); }
.sh-box { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 22px 18px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; max-width: 640px; margin: 0 auto; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sh-x { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; }
.sh-t { font-size: 1.6rem; font-weight: 800; padding-right: 44px; }
.sh-box p { margin: 0; font-size: 1.05rem; }

/* Barra de abajo */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(16,40,52,.06); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .82rem; font-weight: 700; color: #5B6B77; padding: 6px 2px; border-radius: 14px; }
.nav a .ic { width: 27px; height: 27px; }
.nav a.on { color: var(--brand); background: var(--brandL); }
.nav a.add { color: #fff; background: var(--accent); margin: -16px 6px 0; border-radius: 18px; box-shadow: 0 6px 14px rgba(242,101,46,.35); justify-content: center; }
.fab { position: fixed; right: 18px; bottom: calc(96px + env(safe-area-inset-bottom)); width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(242,101,46,.4); z-index: 30; }
.fab .ic { width: 32px; height: 32px; }
.stick { position: sticky; bottom: calc(86px + env(safe-area-inset-bottom)); padding-top: 6px; }

#toast { position: fixed; left: 50%; bottom: calc(100px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #13232E; color: #fff; padding: 14px 18px; border-radius: 14px; font-weight: 700; font-size: 1.02rem; opacity: 0; pointer-events: none; transition: .25s; z-index: 70; max-width: calc(100% - 32px); text-align: center; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 700px) { .agrid { grid-template-columns: repeat(3, 1fr); } }
.ccard.sinfecha { border-left-color: #8FA3B1; }
.sinfecha .sem { background: #EEF3F6; color: var(--brand2); }
[hidden]{display:none!important}
