@font-face {
    font-family: "Fusion Pixel";
    src: url("/static/font/fusion-pixel.ttf") format("truetype");
    font-display: swap;
}

:root {
    /* 颜色 · 中性 */
    --bg-page: #fafafa;
    --bg-surface: #ffffff;
    --bg-subtle: #f4f4f5;
    --bg-hover: #f4f4f5;

    /* 边框 */
    --border: #e4e4e7;
    --border-hover: #d4d4d8;
    --border-strong: #a1a1aa;

    /* 文本 */
    --text-main: #18181b;
    --text-secondary: #3f3f46;
    --text-muted: #52525b;
    --text-subtle: #71717a;
    --text-disabled: #a1a1aa;

    /* 强调色：近黑，与登录按钮一致 */
    --primary: #18181b;
    --primary-hover: #27272a;
    --primary-active: #09090b;

    /* 语义色 */
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-border: #fecaca;
    --danger-text: #991b1b;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --success-border: #bbf7d0;
    --success-text: #15803d;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --warning-border: #fde68a;
    --warning-text: #92400e;
    --info: #0284c7;
    --info-bg: #f0f9ff;
    --info-border: #bae6fd;
    --info-text: #075985;

    /* primary 上的文字色（深色主题的 primary 是浅色，需反转） */
    --primary-text: #ffffff;
    --primary-bg: rgba(24, 24, 27, 0.10);

    /* 强调：与 primary 区分，用于标签、点缀 */
    --accent: #6d28d9;
    --accent-bg: #f5f3ff;

    /* 订阅档位标签：每档独立配色，避免与 FREE 撞色；主题 themes.css 覆盖 */
    --sub-free-bg: #f4f4f5;   --sub-free-fg: #52525b;   --sub-free-bd: #e4e4e7;
    --sub-pro-bg: #f0f9ff;    --sub-pro-fg: #075985;    --sub-pro-bd: #bae6fd;
    --sub-proplus-bg: #f5f3ff;--sub-proplus-fg: #6d28d9;--sub-proplus-bd: #ddd6fe;
    --sub-power-bg: #fffbeb;  --sub-power-fg: #92400e;  --sub-power-bd: #fde68a;
    --sub-other-bg: #ecfdf5;  --sub-other-fg: #047857;  --sub-other-bd: #a7f3d0;

    /* 公告 / 提示条 */
    --announcement-bg: #fef3c7;
    --announcement-text: #78350f;
    --announcement-strong: #b45309;
    --announcement-border: #fde68a;

    /* 用量条 / 结果区 / 选中高亮 */
    --meter-ok: linear-gradient(90deg, #22c55e, #84cc16);
    --meter-warn: linear-gradient(90deg, #f59e0b, #facc15);
    --meter-danger: linear-gradient(90deg, #ef4444, #f97316);
    --result-bg: #f8fafc;
    --selection-bg: rgba(24, 24, 27, 0.14);

    /* 形状 */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    /* 阴影（很薄） */
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 20px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.10);

    /* 动效 */
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    /* 只过渡颜色与阴影：all 会把 padding、width 这类布局属性也纳入过渡，
       主题切换或内容变化时会产生一次无意义的回流 */
    --transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease),
        color 0.18s var(--ease), box-shadow 0.18s var(--ease);

    /* 布局 */
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 68px;

}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html, body {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* 防止触摸设备上的双击缩放 */
    touch-action: manipulation;
}

body {
    font-family: "Fusion Pixel", -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue",
                 "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    font-size: 14px;
    /* 支持移动端安全区域 */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    /* 优化移动端滚动 */
    -webkit-overflow-scrolling: touch;
}

::selection {
    background: var(--selection-bg, rgba(24, 24, 27, 0.14));
    color: var(--primary-active);
}

.login-page {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(24px, env(safe-area-inset-top))
             max(24px, env(safe-area-inset-right))
             max(24px, env(safe-area-inset-bottom))
             max(24px, env(safe-area-inset-left));
    background: var(--bg-page);
    color: var(--text-main);
    overflow: hidden;
    overscroll-behavior: none;
}

.login-wrap {
    width: 100%;
    max-width: 380px;
}

.login-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    box-shadow: none;
}

.login-title {
    margin: 0 0 6px 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--text-main);
    line-height: 1.2;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

.login-input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    caret-color: var(--text-main);
    transition: border-color 0.2s var(--ease),
                box-shadow 0.2s var(--ease),
                background-color 0.2s var(--ease);
}

.login-input::placeholder {
    color: var(--text-disabled);
    transition: color 0.2s ease;
}

.login-input:hover {
    border-color: var(--border-strong);
}

.login-input:focus {
    outline: none;
    border-color: var(--primary-active);
    box-shadow: 0 0 0 4px var(--primary-bg),
                0 1px 2px var(--shadow-sm);
}

.login-input:focus::placeholder {
    color: var(--text-subtle);
}

.login-error {
    min-height: 18px;
    margin: -6px 0 2px;
    font-size: 12px;
    color: var(--danger);
    line-height: 18px;
}

.login-btn {
    width: 100%;
    height: 42px;
    border: none;
    border-radius: var(--radius);
    background: var(--primary);
    color: var(--primary-text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    margin-top: 2px;
    transition: background-color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.login-btn:hover { background: var(--primary-hover); }
.login-btn:active { background: var(--primary-active); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.setup-page {
    align-items: flex-start;
    overflow-y: auto;
}

.setup-wrap {
    max-width: 720px;
    padding: 42px 0;
}

.setup-card {
    gap: 22px;
    padding: 30px;
    border: none;
    box-shadow: var(--shadow-md);
}

.setup-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.setup-title {
    margin-bottom: 4px;
}

.setup-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.setup-state-pill {
    flex: 0 0 auto;
    min-width: 76px;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.setup-state-pill.ok {
    background: var(--success-bg);
    color: var(--success);
}

.setup-state-pill.fail {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.setup-steps {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.setup-step {
    display: grid;
    grid-template-columns: 30px 1fr;
    gap: 10px;
    align-items: center;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--bg-subtle);
    border: none;
}

.setup-step span {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
}

.setup-step strong {
    display: block;
    font-size: 13px;
    color: var(--text-main);
}

.setup-step small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.setup-step.active {
    background: var(--info-bg);
    box-shadow: 0 10px 24px var(--primary-bg);
}

.setup-step.active span {
    background: var(--info);
    color: var(--primary-text);
}

.setup-panel {
    display: none;
    flex-direction: column;
    gap: 16px;
}

.setup-panel.active {
    display: flex;
}

#adminStepPanel {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

.setup-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding-top: 2px;
}

.setup-panel-head h2 {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
    font-weight: 650;
    color: var(--text-main);
}

.setup-panel-head p {
    margin: 4px 0 0;
    color: var(--text-muted);
    font-size: 13px;
}

.setup-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.setup-actions.split {
    justify-content: space-between;
}

.setup-actions .login-btn {
    margin-top: 0;
}

.setup-check-btn {
    flex: 0 0 auto;
    height: 34px;
    padding: 0 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.setup-check-btn:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.setup-check-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.setup-icon-btn {
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.setup-icon-btn:hover {
    background: var(--border);
}

.setup-icon-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.setup-checks-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.setup-check-panel {
    padding: 16px;
    border-radius: var(--radius);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.setup-check-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.setup-check-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.setup-check-panel-title strong,
.setup-check-group-head strong {
    display: block;
    font-size: 14px;
    line-height: 1.25;
    color: var(--text-main);
}

.setup-check-panel-title small,
.setup-check-group-head small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-muted);
}

.setup-check-panel-icon,
.setup-check-group-icon {
    width: 34px;
    height: 34px;
    flex: 0 0 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--info);
    box-shadow: var(--shadow-sm);
}

.setup-check-panel-icon svg,
.setup-check-group-icon svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.setup-check-summary {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.06);
}

.setup-check-panel.ok .setup-check-summary {
    background: var(--success-bg);
    color: var(--success-text);
}

.setup-check-panel.fail .setup-check-summary {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.setup-check-panel.pending .setup-check-summary {
    background: var(--info-bg);
    color: var(--info);
}

.setup-check-panel-body {
    display: flex;
    flex-direction: column;
}

.setup-check-group {
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.setup-check-group:last-child {
    padding-bottom: 0;
    border-bottom: none;
}

.setup-check-group-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.setup-check-group-icon.icon-mysql {
    color: var(--warning);
}

.setup-check-group-icon.icon-postgres,
.setup-check-group-icon.icon-sqlite {
    color: var(--info);
}

.setup-check-list {
    display: flex;
    flex-direction: column;
}

.setup-check-row {
    --check-color: var(--text-muted);
    --check-bg: var(--bg-subtle);
    display: grid;
    grid-template-columns: 30px minmax(120px, 0.52fr) minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 9px 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    min-height: 0;
}

.setup-check-row + .setup-check-row {
    border-top: 1px solid var(--border);
}

.setup-check-row.check-server_runtime {
    --check-color: var(--info);
    --check-bg: var(--info-bg);
}

.setup-check-row.check-server_cpu {
    --check-color: var(--success);
    --check-bg: var(--success-bg);
}

.setup-check-row.check-server_port {
    --check-color: var(--info);
    --check-bg: var(--info-bg);
}

.setup-check-row.check-database_type {
    --check-color: var(--accent);
    --check-bg: var(--accent-bg);
}

.setup-check-row.check-database_type.icon-sqlite {
    --check-color: var(--info);
    --check-bg: var(--info-bg);
}

.setup-check-row.check-database_type.icon-mysql {
    --check-color: var(--warning);
    --check-bg: var(--warning-bg);
}

.setup-check-row.check-database_type.icon-postgres {
    --check-color: var(--info);
    --check-bg: var(--info-bg);
}

.setup-check-row.check-database_config {
    --check-color: var(--warning);
    --check-bg: var(--warning-bg);
}

.setup-check-row.check-database_connection {
    --check-color: var(--info);
    --check-bg: var(--info-bg);
}

.setup-check-mark {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--bg-subtle);
    color: var(--text-disabled);
}

.setup-check-mark::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: currentColor;
}

.setup-check-row.ok {
    background: transparent;
}

.setup-check-row.ok .setup-check-mark {
    background: var(--bg-surface);
    color: var(--check-color);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
}

.setup-check-row.ok .setup-check-mark::after {
    content: "✓";
    width: auto;
    height: auto;
    background: transparent;
    font-size: 15px;
    font-weight: 800;
}

.setup-check-row.fail {
    background: transparent;
}

.setup-check-row.fail .setup-check-mark {
    background: var(--danger-bg);
    color: var(--danger);
}

.setup-check-row.fail .setup-check-mark::after {
    content: "!";
    width: auto;
    height: auto;
    background: transparent;
    font-size: 15px;
    font-weight: 800;
}

.setup-check-row.pending .setup-check-mark::after {
    width: 14px;
    height: 14px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--primary);
    background: transparent;
    animation: spin 0.8s linear infinite;
}

.setup-check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 650;
    color: var(--text-main);
    min-width: 0;
}

.setup-check-logo {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: transparent;
    color: var(--check-color);
    box-shadow: none;
}

.setup-check-logo svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.setup-check-row.icon-mysql .setup-check-logo {
    background: transparent;
}

.setup-check-row.icon-postgres .setup-check-logo,
.setup-check-row.icon-sqlite .setup-check-logo {
    background: transparent;
}

.setup-check-message {
    font-size: 12px;
    line-height: 1.45;
    color: var(--text-muted);
    min-width: 0;
    overflow-wrap: anywhere;
}

.setup-check-row.fail .setup-check-message {
    color: var(--danger);
}

.setup-env-error {
    margin: -4px 0 0;
}

@media (max-width: 720px) {
    .setup-wrap {
        max-width: 100%;
        padding: 12px 0;
    }

    .setup-card {
        padding: 24px 20px;
    }

    .setup-title-row,
    .setup-panel-head,
    .setup-actions.split {
        flex-direction: column;
        align-items: stretch;
    }

    .setup-steps {
        grid-template-columns: 1fr;
    }

    .setup-check-panel-head {
        align-items: flex-start;
    }

    .setup-check-row {
        grid-template-columns: 30px minmax(0, 1fr);
        align-items: start;
    }

    .setup-check-message {
        grid-column: 2;
    }
}

@media (max-width: 520px) {
    .setup-check-panel {
        padding: 14px;
    }

    .setup-check-panel-head {
        flex-direction: column;
        align-items: stretch;
    }

    .setup-check-summary {
        align-self: flex-start;
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: none;
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow: visible;
    transition: width 0.22s var(--ease), box-shadow 0.22s var(--ease);
}

.sidebar-version {
    display: none !important; /* 隐藏版本号胶囊 */
    width: calc(100% - 24px);
    height: 34px;
    margin: 14px 12px 8px;
    padding: 0 11px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    text-align: left;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    -webkit-appearance: none;
    appearance: none;
    user-select: none;
    transition: background-color 0.18s var(--ease),
                color 0.18s var(--ease),
                box-shadow 0.18s var(--ease);
}

.sidebar-version:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.sidebar-version:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.version-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 3px var(--success-bg);
}

.version-label {
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-new {
    display: none;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 999px;
    background: var(--primary);
    color: var(--primary-text);
    font-size: 10px;
    line-height: 1.2;
}

.version-new[hidden] {
    display: none !important;
}

.sidebar-version.has-update {
    background: var(--warning-bg);
    color: var(--warning);
    box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.22);
}

.sidebar-version.has-update .version-dot {
    background: var(--warning);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.16);
}

.sidebar-version.has-update .version-new:not([hidden]) {
    display: inline-flex;
}

.sidebar-tools {
    position: absolute;
    top: 50%;
    right: -24px;
    z-index: 3;
    display: block;
    padding: 0;
    transform: translateY(-50%);
}

.sidebar-collapse-toggle {
    width: 24px;
    height: 74px;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    color: var(--text-secondary);
    border: none;
    border-radius: 0 10px 10px 0;
    box-shadow: 10px 0 20px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: background-color 0.18s var(--ease),
                color 0.18s var(--ease),
                box-shadow 0.18s var(--ease),
                transform 0.18s var(--ease);
}

.sidebar-collapse-toggle::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1px;
    background: var(--bg-surface);
}

.sidebar-collapse-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-main);
    box-shadow: 10px 0 24px rgba(0, 0, 0, 0.12);
    transform: translateX(2px);
}

.sidebar-collapse-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.22s var(--ease);
}

.nav-group {
    flex: 1;
    padding: 4px 12px;
    overflow-y: auto;
}

.nav-item {
    padding: 10px 14px;
    margin-bottom: 2px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition);
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    color: currentColor;
    opacity: 0.78;
}

.nav-icon svg {
    display: block;
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-label {
    display: inline-block;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.18s var(--ease), max-width 0.22s var(--ease);
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

.nav-item.active {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.sidebar-footer {
    padding: 12px;
}

.sidebar-footer .nav-item {
    color: var(--text-muted);
    font-size: 13px;
}

.app-container.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    box-shadow: 6px 0 18px rgba(0, 0, 0, 0.04);
}

.app-container.sidebar-collapsed .sidebar-version {
    width: 34px;
    justify-content: center;
    padding: 0;
    margin-left: auto;
    margin-right: auto;
}

.app-container.sidebar-collapsed .version-label,
.app-container.sidebar-collapsed .version-new {
    display: none;
}

.app-container.sidebar-collapsed .main-wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

.app-container.sidebar-collapsed .sidebar-tools {
    right: -24px;
}

.app-container.sidebar-collapsed .sidebar-collapse-toggle svg {
    transform: rotate(180deg);
}

.app-container.sidebar-collapsed .nav-group,
.app-container.sidebar-collapsed .sidebar-footer {
    padding-left: 10px;
    padding-right: 10px;
}

.app-container.sidebar-collapsed .nav-item {
    justify-content: center;
    gap: 0;
    padding-left: 10px;
    padding-right: 10px;
}

.app-container.sidebar-collapsed .nav-label {
    max-width: 0;
    opacity: 0;
}

/* 侧边栏切换按钮（移动端汉堡）：桌面隐藏 */
.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}
.sidebar-toggle span {
    width: 16px;
    height: 1.5px;
    background: var(--text-main);
    border-radius: 2px;
}

/* 侧边栏遮罩层（移动端） */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.32);
    backdrop-filter: blur(2px);
    z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* 主内容区 */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px 40px;
    min-width: 0;
    transition: margin-left 0.22s var(--ease);
}

.header-bar {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.view-title {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.tab-panel {
    display: none;
}
.tab-panel.active {
    display: block;
    animation: fadeIn 0.2s var(--ease);
}

.k-card {
    background: var(--bg-surface);
    border: none;
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.k-card-header {
    padding: 18px 22px;
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.k-card-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-main);
}

.k-card-body {
    padding: 22px;
}

.stat-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--bg-surface);
    border: none;
    padding: 18px 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.stat-item:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.1px;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-main);
}

.dashboard-chart {
    height: 200px;
}

.cute-status-chart {
    display: grid;
    grid-template-columns: minmax(92px, 1fr) 170px minmax(92px, 1fr);
    align-items: center;
    justify-items: center;
    gap: 22px;
    height: 100%;
}

.cute-status-chart.cute-status-chart-triple {
    grid-template-columns: minmax(82px, 1fr) minmax(82px, 1fr) 170px minmax(82px, 1fr);
    gap: 16px;
}

/* 简洁布局：左侧竖向列表 + 右侧圆环 */
.cute-status-chart-simple {
    display: grid;
    grid-template-columns: minmax(200px, 280px) auto;
    gap: 40px;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    max-width: 600px;
    margin: 0 auto;
}

.cute-status-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cute-stat-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: 10px;
    background: var(--chart-soft);
    transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.cute-stat-item:hover {
    box-shadow: var(--shadow-sm);
}

.cute-stat-item.mint {
    --chart-color: var(--success);
    --chart-soft: var(--success-bg);
}

.cute-stat-item.amber {
    --chart-color: var(--warning);
    --chart-soft: var(--warning-bg);
}

.cute-stat-item.rose {
    --chart-color: var(--danger);
    --chart-soft: var(--danger-bg);
}

.cute-stat-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cute-stat-item .cute-stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-main);
    margin: 0;
}

.cute-stat-item .cute-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--chart-color);
    font-variant-numeric: tabular-nums;
}

.cute-stat-pill {
    width: 100%;
    max-width: 132px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--chart-soft);
    box-shadow: var(--shadow-md);
}

.cute-stat-pill.mint {
    --chart-color: var(--success);
    --chart-soft: var(--success-bg);
}

.cute-stat-pill.amber {
    --chart-color: var(--warning);
    --chart-soft: var(--warning-bg);
}

.cute-stat-pill.rose {
    --chart-color: var(--danger);
    --chart-soft: var(--danger-bg);
}

.cute-stat-label,
.cute-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cute-stat-label {
    color: var(--text-muted);
    font-size: 12px;
    margin-bottom: 8px;
}

.cute-stat-number {
    color: var(--chart-color);
    font-size: 28px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cute-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: var(--chart-color);
    box-shadow: 0 0 0 4px var(--chart-soft);
}

.cute-donut {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 999px;
    background: var(--bg-surface);
    box-shadow: var(--shadow-lg);
}

.cute-donut-svg {
    display: block;
    transform: rotate(-90deg);
}

.cute-ring-segment {
    animation: kRingDraw 0.9s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.cute-ring-segment.delayed {
    animation-delay: 0.15s;
}

.cute-ring-segment.delayed-more {
    animation-delay: 0.3s;
}

.cute-donut-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.cute-donut-value {
    color: var(--text-main);
    font-size: 32px;
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.cute-donut-value span {
    margin-left: 2px;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 700;
}

.cute-donut-label {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.cute-legend-label {
    min-width: 0;
    overflow: hidden;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cute-legend-value {
    margin-left: auto;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.cute-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 20px;
    font-size: 13px;
}

.cute-legend-item {
    min-width: 0;
    padding: 9px 10px;
    border-radius: 14px;
    background: var(--chart-soft);
}

.cute-empty-chart {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.account-table-scroll {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 7px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
    overscroll-behavior-x: contain;
}

.account-table-scroll table {
    /* 原来是 1120px：1024~1280 区间侧边栏收起后容器只有 930px 上下，
       表格永远在横滚，右侧「操作」列的删除按钮要滚动才看得到。
       压缩单元格内边距后 940px 能放下 9 列，横滚只在真正挤不下时出现。 */
    min-width: 900px;
}

/* 数据表单元格内边距：16px 太宽，9~10 列会白吃掉 90px 横向空间 */
#tab-accounts table th,
#tab-accounts table td,
#tab-assigned table th,
#tab-assigned table td,
#tab-cards table th,
#tab-cards table td,
#tab-logs table th,
#tab-logs table td {
    padding-left: 10px;
    padding-right: 10px;
}

/* 已分配表多一列时间，操作列按钮再收紧一点，1024 下也不横滚 */
#tab-accounts table .account-actions,
#tab-assigned table .account-actions {
    gap: 4px;
}
#tab-accounts table .account-actions .ui-btn,
#tab-assigned table .account-actions .ui-btn {
    padding-left: 7px;
    padding-right: 7px;
}

/* 额度用量：数字与百分比一行，进度条在下方 */
.account-usage-figure {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    max-width: 100%;
    font-size: 12px;
    color: var(--text-muted);
}

/* 进度条跟随单元格宽度，避免固定 160px 在窄列里顶到右边界 */
.account-usage-cell {
    min-width: 140px;
}

.account-usage-cell .k-progress-bg {
    width: 100%;
    max-width: 170px;
}

/* 时间列固定 11/09 11:08 一行，换行会把行高从 55 撑到 61 */
#tab-accounts tbody td[data-label="导入时间"],
#tab-accounts tbody td[data-label="最后检查"],
#tab-assigned tbody td[data-label="导入时间"],
#tab-assigned tbody td[data-label="分配时间"],
#tab-assigned tbody td[data-label="最后检查"] {
    white-space: nowrap;
}

.account-table-scroll::-webkit-scrollbar {
    height: 8px;
}

.account-table-scroll::-webkit-scrollbar-track {
    background: var(--bg-page);
    border-radius: 999px;
}

.account-table-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid var(--bg-page);
    border-radius: 999px;
}

.account-table-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

.k-progress-bg {
    display: block;
    width: 160px;
    max-width: 100%;
    height: 6px;
    margin-top: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}

.k-progress-fill {
    display: block;
    height: 100%;
    background: var(--primary);
    border-radius: inherit;
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                background-color 0.2s ease;
}

.k-progress-fill.warn   { background: var(--warning); }
.k-progress-fill.danger { background: var(--danger); }

@keyframes kRingDraw {
    from { opacity: 0; }
    to   { opacity: 1; }
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    letter-spacing: 0.1px;
}

td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-main);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.account-email-cell {
    font-family: inherit;
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    word-break: normal;
    overflow-wrap: normal;
    /* 长邮箱截断，避免把整列撑宽挤掉「操作」列 */
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* 卡密表操作列：与账号表同款，四个按钮不换行 */
.card-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

/* 卡密 / 日志表没有横滚容器，操作列不换行后会把表格撑出卡片；
   交给卡片内部横向滚动，避免按钮被裁切 */
#tab-cards .k-card-body,
#tab-logs .k-card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover { background: var(--bg-subtle); }
tr:last-child td { border-bottom: none; }

.k-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    background: var(--bg-subtle);
    color: var(--text-muted);
    /* 窄列里徽章被压成逐字竖排（「未使/用」），锁住单行 */
    white-space: nowrap;
}

/* 健康状态徽章：圆点 + 文案，来源 static/js/ui.js healthBadge() */
.k-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.k-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.k-status-dot.active    { background: var(--success); }
.k-status-dot.used      { background: var(--warning); }
.k-status-dot.suspended { background: var(--danger); }

/* 额度百分比：与额度条的阈值色一致，避免在 JS 里写死十六进制 */
.credit-pct {
    font-variant-numeric: tabular-nums;
    color: var(--text-muted);
}
.credit-pct.warn   { color: var(--warning); }
.credit-pct.danger { color: var(--danger); }
.k-badge-success { background: var(--success-bg); color: var(--success); }
.k-badge-neutral { background: var(--bg-subtle);  color: var(--text-muted); }

/* 分页器 */
.k-pager {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.k-pager-total {
    font-variant-numeric: tabular-nums;
}

.k-pager-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.k-pager-nav .ui-btn-sm {
    min-width: 32px;
    padding-left: 8px;
    padding-right: 8px;
    font-variant-numeric: tabular-nums;
}

.k-pager-active {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--primary-text);
    cursor: default;
}

.k-pager-gap {
    padding: 0 2px;
    color: var(--text-disabled);
    user-select: none;
}

.k-pager-size,
.k-pager-jump {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.k-pager-select,
.k-pager-input {
    padding: 4px 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.k-pager-select { cursor: pointer; }
.k-pager-input {
    width: 62px;
    text-align: center;
}

.k-pager-select:hover,
.k-pager-input:hover { border-color: var(--border-hover); }

.k-pager-select:focus,
.k-pager-input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .k-pager { gap: 8px 10px; }
    .k-pager-nav { order: 3; width: 100%; }
}

.k-skeleton {
    display: inline-block;
    min-width: 24px;
    border-radius: 4px;
    color: transparent !important;
    background: linear-gradient(90deg, var(--border) 0%, var(--bg-subtle) 50%, var(--border) 100%);
    background-size: 200% 100%;
    animation: shimmer 1.4s linear infinite;
    user-select: none;
}

.k-chart-skeleton {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100%;
    padding: 8px 0;
}
.k-chart-skeleton .k-bar {
    flex: 1;
    min-height: 40px;
    background: linear-gradient(180deg, var(--border) 0%, var(--bg-subtle) 100%);
    border-radius: 4px;
    animation: shimmer-bar 1.4s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes shimmer-bar {
    0%, 100% { opacity: 0.55; }
    50%      { opacity: 0.9; }
}

.ui-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 14px;
    min-height: 36px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background-color 0.15s var(--ease),
                border-color 0.15s var(--ease),
                color 0.15s var(--ease),
                opacity 0.15s var(--ease);
    /* 移动端优化：增大触摸区域 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

/* 移动端增大按钮触摸区域 */
@media (max-width: 1024px) {
    .ui-btn {
        min-height: 44px;
        padding: 10px 16px;
    }
}

.ui-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ui-btn-primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
}
.ui-btn-primary:hover:not(:disabled) { background: var(--primary-hover); border-color: var(--primary-hover); }
.ui-btn-primary:active:not(:disabled) { background: var(--primary-active); border-color: var(--primary-active); }

.ui-btn-secondary {
    background: var(--bg-surface);
    color: var(--text-main);
    border-color: var(--border);
}
.ui-btn-secondary:hover:not(:disabled) {
    background: var(--bg-subtle);
    border-color: var(--border-hover);
}

.ui-btn-danger {
    background: var(--bg-surface);
    color: var(--danger);
    border-color: var(--danger-border);
}
.ui-btn-danger:hover:not(:disabled) {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.ui-btn-warning {
    background: var(--bg-surface);
    color: var(--warning-text);
    border-color: var(--warning-border);
}
.ui-btn-warning:hover:not(:disabled) {
    background: var(--warning-bg);
    border-color: var(--warning);
}

.ui-btn-sm {
    padding: 5px 10px;
    min-height: 28px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}

.k-input {
    width: 100%;
    height: 36px;
    padding: 0 12px;
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    line-height: 1.4;
    -webkit-appearance: none;
    appearance: none;
    caret-color: var(--text-main);
    transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
    /* 移动端优化 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端增大输入框高度，防止 iOS 自动缩放 */
@media (max-width: 1024px) {
    .k-input {
        height: 44px;
        font-size: max(16px, 13px); /* iOS 上 ≥16px 防止聚焦时自动缩放 */
        padding: 0 14px;
    }
    
    textarea.k-input {
        font-size: max(16px, 13px);
        padding: 12px 14px;
    }
}

.k-input::placeholder { color: var(--text-disabled); }
.k-input:hover { border-color: var(--border-hover); }
.k-input:focus {
    outline: none;
    border-color: var(--primary-active);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.k-input:disabled {
    background: var(--bg-subtle);
    color: var(--text-disabled);
    cursor: not-allowed;
}

/* textarea 使用 .k-input 时需要更大高度 */
textarea.k-input {
    min-height: 120px;
    height: auto;
    padding: 10px 12px;
    line-height: 1.5;
    resize: vertical;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

textarea.k-input::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

textarea.k-input::-webkit-scrollbar-track {
    background: transparent;
}

textarea.k-input::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid var(--bg-surface);
    border-radius: 999px;
}

textarea.k-input::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

textarea.k-input::-webkit-scrollbar-corner {
    background: transparent;
}

.settings-label {
    display: block;
    margin-bottom: 7px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
    max-width: 1280px;
}

/* 行高只保底、不封顶：设置项的说明文字长度不一，写死行高会把长文案裁掉，
   卡片还会压住下一项。minmax(82px, auto) 保证短项仍对齐，长项自己撑开。 */
.settings-column {
    display: grid;
    grid-template-rows: none;
    grid-auto-rows: minmax(82px, auto);
    gap: 14px;
}

.settings-toggle-card {
    height: auto;
    min-height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-page);
    border-radius: var(--radius);
}

.settings-toggle-card > div {
    min-width: 0;
}

.settings-toggle-card strong {
    display: block;
    font-size: 14px;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.settings-toggle-card small {
    display: block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
}

.settings-field {
    min-width: 0;
    min-height: 82px;
}

.settings-field .k-input {
    height: 36px;
}

.settings-field textarea.k-input {
    height: auto;
}

.settings-help {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
}

/* 自适应高度的设置区块。
   settings-grid 的行高被 grid-auto-rows 固定为 82px，内容超过就会溢出压住
   下面的字段，所以状态展示、密钥这类高度不定的内容单独放在网格之外。 */
.settings-panel {
    max-width: 1280px;
    margin-top: 22px;
    padding: 16px 18px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.settings-panel-title {
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.settings-panel-text {
    margin-bottom: 10px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.7;
}

.settings-panel-text:last-child {
    margin-bottom: 0;
}

.settings-panel-text code {
    padding: 1px 5px;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 11px;
}

.settings-panel-warn {
    color: var(--warning-text);
}

.settings-panel-code {
    display: block;
    margin: 10px 0 6px;
    padding: 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
    line-height: 1.6;
    word-break: break-all;
    user-select: all;
}

.settings-panel button {
    margin-top: 2px;
}

.version-info-grid {
    display: grid;
    gap: 10px;
}

.version-info-row {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
}

.version-info-row span {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
}

.version-info-row strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.version-update-note {
    margin-top: 14px;
    padding: 12px 14px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.7;
}

.version-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.version-refresh-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(24, 24, 27, 0.18);
    border-top-color: var(--text-main);
    animation: spin 0.7s linear infinite;
}

.version-refresh-btn.loading {
    pointer-events: none;
    opacity: 0.72;
}

.recent-pagination {
    padding: 0 16px 16px;
    border-top: none;
}

.status.success,
.status.error {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
}

.status.success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.status.error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border-color: var(--danger-border);
}

.k-dropdown {
    position: relative;
    display: inline-block;
}

.k-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-height: 36px;
    padding: 0 34px 0 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    position: relative;
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
    /* 移动端优化 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端增大下拉框触摸区域 */
@media (max-width: 1024px) {
    .k-dropdown-trigger {
        min-height: 44px;
        padding: 0 38px 0 14px;
        font-size: max(16px, 13px); /* iOS 上 ≥16px 防止聚焦时自动缩放 */
    }
}

.k-dropdown-trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 7px;
    height: 7px;
    border-right: 1.5px solid var(--text-muted);
    border-bottom: 1.5px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
    transition: transform 0.18s var(--ease);
}

.k-dropdown-trigger:hover {
    border-color: var(--border-hover);
    background: var(--bg-subtle);
}

.k-dropdown.active .k-dropdown-trigger {
    border-color: var(--primary-active);
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.k-dropdown.active .k-dropdown-trigger::after {
    transform: translateY(-30%) rotate(-135deg);
}

/* 当下拉触发器同时用了 .ui-btn 样式（如导出按钮），把 ::after 画在更靠内的位置 */
.k-dropdown-trigger.ui-btn {
    padding-right: 28px;
}
.k-dropdown-trigger.ui-btn::after {
    right: 10px;
}

.k-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 280px;
    overflow-y: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 4px;
    z-index: 200;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.15s var(--ease), transform 0.15s var(--ease);
}

.k-dropdown.active .k-dropdown-menu {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.k-dropdown-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.1s ease;
}
.k-dropdown-item:hover { background: var(--bg-hover); }
.k-dropdown-item.selected {
    background: var(--bg-subtle);
    font-weight: 500;
}
.k-dropdown-item.disabled {
    color: var(--text-disabled);
    cursor: not-allowed;
}
.k-dropdown-item.disabled:hover { background: transparent; }

.k-dropdown-label {
    padding: 6px 10px 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: default;
    user-select: none;
}

.k-dropdown-divider {
    height: 1px;
    margin: 4px 6px;
    background: var(--border);
}

.k-checkbox {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    background: var(--bg-surface);
    cursor: pointer;
    position: relative;
    vertical-align: middle;
    flex-shrink: 0;
    transition: background-color 0.15s var(--ease),
                border-color 0.15s var(--ease);
}
.k-checkbox:hover { border-color: var(--text-muted); }
.k-checkbox:checked {
    background: var(--primary);
    border-color: var(--primary);
}
.k-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 1px;
    width: 5px;
    height: 9px;
    border-right: 1.5px solid var(--primary-text);
    border-bottom: 1.5px solid var(--primary-text);
    transform: rotate(45deg);
}
.k-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.36);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 1000;
    padding: 24px;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    /* 移动端优化滚动 */
    -webkit-overflow-scrolling: touch;
}
.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.15s var(--ease);
}

/* 移动端和 iPad 适配 */
@media (max-width: 1024px) {
    .modal-overlay {
        padding: 16px;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: 8px;
    }
}

.modal-content {
    width: 100%;
    max-width: 720px;
    max-height: calc(100vh - 48px);
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 0.2s var(--ease);
    /* 移动端安全区域 */
    margin-top: env(safe-area-inset-top);
    margin-bottom: env(safe-area-inset-bottom);
}

/* iPad 优化 */
@media (min-width: 641px) and (max-width: 1024px) {
    .modal-content {
        max-width: 90%;
        max-height: calc(90vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
}

/* 移动端优化 */
@media (max-width: 640px) {
    .modal-content {
        max-width: 100%;
        max-height: calc(100vh - 16px);
        border-radius: var(--radius);
    }
}

.modal-header {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
}

.modal-close {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    font: inherit;
    font-size: 0;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    -webkit-appearance: none;
    appearance: none;
    transition: background-color 0.15s ease, color 0.15s ease;
    /* 移动端优化 */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* 移动端增大关闭按钮触摸区域 */
@media (max-width: 1024px) {
    .modal-close {
        width: 36px;
        height: 36px;
        flex: 0 0 36px;
    }
}
.modal-close::before,
.modal-close::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 1.5px;
    border-radius: 1px;
    background: currentColor;
}
.modal-close::before { transform: rotate(45deg); }
.modal-close::after { transform: rotate(-45deg); }
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}
.modal-close:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--primary-bg);
}
.modal-close:active {
    background: var(--border);
}

.modal-body {
    padding: 22px;
    overflow-y: auto;
}

.account-info-modal .modal-content {
    max-width: 860px;
    border: none;
}

.card-log-content {
    max-width: 640px;
}

/* 导入标签页样式 */
.import-tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s var(--ease), background-color 0.2s var(--ease),
        border-color 0.2s var(--ease);
}

.import-tab-btn:hover {
    color: var(--text-main);
    background: var(--bg-hover);
}

.import-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.import-tab-panel {
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-log-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 0;
}

.account-modal-loading {
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
}

.modal-spinner {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
}

.account-modal-error,
.account-empty-state {
    padding: 28px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: var(--radius);
}

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

.account-detail-row,
.model-item {
    background: var(--bg-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}

.account-detail-row {
    padding: 12px 14px;
    min-width: 0;
}

.account-detail-row span {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 12px;
}

.account-detail-row strong {
    display: block;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-detail-section {
    margin-top: 22px;
}

.account-detail-section-title {
    margin-bottom: 10px;
    color: var(--text-main);
    font-size: 14px;
    font-weight: 600;
}

/* 账号详情 · 额度用量：总消耗一条进度条，来源拆分在下面按行列出 */
.account-usage-summary {
    background: var(--bg-subtle);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 16px;
}

.account-usage-readout {
    display: flex;
    align-items: baseline;
    gap: 8px;
    color: var(--text-main);
}

.account-usage-readout strong {
    font-size: 22px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.account-usage-limit {
    color: var(--text-muted);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

.account-usage-pct {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.account-usage-pct.warn   { color: var(--warning); }
.account-usage-pct.danger { color: var(--danger); }

.account-usage-bar {
    width: 100%;
    max-width: none;
    height: 8px;
    margin-top: 10px;
}

.account-usage-breakdown {
    display: grid;
    gap: 4px;
    margin-top: 12px;
}

.account-usage-breakdown-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.account-usage-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex: none;
}

/* 三个来源用中性灰的深浅区分，不额外引入色相：它们的量已经含在总量里，
   再上颜色会和「当前用量」抢注意力，而这只是一份来源说明。 */
.account-usage-dot.base  { background: var(--text-main); }
.account-usage-dot.bonus { background: var(--text-secondary); }
.account-usage-dot.trial { background: var(--text-disabled); }

.account-usage-breakdown-label {
    flex: none;
}

.account-usage-breakdown-value {
    margin-left: auto;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.account-model-loading {
    min-height: 104px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    background: var(--bg-subtle);
    border-radius: var(--radius);
    font-size: 13px;
}

.account-model-loading .modal-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

.model-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(210px, 1fr));
    gap: 8px;
}

.model-title span {
    color: var(--text-main);
    font-weight: 600;
}

.model-item {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px;
    min-width: 0;
}

.model-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    object-fit: contain;
    border: none;
    border-radius: 0;
    background: transparent;
}

.model-content {
    min-width: 0;
    flex: 1;
}

.model-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.model-title span {
    font-size: 12.5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.model-id {
    margin-top: 1px;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.model-desc {
    margin-top: 5px;
    color: var(--text-secondary);
    font-size: 11.5px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.model-params {
    margin-top: 6px;
    display: block;
    color: var(--text-muted);
    font-size: 11px;
    line-height: 1.45;
}

.model-param {
    display: inline;
    white-space: normal;
}

.model-param:not(:last-child)::after {
    content: " · ";
    color: var(--text-disabled);
}

@media (max-width: 760px) {
    .model-list {
        grid-template-columns: 1fr;
    }
}

.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 16px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-8px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(20px); }
}

@media (max-width: 768px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* 卡密健康检测统计卡片 */
.k-stat-card {
  padding: 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.k-stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.k-stat-value {
  font-size: 28px;
  font-weight: 600;
  color: var(--text-main);
}

/* 健康检测表格样式 */
.k-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.k-table thead {
  background: var(--bg-subtle);
  border-bottom: 2px solid var(--border);
}

.k-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.k-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.k-table tbody tr:hover {
  background: var(--bg-subtle);
}

.k-table tbody tr:last-child td {
  border-bottom: none;
}

/* 卡密分布表格样式 */
.k-card-dist-table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.k-card-dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: var(--bg-surface);
}

.k-card-dist-table th,
.k-card-dist-table td {
  padding: 12px 16px;
  text-align: center;
  border: 1px solid var(--border);
}

/* 左上角单元格 */
.k-dist-th-corner {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-muted);
  position: sticky;
  left: 0;
  z-index: 3;
  text-align: left;
  padding-left: 20px;
}

/* 卡密类型表头（每个卡密类型为一列） */
.k-dist-th-card {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  min-width: 100px;
}

/* 统计类型行表头（未使用、已使用、总计） */
.k-dist-th-row {
  background: var(--bg-subtle);
  font-weight: 500;
  color: var(--text-muted);
  text-align: left;
  padding-left: 20px;
  white-space: nowrap;
  position: sticky;
  left: 0;
  z-index: 2;
}

/* 数据单元格 */
.k-dist-td-unused {
  background: var(--bg-surface);
  color: var(--success);
  font-weight: 600;
  font-size: 15px;
}

.k-dist-td-used {
  background: var(--bg-surface);
  color: var(--warning);
  font-weight: 600;
  font-size: 15px;
}

.k-dist-td-total {
  background: var(--bg-surface);
  color: var(--primary);
  font-weight: 700;
  font-size: 15px;
}

/* 鼠标悬停效果 */
.k-card-dist-table tbody tr:hover td {
  background: var(--bg-hover);
}

/* 响应式：小屏幕 */
@media (max-width: 768px) {
  .k-card-dist-table {
    font-size: 12px;
  }
  
  .k-card-dist-table th,
  .k-card-dist-table td {
    padding: 8px 12px;
  }
  
  .k-dist-th-corner,
  .k-dist-th-row {
    padding-left: 12px;
  }
  
  .k-dist-th-card {
    min-width: 80px;
    font-size: 11px;
  }
  
  .k-dist-td-unused,
  .k-dist-td-used,
  .k-dist-td-total {
    font-size: 13px;
  }
}

/* 修复：原先此处残留无选择器的声明块，导致花括号不平衡 */
.cute-bar-chart {
  gap: 12px;
  padding: 12px 0;
}

.cute-bar-legend {
  display: flex;
  gap: 20px;
  padding: 0 0 8px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.cute-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cute-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.cute-legend-dot.used {
  background: linear-gradient(135deg, var(--warning) 0%, var(--danger) 100%);
}

.cute-legend-dot.unused {
  background: linear-gradient(135deg, var(--success) 0%, var(--success) 100%);
}

.cute-legend-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

.cute-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.3s ease-out backwards;
}

.cute-bar-row:nth-child(2) { animation-delay: 0.05s; }
.cute-bar-row:nth-child(3) { animation-delay: 0.1s; }
.cute-bar-row:nth-child(4) { animation-delay: 0.15s; }
.cute-bar-row:nth-child(5) { animation-delay: 0.2s; }
.cute-bar-row:nth-child(6) { animation-delay: 0.25s; }
.cute-bar-row:nth-child(7) { animation-delay: 0.3s; }
.cute-bar-row:nth-child(8) { animation-delay: 0.35s; }
.cute-bar-row:nth-child(9) { animation-delay: 0.4s; }
.cute-bar-row:nth-child(10) { animation-delay: 0.45s; }
.cute-bar-row:nth-child(11) { animation-delay: 0.5s; }

.cute-bar-label {
  min-width: 140px;
  max-width: 140px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.cute-bar-stack-wrapper {
  flex: 1;
  display: flex;
  height: 32px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.cute-bar-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: barGrow 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
  position: relative;
}

.cute-bar-segment.used {
  background: linear-gradient(135deg, var(--warning) 0%, var(--danger) 100%);
}

.cute-bar-segment.unused {
  background: linear-gradient(135deg, var(--success) 0%, var(--success) 100%);
}

.cute-bar-segment-value {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-text);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  padding: 0 6px;
  white-space: nowrap;
}

.cute-bar-total {
  min-width: 36px;
  text-align: right;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  flex-shrink: 0;
}

.cute-bar-wrapper {
  flex: 1;
  position: relative;
  height: 32px;
  display: flex;
  align-items: center;
  background: var(--bg-subtle);
  border-radius: var(--radius);
  overflow: hidden;
}

.cute-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: var(--radius);
  transition: width 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: barGrow 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.cute-bar-value {
  position: relative;
  z-index: 1;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 32px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes barGrow {
  from {
    width: 0 !important;
  }
}

.cute-empty-chart {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}

/* 账号状态图表样式 */
.cute-status-chart-simple {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 32px;
  align-items: center;
  padding: 16px;
}

.cute-status-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cute-stat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.cute-stat-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cute-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cute-stat-item.mint .cute-dot {
  background: linear-gradient(135deg, var(--primary), var(--success));
}

.cute-stat-item.amber .cute-dot {
  background: linear-gradient(135deg, var(--warning), var(--warning));
}

.cute-stat-item.rose .cute-dot {
  background: linear-gradient(135deg, var(--danger), var(--danger));
}

.cute-stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.cute-stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-main);
  min-width: 40px;
  text-align: right;
}

.cute-donut {
  position: relative;
  width: 160px;
  height: 160px;
  flex-shrink: 0;
}

.cute-donut-svg {
  transform: rotate(-90deg);
}

.cute-ring-segment {
  transition: stroke-dasharray 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
              stroke-dashoffset 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cute-ring-segment.delayed {
  animation: fadeIn 0.4s ease-out 0.2s backwards;
}

.cute-ring-segment.delayed-more {
  animation: fadeIn 0.4s ease-out 0.4s backwards;
}

.cute-donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.cute-donut-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

.cute-donut-value span {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-muted);
}

.cute-donut-label {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .cute-status-chart-simple {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  
  .cute-donut {
    margin: 0 auto;
  }
  
  .cute-bar-label {
    min-width: 100px;
    max-width: 100px;
    font-size: 11px;
  }
  
  .cute-bar-total {
    min-width: 28px;
    font-size: 12px;
  }
  
  .cute-bar-segment-value {
    font-size: 10px;
  }
  
  .cute-bar-legend {
    gap: 12px;
  }
}

/* 概览「账号状态」：账号池 / 已分配分栏统计 */
.k-card-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* 两栏状态需要自适应高度，取消 dashboard-chart 的固定高度 */
#accountStatusChart.dashboard-chart {
  height: auto;
  min-height: 200px;
}

/* 全部账号健康率汇总 */
.k-status-summary {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 4px 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.k-status-summary strong {
  color: var(--text-main);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.k-status-summary-sep {
  color: var(--border-strong);
}

.k-status-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 8px 4px;
}

.k-status-group {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-surface);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.k-status-group:hover {
  transform: translateY(-1px);
  /* 原来写死 rgba(24,24,27,.06)，在暗色主题下是一层看不见的黑影 */
  box-shadow: var(--shadow-md);
}

.k-status-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.k-status-group-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.k-status-group-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.k-status-group-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.k-status-group-total {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.k-status-group .cute-stat-item {
  padding: 10px 12px;
}

.k-status-group .cute-stat-value {
  font-size: 18px;
}

.k-status-right {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.k-status-share {
  min-width: 44px;
  text-align: right;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  .k-card-hint {
    display: none;
  }

  .k-status-groups {
    grid-template-columns: 1fr;
  }
}

/* 顶栏“订阅工具”快捷入口（原内联 onmouseover/onmouseout 改为 CSS） */
.header-subtool-link { background: var(--bg-subtle); }
.header-subtool-link:hover { background: var(--border); }

/* 主题切换按钮 */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  font: inherit;
  line-height: 1;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease),
    color 0.18s var(--ease);
}

.theme-toggle-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-hover);
  color: var(--text-main);
}

.theme-toggle-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-bg, rgba(0,0,0,0.1));
}

.theme-toggle-btn svg {
  display: block;
}

/* 主题选择面板样式 */
.theme-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 0;
}

.theme-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-surface);
  cursor: pointer;
  transition: background-color 0.18s var(--ease), border-color 0.18s var(--ease);
  user-select: none;
}

.theme-option:hover {
  background: var(--bg-subtle);
  border-color: var(--border-hover);
}

.theme-option input[type="radio"] {
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
}

.theme-option-label {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  pointer-events: none;
}

.theme-option input[type="radio"]:checked + .theme-option-label {
  color: var(--primary);
  font-weight: 600;
}

/* ── 概览：额度使用 ─────────────────────────────────────────────
   两栏汇总（账号池 / 已分配）在上，已分配账号的邮箱后缀拆分表在下。
   百分比由后端算好，这里只负责排版；填充条用 transform 而不是 width，
   避免每 30 秒刷新时触发重排。 */

.k-credit-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 0 4px;
}

.k-credit-bucket {
  min-width: 0;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}

.k-credit-bucket-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.k-credit-bucket-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.k-credit-bucket-sub {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

.k-credit-figure {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.k-credit-percent {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.k-credit-amount {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.k-credit-bar {
  display: block;
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.k-credit-bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--primary);
  border-radius: inherit;
  transition: transform 0.3s var(--ease), background-color 0.2s var(--ease);
}

.k-credit-bar-fill.warn { background: var(--warning); }
.k-credit-bar-fill.danger { background: var(--danger); }

.k-credit-note {
  margin-top: 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.k-credit-table-wrapper {
  margin-top: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.k-credit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.k-credit-table th,
.k-credit-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.k-credit-table th {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border-bottom: 1px solid var(--border);
}

.k-credit-table tbody tr:hover td {
  background: var(--bg-hover);
}

.k-credit-table tbody tr:last-child td {
  border-bottom: none;
}

.k-credit-th-suffix {
  text-align: left;
}

.k-credit-td-suffix {
  text-align: left;
  color: var(--text-main);
}

.k-credit-td-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
}

.k-credit-td-percent {
  color: var(--text-main);
  font-weight: 500;
}

.k-credit-suffix-none {
  color: var(--text-muted);
}

.k-credit-table-empty {
  margin-top: 20px;
  padding: 20px 4px 4px;
  font-size: 12px;
  color: var(--text-muted);
}
