:root {
    color-scheme: light;
    font-family: "Microsoft YaHei UI", "Segoe UI", sans-serif;
    color: #172033;
    background: #f3f5f7;
    letter-spacing: 0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-width: 320px;
    background: #f3f5f7;
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

input[type="checkbox"] {
    width: auto;
    min-height: auto;
    margin: 0 6px 0 0;
    vertical-align: middle;
}

button,
a.button {
    min-height: 38px;
    border: 1px solid #c7ced8;
    border-radius: 5px;
    padding: 8px 14px;
    background: #ffffff;
    color: #172033;
    cursor: pointer;
    text-decoration: none;
}

button:hover,
a.button:hover {
    border-color: #6b7a90;
    background: #f8fafc;
}

button:disabled {
    cursor: not-allowed;
    opacity: .58;
}

button.primary,
a.primary {
    border-color: #1769aa;
    background: #1769aa;
    color: #ffffff;
}

button.primary:hover,
a.primary:hover {
    border-color: #125889;
    background: #125889;
}

button.danger {
    border-color: #b42318;
    color: #b42318;
}

button.icon-button {
    min-width: 38px;
    width: 38px;
    padding: 7px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 40px;
    border: 1px solid #c7ced8;
    border-radius: 4px;
    padding: 8px 10px;
    background: #ffffff;
    color: #172033;
}

textarea {
    min-height: 88px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #1769aa;
    outline: 2px solid #d8eaf8;
}

label {
    display: block;
    margin: 0 0 6px;
    color: #354154;
    font-size: 13px;
    font-weight: 600;
}

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

h1 {
    margin-bottom: 3px;
    font-size: 20px;
}

h2 {
    margin-bottom: 14px;
    font-size: 18px;
}

h3 {
    margin-bottom: 10px;
    font-size: 15px;
}

.app-header {
    min-height: 64px;
    padding: 12px 24px;
    background: #172033;
    color: #ffffff;
}

.app-header-inner {
    width: min(1180px, 100%);
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.app-subtitle {
    color: #aeb9c9;
    font-size: 12px;
}

.app-header a {
    color: #d7e8f6;
}

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

.auth-shell {
    width: min(470px, 100%);
    margin: 6vh auto 0;
    border: 1px solid #d5dbe3;
    border-radius: 6px;
    background: #ffffff;
}

.auth-heading {
    padding: 22px 24px 8px;
}

.auth-body {
    padding: 18px 24px 24px;
}

.segmented {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid #d5dbe3;
}

.segmented button {
    border: 0;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    background: transparent;
}

.segmented button.active {
    border-bottom-color: #1769aa;
    color: #125889;
    font-weight: 700;
}

.field {
    margin-bottom: 15px;
}

.field-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: end;
}

.captcha-row {
    display: grid;
    grid-template-columns: 1fr 142px 38px;
    gap: 8px;
    align-items: end;
}

.captcha-image {
    display: block;
    width: 142px;
    height: 44px;
    border: 1px solid #c7ced8;
    border-radius: 4px;
    object-fit: cover;
    background: #f8fafc;
}

.form-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.form-actions button {
    margin: 0;
}

.feedback {
    min-height: 22px;
    margin: 0 0 12px;
    color: #4b5a6e;
    font-size: 13px;
}

.feedback.error {
    color: #b42318;
}

.feedback.success {
    color: #157347;
}

.dashboard-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 18px;
}

.dashboard-grid > *, .panel, .panel-body { min-width: 0; }
#memberEmail, #quotaText, #quotaModel, #paymentOrder { overflow-wrap: anywhere; }
.quota-line { flex-wrap: wrap; }
#customRechargeForm { flex-wrap: wrap; justify-content: flex-start; }
#customRechargeForm label, #customRechargeForm button { flex: 0 0 auto; }
#customRechargeAmount { width: 160px; min-width: 0; flex: 1 1 160px; }

.panel {
    border: 1px solid #d5dbe3;
    border-radius: 6px;
    background: #ffffff;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 15px 18px;
    border-bottom: 1px solid #e1e5eb;
}

.panel-header h2,
.panel-header h3 {
    margin: 0;
}

.panel-body {
    padding: 18px;
}

.panel + .panel {
    margin-top: 18px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid #d5dbe3;
    border-radius: 6px;
    background: #ffffff;
    margin-bottom: 18px;
}

.admin-metrics {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
    min-width: 0;
    padding: 16px 18px;
    border-right: 1px solid #e1e5eb;
}

.metric:last-child {
    border-right: 0;
}

.metric-value {
    display: block;
    font-size: 23px;
    font-weight: 700;
    color: #172033;
}

.metric-label {
    display: block;
    margin-top: 4px;
    color: #6a7688;
    font-size: 12px;
}

.quota-line {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 8px;
}

.progress {
    display: block;
    width: 100%;
    height: 10px;
    overflow: hidden;
    border: 0;
    border-radius: 5px;
    background: #e5e9ef;
}

.progress::-webkit-progress-bar {
    background: #e5e9ef;
}

.progress::-webkit-progress-value {
    background: #1769aa;
}

.progress::-moz-progress-bar {
    background: #1769aa;
}

.muted {
    color: #6a7688;
    font-size: 13px;
}

.warning {
    border-left: 3px solid #d97706;
    padding: 9px 11px;
    background: #fff8e8;
    color: #7a4b00;
    font-size: 13px;
}

.success-box {
    border-left: 3px solid #198754;
    padding: 9px 11px;
    background: #ebf7f0;
    color: #115c39;
    font-size: 13px;
}

.token-value {
    width: 100%;
    min-height: 64px;
    padding: 10px;
    border: 1px dashed #8b98aa;
    border-radius: 4px;
    background: #f8fafc;
    font-family: Consolas, monospace;
    overflow-wrap: anywhere;
}

.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.plans {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.plan {
    border: 1px solid #d5dbe3;
    border-radius: 5px;
    padding: 14px;
    background: #ffffff;
}

.plan strong {
    display: block;
    margin-bottom: 7px;
}

.plan-price {
    margin: 9px 0;
    font-size: 18px;
    font-weight: 700;
    color: #125889;
}

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

table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid #e1e5eb;
    text-align: left;
    font-size: 13px;
}

th {
    background: #f7f8fa;
    color: #4b5a6e;
    font-weight: 700;
}

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

td button + button {
    margin-left: 6px;
}

.status {
    display: inline-block;
    border-radius: 4px;
    padding: 3px 7px;
    background: #e9eef5;
    color: #435168;
    font-size: 12px;
}

.status.approved,
.status.active {
    background: #dff3e8;
    color: #146c43;
}

.status.pending {
    background: #fff1cf;
    color: #8a5700;
}

.status.rejected,
.status.disabled {
    background: #fde4e2;
    color: #b42318;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.toolbar input {
    width: min(320px, 100%);
}

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

.settings-grid .full {
    grid-column: 1 / -1;
}

.modal {
    width: min(460px, calc(100% - 28px));
    border: 1px solid #b7c0cd;
    border-radius: 6px;
    padding: 0;
    box-shadow: 0 18px 55px rgba(23, 32, 51, .22);
}

.modal::backdrop {
    background: rgba(23, 32, 51, .58);
}

.modal-head,
.modal-body,
.modal-actions {
    padding: 16px 18px;
}

.modal-head {
    border-bottom: 1px solid #e1e5eb;
}

.modal-head h2 {
    margin: 0;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid #e1e5eb;
}

.payment-qr {
    display: block;
    width: min(260px, 100%);
    aspect-ratio: 1;
    margin: 0 auto 14px;
    object-fit: contain;
    border: 1px solid #d5dbe3;
    background: #ffffff;
}

[hidden] {
    display: none !important;
}

@media (max-width: 820px) {
    .dashboard-grid,
    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid .full {
        grid-column: auto;
    }

    .metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .metric:nth-child(2) {
        border-right: 0;
    }

    .metric:nth-child(-n+2) {
        border-bottom: 1px solid #e1e5eb;
    }

    .plans {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .app-header {
        padding: 12px 14px;
    }

    .page {
        width: calc(100% - 20px);
        margin-top: 12px;
    }

    .app-header-inner,
    .dashboard-head {
        align-items: flex-start;
        flex-direction: column;
    }

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

    .panel-header .toolbar,
    .panel-header .toolbar input {
        width: 100%;
    }

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

    .captcha-row {
        grid-template-columns: 1fr 38px;
    }

    .captcha-row .captcha-input {
        grid-column: 1 / -1;
    }

    .captcha-image {
        width: 100%;
    }

    .metrics {
        grid-template-columns: 1fr;
    }

    .metric,
    .metric:nth-child(2) {
        border-right: 0;
        border-bottom: 1px solid #e1e5eb;
    }

    .metric:last-child {
        border-bottom: 0;
    }
}
