:root {
    --billing-success: #2f8f5b;
    --billing-success-soft: #edf8f1;
    --billing-danger: #c34242;
    --billing-danger-soft: #fbecec;
    --billing-warning: #b7791f;
    --billing-warning-soft: #fdf4e7;
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    color: var(--oto-ink);
    font-family: "Kumbh Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

button,
input {
    font: inherit;
}

button {
    cursor: pointer;
}

.billing-app-main {
    display: grid;
    gap: 22px;
}

.billing-main-content,
.billing-footer-inner {
    width: min(1080px, 100%);
    margin: 0 auto;
}

.billing-main-content {
    display: grid;
    gap: 18px;
    padding-top: 18px;
}

.billing-page-intro {
    width: 100%;
    margin: 0;
}

.auth-gate {
    max-width: 620px;
    margin: 24px auto 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 34px 28px;
    text-align: center;
}

.auth-gate i {
    color: var(--oto-quiet);
    font-size: 36px;
}

.auth-gate h2 {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.08;
}

.auth-gate p {
    max-width: 42ch;
    color: var(--oto-muted);
}

.auth-gate-btn {
    margin-top: 4px;
}

.billing-content {
    display: grid;
    gap: 18px;
}

.status-banner,
.balance-card,
.topup-card,
.history-card,
.admin-card {
    backdrop-filter: blur(18px);
}

.status-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--oto-line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    font-size: 14px;
    font-weight: 600;
}

.status-banner.success {
    color: var(--billing-success);
    background: var(--billing-success-soft);
    border-color: rgba(47, 143, 91, 0.28);
}

.status-banner.cancel {
    color: var(--billing-warning);
    background: var(--billing-warning-soft);
    border-color: rgba(183, 121, 31, 0.28);
}

.status-banner.error {
    color: var(--billing-danger);
    background: var(--billing-danger-soft);
    border-color: rgba(195, 66, 66, 0.22);
}

.billing-overview-grid {
    display: grid;
    grid-template-columns: minmax(300px, 0.94fr) minmax(360px, 1.06fr);
    gap: 18px;
}

.balance-card,
.topup-card,
.history-card,
.admin-card {
    padding: 24px;
}

.balance-header,
.panel-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 14px;
}

.balance-label,
.panel-kicker {
    display: inline-block;
    color: var(--oto-quiet);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.panel-title {
    margin-top: 4px;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.1;
}

.icon-btn {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--oto-muted);
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--oto-line-strong);
    border-radius: 8px;
    transition: border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus-visible {
    color: var(--oto-accent-strong);
    border-color: rgba(47, 127, 167, 0.34);
    box-shadow: 0 8px 18px rgba(18, 31, 45, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.balance-value {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 18px;
}

#balance-amount {
    font-size: clamp(3rem, 5vw, 4.4rem);
    font-weight: 700;
    line-height: 0.95;
    letter-spacing: -0.04em;
}

.balance-unit {
    color: var(--oto-quiet);
    font-size: 18px;
    font-weight: 700;
}

.balance-hint,
.topup-description,
.topup-note,
.admin-description,
.amount-preview {
    color: var(--oto-muted);
}

.balance-hint {
    margin-top: 14px;
    font-size: 14px;
}

.balance-hint a,
.billing-footer-links a {
    color: var(--oto-accent-strong);
    text-decoration: none;
}

.balance-hint a:hover,
.balance-hint a:focus-visible,
.billing-footer-links a:hover,
.billing-footer-links a:focus-visible {
    text-decoration: underline;
    outline: none;
}

.topup-description {
    margin-top: 12px;
    font-size: 14px;
}

.topup-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0;
}

.preset-btn,
.admin-action-btn {
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 16px;
    color: var(--oto-ink);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--oto-line-strong);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 700;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.preset-btn:hover,
.preset-btn:focus-visible,
.admin-action-btn:hover,
.admin-action-btn:focus-visible {
    background: #ffffff;
    border-color: rgba(47, 127, 167, 0.34);
    box-shadow: 0 8px 18px rgba(18, 31, 45, 0.08);
    transform: translateY(-1px);
    outline: none;
}

.preset-btn.active {
    color: var(--oto-accent-strong);
    background: rgba(47, 127, 167, 0.1);
    border-color: rgba(47, 127, 167, 0.24);
    box-shadow: none;
}

.topup-form {
    display: grid;
    gap: 12px;
}

.amount-label {
    color: var(--oto-quiet);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.amount-input-wrap {
    position: relative;
}

.amount-prefix {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--oto-muted);
    font-size: 18px;
    font-weight: 700;
    pointer-events: none;
}

.amount-input {
    width: 100%;
    min-height: 50px;
    padding: 0 16px 0 34px;
    color: var(--oto-ink);
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--oto-line-strong);
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
}

.amount-input:focus {
    border-color: rgba(47, 127, 167, 0.42);
    box-shadow: 0 0 0 4px rgba(47, 127, 167, 0.08);
    outline: none;
}

.btn-checkout {
    min-height: 50px;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 18px;
    color: #ffffff;
    background: linear-gradient(135deg, #55b4df 0%, #f0a8df 100%);
    border: 0;
    border-radius: 8px;
    box-shadow: 0 14px 28px rgba(85, 180, 223, 0.18);
    font-size: 15px;
    font-weight: 700;
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn-checkout:hover,
.btn-checkout:focus-visible {
    box-shadow: 0 18px 34px rgba(85, 180, 223, 0.24);
    transform: translateY(-1px);
    outline: none;
}

.btn-checkout:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.topup-note {
    font-size: 12px;
}

.history-empty {
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 36px 20px;
    color: var(--oto-quiet);
    text-align: center;
}

.history-empty i {
    font-size: 30px;
    opacity: 0.7;
}

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

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th,
.history-table td {
    padding: 12px 10px;
    border-bottom: 1px solid rgba(188, 198, 212, 0.72);
}

.history-table th {
    color: var(--oto-quiet);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
}

.history-table th.num,
.history-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.history-table tr:last-child td {
    border-bottom: 0;
}

.tx-kind {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tx-kind.topup {
    color: var(--billing-success);
    background: var(--billing-success-soft);
}

.tx-kind.spend {
    color: var(--oto-accent-strong);
    background: rgba(47, 127, 167, 0.1);
}

.tx-kind.refund {
    color: var(--billing-warning);
    background: var(--billing-warning-soft);
}

.tx-kind.adjustment {
    color: var(--oto-muted);
    background: var(--oto-surface-soft);
}

.tx-delta.positive {
    color: var(--billing-success);
    font-weight: 700;
}

.tx-delta.negative {
    color: var(--billing-danger);
    font-weight: 700;
}

.admin-description {
    margin-top: 12px;
}

.admin-lookup {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 16px;
}

.admin-result {
    margin-top: 14px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--oto-line);
    border-radius: 8px;
}

.admin-user-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.admin-user-meta {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.admin-user-email {
    font-weight: 700;
}

.admin-user-roles,
.admin-user-balance {
    color: var(--oto-muted);
    font-size: 13px;
}

.admin-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
}

.admin-status {
    margin-top: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
}

.admin-status.success {
    color: var(--billing-success);
    background: var(--billing-success-soft);
}

.admin-status.error {
    color: var(--billing-danger);
    background: var(--billing-danger-soft);
}

.billing-footer {
    padding: 4px 0 10px;
}

.billing-footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    color: var(--oto-quiet);
    font-size: 13px;
}

.billing-footer-links {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.billing-footer-copy {
    margin: 0;
}

@media (max-width: 1080px) {
    .billing-overview-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 980px) {
    .billing-main-content {
        gap: 16px;
        padding-top: 8px;
    }

    .auth-gate {
        margin-top: 12px;
    }
}

@media (max-width: 720px) {
    .billing-page-intro .oto-page-intro-actions {
        width: 100%;
    }

    .billing-page-intro .oto-page-intro-actions > * {
        flex: 1 1 100%;
        justify-content: center;
    }

    .balance-card,
    .topup-card,
    .history-card,
    .admin-card {
        padding: 20px 18px;
    }

    #balance-amount {
        font-size: 2.7rem;
    }

    .admin-lookup {
        grid-template-columns: 1fr;
    }

    .admin-user-row,
    .billing-footer-inner {
        align-items: start;
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .history-table th:first-child,
    .history-table td:first-child {
        display: none;
    }

    .topup-presets {
        gap: 8px;
    }

    .preset-btn {
        flex: 1 1 calc(50% - 8px);
    }
}
