/* ========== 基础样式 ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* 人情世故 · 新中式设计系统（管理后台与网站/小程序同源） */
    --bg-primary: #F5F1E8;
    --bg-secondary: #FFFCF6;
    --bg-tertiary: #EFE8DA;
    --bg-hover: #E9E0CE;
    --accent: #9E2F26;
    --accent-hover: #7C211A;
    --accent-light: #C25A4B;
    --text-primary: #23211E;
    --text-secondary: #5F574B;
    --text-muted: #8C8375;
    --border: #DDD3C0;
    --border-light: #EBE3D4;
    --success: #3F6459;
    --warning: #A9663F;
    --error: #9E2F26;
    --info: #3E5A73;
    --gold: #B08D4F;
    --shadow: 0 4px 14px rgba(74, 56, 36, 0.10);
    --shadow-lg: 0 16px 40px rgba(74, 56, 36, 0.16);
    --radius: 8px;
    --radius-sm: 4px;
    --font-serif: 'Songti SC', 'STSong', 'Noto Serif SC', serif;
    --transition: 0.3s ease;
    --sidebar-width: 240px;
    --sidebar-collapsed: 60px;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* 隐藏类 */
.hidden { display: none !important; }

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

.login-box {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px 32px;
    box-shadow: var(--shadow);
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from { transform: translateY(20px); }
    to { transform: translateY(0); }
}

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

.login-logo {
    font-size: 48px;
    margin-bottom: 12px;
}

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

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

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

.login-form label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

.login-form input::placeholder {
    color: var(--text-muted);
}

.error-msg {
    color: var(--error);
    font-size: 13px;
    margin-bottom: 12px;
    min-height: 20px;
}

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

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

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

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 15px;
}

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

/* ========== 主应用布局 ========== */
.app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition), width var(--transition);
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: 28px;
    flex-shrink: 0;
}

.sidebar-title h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

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

.sidebar-nav {
    flex: 1;
    padding: 12px 10px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    transition: all var(--transition);
    margin-bottom: 4px;
}

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

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

.nav-item.active .nav-icon {
    filter: none;
}

.nav-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.user-avatar {
    font-size: 18px;
}

.btn-logout {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}

.btn-logout:hover {
    background: var(--bg-tertiary);
}

/* ========== 移动端菜单 ========== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    padding: 0;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    transition: all var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(74, 56, 36, 0.10);
    z-index: 90;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.content-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

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

.api-status {
    font-size: 12px;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: 20px;
}

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

/* ========== 页面区块 ========== */
.page-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page-section.active {
    display: block;
}

@keyframes fadeIn {
    from { transform: translateY(6px); }
    to { transform: translateY(0); }
}

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

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform var(--transition), border-color var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-light);
}

.stat-icon {
    font-size: 36px;
    flex-shrink: 0;
}

.stat-info {
    flex: 1;
}

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

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========== 卡片/区块 ========== */
.section-row {
    margin-bottom: 24px;
}

.section-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

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

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

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

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ========== 快速操作 ========== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 20px;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
}

.action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.action-icon {
    font-size: 28px;
}

.action-text {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========== API 健康状态 ========== */
.api-health-list {
    padding: 8px 20px 20px;
}

.api-health-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.api-health-item:last-child {
    border-bottom: none;
}

.api-name {
    font-size: 14px;
    color: var(--text-secondary);
}

.api-status-badge {
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.api-status-badge.online {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
}

.api-status-badge.offline {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
}

.api-status-badge.unknown {
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-muted);
}

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

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

.data-table thead th {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: top;
}

.data-table tbody tr:hover {
    background: var(--bg-tertiary);
}

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

.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

.empty-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 40px !important;
}

/* 表格内容截断 */
.data-table td .cell-content {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.5;
}

/* ========== 表格操作按钮 ========== */
.table-actions {
    display: flex;
    gap: 6px;
}

.action-link {
    font-size: 12px;
    color: var(--accent);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
    cursor: pointer;
    border: none;
    background: none;
}

.action-link:hover {
    background: rgba(194, 53, 49, 0.1);
}

/* ========== 筛选器 ========== */
.select-filter {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    min-width: 120px;
}

.select-filter:focus {
    outline: none;
    border-color: var(--accent);
}

.select-filter option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.page-info {
    font-size: 13px;
    color: var(--text-secondary);
}

/* ========== 设置表单 ========== */
.settings-form {
    padding: 20px;
}

.settings-group {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.settings-group:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.settings-group input[type="text"],
.settings-group input[type="password"],
.settings-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
}

.settings-group input:focus,
.settings-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.settings-group textarea {
    resize: vertical;
    min-height: 80px;
}

.settings-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.settings-actions {
    display: flex;
    gap: 12px;
    padding-top: 8px;
}

/* 错误/成功提示 */
.error-banner, .success-banner {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin: 0 20px 16px;
}

.error-banner {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.success-banner {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.ai-config-card {
    margin-bottom: 24px;
    border-left: 4px solid #3E5A73;
}

.ai-config-card .card-header h3 {
    color: #3E5A73;
}

.ai-config-section {
    padding: 20px;
}

.ai-params-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.ai-params-row .settings-group {
    border-bottom: none;
    padding-bottom: 0;
    margin-bottom: 0;
}

.ai-config-actions {
    display: flex;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    margin-top: 16px;
}

.settings-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999999' d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

.settings-group select:focus {
    outline: none;
    border-color: var(--accent);
}

/* 模型选择器 */
.model-select-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.model-select-wrapper select {
    width: 100%;
}

.model-select-wrapper input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
}

.model-select-wrapper input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

.range-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.range-wrapper input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    outline: none;
}

.range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
}

.range-wrapper input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.range-value {
    min-width: 36px;
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    font-size: 14px;
}

.settings-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
}

.settings-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.settings-group .hint a {
    color: var(--accent);
    text-decoration: none;
}

.settings-group .hint a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .ai-params-row {
        grid-template-columns: 1fr;
    }
}

/* ========== JSON 查看器 ========== */
.json-viewer {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 500px;
    overflow-y: auto;
    color: var(--text-secondary);
}

.json-key { color: #3E5A73; }
.json-string { color: #A9663F; }
.json-number { color: #3F6459; }
.json-boolean { color: #3E5A73; }
.json-null { color: #3E5A73; }
.json-bracket { color: #B08D4F; }

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

.modal.active {
    display: flex;
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.3s ease;
}

.modal-large {
    max-width: 960px;
}

@keyframes modalIn {
    from { transform: scale(0.96); }
    to { transform: scale(1); }
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

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

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

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

/* ========== Toast 提示 ========== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 24px;
    font-size: 14px;
    color: var(--text-primary);
    box-shadow: var(--shadow);
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-color: var(--error);
    color: var(--error);
}

.toast.success {
    border-color: var(--success);
    color: var(--success);
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .content-header {
        padding-left: 64px;
    }
    
    .page-content {
        padding: 16px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .data-table {
        font-size: 12px;
    }
    
    .data-table thead th,
    .data-table tbody td {
        padding: 10px 12px;
    }
    
    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .header-right {
        width: 100%;
    }
    
    .select-filter {
        width: 100%;
    }
    
    .modal-content {
        max-height: 90vh;
        margin: 0;
    }
}

@media (max-width: 480px) {
    .login-box {
        padding: 28px 20px;
    }
    
    .quick-actions {
        grid-template-columns: 1fr;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    .stat-value {
        font-size: 24px;
    }
    
    .table-actions {
        flex-wrap: wrap;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== 标签/徽章 ========== */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
}

.badge-primary {
    background: rgba(194, 53, 49, 0.15);
    color: var(--accent);
}

.badge-secondary {
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-muted);
}

.badge-success {
    background: rgba(76, 175, 80, 0.15);
    color: var(--success);
}
/* ========== 编辑表单样式 ========== */
.edit-form {
    padding: 0;
}

.edit-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.edit-form .form-group {
    margin-bottom: 0;
}

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

.edit-form .form-group input[type="text"],
.edit-form .form-group input[type="number"],
.edit-form .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    transition: border-color var(--transition);
}

.edit-form .form-group input:focus,
.edit-form .form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.edit-form .form-group textarea {
    resize: vertical;
    min-height: 60px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

/* 小按钮 */
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

/* 危险按钮 */
.btn-danger {
    background: rgba(244, 67, 54, 0.15);
    color: var(--error);
    border: 1px solid rgba(244, 67, 54, 0.3);
}

.btn-danger:hover {
    background: rgba(244, 67, 54, 0.25);
}

/* Modal 表单中的 footer 调整 */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

/* 确保 modal 层级正确 */
.modal {
    z-index: 1000;
}

/* 表格中的操作按钮 */
.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.action-link {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: 2px 4px;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.action-link:hover {
    color: var(--accent-hover);
}

/* 卡片头部右侧区域 */
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* 响应式：表单行在移动端改为单列 */
@media (max-width: 768px) {
    .edit-form .form-row {
        grid-template-columns: 1fr;
    }
}

/* ========== 左右分栏布局 ========== */
.modal-body-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
}

.edit-form-panel {
    padding-right: 16px;
    border-right: 1px solid var(--border);
}

.edit-preview-panel {
    padding-left: 8px;
}

.preview-header {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.preview-content {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    min-height: 200px;
    overflow-y: auto;
}

.preview-placeholder {
    color: var(--text-muted);
    text-align: center;
    padding: 40px 16px;
    margin: 0;
}

/* ========== AI生成按钮 ========== */
.ai-generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: linear-gradient(135deg, #B08D4F 0%, #9E2F26 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ai-generate-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

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

.ai-generate-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.ai-generate-btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========== 表单字段带AI按钮的包装 ========== */
.form-field-with-ai {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 16px;
}

.form-field-with-ai .form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-field-with-ai .form-group textarea {
    min-height: 80px;
}

.form-field-with-ai .ai-generate-btn {
    margin-top: 26px;
    align-self: flex-start;
}

.form-field-with-ai > div[style*="flex-direction:column"] {
    margin-top: 26px;
    align-self: flex-start;
}

/* ========== 字段标签样式 ========== */
.edit-form .form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.field-icon {
    font-size: 14px;
}

/* ========== 加载遮罩 ========== */
.modal-loading-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(13, 13, 13, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 10;
    border-radius: var(--radius);
}

.modal-loading-overlay.hidden {
    display: none;
}

.modal-loading-overlay .spinner-large {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.modal-loading-overlay p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== 表单验证提示 ========== */
.field-error {
    color: var(--error);
    font-size: 12px;
    margin-top: 4px;
    display: none;
}

.field-error.show {
    display: block;
}

.input-error {
    border-color: var(--error) !important;
}

/* ========== 成功提示 ========== */
.field-success {
    color: var(--success);
    font-size: 12px;
    margin-top: 4px;
}

/* ========== 选项预览表格 ========== */
.options-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.options-preview-table th,
.options-preview-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.options-preview-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
}

.options-preview-table td {
    color: var(--text-primary);
}

.options-preview-table .option-id {
    font-weight: 600;
    color: var(--accent);
    width: 36px;
}

.options-preview-table .option-text {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.options-preview-table .option-scores {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 11px;
    color: var(--text-muted);
}

/* ========== 响应式：移动端改为上下布局 ========== */
@media (max-width: 768px) {
    .modal-body-split {
        grid-template-columns: 1fr;
    }
    .edit-form-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding-right: 0;
        padding-bottom: 16px;
    }
    .edit-preview-panel {
        padding-left: 0;
        padding-top: 16px;
    }
    .form-field-with-ai {
        flex-direction: column;
    }
    .form-field-with-ai .ai-generate-btn,
    .form-field-with-ai > div[style*="flex-direction:column"] {
        margin-top: 8px;
        align-self: flex-start;
    }
}

/* ========== 新中式统一装饰层 ========== */
html, body {
    background-image:
        radial-gradient(rgba(120, 96, 60, 0.045) 0.6px, transparent 0.7px),
        radial-gradient(ellipse at 10% 0%, rgba(176, 141, 79, 0.10), transparent 45%);
    background-size: 8px 8px, 100% 100%;
}
h1, h2, h3, h4 { font-family: var(--font-serif); letter-spacing: 0.06em; }
.login-box, .sidebar, .card, .stat-card, .table-container { position: relative; }
.login-box::before, .sidebar::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--accent), var(--gold));
    z-index: 2;
}
.login-logo, .sidebar-logo {
    font-family: var(--font-serif);
    color: var(--accent);
}
.btn-primary {
    background: linear-gradient(135deg, #A8352B, #7C211A);
    border: 1px solid #7C211A;
    box-shadow: 0 6px 18px rgba(158, 47, 38, 0.22);
    letter-spacing: 0.08em;
}
.btn-primary:hover { background: #7C211A; }
input:focus, textarea:focus, select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(158, 47, 38, 0.10);
}
::-webkit-scrollbar-thumb { background: #CFC3AC; border-radius: 4px; }

/* ============================================================
   结构化内容编辑器（全屏 overlay）
   ============================================================ */
#structured-editor-overlay {
    display: none;
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(35, 33, 30, 0.55);
    backdrop-filter: blur(3px);
}
#structured-editor-overlay.active { display: flex; align-items: stretch; justify-content: center; }

.se-window {
    flex: 1; max-width: 1080px; margin: 24px;
    background: var(--bg-card, #FFFCF6);
    border: 1px solid rgba(176, 141, 79, 0.35);
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(35, 33, 30, 0.35);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.se-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(90deg, rgba(176,141,79,0.12), rgba(158,47,38,0.10));
    border-bottom: 1px solid rgba(176, 141, 79, 0.30);
    flex-wrap: wrap; gap: 10px;
}
.se-title { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text-main, #23211E); }
.se-icon { font-size: 20px; }
.se-hint { font-size: 12px; font-weight: 400; color: #8A8175; margin-left: 8px; }
.se-header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.se-body { flex: 1; overflow-y: auto; padding: 18px 22px; }
.se-fields { display: flex; flex-direction: column; gap: 14px; }
.se-empty { text-align: center; color: #8A8175; padding: 48px 0; }

.se-field {
    background: var(--bg-card, #FFFCF6);
    border: 1px solid rgba(176, 141, 79, 0.30);
    border-radius: 10px; overflow: hidden;
}
.se-field-head {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: rgba(176, 141, 79, 0.08);
    border-bottom: 1px solid rgba(176, 141, 79, 0.18);
}
.se-key {
    font-weight: 700; color: var(--primary, #9E2F26);
    border: none; background: transparent; outline: none;
    font-size: 14px; min-width: 120px; flex: 0 1 auto;
    border-bottom: 1px dashed rgba(176,141,79,0.5); padding: 2px 4px;
}
.se-type-badge {
    font-size: 11px; padding: 2px 10px; border-radius: 999px;
    background: rgba(158, 47, 38, 0.10); color: var(--primary, #9E2F26);
    border: 1px solid rgba(158, 47, 38, 0.25);
}
.se-field-body { padding: 10px 12px; }

.se-mini {
    border: 1px solid rgba(176,141,79,0.4); background: var(--bg-card, #FFFCF6);
    border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px;
    color: var(--text-main, #23211E); line-height: 1.4;
}
.se-mini:hover { background: rgba(176,141,79,0.12); }
.se-mini.se-danger { color: var(--primary, #9E2F26); border-color: rgba(158,47,38,0.4); }
.se-mini.se-danger:hover { background: rgba(158,47,38,0.10); }

.se-textarea, .se-input, .se-cell, .se-raw {
    width: 100%; box-sizing: border-box;
    border: 1px solid rgba(176,141,79,0.35); border-radius: 8px;
    padding: 8px 10px; font-size: 13px; line-height: 1.6;
    color: var(--text-main, #23211E);
    background: var(--bg-page, #F5F1E8);
    outline: none; resize: vertical;
    font-family: inherit;
}
.se-mono { font-family: Menlo, Consolas, monospace; font-size: 12px; }
.se-textarea:focus, .se-input:focus, .se-cell:focus, .se-raw:focus,
.se-key:focus { border-color: var(--primary, #9E2F26); }

.se-rows { display: flex; flex-direction: column; gap: 6px; }
.se-row { display: flex; align-items: flex-start; gap: 6px; }
.se-row .se-input, .se-row .se-cell { flex: 1; }
.se-kv-key { flex: 0 0 140px; font-weight: 600; }

.se-grid { display: grid; gap: 6px; align-items: start; margin-bottom: 2px; }
.se-col-name {
    font-size: 11px; font-weight: 700; color: var(--gold, #B08D4F);
    letter-spacing: 0.06em; padding: 0 4px;
}
.se-row-ops { display: flex; gap: 4px; align-self: center; }

.se-add {
    margin-top: 8px; width: 100%;
    border: 1px dashed rgba(176,141,79,0.55); background: rgba(176,141,79,0.06);
    color: var(--primary, #9E2F26); border-radius: 8px;
    padding: 8px; cursor: pointer; font-size: 13px;
}
.se-add:hover { background: rgba(176,141,79,0.14); }

.se-raw-wrap { height: 100%; }
.se-raw { height: 100%; min-height: 420px; }

.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; }
.badge-blue { background: rgba(63,100,89,0.12); color: #3F6459; border: 1px solid rgba(63,100,89,0.3); }
.badge-green { background: rgba(176,141,79,0.14); color: #8a6d33; border: 1px solid rgba(176,141,79,0.4); }
