:root {
    --primary-color: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary-color: #f43f5e;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    --bg-color: #f8fafc;
    --sidebar-bg: #0f172a;
    --sidebar-hover: #1e293b;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.35s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== 布局 ===== */
.layout {
    min-height: 100vh;
}

.content {
    margin-left: 250px;
    padding: 30px;
    overflow-x: auto;
    background: var(--bg-color);
    min-height: 100vh;
}

/* ===== 侧边栏 ===== */
.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.sidebar-header p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.nav {
    flex: 1;
    padding: 10px 0;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #94a3b8;
    text-decoration: none;
    transition: all var(--transition-normal);
    font-size: 14px;
    font-weight: 500;
    position: relative;
}

.nav a:hover {
    background: var(--sidebar-hover);
    color: #f1f5f9;
}

.nav a.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-light);
}

.nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.05);
    margin-top: auto;
}

.sidebar-footer p {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-footer .user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.sidebar-footer .user-info span {
    font-size: 13px;
    color: #cbd5e1;
}

/* ===== 卡片 ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
}

.card-title-wrap {
    display: flex;
    flex-direction: column;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 14px;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 14px;
    font-family: inherit;
    background: #fafafa;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    transition: all var(--transition-fast);
    color: #fff;
    white-space: nowrap;
}

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

.btn:active {
    transform: translateY(0);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
}

.btn-success {
    background: linear-gradient(135deg, #10b981, #059669);
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-info {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

/* ===== 提示框 ===== */
.alert {
    padding: 14px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.08);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.08);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.08);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(6, 182, 212, 0.08);
    color: #0891b2;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

/* ===== 表格 ===== */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 12px;
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: #f8fafc;
}

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

.table-actions {
    display: flex;
    gap: 6px;
}

/* ===== 统计卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--border-radius-lg);
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-light));
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
    background: rgba(99, 102, 241, 0.1);
}

.stat-num {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 14px;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 6px;
}

.stat-change.positive {
    color: var(--success-color);
}

.stat-change.negative {
    color: var(--danger-color);
}

/* ===== 徽章 ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
}

.badge-admin {
    background: linear-gradient(135deg, var(--secondary-color), #e11d48);
}

.badge-user {
    background: linear-gradient(135deg, var(--text-secondary), #475569);
}

.badge-active {
    background: var(--success-color);
}

.badge-inactive {
    background: var(--text-muted);
}

.badge-danger {
    background: var(--danger-color);
}

/* ===== 搜索框 ===== */
.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-md);
    font-size: 14px;
    background: var(--card-bg);
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-box::after {
    content: '\1F50D';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

/* ===== 分页 ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination a,
.pagination span {
    padding: 8px 14px;
    border-radius: var(--border-radius-sm);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.pagination a {
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.pagination a:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination span.active {
    background: var(--primary-color);
    color: #fff;
}

/* ===== 登录页 ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
    color: #fff;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* ===== 安装页 ===== */
.install-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
    padding: 20px;
}

.install-card {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
}

.step-indicator {
    display: flex;
    justify-content: space-between;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.step-item {
    flex: 1;
    text-align: center;
    padding: 10px;
    color: var(--text-muted);
    border-bottom: 3px solid var(--border-color);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-normal);
}

.step-item.active {
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.step-item.done {
    color: var(--success-color);
    border-color: var(--success-color);
}

.info-box {
    background: rgba(99, 102, 241, 0.05);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.info-box code {
    background: rgba(99, 102, 241, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Consolas', monospace;
    font-size: 13px;
    color: var(--primary-color);
}

/* ===== 工具表单 ===== */
.tool-form {
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--border-radius-md);
    margin-bottom: 20px;
    background: #fafafa;
}

.tool-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.tool-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.tool-item {
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: var(--border-radius-md);
    margin-bottom: 16px;
    background: #fafafa;
    transition: all var(--transition-fast);
}

.tool-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.08);
}

/* ===== 代码样式 ===== */
code {
    background: rgba(99, 102, 241, 0.08);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    color: var(--primary-color);
}

pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px;
    border-radius: var(--border-radius-md);
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
}

/* ===== 头部 ===== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ===== 开关 ===== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: var(--transition-fast);
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition-fast);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.switch input:checked + .slider {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
}

.switch input:checked + .slider:before {
    transform: translateX(20px);
}

/* ===== 复选框和单选框 ===== */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* ===== 空状态 ===== */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 60px;
        transition: width var(--transition-normal);
        flex-shrink: 0;
    }
    
    .sidebar.expanded {
        width: 250px;
    }
    
    .sidebar-header h2,
    .sidebar-header p,
    .nav a span,
    .sidebar-footer p,
    .sidebar-footer .user-info span {
        display: none;
    }
    
    .sidebar.expanded .sidebar-header h2,
    .sidebar.expanded .sidebar-header p,
    .sidebar.expanded .nav a span,
    .sidebar.expanded .sidebar-footer p,
    .sidebar.expanded .sidebar-footer .user-info span {
        display: block;
    }
    
    .sidebar-header {
        padding: 16px 12px;
    }
    
    .nav a {
        padding: 12px;
        justify-content: center;
    }
    
    .content {
        margin-left: 60px;
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .tool-row {
        grid-template-columns: 1fr;
    }
}

/* ===== 加载动画 ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

/* ===== 滚动条 ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
