/**
 * 驻村工作队管理系统 - 企业级样式表
 * 现代化、响应式、高性能设计
 */

/* ==================== CSS变量定义 ==================== */
:root {
    /* 主色调 - 企业蓝 */
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;

    /* 中性色 */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* 功能色 */
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    --error-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    /* 语义化颜色 */
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-header: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* 尺寸 */
    --sidebar-width: 240px;
    --header-height: 64px;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    /* 过渡 */
    --transition: all 0.2s ease;
}

/* ==================== 全局重置 ==================== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ==================== 登录页面 ==================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-800) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 420px;
    position: relative;
    z-index: 1;
}

.login-box {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--border-radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-lg), 0 0 40px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.login-box-dark {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-box-dark .login-header h1 {
    color: white;
}

.login-box-dark .login-header p {
    color: rgba(255, 255, 255, 0.7);
}

.login-box-dark .form-group label {
    color: rgba(255, 255, 255, 0.9);
}

.login-box-dark .form-group input {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.login-box-dark .form-group input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.login-box-dark .form-group input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.login-box-dark .login-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

.login-box-dark .login-footer a {
    color: rgba(255, 255, 255, 0.8);
}

.login-box-dark .login-footer a:hover {
    color: white;
}

.login-box-dark .alert-error {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
    color: #fca5a5;
}

.login-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 0;
}

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

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-footer {
    margin-top: 24px;
    text-align: center;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.login-footer a {
    color: var(--primary-600);
    text-decoration: none;
    font-size: 14px;
    transition: var(--transition);
}

.login-footer a:hover {
    color: var(--primary-700);
}

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

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

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

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

/* 文件上传 */
.file-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    padding: 32px;
    text-align: center;
    background: var(--gray-50);
    cursor: pointer;
    transition: var(--transition);
}

.file-upload:hover,
.file-upload.dragover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}

.file-upload input[type="file"] {
    display: none;
}

.file-info {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

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

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

.btn-primary {
    background: var(--primary-600);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-700);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-warning {
    background: var(--warning);
    color: white;
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
}

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

.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
}

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

.btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
}

/* ==================== 企业级布局 ==================== */
.dashboard {
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: var(--transition);
    flex-shrink: 0;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    min-height: 60px;
}

.sidebar-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: white;
}

.sidebar-nav {
    padding: 12px 0;
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.nav-section {
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--gray-400);
    padding: 8px 12px;
    letter-spacing: 0.5px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    border-radius: var(--border-radius);
    margin: 2px 8px;
    transition: var(--transition);
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary-600);
    color: white;
}

.nav-icon {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

/* 主内容区 */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 顶部栏 */
.topbar {
    height: var(--header-height);
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

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

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-menu .user-name {
    font-size: 14px;
    color: var(--text-primary);
}

.user-menu .btn-logout {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: var(--transition);
}

.user-menu .btn-logout:hover {
    color: var(--error);
}

/* 内容区 */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
}

.page-content {
    padding: 24px;
    flex: 1;
}

/* 页面标题 */
.page-header {
    margin-bottom: 24px;
}

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

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

/* ==================== 卡片 ==================== */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

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

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

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    background: var(--gray-50);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

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

.stat-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    padding: 20px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 12px;
}

.stat-card .stat-icon.primary {
    background: var(--primary-100);
    color: var(--primary-600);
}

.stat-card .stat-icon.success {
    background: var(--success-light);
    color: var(--success);
}

.stat-card .stat-icon.warning {
    background: var(--warning-light);
    color: var(--warning);
}

.stat-card .stat-icon.info {
    background: var(--info-light);
    color: var(--info);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ==================== 表格 ==================== */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

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

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

.table td {
    font-size: 14px;
    color: var(--text-primary);
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

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

.badge-primary {
    background: var(--primary-100);
    color: var(--primary-700);
}

.badge-success {
    background: var(--success-light);
    color: #047857;
}

.badge-warning {
    background: var(--warning-light);
    color: #b45309;
}

.badge-danger {
    background: var(--error-light);
    color: #b91c1c;
}

.badge-secondary {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ==================== 警告框 ==================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: var(--success-light);
    color: #047857;
    border-left: 4px solid var(--success);
}

.alert-error {
    background: var(--error-light);
    color: #b91c1c;
    border-left: 4px solid var(--error);
}

.alert-warning {
    background: var(--warning-light);
    color: #b45309;
    border-left: 4px solid var(--warning);
}

.alert-info {
    background: var(--info-light);
    color: #0e7490;
    border-left: 4px solid var(--info);
}

/* ==================== 网格布局 ==================== */
.grid {
    display: grid;
    gap: 20px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* ==================== 模态框 ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ==================== 折叠面板 ==================== */
.collapsible {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.collapsible-header {
    padding: 12px 16px;
    background: var(--gray-50);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.collapsible-header:hover {
    background: var(--gray-100);
}

.collapsible-content {
    padding: 16px;
    display: none;
    border-top: 1px solid var(--border-color);
}

.collapsible.active .collapsible-content {
    display: block;
}

.collapsible-toggle {
    transition: transform 0.2s;
}

.collapsible.active .collapsible-toggle {
    transform: rotate(180deg);
}

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

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

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

/* ==================== 批量操作栏 ==================== */
.bulk-actions {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--primary-50);
    border-radius: var(--border-radius);
    margin-bottom: 16px;
}

.bulk-actions.show {
    display: flex;
}

.bulk-actions .selected-count {
    font-size: 14px;
    color: var(--primary-700);
    font-weight: 500;
}

/* ==================== 工具提示 ==================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: var(--gray-800);
    color: white;
    font-size: 12px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

/* ==================== 加载动画 ==================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ==================== 移动端菜单按钮 ==================== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }
    
    .sidebar {
        transform: translateX(-100%);
        width: 260px;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .topbar {
        padding: 0 16px;
    }
    
    .main-content {
        padding: 16px;
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .login-box {
        padding: 24px;
    }
    
    .login-header h1 {
        font-size: 20px;
    }
    
    .page-title {
        font-size: 20px;
    }
    
    .card-header,
    .card-body,
    .card-footer {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .topbar-right .user-name {
        display: none;
    }
    
    .btn {
        padding: 8px 16px;
    }
    
    .modal-content {
        margin: 10px;
        max-height: calc(100vh - 20px);
    }
    
    .bulk-actions {
        flex-wrap: wrap;
    }
}

/* ==================== 打印样式 ==================== */
@media print {
    .sidebar,
    .topbar,
    .mobile-menu-btn {
        display: none;
    }
    
    .main-wrapper {
        margin-left: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

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

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ==================== 侧边栏增强样式 ==================== */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-weight: 600;
    font-size: 15px;
}

.sidebar-logo svg {
    flex-shrink: 0;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    flex-grow: 0;
    background: var(--bg-sidebar);
    min-height: 60px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary-600);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: white;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
}

.user-info .user-name {
    font-size: 13px;
    font-weight: 500;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .user-role {
    font-size: 11px;
    color: var(--gray-400);
}

.logout-btn {
    color: var(--gray-400);
    transition: var(--transition);
    padding: 8px;
    border-radius: var(--border-radius);
    flex-shrink: 0;
}

.logout-btn:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.nav-item-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

/* ==================== 模板列表样式 ==================== */
.template-list {
    max-height: 400px;
    overflow-y: auto;
}

.template-item {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    transition: var(--transition);
}

.template-item:hover {
    border-color: var(--primary-300);
    box-shadow: var(--shadow-sm);
}

.template-item h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.template-item p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.template-meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
}

.template-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ==================== 文件上传区域增强 ==================== */
.file-upload-content {
    pointer-events: none;
}

.file-upload-content svg {
    margin: 0 auto 16px;
    color: var(--gray-400);
}

.file-upload-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.file-upload-hint {
    font-size: 13px;
    color: var(--text-muted);
}

.file-upload-hint strong {
    color: var(--success);
}

/* ==================== 页面头部 ==================== */
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.page-header p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* ==================== 表单操作区 ==================== */
.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.required {
    color: var(--error);
}

/* ==================== 卡片标题增强 ==================== */
.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-header .badge {
    font-size: 11px;
    background: var(--gray-100);
    color: var(--text-secondary);
}

/* ==================== 空状态增强 ==================== */
.empty-state svg {
    color: var(--gray-300);
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.empty-state span {
    font-size: 13px;
    color: var(--text-muted);
}

/* ==================== 折叠侧边栏 ==================== */
.sidebar-collapsed .sidebar {
    width: 60px;
}

.sidebar-collapsed .sidebar .nav-section-title,
.sidebar-collapsed .sidebar .nav-item span,
.sidebar-collapsed .sidebar .sidebar-logo span,
.sidebar-collapsed .sidebar .user-info {
    display: none;
}

.sidebar-collapsed .main-content {
    margin-left: 60px;
}

/* ==================== 辅助类 ==================== */
.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 13px;
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }

.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }

/* ==================== 复选框样式 ==================== */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ==================== 选择框样式 ==================== */
.form-control {
    display: block;
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background: var(--bg-card);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* ==================== 常用链接样式 ==================== */
.common-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.common-link-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition);
}

.common-link-item:hover {
    background: var(--primary-50);
    border-color: var(--primary-300);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.common-link-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    flex-shrink: 0;
}

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

.common-link-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.common-link-desc {
    font-size: 12px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== 多标签页系统 ==================== */
.tab-bar {
    display: flex;
    align-items: stretch;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-color);
    padding: 0 12px;
    min-height: 40px;
    overflow-x: auto;
    overflow-y: hidden;
    flex-shrink: 0;
    scrollbar-width: thin;
}

.tab-bar::-webkit-scrollbar {
    height: 3px;
}

.tab-bar::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    user-select: none;
    flex-shrink: 0;
    max-width: 180px;
}

.tab-item:hover {
    color: var(--text-primary);
    background: var(--gray-50);
}

.tab-item.active {
    color: var(--primary-600);
    border-bottom-color: var(--primary-600);
    font-weight: 500;
}

.tab-title {
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 4px;
    font-size: 15px;
    line-height: 1;
    color: var(--text-muted);
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}

.tab-close:hover {
    background: var(--error-light);
    color: var(--error);
}

.tab-iframe-container {
    flex: 1;
    position: relative;
    min-height: 0;
}

.tab-iframe {
    width: 100%;
    height: 100%;
    border: none;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.tab-iframe.loaded {
    opacity: 1;
}

/* 标签页加载指示器 */
.tab-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary, #fff);
    z-index: 1;
    transition: opacity 0.2s ease;
}

.tab-loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.tab-loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200, #e5e7eb);
    border-top-color: var(--primary-500, #3b82f6);
    border-radius: 50%;
    animation: tab-spin 0.6s linear infinite;
}

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

/* 标签页激活时主内容区需要改为flex布局撑满高度 */
.main-content.has-tabs {
    height: 100vh;
    overflow: hidden;
}

/* 初始标签的 page-content 在标签模式下也需要内部滚动，与 iframe 标签保持一致 */
.main-content.has-tabs > .page-content {
    overflow-y: auto;
    min-height: 0;
}

/* 标签模式下 topbar 不需要 sticky，父容器已固定高度 */
.main-content.has-tabs > .topbar {
    position: relative;
    flex-shrink: 0;
}

/* iframe 内嵌模式：隐藏外壳UI */
html.in-tab-iframe .sidebar, body.in-tab-iframe .sidebar {
    display: none !important;
}

html.in-tab-iframe .main-content, body.in-tab-iframe .main-content {
    margin-left: 0 !important;
}

html.in-tab-iframe .topbar, body.in-tab-iframe .topbar {
    display: none !important;
}

html.in-tab-iframe .tab-bar, body.in-tab-iframe .tab-bar {
    display: none !important;
}

html.in-tab-iframe .page-content, body.in-tab-iframe .page-content {
    padding-top: 16px;
}

/* 夜间模式标签页适配 */
[data-theme="dark"] .tab-bar {
    background: var(--theme-bg-card);
    border-color: var(--theme-border);
}

[data-theme="dark"] .tab-loading-overlay {
    background: var(--theme-bg-card, #1e293b);
}

[data-theme="dark"] .tab-loading-spinner {
    border-color: var(--gray-600, #4b5563);
    border-top-color: var(--primary-400, #60a5fa);
}

[data-theme="dark"] .tab-item:hover {
    background: var(--gray-100);
}

[data-theme="dark"] .tab-item.active {
    color: var(--primary-400);
    border-bottom-color: var(--primary-400);
}

[data-theme="dark"] .tab-close:hover {
    background: rgba(239, 68, 68, 0.2);
}

/* 响应式标签页 */
@media (max-width: 768px) {
    .tab-bar {
        padding: 0 8px;
    }

    .tab-item {
        padding: 0 8px;
        font-size: 12px;
        max-width: 140px;
    }

    html.in-tab-iframe .page-content, body.in-tab-iframe .page-content {
        padding: 12px;
    }
}