:root {
    --navy: #1b2a63;
    --navy-dark: #121d47;
    --red: #a91c3a;
    --bg: #f2f3f7;
    --gray: #8a8f9c;
    --border: #e1e3ea;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--navy-dark);
    display: flex;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.app {
    width: 100%;
    max-width: 480px;
    min-height: 100vh;
    min-height: 100dvh;
    background: #fff;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

.app-header {
    padding: 28px 24px 8px;
    text-align: center;
}

.app-header img {
    max-width: 200px;
    width: 60%;
    height: auto;
}

.app-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 24px 24px;
}

/* ---- Pantalla PIN ---- */

.pin-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.pin-title {
    text-align: center;
    font-size: 1.05rem;
    color: var(--gray);
    margin: 8px 0 24px;
}

.pin-dots {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
}

.pin-dots span {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid var(--navy);
    background: transparent;
    transition: background 0.15s ease;
}

.pin-dots span.filled {
    background: var(--navy);
}

.pin-error {
    color: var(--red);
    font-size: 0.9rem;
    min-height: 1.3em;
    margin-bottom: 8px;
    text-align: center;
}

.pin-dots.shake {
    animation: shake 0.35s;
}

@keyframes shake {
    10%, 90% { transform: translateX(-6px); }
    20%, 80% { transform: translateX(6px); }
    30%, 50%, 70% { transform: translateX(-10px); }
    40%, 60% { transform: translateX(10px); }
}

.keypad {
    width: 100%;
    max-width: 320px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-top: auto;
}

.key {
    aspect-ratio: 1;
    border: none;
    border-radius: 50%;
    background: var(--bg);
    color: var(--navy-dark);
    font-size: 1.6rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.key:active {
    background: var(--border);
}

.key.key-action {
    background: transparent;
    color: var(--gray);
    font-size: 1.2rem;
}

/* ---- Pantalla buscar reserva ---- */

.buscar-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.revisor-badge {
    text-align: center;
    color: var(--gray);
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.buscar-title {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
}

.form-codigo {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.input-codigo {
    width: 100%;
    padding: 16px 14px;
    font-size: 1.4rem;
    letter-spacing: 0.08em;
    text-align: center;
    text-transform: uppercase;
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--navy-dark);
}

.input-codigo:focus {
    outline: none;
    border-color: var(--navy);
}

.btn {
    display: block;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
}

.btn-primary:active {
    background: var(--navy-dark);
}

.btn-secondary {
    background: #fff;
    color: var(--navy);
    border: 2px solid var(--navy);
}

.btn-secondary:active {
    background: var(--bg);
}

.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gray);
    font-size: 0.85rem;
}

.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--border);
}

.msg-error {
    background: #fdecee;
    color: var(--red);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 0.9rem;
    text-align: center;
}

.detalle-reserva {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.detalle-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    font-size: 0.9rem;
}

.detalle-row:not(:last-child) {
    border-bottom: 1px solid var(--border);
}

.detalle-row span {
    color: var(--gray);
}

.detalle-row b {
    text-align: right;
    color: var(--navy-dark);
    font-weight: 600;
}

/* ---- Escaner QR ---- */

.scanner-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 50;
    display: flex;
    flex-direction: column;
}

.scanner-overlay[hidden] {
    display: none;
}

.scanner-video-wrap {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.scanner-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68%;
    max-width: 280px;
    aspect-ratio: 1;
    transform: translate(-50%, -50%);
    border: 3px solid #fff;
    border-radius: 16px;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, 0.45);
}

.scanner-close {
    position: absolute;
    top: 18px;
    right: 18px;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-hint {
    color: #fff;
    text-align: center;
    padding: 18px 24px 28px;
    font-size: 0.95rem;
}

/* ---- Pantalla PDF ---- */

.pdf-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.pdf-header {
    padding: 14px 20px;
    text-align: center;
    font-weight: 600;
    color: var(--navy);
    border-bottom: 1px solid var(--border);
}

.pdf-frame-wrap {
    flex: 1;
}

.pdf-frame-wrap iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.pdf-actions {
    padding: 16px 24px 24px;
}
