/* 导入字体 */
@font-face {
    font-family: 'AlimamFangyuan';
    src: url('阿里妈妈方圆体Bold.TTF') format('truetype');
    font-weight: bold;
    font-style: normal;
    font-display: swap;
}

/* CSS 变量定义 */
:root {
    /* 主色系 - 暖棕焦糖色调，与背景图和谐 */
    --color-primary: #D9A68A;
    --color-primary-dark: #C8956B;
    --color-secondary: #EDDCCE;

    /* 背景色 */
    --color-background: #F5E6D3;
    --color-background-light: #FFFFFF;

    /* 文字色 */
    --color-text: #5A4A42;
    --color-text-light: #7A6A62;

    /* 辅助色 */
    --color-accent: #A8C4A0;
    --color-warning: #D4A95A;
    --color-error: #C75B4A;

    /* 边框和阴影 */
    --color-border: rgba(200, 135, 107, 0.15);
    --shadow-soft: 0 8px 32px rgba(200, 135, 107, 0.15);
    --shadow-hover: 0 12px 48px rgba(200, 135, 107, 0.25);
}

/* 基础样式 */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'AlimamFangyuan', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Microsoft YaHei", sans-serif;
    background: var(--color-background);
    color: var(--color-text);
    line-height: 1.6;
    position: relative;
}
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('6b67d8de28315c42427742c103177172.jpg') center / cover no-repeat;
    opacity: 0.35;
    pointer-events: none;
    z-index: -1;
}
.app { max-width: 1400px; margin: 0 auto; padding: 20px; }
.hidden { display: none !important; }

/* 头部 */
.app-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: var(--color-primary);
    color: white;
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}
.app-header h1 {
    font-family: 'AlimamFangyuan', sans-serif;
    font-size: 32px;
    margin-bottom: 8px;
    color: white;
}
.subtitle {
    opacity: 0.95;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.9);
}

/* 卡片 */
.card { background: white; border-radius: 8px; padding: 30px; box-shadow: 0 2px 8px rgba(0,0,0,0.1); margin-bottom: 20px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 2px solid #f0f0f0; }
.card-header h2 { font-size: 24px; color: #333; }
.card-header-actions { display: flex; gap: 10px; align-items: center; }

/* 表单 */
.form { display: flex; flex-direction: column; gap: 15px; }
.form label { display: flex; flex-direction: column; gap: 5px; }
.form label span { font-weight: 500; color: #555; }
.form input, .form textarea, .form select { padding: 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 14px; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--color-primary); }
.form .inline { flex-direction: row; align-items: center; gap: 8px; }
.form .inline input { width: auto; }

/* 按钮 */
.btn { padding: 10px 20px; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; transition: all 0.2s; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--color-primary); color: white; }
.btn.primary:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn.danger { background: #e74c3c; color: white; }
.btn.danger:hover:not(:disabled) { background: #c0392b; }
.btn.warning { background: #f39c12; color: white; }
.btn.warning:hover:not(:disabled) { background: #e67e22; }
.btn.ghost { background: transparent; border: 1px solid #ddd; color: #666; }
.btn.ghost:hover { background: #f5f5f5; }
.btn.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn.success { background: #27ae60; color: white; }
.btn.success:hover:not(:disabled) { background: #219a52; }

/* 标签 */
.tag { padding: 5px 12px; background: var(--color-primary); color: white; border-radius: 4px; font-size: 13px; }
.quota-badge { padding: 5px 12px; background: #27ae60; color: white; border-radius: 4px; font-size: 13px; margin-right: 8px; }
.quota-badge.negative { background: #e74c3c; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; margin-top: 10px; table-layout: fixed; }
.table thead { background: #f8f9fa; }
.table th, .table td { padding: 8px 4px; text-align: center; border-bottom: 1px solid #eee; font-size: 12px; word-break: break-all; overflow-wrap: break-word; }
.table th { font-weight: 600; color: #555; }
.table td:nth-child(2) { max-width: 120px; text-align: left; }
#all-tasks-table td:nth-child(3) { max-width: 120px; text-align: left; }
.table tbody tr:hover { background: #f8f9fa; }

/* 状态颜色 */
.status-Ready { color: #3498db; font-weight: 500; }
.status-Running { color: #f39c12; font-weight: 500; }
.status-Finished { color: #27ae60; font-weight: 500; }
.status-Abnormal { color: #e74c3c; font-weight: 500; }
.status-NotReady { color: #95a5a6; }
.status-Queued { color: #95a5a6; font-weight: 500; }
.status-Uploading { color: #9b59b6; font-weight: 500; }
.status-Completed { color: #27ae60; font-weight: 500; }
.status-Failed { color: #e74c3c; font-weight: 500; }
.status-Cancelled { color: #f39c12; font-weight: 500; }

/* 网格布局 */
.grid { display: grid; gap: 20px; margin-top: 20px; }
.grid.two-columns { grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); }

/* 区块 */
.section { margin-top: 30px; }
.section h3 { font-size: 18px; margin-bottom: 15px; color: #333; }

/* 调度控制 */
.scheduler-control { background: #f8f9fa; padding: 20px; border-radius: 8px; margin-bottom: 20px; }
.control-panel { display: flex; gap: 15px; align-items: center; margin-bottom: 15px; }
.control-panel span { font-weight: 500; color: #555; }

/* GPU状态 */
.gpu-status { display: flex; gap: 10px; flex-wrap: wrap; }
.gpu-badge { padding: 6px 12px; border-radius: 4px; font-size: 13px; font-weight: 500; }
.gpu-badge.free { background: #d4edda; color: #155724; }
.gpu-badge.busy { background: #f8d7da; color: #721c24; }

/* 配置表单 */
.config-form .config-grid, .form .config-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 15px; margin-bottom: 20px; }
.config-form label { display: flex; flex-direction: column; gap: 5px; }
.config-form label span { font-size: 13px; font-weight: 500; color: #555; }
.config-form input { padding: 8px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }

/* 上传进度列表 */
.upload-progress-list { margin-top: 15px; display: flex; flex-direction: column; gap: 10px; }
.upload-progress-item { background: #f8f9fa; padding: 12px; border-radius: 6px; border-left: 3px solid var(--color-primary); position: relative; }
.upload-progress-item.success { border-left-color: #27ae60; background: #d4edda; }
.upload-progress-item.error { border-left-color: #e74c3c; background: #f8d7da; }
.upload-info { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.upload-filename { font-weight: 500; color: #333; font-size: 14px; }
.upload-status { font-size: 13px; color: #666; }
.progress-bar { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--color-primary); transition: width 0.3s ease; }
.upload-progress-item .btn-cancel { position: absolute; top: 8px; right: 8px; padding: 3px 10px; font-size: 11px; }

/* 上传区域 */
.upload-sections { margin-top: 20px; display: flex; flex-direction: column; gap: 15px; }
.upload-section { background: #f8f9fa; padding: 15px; border-radius: 6px; }
.upload-section h4 { font-size: 14px; color: #555; margin-bottom: 10px; }
.upload-section .required { color: #e74c3c; font-size: 12px; }
.upload-section .optional { color: #95a5a6; font-size: 12px; }
.upload-row { display: flex; gap: 15px; }
.upload-section.half { flex: 1; }

.scene-upload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 10px; }

/* 文件拖拽区 */
.file-drop-zone { border: 2px dashed #ccc; border-radius: 6px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; position: relative; }
.file-drop-zone:hover, .file-drop-zone.drag-over { border-color: var(--color-primary); background: #f0f0ff; }
.file-drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-zone p { color: #999; font-size: 13px; pointer-events: none; }

/* 文件列表 */
.file-list { margin-top: 8px; }
.file-item { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; background: white; border-radius: 3px; margin-bottom: 3px; font-size: 13px; }
.file-item span { color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 200px; }
.btn-remove { background: none; border: none; color: #e74c3c; cursor: pointer; font-size: 14px; padding: 2px 6px; }
.btn-remove:hover { background: #fee; border-radius: 3px; }

/* ========== 调色弹窗 ========== */
.cg-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 1000; display: flex; align-items: center; justify-content: center; }
.cg-modal { background: #fff; border-radius: 8px; width: 95vw; height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.cg-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; border-bottom: 1px solid #eee; flex-shrink: 0; }
.cg-header span { font-size: 18px; font-weight: 600; }
.cg-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.cg-section { margin-bottom: 24px; }
.cg-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.cg-separator { color: #ccc; margin: 0 4px; }

/* 两栏布局 */
.cg-main-layout { display: flex; gap: 16px; align-items: flex-start; }
.cg-left { flex: 3; min-width: 0; }
.cg-right { flex: 2; min-width: 280px; position: sticky; top: 0; max-height: calc(100vh - 120px); overflow-y: auto; }

/* 滑块网格 */
.cg-controls { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 16px; padding: 12px; background: #f8f9fa; border-radius: 6px; }
.cg-control { display: flex; flex-direction: column; gap: 2px; }
.cg-control label { font-size: 12px; color: #555; display: flex; justify-content: space-between; }
.cg-control label .cg-val { font-weight: 600; color: #333; width: 58px; text-align: right; border: 1px solid #ccc; border-radius: 3px; padding: 0 4px; font-size: 12px; -moz-appearance: textfield; }
.cg-control label .cg-val::-webkit-inner-spin-button, .cg-control label .cg-val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.cg-range-row { display: flex; align-items: center; gap: 4px; }
.cg-control input[type="range"] { flex: 1; min-width: 0; accent-color: var(--color-primary); height: 22px; -webkit-appearance: none; appearance: none; background: transparent; }
.cg-control input[type="range"]::-webkit-slider-runnable-track { height: 12px; background: #ddd; border-radius: 6px; }
.cg-control input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); margin-top: -4px; cursor: pointer; }
.cg-control input[type="range"]::-moz-range-track { height: 12px; background: #ddd; border-radius: 6px; border: none; }
.cg-control input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); border: none; cursor: pointer; }
.cg-control.mixed label .cg-val { color: #999; font-style: italic; }
.cg-control.mixed input[type="range"] { opacity: 0.5; }

/* 图片网格 */
.cg-grid { display: flex; flex-wrap: nowrap; gap: 8px; min-height: 60px; overflow-x: auto; padding: 8px; border: 1px dashed #ddd; border-radius: 6px; }
.cg-frozen-area { background: #f0f0f0; border-color: #bbb; }
.cg-thumb { position: relative; cursor: pointer; border: 3px solid transparent; border-radius: 4px; transition: border-color 0.15s; }
.cg-thumb.selected { border-color: #22c55e; border-width: 4px; box-shadow: 0 0 8px rgba(34,197,94,0.6); }
.cg-thumb canvas { display: block; border-radius: 2px; }
.cg-thumb .cg-label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.55); color: #fff; font-size: 10px; text-align: center; padding: 1px 0; border-radius: 0 0 2px 2px; }

/* 框选矩形 */
.cg-select-rect { position: fixed; border: 1px solid var(--color-primary); background: rgba(200, 135, 107, 0.15); z-index: 1100; pointer-events: none; }

/* 双击放大 */
.cg-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 1200; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cg-lightbox canvas { max-width: 95vw; max-height: 95vh; }

/* HSL 面板 */
.cg-hsl-panel { padding: 0; }
.cg-hsl-title { font-size: 13px; color: #555; margin: 8px 0 6px; font-weight: 600; }
.cg-hsl-hues { display: flex; gap: 6px; margin-bottom: 10px; justify-content: center; }
.cg-hue-dot { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 3px solid transparent; transition: border-color 0.15s, box-shadow 0.15s; }
.cg-hue-dot.active { border-color: #333; box-shadow: 0 0 4px rgba(0,0,0,0.3); }
.cg-hsl-sliders { display: flex; flex-direction: column; gap: 6px; background: #f8f9fa; border-radius: 6px; padding: 8px 12px; }
.cg-hsl-row { display: flex; align-items: center; gap: 6px; }
.cg-hsl-row label { display: flex; align-items: center; gap: 2px; font-size: 11px; color: #777; flex: 1; }
.cg-hsl-row .cg-range-row { flex: 1; min-width: 0; }
.cg-hsl-row input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--color-primary); height: 22px; -webkit-appearance: none; appearance: none; background: transparent; }
.cg-hsl-row input[type="range"]::-webkit-slider-runnable-track { height: 12px; background: #ddd; border-radius: 6px; }
.cg-hsl-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); margin-top: -4px; cursor: pointer; }
.cg-hsl-row input[type="range"]::-moz-range-track { height: 12px; background: #ddd; border-radius: 6px; border: none; }
.cg-hsl-row input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--color-primary); border: none; cursor: pointer; }
.cg-hsl-val { width: 46px; text-align: right; border: 1px solid #ccc; border-radius: 3px; padding: 0 3px; font-size: 11px; -moz-appearance: textfield; }
.cg-hsl-val::-webkit-inner-spin-button, .cg-hsl-val::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* 底部操作栏 */
.cg-footer-bar { display: flex; gap: 10px; justify-content: center; padding: 12px 20px; border-top: 1px solid #eee; flex-shrink: 0; }

/* 素材替换网格 */
#replacement-grid { border-top: 1px solid #eee; padding-top: 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px 12px; }
.rep-row { display: flex; flex-direction: column; gap: 6px; padding: 8px; border: 1px solid #e8e8e8; border-radius: 6px; font-size: 12px; background: #fafafa; }
.rep-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rep-rank { font-weight: 600; flex-shrink: 0; }
.rep-timerange { font-size: 11px; color: #888; white-space: nowrap; flex-shrink: 0; }
.rep-select { flex: 1; min-width: 160px; }
.rep-select select { width: 100%; font-size: 12px; padding: 3px 4px; }
.rep-fname { font-size: 11px; color: var(--color-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rep-preview { width: 100%; }
.rep-preview img { width: 100%; border-radius: 4px; background: #eee; display: block; }

.cg-grid h4, .cg-body h4 { font-size: 14px; color: #555; margin: 12px 0 6px; }
.cg-body h4 small { font-weight: normal; color: #999; }
.cg-preview-details { margin: 8px 0; }
.cg-preview-details summary { cursor: pointer; font-size: 13px; font-weight: 600; color: #555; }
.cg-preview-box { text-align: center; max-height: 800px; overflow: auto; margin-top: 6px; }
.cg-preview-box img { max-width: 100%; max-height: 760px; border-radius: 4px; }

/* 操作按钮网格 */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.action-grid .btn { padding: 4px 8px; font-size: 11px; white-space: nowrap; }

/* 分页导航 */
.paging-nav { margin-top: 8px; text-align: center; display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.paging-nav .btn { min-width: 28px; }

/* 复原按钮 */
.cg-reset-btn { background: none; border: none; cursor: pointer; color: #999; padding: 2px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s; }
.cg-reset-btn:hover { color: var(--color-primary); background: #f0f0ff; }
.cg-reset-all { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; background: none; border: 1px solid #ddd; border-radius: 4px; padding: 4px 10px; cursor: pointer; font-size: 12px; color: #666; transition: all 0.15s; }
.cg-reset-all:hover { border-color: var(--color-primary); color: var(--color-primary); background: #f0f0ff; }

/* 显眼保存按钮 */
.btn.save-all { background: #27ae60; color: white; font-weight: 600; box-shadow: 0 2px 8px rgba(39,174,96,0.3); padding: 8px 20px; }
.btn.save-all:hover { background: #219a52; }


/* 区域标题行 */
.cg-section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cg-section-header h3 { font-size: 16px; color: #333; margin: 0; }
.cg-section-header h4 { margin: 0; }

/* 提交微调按钮 */
.btn.submit-finetune { background: var(--color-primary); color: white; font-weight: 600; box-shadow: 0 2px 8px rgba(200, 135, 107, 0.3); padding: 8px 20px; }
.btn.submit-finetune:hover:not(:disabled) { background: var(--color-primary-dark); }
