@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;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-bg: #fffbeb;

    /* 形状 */
    --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);
    --transition: all 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%;
}

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;
}

::selection {
    background: 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 rgba(24, 24, 27, 0.08),
                0 1px 2px rgba(0, 0, 0, 0.04);
}

.login-input:focus::placeholder {
    color: #c4c4c8;
}

.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: #fff;
    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);
}

.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: #f4f4f5;
    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: #eff6ff;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.10);
}

.setup-step.active span {
    background: #2563eb;
    color: #fff;
}

.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: #ececef;
    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: #f4f4f5;
    color: var(--text-main);
    cursor: pointer;
    transition: var(--transition);
}

.setup-icon-btn:hover {
    background: #e4e4e7;
}

.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: #f8fafc;
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

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

.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: #fff;
    color: #2563eb;
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.07);
}

.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: #fff;
    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: #ecfdf5;
    color: #047857;
}

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

.setup-check-panel.pending .setup-check-summary {
    background: #eff6ff;
    color: #2563eb;
}

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

.setup-check-group {
    padding: 14px 0;
    border-bottom: 1px solid #ececef;
}

.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: #f59e0b;
}

.setup-check-group-icon.icon-postgres,
.setup-check-group-icon.icon-sqlite {
    color: #2563eb;
}

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

.setup-check-row {
    --check-color: #64748b;
    --check-bg: #f8fafc;
    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 #f0f0f1;
}

.setup-check-row.check-server_runtime {
    --check-color: #2563eb;
    --check-bg: #eff6ff;
}

.setup-check-row.check-server_cpu {
    --check-color: #16a34a;
    --check-bg: #f0fdf4;
}

.setup-check-row.check-server_port {
    --check-color: #0891b2;
    --check-bg: #ecfeff;
}

.setup-check-row.check-database_type {
    --check-color: #7c3aed;
    --check-bg: #f5f3ff;
}

.setup-check-row.check-database_type.icon-sqlite {
    --check-color: #2563eb;
    --check-bg: #eff6ff;
}

.setup-check-row.check-database_type.icon-mysql {
    --check-color: #f59e0b;
    --check-bg: #fff7ed;
}

.setup-check-row.check-database_type.icon-postgres {
    --check-color: #2563eb;
    --check-bg: #eff6ff;
}

.setup-check-row.check-database_config {
    --check-color: #d97706;
    --check-bg: #fffbeb;
}

.setup-check-row.check-database_connection {
    --check-color: #0891b2;
    --check-bg: #ecfeff;
}

.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: #fff;
    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: #fee2e2;
    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 #d4d4d8;
    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(24, 24, 27, 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 {
    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: #f4f4f5;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    transition: background-color 0.18s var(--ease),
                color 0.18s var(--ease),
                box-shadow 0.18s var(--ease);
}

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

.version-dot {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 999px;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.12);
}

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

.version-new {
    display: none;
    margin-left: auto;
    padding: 2px 6px;
    border-radius: 999px;
    background: #18181b;
    color: #fff;
    font-size: 10px;
    line-height: 1.2;
}

.sidebar-version.has-update {
    background: #fff7ed;
    color: #9a3412;
    box-shadow: inset 0 0 0 1px rgba(251, 146, 60, 0.22);
}

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

.sidebar-version.has-update .version-new {
    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(24, 24, 27, 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(24, 24, 27, 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: rgba(24, 24, 27, 0.06);
    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(24, 24, 27, 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-stat-pill {
    width: 100%;
    max-width: 132px;
    padding: 14px 16px;
    border-radius: 18px;
    background: var(--chart-soft);
    box-shadow: 0 12px 30px rgba(24, 24, 27, 0.06);
}

.cute-stat-pill.mint {
    --chart-color: #34d399;
    --chart-soft: #ecfdf5;
}

.cute-stat-pill.rose {
    --chart-color: #fb7185;
    --chart-soft: #fff1f2;
}

.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: #fff;
    box-shadow: 0 16px 36px rgba(24, 24, 27, 0.08);
}

.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-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: #d4d4d8 transparent;
    overscroll-behavior-x: contain;
}

.account-table-scroll table {
    min-width: 1120px;
}

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

.account-table-scroll::-webkit-scrollbar-track {
    background: #fafafa;
    border-radius: 999px;
}

.account-table-scroll::-webkit-scrollbar-thumb {
    background: #d4d4d8;
    border: 2px solid #fafafa;
    border-radius: 999px;
}

.account-table-scroll::-webkit-scrollbar-thumb:hover {
    background: #c4c4cc;
}

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

.k-progress-fill {
    display: block;
    height: 100%;
    background: #18181b;
    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: #f59e0b; }
.k-progress-fill.danger { background: #dc2626; }

@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;
}

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

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);
}
.k-badge-success { background: var(--success-bg); color: var(--success); }
.k-badge-neutral { background: var(--bg-subtle);  color: var(--text-muted); }

.k-skeleton {
    display: inline-block;
    min-width: 24px;
    border-radius: 4px;
    color: transparent !important;
    background: linear-gradient(90deg, #e4e4e7 0%, #f4f4f5 50%, #e4e4e7 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;
    background: linear-gradient(180deg, #e4e4e7 0%, #f4f4f5 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;
    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);
}

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

.ui-btn-primary {
    background: var(--primary);
    color: #fff;
    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-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);
}

.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 rgba(24, 24, 27, 0.08);
}
.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: #d4d4d8 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: #d4d4d8;
    border: 2px solid var(--bg-surface);
    border-radius: 999px;
}

textarea.k-input::-webkit-scrollbar-thumb:hover {
    background: #a1a1aa;
}

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;
}

.settings-column {
    display: grid;
    grid-template-rows: 84px;
    grid-auto-rows: 82px;
    gap: 14px;
}

.settings-toggle-card {
    height: 84px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    background: #fafafa;
    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;
    height: 32px;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
    overflow: hidden;
}

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

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

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

.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: #f8fafc;
    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;
}

.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: #ecfdf5;
    color: #047857;
}

.status.error {
    background: #fef2f2;
    color: #b91c1c;
}

.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);
}

.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 rgba(24, 24, 27, 0.08);
}
.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: rgba(24, 24, 27, 0.06);
    font-weight: 500;
}
.k-dropdown-item.disabled {
    color: var(--text-disabled);
    cursor: not-allowed;
}
.k-dropdown-item.disabled:hover { background: transparent; }

.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 #fff;
    border-bottom: 1.5px solid #fff;
    transform: rotate(45deg);
}
.k-checkbox:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(24, 24, 27, 0.12);
}

.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;
}
.modal-overlay.active {
    display: flex;
    animation: fadeIn 0.15s var(--ease);
}

.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);
}

.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;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 22px;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-main);
}

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

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

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

.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 #e4e4e7;
    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-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); }
}
