:root {
    --bg: #f4f6f5;
    --surface: #fff;
    --surface-soft: #f8faf9;
    --sidebar: #17201c;
    --text: #202824;
    --muted: #68736d;
    --border: #dce2df;
    --border-strong: #c8d0cc;
    --accent: #137a52;
    --accent-hover: #0f6644;
    --accent-soft: #e6f3ed;
    --warning: #a85f0d;
    --warning-soft: #fff3df;
    --danger: #b83a35;
    --danger-soft: #fbe9e8;
    --info: #386a87;
    --info-soft: #e8f1f6;
    --radius: 6px;
    --sidebar-width: 240px;
}

* { box-sizing: border-box; letter-spacing: 0; }
html { color-scheme: light; }
body {
    margin: 0;
    min-height: 100dvh;
    overflow-x: hidden;
    color: var(--text);
    background: var(--bg);
    font: 14px/1.5 "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}
button, input, textarea, select { font: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid #56b98c;
    outline-offset: 2px;
}
a { color: inherit; text-decoration: none; }

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 30;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    color: #edf3f0;
    background: var(--sidebar);
    border-right: 1px solid #2b3832;
    transition: transform 160ms ease;
}
.brand { height: 64px; display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid #2b3832; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; color: #fff; background: var(--accent); border-radius: 6px; }
.brand-mark svg { width: 19px; }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: #9eaaa4; font-size: 10px; }
.nav { flex: 1; overflow-y: auto; padding: 18px 10px; }
.nav-title { margin: 10px 10px 7px; color: #8f9c95; font-size: 11px; }
.nav-link { min-height: 40px; display: flex; align-items: center; gap: 10px; margin-bottom: 3px; padding: 0 11px; color: #cbd5d0; border-radius: 5px; transition: 150ms ease; }
.nav-link:hover { color: #fff; background: #222d28; }
.nav-link.active { color: #fff; background: #284b3d; }
.nav-link svg { width: 17px; height: 17px; }
.account { padding: 14px; border-top: 1px solid #2b3832; }
.account strong, .account small { display: block; }
.account small { color: #9eaaa4; font-size: 11px; }
.account .account-expiry { margin-top: 2px; color: #bdc8c2; }
.logout { margin-top: 10px; width: 100%; justify-content: center; color: #cbd5d0; background: transparent; border-color: #3b4942; }

.app-main { min-height: 100dvh; margin-left: var(--sidebar-width); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 26px; background: #fff; border-bottom: 1px solid var(--border); }
.topbar strong { display: block; }
.topbar small { color: var(--muted); font-size: 11px; }
.mobile-menu { display: none !important; }
.content { width: min(1320px, 100%); margin: 0 auto; padding: 24px 26px 48px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.page-heading h1 { margin: 0; font-size: 25px; line-height: 1.25; }
.page-heading p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; gap: 8px; }
.live-state { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.live-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; box-shadow: 0 0 0 3px var(--accent-soft); }

.button { min-height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; transition: 150ms ease; }
.button:hover { border-color: #9caaa3; transform: translateY(-1px); }
.button:active { transform: translateY(1px); }
.button svg { width: 16px; height: 16px; }
.button.primary { color: #fff; background: var(--accent); border-color: var(--accent); }
.button.primary:hover { background: var(--accent-hover); }
.button.danger { color: var(--danger); border-color: #e4aaa7; }
.icon-button { width: 36px; height: 36px; display: inline-grid; place-items: center; padding: 0; color: var(--muted); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; }
.icon-button svg { width: 17px; height: 17px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.metric { min-height: 108px; padding: 15px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.metric-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 12px; }
.metric-head svg { width: 17px; height: 17px; }
.metric-value { margin-top: 10px; font-size: 25px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1; }
.metric-note { margin-top: 8px; color: var(--muted); font-size: 11px; }
.metric-note.good { color: var(--accent); }

.surface { min-width: 0; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.surface + .surface { margin-top: 14px; }
.surface-header { min-height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 15px; border-bottom: 1px solid var(--border); }
.surface-header h2 { margin: 0; font-size: 14px; }
.surface-header p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.surface-body { padding: 16px; }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); background: var(--surface-soft); font-size: 11px; font-weight: 650; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
.clickable-row { cursor: pointer; transition: background 120ms ease; }
.clickable-row:hover, .clickable-row:focus { background: #f3f8f5; }
.cell-main { font-weight: 650; }
.cell-sub { margin-top: 2px; color: var(--muted); font-size: 11px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 30px; height: 30px; margin-bottom: 8px; }

.badge { min-height: 22px; display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 11px; font-size: 10px; font-weight: 650; white-space: nowrap; }
.badge.success { color: #0c6642; background: var(--accent-soft); }
.badge.warning { color: #8a4f0d; background: var(--warning-soft); }
.badge.info { color: #315f78; background: var(--info-soft); }
.badge.danger { color: #9d2f2b; background: var(--danger-soft); }
.badge.neutral { color: #53605a; background: #eef1ef; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.field.full { grid-column: 1 / -1; }
.field label { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; color: #35413b; font-size: 12px; font-weight: 650; }
.field label small { color: var(--muted); font-size: 10px; font-weight: 400; }
.input, .textarea, .select { width: 100%; color: var(--text); background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); outline: 0; }
.input, .select { height: 40px; padding: 0 10px; }
.textarea { min-height: 136px; padding: 10px; resize: vertical; line-height: 1.65; }
.textarea.short { min-height: 84px; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(19, 122, 82, .12); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border); }
.form-help { margin: 7px 0 0; color: var(--muted); font-size: 11px; }
.error-text { margin-top: 5px; color: var(--danger); font-size: 11px; }
.alert { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius); }
.alert.success { color: #0c6642; background: var(--accent-soft); border-color: #cce7da; }
.alert.danger { color: #8f2f2b; background: var(--danger-soft); border-color: #efc5c3; }
.alert ul { margin: 0; padding-left: 18px; }
.notice { padding: 10px 12px; color: var(--muted); background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); font-size: 11px; }
.notice.warning { color: #8a4f0d; background: var(--warning-soft); border-color: #f0d6ab; }
.notice.danger { color: #8f2f2b; background: var(--danger-soft); border-color: #efc5c3; }
.share-format-warning { margin: 8px 0 10px; }
.share-format-warning strong { display: block; margin-bottom: 3px; font-size: 13px; }
.validation { margin-top: 9px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.validation.hidden { display: none; }
.validation-summary { padding: 8px 10px; font-size: 11px; font-weight: 650; }
.validation-summary.success { color: #0c6642; background: var(--accent-soft); }
.validation-summary.danger { color: #9d2f2b; background: var(--danger-soft); }
.validation-item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; padding: 8px 10px; border-top: 1px solid var(--border); font-size: 11px; }
.validation-item span:last-child { color: var(--muted); }
.validation-remainder { background: var(--surface-soft); }

.progress { height: 7px; overflow: hidden; background: #e1e7e4; border-radius: 4px; }
.progress > span { display: block; height: 100%; background: var(--accent); }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--border); }
.detail-item { padding: 14px; background: #fff; }
.detail-item span, .detail-item strong { display: block; }
.detail-item span { color: var(--muted); font-size: 11px; }
.detail-item strong { margin-top: 5px; }
.answer-preview { max-width: 440px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.answer-cell { position: relative; max-width: 440px; outline: 0; }
.answer-cell[data-has-answer="1"] { cursor: help; }
.answer-cell:focus-visible { border-radius: 3px; box-shadow: 0 0 0 2px rgba(19, 122, 82, .2); }
.answer-html-popover { position: fixed; z-index: 70; width: min(520px, calc(100vw - 24px)); height: 284px; display: none; grid-template-rows: 38px 1fr; overflow: hidden; background: #fff; border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: 0 14px 32px rgba(23, 32, 28, .16); pointer-events: none; }
.answer-html-popover.visible { display: grid; }
.answer-html-title { display: flex; align-items: center; padding: 0 12px; color: var(--muted); background: var(--surface-soft); border-bottom: 1px solid var(--border); font-size: 11px; font-weight: 650; }
.answer-html-popover iframe { width: 100%; height: 100%; background: #fff; border: 0; }

.prompt-row { display: grid; grid-template-columns: minmax(160px, .65fr) minmax(280px, 1.8fr) auto; gap: 14px; padding: 16px; border-bottom: 1px solid var(--border); }
.prompt-row:last-child { border-bottom: 0; }
.prompt-copy { display: grid; gap: 10px; }
.prompt-flags { display: flex; align-items: center; gap: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.upload-grid, .server-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.upload-grid { align-items: stretch; }
.upload-grid > .surface + .surface { margin-top: 0; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 14px; align-items: start; }
.settings-grid > .surface + .surface { margin-top: 0; }
.status-list { display: grid; gap: 0; }
.status-line { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.status-line:first-child { padding-top: 0; }
.status-line:last-child { padding-bottom: 0; border-bottom: 0; }
.status-line > span:first-child { color: var(--muted); font-size: 11px; }
.status-value { max-width: 220px; overflow-wrap: anywhere; text-align: right; }
.account-security { max-width: 760px; }
.guide { max-width: 980px; }
.guide-section { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--border); }
.guide-section:first-child { padding-top: 0; }
.guide-section:last-child { padding-bottom: 0; border-bottom: 0; }
.guide-index { width: 34px; height: 34px; display: grid; place-items: center; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius); font-size: 11px; font-weight: 750; }
.guide-section h3 { margin: 4px 0 7px; font-size: 14px; }
.guide-section p { margin: 0; color: var(--muted); font-size: 12px; }
.guide-section ol { margin: 8px 0 12px; padding-left: 20px; color: #35413b; font-size: 12px; }
.guide-section li + li { margin-top: 7px; }
.guide-gallery { display: grid; gap: 14px; margin: 14px 0; }
.guide-gallery figure { margin: 0; }
.guide-gallery a { display: block; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #f5f7f6; }
.guide-gallery img { display: block; width: auto; max-width: 100%; height: auto; margin: 0 auto; }
.guide-gallery figcaption { margin-top: 6px; color: var(--muted); font-size: 11px; }
.code-example { margin-top: 11px; padding: 11px 12px; overflow-wrap: anywhere; color: #334039; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); font: 11px/1.7 Consolas, "Microsoft YaHei UI", monospace; }
.limit-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.limit-card { padding: 13px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.limit-card span, .limit-card strong, .limit-card small { display: block; }
.limit-card span { color: var(--muted); font-size: 11px; }
.limit-card strong { margin: 7px 0 4px; font-size: 22px; font-variant-numeric: tabular-nums; }
.limit-card small { color: var(--muted); font-size: 10px; }
.inline-form { display: flex; align-items: center; gap: 7px; }
.inline-form .input, .inline-form .select { min-width: 120px; }
.table-actions { display: flex; align-items: center; gap: 6px; }
.copy-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.referral-share { display: grid; grid-template-columns: minmax(0, 1fr) 180px; align-items: center; gap: 20px; }
.referral-qr { margin: 0; text-align: center; }
.referral-qr img { display: block; width: 180px; height: 180px; border: 1px solid var(--border); }
.referral-qr figcaption { margin-top: 6px; color: var(--muted); font-size: 11px; }
.redemption-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.redemption-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px; background: var(--surface-soft); border: 1px solid var(--border); border-radius: var(--radius); }
.redemption-item strong, .redemption-item span { display: block; }
.redemption-item span { margin-top: 3px; color: var(--muted); font-size: 11px; }
.rule-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; }
.rule-block { padding: 14px 0; border-bottom: 1px solid var(--border); }
.rule-block h3 { margin: 0 0 6px; font-size: 13px; }
.rule-block p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.75; }
.points-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.points-value.positive { color: var(--accent); }
.points-value.negative { color: var(--danger); }

.pricing-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.plan-card { position: relative; display: flex; flex-direction: column; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); transition: 150ms ease; }
.plan-card[data-plan-select] { cursor: pointer; }
.plan-card[data-plan-select]:hover { border-color: #8ebaa5; transform: translateY(-2px); }
.plan-card.selected { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent), 0 6px 16px rgba(22, 78, 54, .08); }
.plan-card.locked { color: #7a8580; background: #f0f2f1; cursor: not-allowed; }
.plan-card.current { border-color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }
.plan-option { position: absolute; width: 1px; height: 1px; opacity: 0; }
.plan-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.plan-title-row svg { width: 16px; height: 16px; color: var(--muted); }
.plan-card h2 { margin: 0; font-size: 15px; }
.plan-price { margin: 14px 0; font-size: 24px; font-weight: 750; }
.plan-price small { color: var(--muted); font-size: 11px; font-weight: 400; }
.plan-spec { display: flex; justify-content: space-between; padding: 7px 0; color: var(--muted); font-size: 11px; border-top: 1px solid var(--border); }
.plan-spec strong { color: var(--text); }
.plan-state { min-height: 32px; display: flex; align-items: flex-end; margin-top: 12px; color: var(--muted); font-size: 11px; }
.plan-checkout-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: -3px 0 16px; padding: 13px 15px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.plan-checkout-bar span { font-weight: 650; }

.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: #edf2ef; }
.auth-panel { width: min(420px, 100%); background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 14px 36px rgba(22, 48, 36, .09); }
.auth-brand { display: flex; align-items: center; gap: 10px; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.auth-body { padding: 22px; }
.auth-body h1 { margin: 0 0 4px; font-size: 22px; }
.auth-body > p { margin: 0 0 20px; color: var(--muted); font-size: 12px; }
.auth-body .field { margin-bottom: 14px; }
.auth-body .button { width: 100%; }
.auth-switch { margin-top: 16px; color: var(--muted); text-align: center; font-size: 12px; }
.auth-switch a { color: var(--accent); font-weight: 650; }

.overlay { display: none; }
.pagination { display: flex; justify-content: flex-end; gap: 6px; padding: 12px 14px; }
.pagination a, .pagination span { min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 8px; border: 1px solid var(--border); border-radius: 5px; font-size: 11px; }
.pagination .current { color: #fff; background: var(--accent); border-color: var(--accent); }

@media (max-width: 1100px) {
    .metric-grid, .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pricing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
    .mobile-menu { display: inline-grid !important; }
    .overlay.show { position: fixed; inset: 0; z-index: 20; display: block; background: rgba(23, 32, 28, .42); }
    .content { padding: 18px 14px 40px; }
    .redemption-grid, .rule-grid, .referral-share { grid-template-columns: 1fr; }
    .referral-qr { justify-self: center; }
    .copy-row { grid-template-columns: 1fr; }
    .topbar { padding: 0 14px; }
    .prompt-row { grid-template-columns: 1fr; }
    .upload-grid, .server-grid, .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .page-heading { align-items: stretch; flex-direction: column; }
    .heading-actions .button { flex: 1; }
    .metric-grid, .detail-grid, .pricing-grid, .form-grid { grid-template-columns: 1fr; }
    .limit-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .surface-header { align-items: flex-start; flex-direction: column; }
    .form-actions { align-items: stretch; flex-direction: column-reverse; }
    .form-actions .button { width: 100%; }
}

@media (max-width: 420px) {
    .limit-grid { grid-template-columns: 1fr; }
}
