:root {
    color-scheme: dark;
    --bg: #00134d;
    --surface: #00234d;
    --surface-soft: #063366;
    --ink: #ffffff;
    --muted: #f0f0f0;
    --quiet: #c9d4e6;
    --line: rgba(255, 255, 255, 0.16);
    --field: #ffffff;
    --field-ink: #0f172a;
    --action: #4caf50;
    --action-hover: #45a049;
    --gold: #ffb51b;
    --danger: #ffb3a9;
    --danger-bg: #b3261e;
    --radius: 5px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    width: 100%;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--bg);
}

body {
    line-height: 1.45;
}

a,
button,
input,
textarea {
    font: inherit;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 18px 15px 8px;
    background: var(--bg);
}

.brand {
    grid-column: 2;
    display: inline-flex;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
}

.brand img {
    display: block;
    width: min(280px, 70vw);
    height: 98px;
    object-fit: cover;
    object-position: center;
}

.nav-links {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    overflow-x: auto;
}

.nav-links:empty {
    display: none;
}

.nav-links a,
.nav-links button {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    background: transparent;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}

.nav-links a:hover,
.nav-links a:focus-visible,
.nav-links button:hover,
.nav-links button:focus-visible,
.nav-links a.is-active {
    color: var(--ink);
    background: var(--surface-soft);
    outline: none;
}

.portal-main {
    width: min(100% - 30px, 920px);
    margin: 0 auto;
    padding: 18px 0 48px;
}

.portal-main:focus {
    outline: none;
}

.back-row {
    width: min(100%, 680px);
    margin: 0 auto 12px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 7px 12px;
    color: var(--ink);
    background: var(--surface);
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.back-link:hover,
.back-link:focus-visible {
    background: var(--surface-soft);
    outline: 3px solid rgba(255, 255, 255, 0.22);
}

.auth-panel {
    width: min(100%, 430px);
    margin: 0 auto;
}

.auth-panel > h1 {
    margin: 0 0 18px;
    text-align: center;
}

.hero-panel,
.flow-panel,
.info-card,
.dashboard-card,
.preference-card,
.message-panel,
.image-card {
    border-radius: var(--radius);
    background: var(--surface);
}

.hero-panel,
.flow-panel {
    padding: 20px;
}

.hero-panel.compact {
    max-width: 680px;
    margin: 0 auto;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 12px;
    font-size: 28px;
    line-height: 1.12;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 8px;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: 0;
}

p {
    margin-bottom: 0;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--gold);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.intro-copy,
.form-copy,
.form-note,
.info-card p,
.dashboard-card p,
.preference-card p,
.business-meta,
.business-summary p,
.fallback-note {
    color: var(--quiet);
}

.intro-copy strong,
.fallback-note strong {
    color: var(--ink);
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

button,
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    border: 0;
    border-radius: var(--radius);
    padding: 10px 14px;
    color: #ffffff;
    background: var(--action);
    cursor: pointer;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

button:hover,
button:focus-visible,
.button-link:hover,
.button-link:focus-visible {
    background: var(--action-hover);
    outline: 3px solid rgba(255, 255, 255, 0.22);
}

button.secondary,
.button-link.secondary {
    border: 1px solid var(--line);
    color: var(--ink);
    background: transparent;
}

button.secondary:hover,
button.secondary:focus-visible,
.button-link.secondary:hover,
.button-link.secondary:focus-visible {
    background: var(--surface-soft);
}

button:disabled {
    cursor: wait;
    opacity: 0.72;
}

.portal-form button[type="submit"] {
    width: 100%;
    margin-top: 10px;
}

.button-row button,
.button-row .button-link {
    flex: 1 1 180px;
}

.info-grid,
.dashboard-grid,
.preference-grid,
.image-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 14px;
}

.preference-section {
    margin-top: 22px;
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
}

.section-heading.compact {
    display: block;
}

.section-heading h2,
.section-heading p {
    margin-bottom: 0;
}

.section-heading p:not(.eyebrow) {
    margin-top: 6px;
}

.info-card,
.dashboard-card,
.preference-card,
.image-card,
.message-panel {
    border: 1px solid var(--line);
}

.info-card,
.dashboard-card,
.preference-card {
    padding: 16px;
}

.dashboard-card,
.preference-card {
    position: relative;
}

.dashboard-card {
    min-height: 118px;
}

.dashboard-card-link {
    display: block;
    color: var(--ink);
    text-decoration: none;
}

.dashboard-card-link:hover,
.dashboard-card-link:focus-visible {
    color: var(--ink);
    background: var(--surface-soft);
    outline: 3px solid rgba(255, 255, 255, 0.22);
}

.identifier-value {
    overflow-wrap: anywhere;
    color: var(--ink);
    font-weight: 700;
}

.dashboard-actions {
    margin-top: 16px;
}

.google-wallet-button {
    border: 1px solid #d7d7d7;
    color: var(--bg);
    background: #ffffff;
}

.google-wallet-button:hover,
.google-wallet-button:focus-visible {
    color: var(--bg);
    background: #f0f0f0;
}

.wallet-message {
    margin-top: 10px;
}

.reward-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.reward-item {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.reward-item-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.reward-item h3 {
    margin: 0;
    overflow-wrap: anywhere;
    font-size: 16px;
    line-height: 1.2;
}

.reward-item-heading span,
.reward-empty {
    color: var(--quiet);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.reward-item p {
    color: var(--ink);
    font-size: 14px;
}

.reward-progress {
    height: 7px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
}

.reward-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--gold);
}

.reward-progress-fill.progress-0 { width: 0%; }
.reward-progress-fill.progress-5 { width: 5%; }
.reward-progress-fill.progress-10 { width: 10%; }
.reward-progress-fill.progress-15 { width: 15%; }
.reward-progress-fill.progress-20 { width: 20%; }
.reward-progress-fill.progress-25 { width: 25%; }
.reward-progress-fill.progress-30 { width: 30%; }
.reward-progress-fill.progress-35 { width: 35%; }
.reward-progress-fill.progress-40 { width: 40%; }
.reward-progress-fill.progress-45 { width: 45%; }
.reward-progress-fill.progress-50 { width: 50%; }
.reward-progress-fill.progress-55 { width: 55%; }
.reward-progress-fill.progress-60 { width: 60%; }
.reward-progress-fill.progress-65 { width: 65%; }
.reward-progress-fill.progress-70 { width: 70%; }
.reward-progress-fill.progress-75 { width: 75%; }
.reward-progress-fill.progress-80 { width: 80%; }
.reward-progress-fill.progress-85 { width: 85%; }
.reward-progress-fill.progress-90 { width: 90%; }
.reward-progress-fill.progress-95 { width: 95%; }
.reward-progress-fill.progress-100 { width: 100%; }

.reward-empty {
    padding: 4px 0;
    white-space: normal;
}

.profile-panel {
    margin-top: 14px;
}

.linked-list {
    display: grid;
    gap: 8px;
}

.linked-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.linked-item span {
    color: var(--quiet);
    font-size: 13px;
    font-weight: 700;
}

.linked-item strong {
    overflow-wrap: anywhere;
    text-align: right;
}

.preference-card {
    display: grid;
    gap: 14px;
    align-items: start;
}

.business-card .button-link {
    align-self: end;
}

.business-summary p {
    margin-bottom: 0;
}

.fallback-note strong {
    display: block;
    margin-top: 6px;
    font-weight: 700;
}

.card-link {
    display: inline-flex;
    width: fit-content;
    margin-top: 14px;
    color: var(--gold);
    font-weight: 700;
    text-decoration: none;
}

.card-link:hover,
.card-link:focus-visible {
    color: var(--ink);
    outline: none;
}

.status-pill {
    display: inline-flex;
    width: fit-content;
    margin-bottom: 10px;
    padding: 4px 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--quiet);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill.saved {
    border-color: rgba(76, 175, 80, 0.55);
    color: #a6f3b0;
    background: rgba(76, 175, 80, 0.14);
}

.status-pill.fallback {
    border-color: rgba(255, 181, 27, 0.55);
    color: var(--gold);
    background: rgba(255, 181, 27, 0.12);
}

.scanned-card {
    display: grid;
    gap: 4px;
    margin: 16px 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.06);
}

.scanned-card span {
    color: var(--quiet);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.scanned-card strong {
    overflow-wrap: anywhere;
    font-size: 18px;
    letter-spacing: 0;
}

.portal-form,
.image-upload-form {
    display: grid;
    gap: 12px;
    margin-top: 0;
}

label {
    display: block;
    color: var(--muted);
    font-size: 16px;
    font-weight: 700;
}

label span {
    display: block;
    margin-top: 2px;
    color: var(--quiet);
    font-size: 13px;
    font-weight: 400;
}

input,
textarea {
    width: 100%;
    margin-top: 8px;
    border: none;
    border-radius: var(--radius);
    padding: 10px;
    color: var(--field-ink);
    background: var(--field);
    font-size: 16px;
}

input {
    min-height: 46px;
}

textarea {
    min-height: 150px;
    resize: vertical;
    line-height: 1.45;
}

input[type="file"] {
    color: var(--field-ink);
}

input[readonly] {
    color: #4b5563;
    background: #dfe7f3;
}

input:focus,
textarea:focus {
    outline: 3px solid rgba(255, 181, 27, 0.34);
}

.form-message {
    min-height: 22px;
    color: var(--quiet);
    font-size: 14px;
}

.form-message.error,
.message-panel.error {
    color: var(--danger);
}

.form-message.loading {
    color: var(--gold);
}

.form-message.success {
    color: #a6f3b0;
}

.form-note {
    margin: 8px 0 0;
    overflow-wrap: anywhere;
    font-size: 13px;
}

.auth-switch {
    margin: 16px 0 0;
    color: var(--quiet);
    text-align: center;
}

.auth-switch a {
    color: var(--gold);
    font-weight: 700;
    text-decoration: none;
}

.auth-switch a:hover,
.auth-switch a:focus-visible {
    color: var(--ink);
    outline: none;
}

.message-panel {
    margin-top: 14px;
    padding: 12px;
}

.loading-state {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--quiet);
    font-weight: 700;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 4px solid rgba(255, 255, 255, 0.28);
    border-top-color: var(--action);
    border-radius: 50%;
    animation: spin 0.85s linear infinite;
}

.preference-editor {
    margin-top: 18px;
}

.image-upload-section {
    display: grid;
    gap: 14px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.image-count {
    margin: 0;
    color: var(--gold);
    font-size: 13px;
    font-weight: 700;
}

.image-card {
    display: grid;
    gap: 12px;
    padding: 12px;
}

.image-card p {
    margin-bottom: 4px;
    font-weight: 700;
}

.image-card span {
    color: var(--quiet);
    font-size: 13px;
}

.image-card button {
    width: 100%;
}

.image-thumb-frame {
    position: relative;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.08);
}

.image-thumb-frame.is-missing::after {
    content: "Image unavailable";
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 12px;
    color: var(--quiet);
    text-align: center;
    font-weight: 700;
}

.preference-image-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.danger {
    color: #ffffff;
    background: var(--danger-bg);
}

button.secondary.danger {
    border-color: rgba(255, 179, 169, 0.5);
    color: var(--danger);
    background: transparent;
}

button.secondary.danger:hover,
button.secondary.danger:focus-visible {
    color: #ffffff;
    background: var(--danger-bg);
}

footer,
[data-testid="footer"],
[class*="footer"],
[id*="footer"] {
    display: none !important;
}

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

@media (max-width: 600px) {
    .portal-main {
        width: 100%;
        padding: 14px 15px 40px;
    }

    .hero-panel,
    .flow-panel {
        padding: 15px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 18px;
    }

    input,
    textarea,
    button,
    .button-link {
        font-size: 14px;
    }

    .linked-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .linked-item strong {
        text-align: left;
    }
}

@media (min-width: 720px) {
    .app-header {
        grid-template-columns: 1fr auto 1fr;
        padding: 22px 24px 10px;
    }

    .brand img {
        width: 320px;
        height: 112px;
    }

    .nav-links {
        grid-column: 3;
        justify-content: flex-end;
        padding-top: 0;
    }

    .portal-main {
        padding-top: 24px;
    }

    h1 {
        font-size: 34px;
    }

    .info-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-grid,
    .preference-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .preference-card {
        min-height: 176px;
    }

    .image-upload-form {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
        align-items: end;
    }

    .image-upload-form .button-row {
        grid-column: 1 / -1;
        margin-top: 0;
    }

    .image-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
