:root {
    color-scheme: light;
    --bg: #f3f5fb;
    --panel: #ffffff;
    --line: #d9dfef;
    --text: #1f2940;
    --muted: #61718f;
    --primary: #2f5bea;
    --primary-dark: #213fa7;
    --danger: #bf2c43;
    --success: #1b7f4b;
    --warning: #8a5a00;
    --accent: #ffb703;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Inter", Arial, Helvetica, sans-serif;
    background: linear-gradient(180deg, #eef2ff 0%, var(--bg) 100%);
    color: var(--text);
}

h1, h2, .brand-badge, .channel-pill, .button-lg {
    font-family: "Poppins", Arial, Helvetica, sans-serif;
}

code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.page-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

/* Header */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.brand-badge {
    font-weight: 700;
    font-size: 1.1rem;
}

.channel-pill {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary-dark);
    text-decoration: none;
    white-space: nowrap;
}

/* Hero */
.hero {
    text-align: center;
    padding: 40px 16px 48px;
    background: linear-gradient(135deg, #2f5bea 0%, #6c3ce9 100%);
    border-radius: 24px;
    color: #fff;
    margin-bottom: 32px;
    box-shadow: 0 24px 60px rgba(47, 91, 234, 0.25);
}

.hero .eyebrow {
    color: #ffe9a8;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin: 0 0 10px;
}

.hero h1 {
    margin: 0 0 14px;
    font-size: clamp(2rem, 5vw, 3.2rem);
    line-height: 1.1;
    font-weight: 800;
}

.hero-sub {
    max-width: 640px;
    margin: 0 auto 28px;
    font-size: 1.05rem;
    opacity: 0.95;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 14px;
}

.button-ghost {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.button-ghost:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* Layout */
.public-layout {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 24px;
    align-items: start;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(34, 52, 112, 0.08);
    padding: 28px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 20px;
}

.step-badge {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
}

.panel-heading h2 {
    margin: 0 0 4px;
    font-size: 1.4rem;
}

.panel-main h1,
.auth-card h1,
.confirmation-card h1 {
    margin-top: 0;
    font-size: clamp(2rem, 4vw, 3rem);
    line-height: 1.08;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.lead {
    color: var(--muted);
    margin: 0;
}

.stack {
    display: grid;
    gap: 16px;
}

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

label,
fieldset {
    display: grid;
    gap: 8px;
}

label > span {
    font-weight: 600;
    font-size: 0.92rem;
}

input,
select,
button {
    font: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="file"],
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 91, 234, 0.15);
}

.choice-group {
    border: none;
    padding: 0;
}

.choice-group legend {
    padding: 0 0 10px;
    font-weight: 700;
}

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

.choice-card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
        "icon label"
        "icon desc";
    align-items: center;
    gap: 4px 12px;
    border: 2px solid var(--line);
    border-radius: 16px;
    padding: 16px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.choice-card input {
    position: absolute;
    opacity: 0;
}

.choice-card .choice-icon {
    grid-area: icon;
    font-size: 1.6rem;
}

.choice-card .choice-label {
    grid-area: label;
    font-weight: 700;
}

.choice-card .choice-desc {
    grid-area: desc;
    font-size: 0.82rem;
    color: var(--muted);
}

.choice-card:has(input:checked) {
    border-color: var(--primary);
    background: #f2f6ff;
}

.file-drop {
    border: 2px dashed var(--line);
    border-radius: 16px;
    padding: 18px;
    background: #fbfcff;
}

.upload-section {
    padding-top: 4px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: 12px;
    padding: 12px 18px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    transition: transform 0.1s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.button:active {
    transform: scale(0.98);
}

.button-lg {
    padding: 14px 26px;
    font-size: 1.02rem;
    border-radius: 14px;
}

.button-block {
    width: 100%;
}

.button-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 24px rgba(47, 91, 234, 0.28);
}

.button-primary:hover {
    background: var(--primary-dark);
}

.button-secondary {
    background: #eef3ff;
    color: var(--primary-dark);
}

.button-secondary:hover {
    background: #dfe8ff;
}

.button-link {
    background: transparent;
    color: var(--muted);
}

.button-danger {
    background: #ffe7eb;
    color: var(--danger);
}

.hint {
    margin: 0;
    color: var(--muted);
    font-size: 0.88rem;
}

.hint-center {
    text-align: center;
}

.disclaimer-box {
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    background: #fbfcff;
}

.disclaimer-box p {
    margin: 0 0 12px;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--text);
}

.disclaimer-box p:last-child {
    margin-bottom: 0;
}

.disclaimer-title {
    font-weight: 700;
}

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.checkbox-row input[type="checkbox"] {
    margin-top: 2px;
}

.checkbox-row > span {
    font-weight: 600;
}

.field-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.85rem;
    font-weight: 600;
}

#disclaimer-wrapper.is-invalid .disclaimer-box {
    border-color: #f8bec9;
}

.upload-progress {
    border: 1px solid #b7c9ff;
    border-radius: 12px;
    padding: 14px;
    background: #f2f6ff;
}

.upload-warning {
    margin: 0 0 12px;
    color: var(--primary-dark);
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: #dce6ff;
    overflow: hidden;
}

.progress-fill {
    width: 0;
    height: 100%;
    background: var(--primary);
    transition: width 0.15s ease;
}

.progress-text {
    margin: 10px 0 0;
    color: var(--primary-dark);
    font-size: 0.9rem;
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.alert ul {
    margin-bottom: 0;
}

.alert-error {
    background: #ffecef;
    color: #92253a;
    border: 1px solid #f8bec9;
}

.alert-success {
    background: #e8fff3;
    color: #16663d;
    border: 1px solid #b5ebca;
}

.alert-warning {
    background: #fff7e5;
    color: var(--warning);
    border: 1px solid #f1d18b;
}

/* Donation box */
.donation-box {
    position: sticky;
    top: 24px;
    text-align: center;
    background: linear-gradient(160deg, #fff8e8 0%, #ffffff 60%);
    border-color: #ffe4a3;
}

.donation-icon {
    font-size: 2.4rem;
    margin-bottom: 6px;
}

.donation-box h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
}

.donation-box p {
    color: var(--muted);
    margin: 0 0 18px;
}

/* Footer */
.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin-top: 40px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.58);
    z-index: 50;
}

/* Critical fix: the [hidden] attribute must win over display:grid above,
   otherwise the modal stays visible and effectively "unclosable". */
.modal[hidden] {
    display: none !important;
}

.modal-card {
    position: relative;
    width: min(100%, 480px);
    background: #fff;
    border-radius: 20px;
    padding: 32px 28px 28px;
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
    text-align: center;
}

.modal-icon {
    font-size: 2.2rem;
    margin-bottom: 8px;
}

.modal-card h2 {
    margin: 0 0 10px;
    font-size: 1.3rem;
}

.modal-card p {
    color: var(--muted);
    margin: 0 0 8px;
}

.modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border: none;
    background: #f1f3fb;
    color: var(--muted);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.modal-close:hover {
    background: #e3e7f7;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

#close-modal {
    margin-top: 10px;
}

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

.admin-topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-topbar a {
    color: var(--primary-dark);
    text-decoration: none;
    font-weight: 700;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    white-space: nowrap;
}

.auth-card,
.confirmation-card {
    max-width: 640px;
    margin: 0 auto;
}

@media (max-width: 860px) {
    .public-layout,
    .grid-two,
    .choice-cards,
    .admin-topbar {
        grid-template-columns: 1fr;
        display: grid;
    }

    .admin-topbar {
        gap: 12px;
    }

    .donation-box {
        position: static;
    }

    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
