:root {
    --brand-primary: #1e3a5f;
    --brand-primary-hover: #274a77;
    --header-neutral: #f9f9f9;
    --surface: #ffffff;
    --surface-soft: #f7f9fc;
    --surface-border: #dfe7f1;
    --text-main: #1f2937;
    --text-muted: #5f6f84;
    --danger: #b43a3a;
    --shadow: 0 14px 36px rgba(30, 58, 95, 0.14);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text-main);
    background: var(--surface-soft);
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

.login-shell,
.app-shell {
    width: min(1080px, 100%);
    margin: 0 auto;
    padding: 16px;
}

.unauthenticated .app-shell {
    display: none;
}

.authenticated .login-shell {
    display: none;
}

.login-card,
.panel,
.scanner-card {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    box-shadow: var(--shadow);
}

.login-card {
    margin: 8vh auto 0;
    max-width: 520px;
    padding: 22px;
    border-radius: 10px;
}

.login-card h1 {
    margin: 0 0 8px;
    color: #1e3a5f;
}

.login-card p {
    margin: 0 0 16px;
    color: var(--text-muted);
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #d7e8ff, #eef3f9 60%);
}

.login-form label {
    display: block;
    margin: 10px 0 6px;
    font-weight: 600;
}

.login-form #loginBtn {
    margin-top: 10px;
}

.account-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
}

input,
button {
    min-height: 44px;
    border-radius: 4px;
    border: 1px solid var(--surface-border);
    font: inherit;
}

input:not([type="radio"]):not([type="checkbox"]) {
    width: 100%;
    padding: 10px 12px;
}

#birthdateInput {
    width: min(100%, 240px);
    min-height: 38px;
    padding: 6px 10px;
}

button {
    padding: 10px 14px;
    background: #fff;
    color: var(--text-main);
    cursor: pointer;
}

button.primary {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: #fff;
    font-weight: 700;
}

button.primary:hover {
    background: var(--brand-primary-hover);
}

button.ghost {
    background: #f4f7fb;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    background: var(--header-neutral);
    color: var(--brand-primary);
    border-radius: 0;
    padding: 12px 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.app-header h1 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.2;
}

.app-header .ghost {
    border-color: #e0e0e0;
    background: #f9f9f9;
    color: var(--brand-primary);
}

.app-header .ghost:hover {
    background: #f1f1f1;
}

main {
    display: grid;
    gap: 12px;
}

.panel {
    padding: 14px;
    border-radius: 4px;
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.1rem;
}

.account-grid {
    margin-top: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.account-item {
    padding: 10px;
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    background: #f9fbff;
}

.account-item .label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.account-item .value {
    margin-top: 4px;
    font-weight: 700;
}

.actions-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.account-summary-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    align-items: center;
}

.transactions-list {
    margin-top: 10px;
    display: grid;
    gap: 8px;
    overflow-y: auto;
    max-height: calc((5 * 70px) + (4 * 8px));
    padding-right: 4px;
}

.transaction-row {
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    padding: 10px;
    background: #f9fbff;
    min-height: 70px;
}

.transaction-row.transaction-row-cancelled {
    background: #fff0f0;
    border-color: #ef4444;
}

.transaction-row.transaction-row-rejected-refund {
    background: #fff3f3;
    border-color: #e86a6a;
}

.transaction-row .meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.transaction-row .details {
    margin-top: 6px;
    font-weight: 600;
}

.transaction-badge {
    display: inline-flex;
    align-items: center;
    margin-top: 8px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 12px;
    font-weight: 700;
}

.transaction-badge.cancelled {
    border-color: #d32f2f;
    background: #ffeaea;
    color: #a71f1f;
}

.transaction-badge.rejected {
    border-color: #c62828;
    background: #ffdede;
    color: #8f1b1b;
}

.donation-options {
    margin: 8px 0;
    display: grid;
    gap: 6px;
}

.donation-options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    line-height: 1.2;
}

.donation-options input[type="radio"] {
    width: 16px;
    height: 16px;
    min-height: 16px;
    margin: 0;
    accent-color: var(--brand-primary);
}

#donationPanel > p {
    margin: 0 0 8px;
}

#partialAmountWrap {
    margin-top: 2px;
    max-width: 240px;
}

#partialAmountWrap label {
    margin: 0 0 4px;
    font-size: 0.95rem;
}

#partialAmountWrap input {
    min-height: 36px;
    padding: 6px 10px;
}

#donationPanel #donateBtn {
    min-height: 38px;
    padding: 8px 12px;
}

.online-deposit-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 240px) 1fr;
    align-items: end;
}

#onlineDepositAmountSelect {
    width: 100%;
    min-height: 38px;
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    padding: 6px 10px;
    background: #fff;
}

.online-deposit-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.online-deposit-actions button {
    white-space: nowrap;
}

.online-deposit-status {
    margin-top: 10px;
    font-size: 0.92rem;
    color: var(--text-muted);
}

.online-deposit-status.success {
    color: #2e7d32;
}

.online-deposit-element {
    display: none;
    margin-top: 10px;
    border: 1px solid var(--surface-border);
    border-radius: 6px;
    background: #fff;
    padding: 10px;
}

.online-deposit-element.is-open {
    display: block;
}

.action-panels {
    display: none;
    gap: 12px;
}

.action-panels.two-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.action-panels.three-panels {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-panels.only-donation,
.action-panels.only-online-deposit,
.action-panels.only-online-refund {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.action-panels.only-donation #onlineDepositPanel,
.action-panels.only-donation #onlineRefundPanel,
.action-panels.only-online-deposit #donationPanel,
.action-panels.only-online-deposit #onlineRefundPanel,
.action-panels.only-online-refund #donationPanel,
.action-panels.only-online-refund #onlineDepositPanel {
    display: none !important;
}

.online-refund-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: minmax(180px, 240px) 1fr;
    align-items: end;
}

.online-refund-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

#onlineRefundRequestBtn:disabled,
#onlineRefundRequestBtn.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(0.2);
}

.online-refund-max-hint {
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.online-refund-list {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.online-refund-row {
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    padding: 8px 10px;
    background: #f9fbff;
}

.online-refund-row-meta {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.online-refund-row-details {
    margin-top: 6px;
    font-weight: 600;
}

.feedback {
    position: fixed;
    right: 20px;
    top: 68px;
    z-index: 80;
    min-width: 320px;
    max-width: min(520px, calc(100vw - 24px));
    border-radius: 10px;
    padding: 14px 16px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.32);
    border-left: 8px solid rgba(255, 255, 255, 0.5);
    animation: toast-in 0.16s ease-out;
}

.feedback.success {
    background-color: #2e7d32;
}

.feedback.error {
    background-color: #c62828;
}

.feedback.warning {
    background-color: #ef6c00;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-error {
    margin-top: 10px;
    color: var(--danger);
    font-size: 0.9rem;
}

.scanner-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    z-index: 50;
}

.scanner-card {
    width: min(640px, 100%);
    padding: 14px;
    border-radius: 4px;
}

.scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 10px;
}

#scannerVideo {
    width: 100%;
    max-height: min(65vh, 420px);
    border-radius: 4px;
    background: #1f1f1f;
}

.scanner-hint {
    margin: 8px 0 0;
    color: var(--text-muted);
}

.donation-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    z-index: 55;
}

.donation-modal-card {
    width: min(460px, 100%);
    background: var(--surface);
    border: 1px solid var(--surface-border);
    border-radius: 4px;
    box-shadow: var(--shadow);
    padding: 14px;
}

.donation-modal-card h2 {
    margin: 0;
    color: var(--brand-primary);
    font-size: 1.05rem;
}

.donation-modal-card p {
    margin: 10px 0 0;
    color: var(--text-main);
    line-height: 1.4;
}

.donation-modal-actions {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.donation-modal-actions button {
    min-width: 120px;
}

.online-payment-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    z-index: 70;
}

.online-payment-modal.success {
    background: #1e8e3e;
    color: #ffffff;
}

.online-payment-modal.error {
    background: #c62828;
    color: #ffffff;
}

.online-payment-card {
    width: min(92vw, 760px);
    display: flex;
    flex-direction: column;
    gap: 18px;
    border-radius: 18px;
    padding: 28px 32px;
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.28);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

.online-payment-card h2 {
    margin: 0;
    font-size: clamp(28px, 5.5vh, 56px);
    font-weight: 800;
    line-height: 1.08;
    letter-spacing: -0.02em;
}

.online-payment-card p {
    margin: 0;
    font-size: clamp(20px, 3vh, 32px);
    font-weight: 700;
    line-height: 1.25;
    opacity: 0.98;
}

.online-payment-details {
    display: grid;
    gap: 10px;
    text-align: left;
}

.online-payment-detail-text {
    margin: 0;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
    font-size: clamp(14px, 2vh, 18px);
    font-weight: 500;
    line-height: 1.4;
    opacity: 0.95;
}

.online-payment-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.28);
}

.online-payment-label {
    font-size: clamp(14px, 2vh, 20px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.9;
}

.online-payment-value {
    font-size: clamp(24px, 4vh, 40px);
    font-weight: 800;
    text-align: right;
}

.online-payment-actions {
    display: flex;
    justify-content: flex-end;
}

.online-payment-actions .primary {
    min-width: 160px;
    border-color: rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.online-payment-actions .primary:hover {
    background: rgba(255, 255, 255, 0.3);
}

@media (min-width: 860px) {
    .action-panels.two-panels {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 560px) {
    .feedback {
        left: 12px;
        right: 12px;
        top: 12px;
        min-width: 0;
    }

    .account-grid {
        grid-template-columns: 1fr;
    }

    .account-summary-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .actions-row {
        justify-content: stretch;
    }

    .actions-row button {
        width: 100%;
    }

    .action-panels,
    .action-panels.two-panels,
    .action-panels.three-panels,
    .action-panels.only-donation,
    .action-panels.only-online-deposit,
    .action-panels.only-online-refund {
        grid-template-columns: 1fr;
    }

    .online-deposit-grid {
        grid-template-columns: 1fr;
    }

    .online-refund-grid {
        grid-template-columns: 1fr;
    }

    .online-deposit-actions {
        justify-content: flex-start;
        overflow-x: auto;
    }

    .online-payment-card {
        padding: 18px;
        gap: 14px;
    }

    .online-payment-card h2 {
        font-size: clamp(26px, 8vw, 38px);
    }

    .online-payment-card p {
        font-size: clamp(18px, 5.4vw, 24px);
    }

    .online-payment-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .online-payment-value {
        text-align: left;
    }

    #birthdateInput {
        width: min(100%, 200px);
        min-height: 34px;
        padding: 5px 8px;
    }
}
