:root {
  --blue: #28AAE2;
  --blue-dark: #1a8fc4;
  --blue-soft: #e8f4fc;
  --navy: #0B2141;
  --ink: #243140;
  --muted: #667583;
  --line: #e1edf5;
  --bg: #f4f8fb;
  --card: #fff;
  --orange: #f39c12;
  --ok: #1f8a4c;
  --warn: #9a6700;
  --bad: #b42318;
  --shadow: 0 8px 22px rgba(11, 33, 65, .06);
  --footer-h: 74px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: #d5e0e8;
  color: var(--ink);
  font-family: "Segoe UI", Nunito, sans-serif;
}
button, input, select { font-family: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.app {
  width: min(480px, 100%);
  height: 100%;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 28px rgba(11, 33, 65, .16);
  overflow: hidden;
}
.app-header {
  flex: 0 0 auto;
  background: #fff;
  border-bottom: 1px solid #edf2f6;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  z-index: 5;
}
.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.logo-lockup { display: flex; flex-direction: column; line-height: 1; }
.logo-line { display: flex; align-items: flex-end; }
.logo-ama {
  font-family: Pacifico, "Segoe Script", cursive;
  color: var(--blue);
  font-size: 28px;
  line-height: .85;
  margin-right: 1px;
}
.logo-upcn {
  font-weight: 800;
  color: #1a7eb4;
  font-size: 26px;
  letter-spacing: -.6px;
  line-height: .9;
}
.logo-sub {
  margin-top: 3px;
  font-size: 8px;
  letter-spacing: 1.4px;
  color: #8aa0b0;
  text-align: right;
}
.logo-lockup.lg { align-items: center; }
.logo-lockup.lg .logo-ama { font-size: 40px; }
.logo-lockup.lg .logo-upcn { font-size: 36px; }
.logo-lockup.lg .logo-sub { text-align: center; font-size: 10px; letter-spacing: 1.8px; }
.logout-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
}
.screen {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(16px + var(--safe-b));
}
.screen-pad-footer { padding-bottom: calc(20px + var(--safe-b)); }

#screen-login {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #ffffff 0%, #ffffff 58%, #d7f3ff 100%);
  padding: 42px 26px 22px;
}
.login-main { width: min(400px, 100%); margin: 0 auto; }
.login-title {
  margin: 8px 0 6px;
  text-align: center;
  color: var(--blue);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -.03em;
}
.login-sub, .login-help {
  margin: 0;
  text-align: center;
}
.login-sub { color: #7b8792; font-size: 15px; }
.login-help {
  margin-top: 28px;
  color: var(--blue);
  font-weight: 700;
  font-size: 16px;
}
.field { margin-top: 16px; }
.field-label {
  display: block;
  margin-bottom: 6px;
  color: var(--blue);
  font-weight: 700;
  font-size: 14px;
}
.input, .select {
  width: 100%;
  border: 1.5px solid #d5dee6;
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  min-height: 48px;
  padding: 12px 14px;
  font-size: 16px;
}
.select { text-transform: uppercase; }
.input:focus, .select:focus {
  outline: 2px solid rgba(40, 170, 226, .25);
  border-color: var(--blue);
}
.btn {
  border: 0;
  border-radius: 12px;
  min-height: 48px;
  padding: 12px 16px;
  font-weight: 700;
  font-size: 16px;
}
.btn-navy {
  width: 100%;
  margin-top: 22px;
  background: var(--navy);
  color: #fff;
}
.btn-navy:disabled { opacity: .55; cursor: wait; }
.btn-outline {
  background: #fff;
  color: var(--blue-dark);
  border: 1.5px solid var(--blue);
}
.btn-block { width: 100%; margin-top: 10px; }
.btn-call {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 22px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-call:hover,
.btn-call:focus,
.btn-call:active {
  text-decoration: none;
}
.btn-call svg { flex: 0 0 auto; }
.login-hint {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.login-extra {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.btn-register {
  border: 1px solid #c5d0d8;
  background: #fff;
  color: #31404c;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
}
.link-forgot {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  text-decoration: underline;
  padding: 6px 0;
}
.login-logo {
  margin-top: auto;
  display: flex;
  justify-content: center;
  padding-top: 28px;
}
.alert {
  display: none;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #fde8e6;
  color: var(--bad);
  font-size: 14px;
}
.alert.show { display: block; }
.alert.ok { background: #e5f6ec; color: var(--ok); }

.welcome-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}
.welcome-text h1 {
  margin: 0;
  color: var(--blue);
  font-size: 24px;
  font-weight: 800;
}
.welcome-text p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.btn-token {
  border: 1.5px solid var(--blue);
  background: transparent;
  color: var(--blue);
  border-radius: 20px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.credential-card, .card, .item-card, .turno-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.credential-card { margin-bottom: 16px; overflow: hidden; }
.credential-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border: 0;
  border-bottom: 4px solid var(--blue);
  background: #fff;
  text-align: left;
}
.cred-title { font-size: 18px; font-weight: 800; color: var(--ink); }
.cred-side { display: flex; align-items: center; gap: 8px; }
.cred-brand { display: flex; align-items: center; gap: 4px; font-weight: 800; color: var(--blue); }
.cred-brand-ba {
  background: var(--blue);
  color: #fff;
  font-size: 10px;
  border-radius: 3px;
  padding: 1px 4px;
}
.chev {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #dde6e9;
  color: #5d6b76;
  display: grid;
  place-items: center;
  transition: transform .2s ease;
}
.credential-collapsible {
  max-height: 420px;
  overflow: hidden;
  opacity: 1;
  transition: max-height .28s ease, opacity .28s ease;
}
.credential-collapsible.collapsed { max-height: 0; opacity: 0; }
.credential-body {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}
.credential-info h2 {
  margin: 0 0 8px;
  font-size: 14px;
  letter-spacing: .02em;
  color: #5c6b76;
}
.credential-info p { margin: 0 0 3px; font-size: 13px; color: var(--muted); }
.credential-info p span { color: var(--blue); font-weight: 700; }
.credential-info .ministerio { margin-top: 8px; }
.qr-code-box {
  width: 96px;
  height: 96px;
  border: 1px solid #e4e4e4;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
  display: grid;
  place-items: center;
}
.qr-code-box canvas { width: 86px !important; height: 86px !important; }
.credential-footer {
  background: #fafbfc;
  border-top: 1px solid #f0f0f0;
  text-align: right;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 16px 10px;
}
.turnos-container {
  display: grid;
  grid-template-columns: 2.1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}
.turno-card { background: var(--blue-soft); padding: 14px; text-align: left; width: 100%; }
.turno-badge-row, .item-card-top, .detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.turno-tag { color: var(--blue); font-size: 12px; font-weight: 700; }
.turno-time {
  background: var(--orange);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}
.turno-card h3, .empty-turno h3 { margin: 8px 0 2px; font-size: 15px; }
.especialidad, .meta, .item-card p { margin: 0; color: var(--muted); font-size: 13px; }
.turno-fecha { margin: 10px 0 0; font-size: 12px; font-weight: 650; }
.nuevo-turno-card {
  border: 0;
  border-radius: 16px;
  background: var(--blue);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 124px;
  box-shadow: 0 6px 14px rgba(40, 170, 226, .28);
}
.nuevo-turno-card:hover { background: #c2e6f5; color: var(--blue); }
.plus-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.22);
  font-size: 20px;
}
.section-block { margin-bottom: 22px; }
.section-block h2 { margin: 0; font-size: 18px; }
.section-subtitle { margin: 2px 0 14px; color: var(--muted); font-size: 12px; }
.grid-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.menu-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  min-height: 112px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.02);
}
.menu-item:hover, .item-card:hover { border-color: var(--blue); }
.menu-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--blue-soft);
  color: var(--blue);
  display: grid;
  place-items: center;
}
.menu-item span { font-size: 12px; font-weight: 700; text-align: center; color: var(--ink); }
.banner-slider {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 6px;
  scrollbar-width: none;
}
.banner-slider::-webkit-scrollbar { display: none; }
.banner-card {
  flex: 0 0 260px;
  scroll-snap-align: start;
  height: 132px;
  border: 0;
  border-radius: 16px;
  padding: 14px;
  color: #fff;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
}
.banner-card strong { font-size: 16px; line-height: 1.2; }
.banner-kicker {
  align-self: flex-start;
  background: rgba(255,255,255,.2);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}
.banner-t0 { background: linear-gradient(160deg, #39b8ea, #0B2141); }
.banner-t1 { background: linear-gradient(160deg, #0B2141, #28AAE2); }
.banner-t2 { background: linear-gradient(160deg, #1477a8, #08304a); }
.banner-t3 { background: linear-gradient(160deg, #21c1b0, #0B2141); }

.app-footer {
  flex: 0 0 auto;
  background: #fff;
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
  z-index: 6;
}
.bottom-nav {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  min-height: var(--footer-h);
  padding: 6px 4px 8px;
}
.nav-item {
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 650;
  min-height: 52px;
  padding: 4px 2px;
}
.nav-item.active { color: var(--blue); }
.nav-item span {
  max-width: 72px;
  text-align: center;
  line-height: 1.15;
}
.nav-item svg { display: block; }
.nav-item.is-disabled { opacity: .38; }
.nav-center { position: relative; top: -18px; }
.center-icon {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: grid;
  place-items: center;
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(40, 170, 226, .4);
}

.back-nav {
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 12px;
  font-size: 15px;
}
.page-title { margin: 0; font-size: 22px; }
.page-lead { margin: 4px 0 14px; color: var(--muted); font-size: 14px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  width: 100%;
  text-align: left;
  padding: 14px;
  color: inherit;
}
.item-card strong { font-size: 15px; }
.item-card p { margin-top: 4px; }
.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  background: #e7f3fa;
  color: #146f96;
  white-space: nowrap;
}
.chip-ok { background: #e5f6ec; color: var(--ok); }
.chip-warn { background: #fff4d6; color: var(--warn); }
.chip-bad { background: #fde8e6; color: var(--bad); }
.chip-mute { background: #eef1f4; color: #60707c; }
.empty-box {
  border: 1px dashed #c9d8e3;
  border-radius: 16px;
  padding: 18px 14px;
  text-align: center;
  color: var(--muted);
  background: #fff;
}
.detail-card { padding: 16px; }
.detail-card h1 { margin: 8px 0; font-size: 22px; line-height: 1.2; }
.detail-list { margin: 12px 0 0; display: grid; gap: 10px; }
.detail-list div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f0f4f7;
}
.detail-list dt { margin: 0; color: var(--blue); font-size: 13px; font-weight: 700; }
.detail-list dd { margin: 0; font-size: 14px; }
.prose { white-space: pre-wrap; line-height: 1.45; color: #31404c; }

.tabs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.tabs-row h1 { margin: 0; font-size: 18px; }
.btn-chip {
  border: 0;
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 13px;
  white-space: nowrap;
}
.step-title, .step-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-title { margin: 18px 0 4px; }
.step-title h2, .step-row h2 { margin: 0; font-size: 16px; }
.step-row { justify-content: space-between; flex-wrap: wrap; margin-top: 18px; }
.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e7f6fd;
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 800;
  flex: 0 0 auto;
}
.check-line {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #60707c;
  font-size: 12px;
  font-weight: 650;
}
.disp-banner {
  margin-top: 12px;
  background: #dff3fc;
  color: #18739a;
  text-align: center;
  font-weight: 800;
  border-radius: 12px;
  padding: 14px 10px;
}
.prof-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.prof-card {
  background: var(--navy);
  color: #fff;
  border-radius: 16px;
  padding: 16px;
  border: 3px solid transparent;
}
.prof-card.is-selected { border-color: var(--blue); }
.prof-card h3 { margin: 0 0 6px; letter-spacing: .04em; font-size: 18px; }
.prof-card p { margin: 0; font-size: 13px; color: #d5e4ef; }
.prof-top { display: flex; justify-content: space-between; gap: 8px; }
.prof-phone {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,.75);
  color: #fff;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  text-decoration: none;
}
.slots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.slot {
  min-width: 76px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid #d5e0e8;
  background: #eef2f5;
  color: var(--ink);
  font-weight: 700;
}
.slot.is-selected { background: var(--blue); color: #fff; border-color: var(--blue); }
.turno-resumen { margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 33, 65, .48);
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-card {
  width: min(480px, 100%);
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + var(--safe-b));
  max-height: min(88dvh, 760px);
  overflow: auto;
  position: relative;
}
.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--muted);
}
.qr-wrap {
  width: fit-content;
  margin: 12px auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  position: relative;
}
.qr-timer { text-align: center; font-weight: 800; color: var(--blue); margin: 4px 0 12px; }
.qr-expired {
  position: absolute;
  inset: 10px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.88);
  color: var(--bad);
  font-weight: 800;
  border-radius: 12px;
}
.contact-item, .guard-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-top: 10px;
  background: #f8fbfd;
}
.contact-item h3, .guard-item h3 { margin: 0 0 2px; font-size: 16px; }
.area-label { margin: 0 0 6px; color: var(--blue); font-size: 12px; font-weight: 800; }
.contact-item p, .guard-item p { margin: 2px 0; font-size: 14px; color: #3e4d5a; }
.contact-item a, .guard-item a { color: var(--navy); font-weight: 700; text-decoration: none; }

.qr-frame {
  position: relative;
  height: min(52vh, 360px);
  border-radius: 18px;
  overflow: hidden;
  background: #111;
}
.qr-frame video { width: 100%; height: 100%; object-fit: cover; }
.qr-overlay {
  position: absolute;
  inset: 18%;
  border: 2px solid rgba(40, 170, 226, .95);
  border-radius: 16px;
  box-shadow: 0 0 0 2000px rgba(0,0,0,.28);
  pointer-events: none;
}
.scan-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--footer-h) + 24px);
  transform: translateX(-50%) translateY(12px);
  width: min(420px, calc(100% - 32px));
  background: var(--navy);
  color: #fff;
  text-align: center;
  font-weight: 700;
  border-radius: 12px;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition: .2s ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.boot-splash {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: linear-gradient(180deg, #fff, #e7f7fd);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
}
html.has-session:not(.ready) .boot-splash { display: flex; }
html.has-session:not(.ready) #screen-login { display: none !important; }
.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid #d5eef7;
  border-top-color: var(--blue);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 540px) {
  .modal { align-items: center; padding: 16px; }
  .modal-card { border-radius: 20px; }
}
@media (max-width: 360px) {
  .grid-menu { gap: 8px; }
  .menu-item span { font-size: 11px; }
  .login-title { font-size: 24px; }
}
