.public-detail-main {
    padding-top: 0.75rem;
    padding-bottom: 1.5rem;
}

.public-detail-page {
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* Keep the public banner consistent with the 8:1 admin upload/editor frame. */
.program-hero {
    height: auto;
    border-radius: 0.75rem;
    overflow: hidden;
    flex: 0 0 auto;
}

.program-detail-banner {
    width: 100%;
    aspect-ratio: 8 / 1;
}

.program-detail-banner img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 35%;
}

.program-detail-panel {
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
    border-radius: 0.75rem;
}

.program-tab-stage {
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* Tab panel switching rules */
.tab-panel.hidden {
    display: none !important;
}

.tab-panel:not(.hidden) {
    display: flex;
    flex-direction: column;
    width: 100%;
}

#tab-rules:not(.hidden),
#tab-prizes:not(.hidden) {
    overflow-y: visible;
}

.program-document {
    --document-accent: #348f1d;
    --document-accent-dark: #287216;
    --document-accent-soft: #f0fdf4;
    --document-accent-border: #bbf7d0;
    overflow: hidden;
    border: 1px solid var(--document-accent-border);
    border-radius: 0.875rem;
    background: #fff;
    box-shadow: 0 8px 28px rgb(15 23 42 / 0.07);
}

.program-document__header {
    display: grid;
    grid-template-columns: 3rem minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.875rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, var(--document-accent-soft), #fff 72%);
    padding: 1rem 1.125rem;
}

.program-document__icon {
    display: grid;
    width: 3rem;
    height: 3rem;
    place-items: center;
    border-radius: 0.75rem;
    background: #fff;
    color: var(--document-accent);
    box-shadow: 0 4px 14px rgb(15 23 42 / 0.08);
}

.program-document__icon svg {
    width: 1.6rem;
    height: 1.6rem;
}

.program-pdf-card {
    --pdf-card-accent: #2563eb;
    --pdf-card-soft: #eff6ff;
    --pdf-card-border: #bfdbfe;
    width: 100%;
    max-width: 54rem;
    margin-inline: auto;
    overflow: hidden;
    border: 1px solid var(--pdf-card-border);
    border-radius: 0.875rem;
    background: #fff;
    box-shadow: 0 8px 28px rgb(15 23 42 / 0.08);
}

.program-pdf-card--green {
    --pdf-card-accent: #348f1d;
    --pdf-card-soft: #f0f7ed;
    --pdf-card-border: #c8ddc1;
}

.program-pdf-card__header {
    display: grid;
    grid-template-columns: 2.75rem minmax(0, 1fr);
    align-items: center;
    gap: 0.875rem;
    border-bottom: 1px solid var(--pdf-card-border);
    background: linear-gradient(135deg, var(--pdf-card-soft), #fff 74%);
    padding: 0.875rem 1rem;
}

.program-pdf-card__icon {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border-radius: 0.7rem;
    background: var(--pdf-card-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgb(15 23 42 / 0.1);
}

.program-pdf-card__icon svg {
    width: 1.45rem;
    height: 1.45rem;
}

.program-pdf-card__header h2 {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.35;
}

.program-pdf-card__header p {
    margin-top: 0.15rem;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
}

.program-pdf-card__body {
    padding: 0.75rem;
    background: #f6f8f5;
}

.program-pdf-container {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: min(82vh, 54rem);
    min-height: 32rem;
    overflow: auto;
    border: 1px solid #dce5d9;
    border-radius: 0.625rem;
    background: #edf2eb;
    scrollbar-color: #9aaa94 #dfe8dc;
    scrollbar-width: thin;
}

.program-pdf-pages {
    box-sizing: border-box;
    display: flex;
    width: 100%;
    min-height: 100%;
    flex-direction: column;
    align-items: center;
    gap: 0.875rem;
    padding: 0.75rem;
}

.program-pdf-page {
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid #d8e1d5;
    border-radius: 0.2rem;
    background: #fff;
    box-shadow: 0 4px 16px rgb(15 23 42 / 0.12);
}

.program-pdf-page canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.program-pdf-status {
    position: absolute;
    z-index: 2;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1.5rem;
    background: #edf2eb;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.program-pdf-status[hidden] {
    display: none;
}

.program-pdf-status.is-error {
    flex-direction: column;
}

.program-pdf-status.is-error .program-pdf-spinner {
    display: none;
}

.program-pdf-status a {
    border-radius: 0.5rem;
    background: var(--pdf-card-accent, #348f1d);
    padding: 0.55rem 0.8rem;
    color: #fff;
    font-size: 0.8rem;
    text-decoration: none;
}

.program-pdf-spinner {
    width: 1.1rem;
    height: 1.1rem;
    flex: 0 0 auto;
    border: 2px solid #cbd5e1;
    border-top-color: #348f1d;
    border-radius: 999px;
    animation: program-pdf-spin 0.75s linear infinite;
}

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

.program-document__content {
    --document-accent: #2563eb;
    --document-accent-soft: #eff6ff;
    --document-accent-border: #bfdbfe;
    overflow: hidden;
    border: 1px solid var(--document-accent-border);
    border-radius: 0.875rem;
    background: #fff;
    box-shadow: 0 8px 28px rgb(15 23 42 / 0.07);
}

.program-document__content--green {
    --document-accent: #348f1d;
    --document-accent-soft: #f0fdf4;
    --document-accent-border: #bbf7d0;
}

.program-document__content-header {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, var(--document-accent-soft), #fff 72%);
    padding: 1rem 1.125rem;
}

.program-document__content-icon {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 999px;
    background: var(--document-accent);
    color: #fff;
    font-size: 1.1rem;
    font-weight: 900;
}

.program-document__content-header h2 {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 900;
    line-height: 1.4;
}

.program-document__content-header p {
    margin-top: 0.2rem;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.4;
}

.program-document__content-body {
    padding: 1.25rem;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.75;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.program-document__fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
}

.program-document__fallback {
    min-height: 20rem;
    flex-direction: column;
    padding: 2rem;
    color: #475569;
}

.program-document__fallback strong {
    color: #0f172a;
}

.program-document__fallback a {
    border-radius: 0.5rem;
    background: var(--document-accent);
    padding: 0.6rem 0.9rem;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 800;
}

.lookup-panel {
    display: flex;
    flex-direction: column;
    width: 100%;
}

.lookup-heading {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .lookup-heading {
        flex-direction: row;
        align-items: flex-end;
        justify-content: space-between;
    }
}

.lookup-heading h2 {
    font-size: 1.25rem;
    line-height: 1.3;
}

@media (min-width: 768px) {
    .lookup-heading h2 {
        font-size: 1.5rem;
    }
}

.lookup-controls {
    margin-top: 0.875rem;
    padding: 0.875rem 1rem;
    gap: 0.75rem;
}

.lookup-controls label {
    font-size: 0.825rem;
    line-height: 1.2rem;
    margin-bottom: 0.25rem;
}

.lookup-controls select,
.lookup-controls #searchInput {
    min-height: 2.6rem;
    font-size: 0.9rem;
}

/* The interface provides its own clear button, so hide the browser-native X. */
.lookup-controls #searchInput::-webkit-search-cancel-button,
.lookup-controls #searchInput::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.lookup-controls #searchStatus {
    display: block;
}

.lookup-results {
    display: flex;
    flex-direction: column;
    margin-top: 1rem;
    border-radius: 0.75rem;
    overflow: hidden;
}

.lookup-results > div:first-child {
    padding: 0.625rem 1rem;
}

.export-label-short {
    display: none;
}

.program-tabs,
.result-table-scroll,
#tab-rules,
#tab-prizes {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
    scrollbar-color: #348f1d #e5f0df;
    scrollbar-width: thin;
}

.program-tabs {
    scroll-snap-type: x proximity;
}

.program-tabs .tab-button {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.result-table-scroll {
    width: 100%;
    max-height: 700px;
    overflow: auto;
    scrollbar-gutter: stable;
    touch-action: pan-x pan-y;
}

.result-table-scroll:focus-visible {
    outline: 3px solid rgba(52, 143, 29, 0.25);
    outline-offset: -3px;
}

.result-table {
    table-layout: auto;
    min-width: 58rem;
    width: 100%;
}

.result-table th,
.result-table td {
    line-height: 1.4;
    padding: 0.65rem 0.875rem;
    font-size: 0.875rem;
}

.result-table th {
    font-size: 0.8rem;
    font-weight: 800;
}

@media (min-width: 768px) {
    .result-table .result-col--index {
        width: 4rem;
        text-align: center;
    }

    .result-table .result-col--prize {
        width: 10rem;
    }

    .result-table .result-col--code,
    .result-table .result-col--default {
        width: 11rem;
    }

    .result-table .result-col--customer {
        width: 25rem;
    }

    .result-table .result-col--location {
        width: 10rem;
    }
}

.result-table-scroll::-webkit-scrollbar,
.program-tabs::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.result-table-scroll::-webkit-scrollbar-track,
.program-tabs::-webkit-scrollbar-track {
    background: #e5f0df;
}

.result-table-scroll::-webkit-scrollbar-thumb,
.program-tabs::-webkit-scrollbar-thumb {
    border: 2px solid #e5f0df;
    border-radius: 999px;
    background: #348f1d;
}

@media (max-width: 767px) {
    .public-detail-main {
        padding: 0.5rem 0.5rem 1.5rem 0.5rem;
    }

    .program-tabs .tab-button {
        padding: 0.5rem 0.75rem;
        font-size: 0.825rem;
    }

    .program-pdf-container {
        height: 70vh;
        min-height: 26rem;
    }

    .program-pdf-card__header {
        align-items: flex-start;
        padding: 0.75rem;
    }

    .program-pdf-card__body,
    .program-pdf-pages {
        padding: 0.4rem;
    }

    .program-document__header {
        grid-template-columns: 2.75rem minmax(0, 1fr);
        padding: 0.875rem;
    }

    .program-document__content-header {
        align-items: flex-start;
        padding: 0.875rem;
    }

    .program-document__content-body {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .program-document__icon {
        width: 2.75rem;
        height: 2.75rem;
    }

    .program-document__actions {
        display: grid;
        grid-column: 1 / -1;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .program-document__viewer {
        padding: 0.35rem;
    }

    .export-label-full {
        display: none;
    }

    .export-label-short {
        display: inline;
    }

    .lookup-controls {
        grid-template-columns: 1fr;
        padding: 0.75rem;
    }

    .result-table {
        min-width: 48rem;
    }
}
