:root {
  --app-full-height: 100vh;
  --app-visible-height: 100vh;
  --browser-bottom-inset: 0px;
  --content-bottom-inset: 0px;
  --blue-top: #2f63ef;
  --blue-bottom: #2c56ec;
  --screen-bg: #f1f1f3;
  --panel-bg: #ecebed;
  --white: #ffffff;
  --text-main: #ffffff;
  --text-muted: rgba(255, 255, 255, 0.72);
  --status-text: #7f7f88;
  --note-bg: #f2dde1;
  --note-text: #d94d55;
  --header-shadow: 0 10px 24px rgba(37, 74, 182, 0.18);
  --phone-shadow: 0 24px 60px rgba(29, 41, 82, 0.14);
  --font-ui: "Montserrat", "Segoe UI", sans-serif;
  --font-weight-semi-bold: 550;
  --font-weight-bold: 700;
  --font-size-booking-title: 1.3rem;
  --font-size-mobile-line: 0.80rem;
  --font-size-status-strip: 0.75rem;
  --font-size-countdown: 12cqw;
  --font-size-booked-on-display: 7.5cqw;
  --font-size-distance: 3cqw;
  --font-size-ticket-type: 3.2cqw;
  --font-size-card-default: 3.7cqw;
  --booked-on-display-width: 62%;
  --countdown-width: 100%;
  --countdown-seconds-width: 2ch;
  --countdown-window-height: 1.2em;
  --countdown-animation-duration: 500ms;
  --color-distance-text: #474c53;
  --header-icon-button-size: 34px;
  --header-icon-glyph-size: 20px;
  --header-back-border-width: 1px;
  --progress-bar-track: #D2D2D2;
  --progress-bar-fill: #76C4DA;
  --progress-bar-radius: 0px;

  /* Ajusta aqui las coordenadas de cada texto sobre la tarjeta.
     En los campos del bloque `Right align`, la `x` se mide desde la derecha. */
  /* Progress bar */
  --progress-bar-x: 0%;
  --progress-bar-y: 36.6%;
  --progress-bar-size-x: 100%;
  --progress-bar-size-y: 0.87%;
  /* Left align */
  --ticket-type-x: 2.5%;
  --ticket-type-y: 70.5%;
  --origin-station-x: 2.5%;
  --origin-station-y: 46.6%;
  --valid-from-x: 2.5%;
  --valid-from-y: 66%;
  --name-x: 2.5%;
  --name-y: 84.5%;
  --id-type-x: 2.5%;
  --id-type-y: 93%;
  /* Center align */
  --countdown-y: 9%;
  --distance-y: 46.7%;
  --booked-on-display-y: 22.8%;
  /* Right align */
  --destination-station-x: 2.5%;
  --destination-station-y: 46.6%;
  --season-ticket-x: 2.5%;
  --season-ticket-y: 40%;
  --booked-on-x: 2.5%;
  --booked-on-y: 55.5%;
  --valid-till-x: 3%;
  --valid-till-y: 66%;
  --age-x: 2.5%;
  --age-y: 84.5%;
  --id-number-x: 2.5%;
  --id-number-y: 93%;
}

@supports (height: 100dvh) {
  :root {
    --app-visible-height: 100dvh;
  }
}

@supports (height: 100lvh) {
  :root {
    --app-full-height: 100lvh;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: -webkit-fill-available;
  margin: 0;
  min-height: var(--app-full-height);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: -webkit-fill-available;
  min-height: var(--app-full-height);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-ui);
  background-color: var(--blue-bottom);
  background:
    radial-gradient(circle at top left, rgba(89, 132, 255, 0.24), transparent 30%),
    linear-gradient(180deg, #e6ebff 0%, #f6f7fb 48%, #ececef 100%);
  color: #1d1d1f;
}

button,
input,
textarea {
  font: inherit;
}

button {
  appearance: none;
  -webkit-appearance: none;
}

.app-locked {
  overflow: hidden;
}

.app-shell {
  position: relative;
  min-height: var(--app-full-height);
  width: 100%;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  min-height: var(--app-visible-height);
  padding:
    max(24px, calc(env(safe-area-inset-top) + 12px)) max(24px, calc(env(safe-area-inset-right) + 16px)) max(24px, calc(env(safe-area-inset-bottom) + 12px)) max(24px, calc(env(safe-area-inset-left) + 16px));
  background:
    radial-gradient(circle at top, rgba(109, 150, 255, 0.32), transparent 32%),
    linear-gradient(180deg, #eef3ff 0%, #dbe5ff 44%, #cbd9ff 100%);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  position: relative;
  isolation: isolate;
  width: min(100%, 420px);
  max-height: min(calc(var(--app-visible-height) - 32px), 760px);
  overflow: auto;
  padding: 28px 22px 24px;
  border-radius: 28px;
  border: 1px solid rgba(133, 157, 223, 0.28);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(243, 247, 255, 0.96) 100%);
  box-shadow:
    0 28px 70px rgba(29, 56, 132, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.auth-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background:
    radial-gradient(circle at top center, rgba(94, 132, 255, 0.16), transparent 40%);
  pointer-events: none;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.auth-logo {
  width: 82px;
  height: 82px;
  display: block;
  border-radius: 22px;
  object-fit: cover;
  box-shadow: 0 18px 32px rgba(44, 86, 236, 0.2);
}

.auth-kicker {
  margin: 16px 0 8px;
  color: #4d6bdd;
  font-size: 0.8rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.auth-title {
  margin: 0;
  color: #16203d;
  font-size: clamp(1.45rem, 5.4vw, 1.6rem);
  line-height: 1.05;
  text-wrap: balance;
}

.auth-copy {
  margin: 10px 0 0;
  color: #63708c;
  font-size: clamp(0.92rem, 3.7vw, 0.95rem);
  line-height: 1.35;
  text-wrap: balance;
}

.pin-display {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin: 24px 0 12px;
}

.pin-dot {
  aspect-ratio: 1;
  border-radius: 18px;
  border: 2px solid rgba(76, 102, 179, 0.22);
  background: #f3f6ff;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.pin-dot.is-filled {
  transform: scale(0.94);
  border-color: #2c56ec;
  background: radial-gradient(circle, #2c56ec 0 42%, #dbe4ff 44% 100%);
}

.auth-error {
  min-height: 1.2em;
  margin: 0 0 14px;
  color: #d13b4d;
  font-size: 0.88rem;
  text-align: center;
}

.auth-gate.has-error .pin-dot {
  border-color: rgba(209, 59, 77, 0.32);
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.pin-key {
  display: grid;
  place-items: center;
  min-height: 64px;
  padding: 0 10px;
  border: 0;
  border-radius: 20px;
  border: 1px solid rgba(143, 164, 223, 0.28);
  background: linear-gradient(180deg, #ffffff 0%, #edf2ff 100%);
  color: #1d2850;
  font-size: clamp(1.18rem, 4.8vw, 1.35rem);
  font-weight: var(--font-weight-semi-bold);
  line-height: 1;
  box-shadow:
    0 12px 24px rgba(56, 86, 167, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.pin-key:focus-visible {
  outline: 2px solid rgba(44, 86, 236, 0.32);
  outline-offset: 2px;
}

.pin-key:active {
  transform: translateY(1px);
}

.pin-key-muted {
  font-size: clamp(0.88rem, 3.8vw, 0.98rem);
  color: #50607d;
}

.phone-screen {
  width: 100%;
  min-height: var(--app-full-height);
  height: auto;
  background: var(--screen-bg);
  display: flex;
  flex-direction: column;
}

.hero {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: calc(70px + env(safe-area-inset-top));
  padding: calc(4px + env(safe-area-inset-top)) 14px 10px 14px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
  background: linear-gradient(180deg, var(--blue-top) 0%, var(--blue-bottom) 100%);
  box-shadow: var(--header-shadow);
}

.icon-button,
.share-button {
  width: var(--header-icon-button-size);
  height: var(--header-icon-button-size);
  border: 0;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: transparent;
  color: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.share-button {
  color: #ffffff;
}

.icon-button {
  border: var(--header-back-border-width) solid rgba(255, 255, 255, 0.4);
  background: transparent;
}

.icon-button svg,
.share-button svg {
  width: var(--header-icon-glyph-size);
  height: var(--header-icon-glyph-size);
}

.icon-button svg {
  fill: currentColor;
}

.share-button svg {
  display: block;
  fill: #ffffff;
  overflow: visible;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.eyebrow,
.subline {
  margin: 0;
}

.eyebrow {
  font-size: var(--font-size-booking-title);
  line-height: 1;
  font-weight: var(--font-weight-semi-bold);
  letter-spacing: -0.03em;
}

.subline {
  font-size: var(--font-size-mobile-line);
  color: var(--text-muted);
}

.status-strip {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--status-text);
  font-size: var(--font-size-status-strip);
  letter-spacing: -0.02em;
}

.content-scroll {
  flex: 1;
  min-height: auto;
  display: flex;
  flex-direction: column;
  padding-bottom: var(--content-bottom-inset);
  background: var(--panel-bg);
}

.ticket-panel {
  flex: 1;
  background: #ecebed;
  min-height: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.ticket-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 18px 0;
}

.ticket-card-wrap {
  width: 100%;
  position: relative;
  container-type: inline-size;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}

.ticket-card {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 12px;
  pointer-events: none;
  -webkit-user-drag: none;
}

.ticket-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.field-progress-bar {
  position: absolute;
  left: var(--progress-bar-x);
  top: var(--progress-bar-y);
  width: var(--progress-bar-size-x);
  height: var(--progress-bar-size-y);
  overflow: hidden;
  border-radius: var(--progress-bar-radius);
  background: var(--progress-bar-track);
}

.card-progress-fill {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--progress-bar-fill);
  transform: scaleX(var(--countdown-progress, 0));
  transform-origin: left center;
  transition: transform 1s linear;
  will-change: transform;
}

.card-field {
  position: absolute;
  display: block;
  max-width: 34%;
  color: #232a36;
  font-size: var(--font-size-card-default);
  font-weight: var(--font-weight-semi-bold);
  line-height: 1.05;
  letter-spacing: -0.015em;
  text-wrap: balance;
  z-index: 1;
}

.field-countdown,
.field-distance,
.field-booked-on-display {
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.field-countdown {
  top: var(--countdown-y);
  width: var(--countdown-width);
  max-width: var(--countdown-width);
  color: #d33535;
  font-size: var(--font-size-countdown);
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.countdown-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.08em;
  width: 100%;
}

.countdown-separator {
  flex: 0 0 auto;
}

.countdown-window {
  position: relative;
  display: block;
  width: var(--countdown-seconds-width);
  height: var(--countdown-window-height);
  padding-inline: 0.08ch;
  box-sizing: border-box;
  overflow: hidden;
}

.countdown-value {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
}

.countdown-current {
  transform: translateY(0);
}

.countdown-next {
  transform: translateY(-100%);
}

.countdown-window.is-animating .countdown-current {
  transition:
    transform var(--countdown-animation-duration) linear,
    opacity var(--countdown-animation-duration) linear;
  transform: translateY(100%);
  opacity: 0.2;
}

.countdown-window.is-animating .countdown-next {
  transition:
    transform var(--countdown-animation-duration) linear,
    opacity var(--countdown-animation-duration) linear;
  transform: translateY(0);
}

.field-origin-station {
  top: var(--origin-station-y);
  left: var(--origin-station-x);
  /* max-width: 44%; */
}

.field-ticket-type {
  top: var(--ticket-type-y);
  left: var(--ticket-type-x);
  max-width: none;
  font-size: var(--font-size-ticket-type);
  font-weight: 400;
}

.field-destination-station {
  top: var(--destination-station-y);
  right: var(--destination-station-x);
  /* max-width: 44%; */
  text-align: right;
}

.field-distance {
  top: var(--distance-y);
  /* max-width: 24%; */
  color: var(--color-distance-text);
  font-size: var(--font-size-distance);
  font-weight: 400;
}

.field-booked-on-display {
  top: var(--booked-on-display-y);
  min-width: var(--booked-on-display-width);
  width: max-content;
  max-width: none;
  color: #d8881f;
  font-size: var(--font-size-booked-on-display);
  font-weight: var(--font-weight-semi-bold);
  white-space: nowrap;
}

.field-season-ticket {
  top: var(--season-ticket-y);
  right: var(--season-ticket-x);
  /* max-width: 28%; */
  font-weight: var(--font-weight-bold);
  text-align: right;
}

.field-booked-on {
  top: var(--booked-on-y);
  right: var(--booked-on-x);
  /* max-width: 34%; */
  text-align: right;
}

.field-valid-from {
  top: var(--valid-from-y);
  left: var(--valid-from-x);
}

.field-valid-till {
  top: var(--valid-till-y);
  right: var(--valid-till-x);
  text-align: right;
}

.field-name {
  top: var(--name-y);
  left: var(--name-x);
  /* max-width: 52%; */
}

.field-age {
  top: var(--age-y);
  right: var(--age-x);
  /* max-width: 10%; */
  text-align: right;
}

.field-id-type {
  top: var(--id-type-y);
  left: var(--id-type-x);
  /* max-width: 24%; */
}

.field-id-number {
  top: var(--id-number-y);
  right: var(--id-number-x);
  /* max-width: 42%; */
  text-align: right;
}

.warning-note {
  margin: 0;
  padding: 8px 18px;
  border-radius: 11px;
  background: var(--note-bg);
  color: var(--note-text);
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.15;
  text-align: center;
  box-shadow: 0 8px 20px rgba(209, 123, 132, 0.12);
}

.qr-block,
.info-block {
  display: block;
  border-radius: 0;
  box-shadow: 0 1px 0 rgba(51, 58, 81, 0.04);
}

.qr-block {
  background-color: rgba(255, 255, 255, 0.62);
  margin-top: 10px;
  padding: 18px;
  display: flex;
  justify-content: center;
}

.qr-image {
  width: min(100%, 170px);
  aspect-ratio: 1;
  display: block;
  object-fit: contain;
  background: #ffffff;
}

.info-block {
  background-color: #ffffff;
  padding: 14px 16px 18px;
  color: #737783;
}

.info-title {
  margin: 0 0 12px;
  color: #22242a;
  font-size: 1rem;
  font-weight: var(--font-weight-bold);
  line-height: 1.1;
}

.info-copy {
  margin: 0 0 14px;
  font-size: 0.9rem;
  line-height: 1.35;
}

.info-copy:last-child {
  margin-bottom: 0;
}

.scroll-tail {
  height: 30px;
}

.editor-open {
  overflow: hidden;
}

.editor-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.editor-modal[hidden] {
  display: none;
}

.editor-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 20, 42, 0.45);
  backdrop-filter: blur(2px);
}

.editor-panel {
  position: relative;
  width: min(100%, 520px);
  max-height: min(calc(var(--app-visible-height) - 40px), 760px);
  overflow: auto;
  border-radius: 22px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 24px 60px rgba(22, 30, 59, 0.22);
}

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.editor-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: var(--font-weight-bold);
  color: #18213a;
}

.editor-close {
  border: 0;
  background: transparent;
  color: #50607d;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.editor-section {
  grid-column: 1 / -1;
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid #e1e7f2;
  font-size: 0.8rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #55637d;
}

.editor-grid>.editor-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.editor-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.editor-field-full {
  grid-column: 1 / -1;
}

.editor-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.editor-label {
  font-size: 0.84rem;
  font-weight: var(--font-weight-semi-bold);
  color: #5a6781;
}

.editor-inline-button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: var(--font-weight-semi-bold);
  color: #ffffff;
  background: #2c56ec;
  cursor: pointer;
  white-space: nowrap;
}

.editor-inline-button:focus {
  outline: 2px solid rgba(44, 86, 236, 0.18);
}

.editor-input {
  width: 100%;
  border: 1px solid #d7ddea;
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  color: #1a2338;
  background: #f9fbff;
}

.editor-input:focus {
  outline: 2px solid rgba(44, 86, 236, 0.18);
  border-color: #6688f4;
}

.editor-textarea {
  min-height: 120px;
  resize: vertical;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.editor-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: var(--font-weight-semi-bold);
  cursor: pointer;
}

.editor-button-secondary {
  background: #eef2fb;
  color: #394662;
}

.editor-button-primary {
  background: #2c56ec;
  color: #ffffff;
}

@media (max-width: 420px) {
  .auth-gate {
    padding:
      max(18px, calc(env(safe-area-inset-top) + 10px)) max(18px, calc(env(safe-area-inset-right) + 12px)) max(18px, calc(env(safe-area-inset-bottom) + 10px)) max(18px, calc(env(safe-area-inset-left) + 12px));
  }

  .auth-card {
    padding: 24px 18px 20px;
    border-radius: 24px;
  }

  .pin-display {
    gap: 8px;
  }

  .pin-key {
    min-height: 58px;
    border-radius: 18px;
  }

  .phone-screen {
    width: 100%;
    min-height: 100vh;
  }

  .eyebrow {
    font-size: 1.55rem;
  }

  .status-strip {
    font-size: 0.88rem;
  }

  .editor-grid {
    grid-template-columns: 1fr;
  }

  .warning-note {
    font-size: 0.73rem;
    bottom: 14px;
  }
}