:root {
    color-scheme: light;
    --ink: #102027;
    --muted: #5b6871;
    --line: #d8e1e7;
    --brand: #0369a1;
    --brand-strong: #075985;
    --surface: #f0f4f8;
    --panel: #ffffff;
    --success: #087f5b;
    --success-bg: #ecfdf5;
    --danger: #b42318;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: var(--surface);
    color: var(--ink);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

button,
input,
textarea {
    font: inherit;
}

.boot-screen,
.kiosk-shell {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(8px, 2vmin, 28px);
    background: linear-gradient(160deg, #e6f3fa 0%, #f4f8fb 45%, #eaf4ee 100%);
}

.kiosk-panel {
    width: min(1180px, 100%);
    height: 100%;
    max-height: 920px;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: clamp(12px, 2.4vmin, 22px);
    padding: clamp(16px, 2.6vmin, 28px);
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 32px 80px rgba(10, 40, 55, 0.14), 0 4px 16px rgba(10, 40, 55, 0.06);
    border-radius: clamp(14px, 2vmin, 20px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.kiosk-footer {
    text-align: center;
    font-size: clamp(0.7rem, 1.4vmin, 0.85rem);
    font-weight: 600;
    color: rgba(10, 40, 55, 0.45);
    letter-spacing: 0.02em;
}

.kiosk-body {
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    justify-content: safe center;
    gap: clamp(12px, 2.4vmin, 22px);
}

.kiosk-header,
.actions-row,
.progress-strip,
.choice-row {
    display: flex;
    align-items: center;
}

.kiosk-header {
    justify-content: space-between;
}

.kiosk-brand {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.brand-mark {
    width: clamp(46px, 7vmin, 62px);
    height: clamp(46px, 7vmin, 62px);
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, var(--brand), var(--brand-strong));
    color: #fff;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.25);
}

.brand-logo {
    width: clamp(120px, 18vmin, 192px);
    height: clamp(64px, 12vmin, 124px);
    object-fit: contain;
    object-position: left center;
}

.brand-name {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.unit-name {
    margin-top: 4px;
    color: var(--ink);
    font-size: 1.05rem;
    font-weight: 900;
}

.session-pill {
    min-width: 120px;
    padding: 12px 18px;
    border: 1px solid rgba(3, 105, 161, 0.3);
    border-radius: 999px;
    text-align: center;
    background: #f0f9ff;
    color: var(--brand);
    font-weight: 800;
    font-size: 0.95rem;
}

.scheduled-start {
    padding: 12px 16px;
    border: 1px solid rgba(3, 105, 161, 0.3);
    border-radius: 14px;
    background: #f0f9ff;
    color: var(--brand-strong);
    font-weight: 700;
    font-size: 1.05rem;
}

.scheduled-start strong {
    font-weight: 900;
}

.center-stage,
.step-card {
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.center-stage h1,
.step-card h1,
.step-copy h1 {
    margin: 0;
    font-size: clamp(2rem, 5.2vmin, 4.8rem);
    line-height: 1.04;
    letter-spacing: -0.01em;
}

.center-stage p,
.step-card p,
.step-copy p {
    max-width: 720px;
    margin: clamp(10px, 1.8vmin, 18px) 0 0;
    color: var(--muted);
    font-size: clamp(1.05rem, 2.2vmin, 1.35rem);
    line-height: 1.5;
}

.eyebrow {
    color: var(--brand) !important;
    font-size: 0.9rem !important;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 8px;
}

.primary-action,
.secondary-action,
.choice,
.key {
    min-height: clamp(52px, 8vmin, 70px);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 900;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.primary-action {
    margin-top: clamp(20px, 3.4vmin, 36px);
    padding: 0 clamp(24px, 4vmin, 42px);
    background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(3, 105, 161, 0.22);
}

.primary-action,
.secondary-action {
    font-size: clamp(1.1rem, 2.1vmin, 1.4rem);
}

.primary-action:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(3, 105, 161, 0.3);
}

.actions-row .primary-action {
    margin-top: 0;
}

.primary-action.xl {
    min-width: min(360px, 100%);
    min-height: clamp(64px, 10vmin, 92px);
    font-size: clamp(1.3rem, 2.6vmin, 1.65rem);
}

.secondary-action {
    padding: 0 36px;
    background: #e9f1f4;
    color: var(--ink);
    border: 1px solid var(--line);
}

.secondary-action:hover {
    background: #dce8ed;
}

.primary-action:active,
.secondary-action:active,
.choice:active,
.key:active {
    transform: translateY(2px);
    box-shadow: none;
}

.loader {
    width: 78px;
    height: 78px;
    border: 8px solid #d9e8ee;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 900ms linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-strip {
    height: 24px;
    justify-content: center;
    gap: 10px;
    align-items: center;
}

.progress-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #c8d8de;
    transition: width 200ms ease, background 200ms ease;
}

.progress-dot.active {
    width: 36px;
    border-radius: 999px;
    background: var(--brand);
}

.step-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 440px);
    gap: clamp(18px, 3.4vmin, 32px);
    align-items: center;
    width: 100%;
}

.step-copy {
    min-width: 0;
}

.cpf-display {
    width: min(620px, 100%);
    min-height: clamp(72px, 11vmin, 108px);
    margin-top: clamp(18px, 3.2vmin, 34px);
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: #fafcfe;
    color: var(--brand-strong);
    font-size: clamp(1.8rem, 4.6vmin, 4.2rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    transition: border-color 200ms ease;
}

.keyboard {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(8px, 1.6vmin, 14px);
    width: 100%;
}

.key {
    min-height: clamp(58px, 9.5vmin, 92px);
    background: #edf5f8;
    color: var(--ink);
    font-size: clamp(1.4rem, 3.2vmin, 2rem);
    border-radius: 10px;
    box-shadow: 0 3px 0 #c0d4db, inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.key:hover {
    background: #e0eef3;
}

.key.utility {
    font-size: clamp(0.9rem, 2vmin, 1.15rem);
    font-weight: 800;
    background: #ddeaee;
    box-shadow: 0 3px 0 #b4cad2;
}

.key.utility:hover {
    background: #d0e1e6;
}

.step-card {
    align-items: stretch;
    justify-content: flex-start;
    width: min(850px, 100%);
    margin: 0 auto;
    padding-top: 8px;
    text-align: left;
}

.step-card h1 {
    font-size: clamp(1.7rem, 4.4vmin, 3.6rem);
}

.data-list {
    display: grid;
    gap: 12px;
    margin-top: 22px;
}

.data-list div,
.question-block {
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    transition: border-color 150ms ease;
}

.data-list span,
.question-block label {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-list strong {
    display: block;
    margin-top: 6px;
    font-size: clamp(1.05rem, 2.2vmin, 1.35rem);
}

.data-exames {
    padding: 14px 18px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.data-exames span {
    display: block;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.exames-scroll {
    max-height: clamp(120px, 26vh, 220px);
    overflow-y: auto;
    margin-top: 4px;
    padding-right: 12px;
    scrollbar-width: auto;
}

.exames-scroll::-webkit-scrollbar {
    width: 20px;
}

.exames-scroll::-webkit-scrollbar-track {
    background: #eef3f6;
    border-radius: 10px;
}

.exames-scroll::-webkit-scrollbar-thumb {
    background: var(--brand);
    border-radius: 10px;
    border: 4px solid #eef3f6;
}

.data-exames strong {
    display: block;
    margin-top: 8px;
    font-size: 1.15rem;
    padding-left: 12px;
    border-left: 3px solid var(--brand);
}

.actions-row {
    justify-content: flex-end;
    gap: 16px;
    margin-top: 22px;
    width: 100%;
    padding-right: 0;
}

.actions-row .primary-action,
.actions-row .secondary-action {
    min-height: 56px;
}

/* Botoes fixos em todas as telas do fluxo: a barra de acoes (e o botao das telas
   centralizadas) fica colada no rodape do corpo rolavel; apenas o conteudo rola
   quando nao couber. Evita que o botao "suma" abaixo da area visivel. */
.actions-row {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding-top: 16px;
    padding-bottom: 2px;
    background: linear-gradient(to top, var(--panel) 62%, rgba(255, 255, 255, 0));
}

.center-stage > .primary-action {
    position: sticky;
    bottom: 0;
    z-index: 3;
}

.lgpd-text {
    max-height: clamp(120px, 28vh, 260px);
    overflow: auto;
    padding: clamp(14px, 2.4vmin, 22px);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fafcfe;
    color: var(--muted);
    line-height: 1.65;
    font-size: clamp(0.98rem, 2vmin, 1.1rem);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: clamp(14px, 2.4vmin, 24px);
    font-size: clamp(1.05rem, 2.2vmin, 1.35rem);
    font-weight: 800;
}

.check-row input {
    width: 36px;
    height: 36px;
    accent-color: var(--brand);
    border-radius: 6px;
}

.field-error {
    color: var(--danger) !important;
    font-weight: 900;
}

.question-list {
    display: grid;
    gap: 16px;
    margin-top: 26px;
}

.question-block input,
.question-block textarea {
    width: 100%;
    margin-top: 12px;
    padding: clamp(12px, 2vmin, 18px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdfe;
    font-size: clamp(1rem, 2vmin, 1.2rem);
    transition: border-color 150ms ease;
}

.question-block input:focus,
.question-block textarea:focus {
    outline: none;
    border-color: var(--brand);
}

.question-block textarea {
    min-height: clamp(90px, 16vh, 130px);
    resize: none;
}

.choice-row,
.choice-column {
    gap: 14px;
    margin-top: 14px;
}

.choice-column {
    display: grid;
    grid-template-columns: 1fr;
}

.choice {
    flex: 1;
    background: #edf5f8;
    color: var(--ink);
    font-size: clamp(1rem, 2vmin, 1.2rem);
    border: 1px solid var(--line);
}

.choice:hover {
    background: #dce8ed;
}

.choice.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand-strong);
}

.choice.active:hover {
    background: var(--brand-strong);
}

.success h1 {
    color: var(--success);
}

.success-badge {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    background: var(--success-bg);
    border: 2px solid rgba(8, 127, 91, 0.3);
    display: grid;
    place-items: center;
    margin-bottom: 20px;
    animation: pop-in 400ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.success-badge::after {
    content: '✓';
    font-size: 2.6rem;
    color: var(--success);
    font-weight: 900;
    line-height: 1;
}

@keyframes pop-in {
    0% { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.protocol {
    margin-top: 16px;
    padding: 10px 32px;
    border-radius: 999px;
    background: var(--success-bg);
    border: 1px solid rgba(8, 127, 91, 0.2);
    color: var(--brand-strong);
    font-size: clamp(1.6rem, 4vw, 3rem);
}

.pin-display {
    width: min(460px, 100%);
    min-height: clamp(72px, 11vmin, 108px);
    margin-top: clamp(18px, 3.2vmin, 34px);
    display: grid;
    place-items: center;
    border: 2px solid var(--line);
    border-radius: 12px;
    background: #fafcfe;
    color: var(--brand-strong);
    font-size: clamp(1.8rem, 4.6vmin, 3.8rem);
    font-weight: 900;
    letter-spacing: 0.18em;
    transition: border-color 200ms ease;
}

.pin-display.pin-error {
    border-color: var(--danger);
    color: var(--danger);
    animation: shake 300ms ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

/* Carrossel na tela inicial: imagem grande + faixa inferior com o botao */
.carousel-splash {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: clamp(12px, 2.2vmin, 20px);
    min-height: 0;
}

.carousel-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: clamp(12px, 2vmin, 18px);
    overflow: hidden;
    background: #ffffff;
}

.carousel-slide {
    position: absolute;
    inset: 0;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    align-items: flex-end;
    opacity: 0;
    transition: opacity 800ms ease;
}

.carousel-slide.active {
    opacity: 1;
}

.carousel-caption {
    width: 100%;
    padding: clamp(14px, 2.6vmin, 28px);
    background: linear-gradient(to top, rgba(8, 24, 33, 0.62), rgba(8, 24, 33, 0));
    color: #fff;
    font-size: clamp(1.1rem, 2.6vmin, 2rem);
    font-weight: 800;
    line-height: 1.25;
}

.carousel-bar {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: clamp(14px, 2.4vmin, 24px);
}

.carousel-bar-text {
    min-width: 0;
}

.carousel-bar-text .eyebrow {
    margin: 0 0 4px;
}

.carousel-bar-text strong {
    display: block;
    font-size: clamp(1.2rem, 2.8vmin, 2.2rem);
    line-height: 1.1;
}

.carousel-bar .primary-action {
    margin-top: 0;
    flex: none;
}

@media (orientation: portrait) {
    .carousel-bar {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .carousel-bar .primary-action.xl {
        width: 100%;
    }
}

/* Retrato (tablet/celular de pe): empilha CPF/PIN + teclado numa coluna */
@media (orientation: portrait) {
    .step-grid {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .step-copy {
        text-align: center;
        width: 100%;
    }

    .step-copy .cpf-display,
    .step-copy .pin-display {
        margin-left: auto;
        margin-right: auto;
    }

    .step-grid .keyboard {
        width: min(460px, 100%);
    }
}

/* Telas estreitas: acoes em largura total e empilhadas */
@media (max-width: 560px) {
    .actions-row {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .actions-row .primary-action,
    .actions-row .secondary-action {
        width: 100%;
    }

    .primary-action.xl {
        width: 100%;
    }
}

/* Painel de TV */
.panel-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    color: #0f172a;
    padding: 32px 40px;
    gap: 28px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header .brand-logo {
    width: auto;
    height: 110px;
    max-width: 360px;
}

.panel-header .brand-name { font-size: 34px; font-weight: 900; }
.panel-header .unit-name { font-size: 22px; opacity: 0.8; }

.panel-clock {
    font-size: 40px;
    font-weight: 900;
    letter-spacing: 1px;
}

.panel-start-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.panel-start-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    text-align: center;
    background: #ffffff;
    color: #0f172a;
    border-radius: 28px;
    padding: 48px 56px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
    max-width: 90vw;
}

.panel-start-logo { max-height: 90px; max-width: 240px; object-fit: contain; }
.panel-start-title { font-size: 40px; font-weight: 900; margin: 0; }
.panel-start-subtitle { font-size: 22px; font-weight: 600; opacity: 0.7; margin: 0; }

.panel-start-btn {
    margin-top: 12px;
    border: none;
    background: linear-gradient(145deg, var(--brand, #0369a1), var(--brand-strong, #075985));
    color: #ffffff;
    font-size: 28px;
    font-weight: 800;
    padding: 20px 56px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 16px 40px rgba(3, 105, 161, 0.35);
    animation: panelStartPulse 1.8s ease-in-out infinite;
}

.panel-start-hint { font-size: 16px; opacity: 0.55; margin: 0; }

@keyframes panelStartPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}

.panel-body {
    flex: 1;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 28px;
    min-height: 0;
}

.panel-section-title {
    font-size: 20px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.75;
    margin-bottom: 18px;
}

.panel-now {
    display: flex;
    flex-direction: column;
}

.panel-now-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    font-weight: 800;
    opacity: 0.5;
}

.panel-now-card {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 24px;
    border-radius: 24px;
    background: linear-gradient(145deg, var(--brand), var(--brand-strong));
    color: #ffffff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.2);
    animation: panelPulse 1.2s ease-in-out 2;
}

.panel-now-number {
    font-size: clamp(56px, 9vw, 120px);
    font-weight: 900;
    line-height: 1;
}

.panel-now-name { font-size: clamp(22px, 3vw, 38px); font-weight: 800; }
.panel-now-room { font-size: clamp(18px, 2.2vw, 28px); font-weight: 700; opacity: 0.9; }

.panel-history {
    margin-top: 28px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.panel-history-title {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0.6;
    margin-bottom: 12px;
}

.panel-history-list {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.panel-history-item {
    display: grid;
    grid-template-columns: 64px 1fr auto auto;
    align-items: baseline;
    gap: 16px;
    padding: 12px 6px;
    border-bottom: 1px solid #e2e8f0;
}

.panel-history-number { font-size: 26px; font-weight: 900; }
.panel-history-name { font-size: 22px; font-weight: 700; }
.panel-history-room { font-size: 18px; font-weight: 700; opacity: 0.75; }
.panel-history-time { font-size: 18px; font-weight: 600; opacity: 0.6; white-space: nowrap; }

.panel-waiting {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 22px;
    overflow-y: auto;
}

.panel-waiting-empty { opacity: 0.6; font-size: 18px; }

.panel-waiting-item {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.panel-waiting-item span { font-size: 30px; font-weight: 900; min-width: 56px; }
.panel-waiting-item small { font-size: 18px; opacity: 0.85; }

@keyframes panelPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); box-shadow: 0 28px 80px rgba(56, 189, 248, 0.5); }
}

@media (max-width: 900px) {
    .panel-body { grid-template-columns: 1fr; }
}

/* QR de presenca do check-in pelo app (painel de TV) */
.panel-presence-qr {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    color: #0f172a;
    border-radius: 18px;
    padding: 14px;
    margin-bottom: 22px;
}

.panel-presence-qr img {
    width: 170px;
    height: 170px;
    image-rendering: pixelated;
    flex-shrink: 0;
}

.panel-presence-qr strong {
    display: block;
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 6px;
}

.panel-presence-qr span {
    font-size: 16px;
    opacity: 0.75;
}
