:root {
    --adm-primary: #2563eb;
    --adm-primary-dark: #1d4ed8;
    --adm-primary-light: #dbeafe;
    --adm-bg: #f1f5f9;
    --adm-surface: #ffffff;
    --adm-text: #0f172a;
    --adm-muted: #64748b;
    --adm-border: #e2e8f0;
    --adm-sidebar-w: 240px;
    --adm-radius: 12px;
    --adm-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.04);
}

body {
    background: var(--adm-bg);
    color: var(--adm-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.btn-primary {
    --bs-btn-bg: var(--adm-primary);
    --bs-btn-border-color: var(--adm-primary);
    --bs-btn-hover-bg: var(--adm-primary-dark);
    --bs-btn-hover-border-color: var(--adm-primary-dark);
}

/* 布局 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--adm-sidebar-w);
    background: var(--adm-surface);
    border-right: 1px solid var(--adm-border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease;
}

.admin-sidebar-brand {
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--adm-border);
}

.admin-sidebar-brand .brand-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--adm-text);
    margin: 0;
}

.admin-sidebar-brand .brand-sub {
    font-size: 0.75rem;
    color: var(--adm-muted);
    margin: 0;
}

.admin-sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
    overflow-y: auto;
}

.admin-sidebar-nav .nav-link {
    color: var(--adm-muted);
    padding: 0.65rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 2px;
}

.admin-sidebar-nav .nav-link i {
    font-size: 1.1rem;
    width: 1.25rem;
}

.admin-sidebar-nav .nav-link:hover {
    background: #f8fafc;
    color: var(--adm-primary);
}

.admin-sidebar-nav .nav-link.active {
    background: var(--adm-primary-light);
    color: var(--adm-primary);
    font-weight: 600;
}

.admin-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--adm-border);
}

.admin-main {
    flex: 1;
    margin-left: var(--adm-sidebar-w);
    min-width: 0;
}

.admin-topbar {
    background: var(--adm-surface);
    border-bottom: 1px solid var(--adm-border);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.admin-topbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.admin-topbar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: #f8fafc;
    border: 1px solid var(--adm-border);
    border-radius: 10px;
    padding: 0.35rem 0.85rem;
    min-width: 220px;
}

.admin-topbar-search i { color: var(--adm-muted); }

.admin-topbar-search input {
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.875rem;
    width: 100%;
}

.admin-user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--adm-primary-light);
    color: var(--adm-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.admin-user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--adm-text);
}

.admin-topbar h1 {
    font-size: 1.35rem;
    font-weight: 700;
    margin: 0;
}

.admin-topbar .page-desc {
    color: var(--adm-muted);
    font-size: 0.875rem;
    margin: 0.25rem 0 0;
}

.admin-content {
    padding: 1.5rem;
}

/* 统计卡片 */
.stat-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 1.25rem;
    box-shadow: var(--adm-shadow);
    height: 100%;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.stat-card .stat-body { min-width: 0; }

.stat-card .stat-icon.blue { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green { background: #dcfce7; color: #16a34a; }
.stat-card .stat-icon.cyan { background: #cffafe; color: #0891b2; }
.stat-card .stat-icon.purple { background: #ede9fe; color: #7c3aed; }
.stat-card .stat-icon.gray { background: #f1f5f9; color: #64748b; }
.stat-card .stat-icon.orange { background: #ffedd5; color: #ea580c; }

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
}

.stat-card .stat-label {
    color: var(--adm-text);
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 0.35rem;
}

.stat-card .stat-hint {
    color: var(--adm-muted);
    font-size: 0.75rem;
    margin-top: 0.15rem;
}

/* 仪表盘列表 */
.dash-empty {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--adm-muted);
    font-size: 0.9rem;
}

.dash-list,
.dash-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-list li,
.dash-cat-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--adm-border);
    gap: 1rem;
}

.dash-list li:last-child,
.dash-cat-list li:last-child { border-bottom: none; }

.dash-rank-list,
.dash-app-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.dash-rank-list li,
.dash-app-list li {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.25rem;
    border-bottom: 1px solid var(--adm-border);
}

.dash-rank-list li:last-child,
.dash-app-list li:last-child { border-bottom: none; }

.dash-rank {
    width: 22px;
    font-weight: 800;
    color: var(--adm-primary);
    text-align: center;
    font-size: 0.85rem;
}

.dash-rank-list img,
.dash-app-list img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--adm-primary-light);
}

.dash-rank-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dash-rank-dl {
    font-size: 0.8rem;
    color: var(--adm-muted);
    font-weight: 600;
}

.dash-quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.settings-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.settings-nav a {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--adm-border);
    background: var(--adm-surface);
    color: var(--adm-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

.settings-nav a:hover {
    border-color: var(--adm-primary);
    color: var(--adm-primary);
    background: var(--adm-primary-light);
}

.env-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

.env-check-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--adm-border);
    border-radius: 10px;
    font-size: 0.9rem;
}

.env-check-card .env-label { font-weight: 600; }
.env-check-card .env-value { color: var(--adm-muted); font-size: 0.8rem; }

/* 卡片 */
.admin-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    box-shadow: var(--adm-shadow);
    margin-bottom: 1.5rem;
}

.admin-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--adm-border);
    padding: 1rem 1.25rem;
    font-weight: 600;
}

.admin-card .card-body { padding: 1.25rem; }

/* 表格 */
.admin-table-wrap {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    box-shadow: var(--adm-shadow);
    overflow: hidden;
}

.admin-table {
    margin: 0;
}

.admin-table thead th {
    background: #f8fafc;
    border-bottom: 1px solid var(--adm-border);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--adm-muted);
    padding: 0.85rem 1rem;
    white-space: nowrap;
}

.admin-table tbody td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-color: var(--adm-border);
}

.admin-table tbody tr:hover {
    background: #fafbfc;
}

.app-cell {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-cell img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--adm-primary-light);
}

.app-cell .name { font-weight: 600; }
.app-cell .slug { font-size: 0.8rem; color: var(--adm-muted); }

/* Badge */
.badge-published { background: #dcfce7; color: #15803d; }
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-disabled { background: #fee2e2; color: #b91c1c; }

/* 上传区域 */
.upload-dropzone {
    border: 2px dashed var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 2rem;
    text-align: center;
    background: #fafbfc;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--adm-primary);
    background: var(--adm-primary-light);
}

.upload-dropzone i {
    font-size: 2.5rem;
    color: var(--adm-primary);
    margin-bottom: 0.75rem;
}

.upload-file-info {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: 8px;
    display: none;
}

.upload-file-info.show { display: block; }

/* 表单分区 */
.form-section {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--adm-shadow);
}

.form-section-title {
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--adm-border);
}

/* 环境检查 */
.env-check-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--adm-border);
}

.env-check-item:last-child { border-bottom: none; }

.env-badge-ok { background: #dcfce7; color: #15803d; }
.env-badge-warn { background: #fef9c3; color: #a16207; }
.env-badge-bad { background: #fee2e2; color: #b91c1c; }

/* 页面工具栏 */
.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

/* 移动端 */
.admin-mobile-toggle {
    display: none;
    background: none;
    border: 1px solid var(--adm-border);
    border-radius: 8px;
    padding: 0.35rem 0.65rem;
}

@media (max-width: 991px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.show {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .admin-mobile-toggle {
        display: inline-flex;
    }
    .admin-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.4);
        z-index: 1035;
    }
    .admin-sidebar-overlay.show { display: block; }
}
