:root {
    --bg: #f7f8fa;
    --sidebar-bg: #fff;
    --card: #fff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --primary: #111827;
    --accent: #2563eb;
    --accent-light: #eff6ff;
    --success: #059669;
    --danger: #dc2626;
    --radius: 12px;
    --sidebar-w: 220px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: "Outfit", "Noto Sans SC", "Microsoft YaHei", "PingFang SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar {
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}
.brand { font-weight: 800; font-size: 18px; display: flex; align-items: center; gap: 8px; }
.brand img { width: 24px; height: 24px; flex-shrink: 0; }
.brand span { color: var(--accent); }
.topnav { display: flex; gap: 20px; font-size: 14px; color: var(--muted); }
.topnav a.active { color: var(--text); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--muted); }
.lang-switch { position: relative; display: inline-block; font-size: 12px; }
.lang-switch .lang-current {
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    padding: 4px 10px;
    font: inherit;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 96px;
    justify-content: space-between;
}
.lang-switch .lang-current:hover { border-color: #c5cad3; }
.lang-caret {
    width: 0; height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    opacity: 0.55;
}
.lang-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 140px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    padding: 4px;
    z-index: 40;
}
.lang-switch.open .lang-menu { display: block; }
.lang-option {
    display: block;
    width: 100%;
    text-align: left;
    border: 0;
    background: transparent;
    color: #374151;
    cursor: pointer;
    padding: 8px 10px;
    font: inherit;
    border-radius: 6px;
}
.lang-option:hover { background: #f3f4f6; }
.lang-option.active { color: var(--accent); font-weight: 700; background: #eef8f6; }

/* Layout */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    padding: 16px 0;
    flex-shrink: 0;
}
.sidebar-section { padding: 8px 16px 4px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sidebar a {
    display: block;
    padding: 10px 20px;
    color: #374151;
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
}
.sidebar a:hover { background: #f9fafb; }
.sidebar a.active { background: var(--accent-light); color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.main { flex: 1; padding: 24px 28px 48px; min-width: 0; }

/* Cards & panels */
.panel {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.panel-title { font-size: 18px; font-weight: 700; margin: 0 0 16px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.panel-header h2 { margin: 0; font-size: 18px; font-weight: 700; }

.metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
@media (max-width: 768px) { .metrics { grid-template-columns: 1fr; } }
.metric {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.metric-label { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.metric-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Token plan */
.plan-hero { text-align: center; margin-bottom: 28px; }
.plan-hero h1 { font-size: 26px; font-weight: 800; margin: 0 0 20px; }
.tabs {
    display: inline-flex;
    gap: 4px;
    background: #f3f4f6;
    border-radius: 999px;
    padding: 4px;
}
.tab {
    border: none; background: transparent; padding: 10px 20px; border-radius: 999px;
    font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tab.active { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }
.tab-badge {
    display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 4px;
    background: var(--accent-light); color: var(--accent); font-size: 11px; font-weight: 600;
}
.validity-note { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 24px; }
.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 960px) { .cards { grid-template-columns: 1fr; } }
.plan-card {
    border: 1px solid var(--border); border-radius: 16px; padding: 24px 20px;
    display: flex; flex-direction: column; min-height: 400px; background: #fff;
}
.plan-card.recommended { border-color: #bfdbfe; box-shadow: 0 0 0 1px #dbeafe; }
.plan-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.plan-name { font-size: 18px; font-weight: 700; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--accent-light); color: var(--accent); font-weight: 600; }
.price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.price { font-size: 34px; font-weight: 800; }
.price-original { color: var(--muted); text-decoration: line-through; font-size: 14px; }
.savings { color: var(--accent); font-size: 12px; font-weight: 600; }
.cta {
    width: 100%; padding: 12px; border: none; border-radius: 10px;
    background: var(--primary); color: #fff; font-size: 15px; font-weight: 600; cursor: pointer; margin-bottom: 18px;
}
.cta:hover { opacity: .9; }
.cta.outline { background: #fff; color: var(--text); border: 1px solid var(--border); }
.highlight {
    display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px;
    margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border);
}
.features { list-style: none; padding: 0; margin: 0; flex: 1; }
.features li { font-size: 13px; color: #374151; line-height: 1.65; margin-bottom: 8px; padding-left: 18px; position: relative; }
.features li::before { content: "✓"; position: absolute; left: 0; color: var(--muted); }
.points-footer { margin-top: auto; padding-top: 14px; font-weight: 600; color: var(--success); display: flex; align-items: center; gap: 6px; }

/* Progress bar */
.progress-wrap { margin: 16px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.progress-bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.progress-fill.warn { background: #f59e0b; }
.progress-fill.danger { background: var(--danger); }

/* Table */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--border); padding: 12px 10px; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
.status-tag {
    display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 600;
}
.status-tag.paid, .status-tag.ACTIVE, .status-tag.ISSUED, .status-tag.COMPLETED { background: #ecfdf5; color: #059669; }
.status-tag.PENDING, .status-tag.PROCESSING { background: #fef3c7; color: #b45309; }
.status-tag.REFUNDED, .status-tag.CANCELLED, .status-tag.EXPIRED { background: #f3f4f6; color: #6b7280; }

/* Buttons */
.btn { padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: #fff; }
.btn:hover { background: #f9fafb; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { opacity: .9; background: var(--primary); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tabs inner */
.inner-tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.inner-tab {
    padding: 10px 0; border: none; background: none; cursor: pointer; font-size: 14px;
    color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.inner-tab.active { color: var(--text); font-weight: 600; border-bottom-color: var(--primary); }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-field input, .form-field select, .form-field textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.form-field.full { grid-column: 1 / -1; }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 14px;
    margin: 8px 0 4px;
}
@media (max-width: 1100px) { .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .filter-grid { grid-template-columns: 1fr; } }
.filter-hint { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
.table-wrap { overflow-x: auto; }

/* Dialog */
.dialog-backdrop {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
    align-items: center; justify-content: center; padding: 16px;
}
.dialog-backdrop.open { display: flex; }
.dialog {
    background: #fff; border-radius: 16px; width: min(520px, 100%); padding: 24px;
    max-height: 90vh; overflow-y: auto;
}
.dialog h3 { margin: 0 0 16px; font-size: 18px; }
.pkg-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.pkg-option {
    border: 1px solid var(--border); border-radius: 12px; padding: 14px 10px; text-align: center; cursor: pointer;
}
.pkg-option.selected { background: #1f2937; border-color: #1f2937; color: #fff; }
.pkg-option .pkg-price { font-size: 20px; font-weight: 800; }
.summary-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f3f4f6; font-size: 14px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Login */
body.login-view .sidebar { display: none; }
body.login-view .main {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 20px 64px;
    min-height: calc(100vh - 56px);
}
.login-page {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    padding: 36px 32px 28px;
    box-shadow: 0 8px 30px rgba(17, 24, 39, 0.06);
}
.login-page h2 {
    margin: 0 0 8px;
    text-align: center;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.login-subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    margin: 0 0 24px;
    line-height: 1.5;
}
.login-mode-tabs {
    display: flex;
    margin: 0 0 24px;
    border-bottom: 1px solid var(--border);
}
.login-mode-tab {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 10px 8px 12px;
    font-size: 14px;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.login-mode-tab:hover { color: var(--text); }
.login-mode-tab.active {
    color: var(--text);
    font-weight: 700;
    border-bottom-color: var(--primary);
}
.login-field { margin-bottom: 16px; }
.login-field label {
    display: block;
    font-size: 13px;
    color: #374151;
    font-weight: 500;
    margin-bottom: 6px;
}
.login-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 6px;
}
.login-field-head label { margin-bottom: 0; }
.login-channel {
    display: inline-flex;
    align-items: center;
    gap: 0;
    background: #f3f4f6;
    border-radius: 8px;
    padding: 2px;
}
.login-channel-btn {
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    line-height: 1.3;
    transition: background .15s, color .15s, box-shadow .15s;
}
.login-channel-btn:hover { color: var(--text); }
.login-channel-btn.active {
    background: #fff;
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.login-channel-sep { display: none; }
.login-field input {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus {
    outline: none;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.login-code-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}
.login-code-row input { flex: 1; min-width: 0; }
.login-send-btn {
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    border-color: #bfdbfe;
    background: var(--accent-light);
}
.login-send-btn:hover {
    background: #dbeafe;
    border-color: #93c5fd;
}
.login-send-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.login-forgot {
    font-size: 12px;
    color: var(--accent);
}
.login-field-extra {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}
.login-submit {
    margin-top: 4px;
    margin-bottom: 0;
    padding: 13px;
    border-radius: 10px;
    font-size: 15px;
}
.login-hint {
    text-align: center;
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}
.login-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 18px;
    font-size: 13px;
}
.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }

.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: #1f2937; color: #fff; padding: 12px 24px; border-radius: 8px; z-index: 300; display: none;
}
.toast.show { display: block; }
.hidden { display: none !important; }
.loading { text-align: center; padding: 40px; color: var(--muted); }

.alert-banner {
    padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px;
    background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
}
.key-reveal {
    font-family: Consolas, Monaco, monospace; font-size: 13px; word-break: break-all;
    background: #f3f4f6; padding: 14px; border-radius: 8px; border: 1px solid var(--border);
    line-height: 1.6;
}
.key-mask { font-family: Consolas, Monaco, monospace; font-size: 13px; color: var(--muted); }
.status-tag.REVOKED { background: #fee2e2; color: #b91c1c; }
.status-tag.ACTIVE { background: #ecfdf5; color: #059669; }
