/* 极简明亮风 (Premium Light Style) */
:root {
    --bg-color: #f8fafc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --brand-primary: #0ea5e9;
    --brand-gradient: linear-gradient(135deg, #0ea5e9, #3b82f6);
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --card-shadow: 0 10px 40px -10px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

body { background: var(--bg-color); color: var(--text-primary); min-height: 100vh; }

/* 登录页 */
.login-body {
    display: flex; align-items: center; justify-content: center;
    background: radial-gradient(circle at top right, #e0f2fe 0%, #f8fafc 100%);
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
.login-glass {
    background: var(--glass-bg); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border); padding: 40px; border-radius: 24px;
    box-shadow: var(--card-shadow); text-align: center;
}
.login-logo { width: 80px; height: 80px; border-radius: 16px; margin-bottom: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.login-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.login-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 30px; }
.input-group { margin-bottom: 20px; }
.input-group input {
    width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid #e2e8f0;
    font-size: 16px; transition: all 0.2s; background: #fff;
}
.input-group input:focus { outline: none; border-color: var(--brand-primary); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1); }
.login-btn {
    width: 100%; padding: 14px; border: none; border-radius: 12px; background: var(--brand-gradient);
    color: #fff; font-size: 16px; font-weight: 600; cursor: pointer; transition: transform 0.2s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(14, 165, 233, 0.3); }
.error-msg { color: #ef4444; font-size: 14px; margin-bottom: 15px; min-height: 20px; }

/* 大屏页 */
.dashboard-body { background: #f1f5f9; display: flex; flex-direction: column; }
.topbar {
    display: flex; justify-content: space-between; align-items: center; padding: 16px 32px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.05); position: sticky; top: 0; z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.nav-logo { width: 36px; height: 36px; border-radius: 8px; }
.nav-brand { font-size: 18px; font-weight: 700; color: #0f172a; letter-spacing: 0.5px; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.nav-time { font-size: 14px; color: var(--text-secondary); font-family: monospace; }
.logout-btn { background: #f1f5f9; border: none; padding: 8px 16px; border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 500; color: var(--text-primary); transition: background 0.2s; }
.logout-btn:hover { background: #e2e8f0; }

.dashboard-main { padding: 32px; max-width: 1400px; margin: 0 auto; width: 100%; flex: 1; }
.loading-state { text-align: center; margin-top: 100px; font-size: 18px; color: var(--text-secondary); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

.dashboard-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.full-width { grid-column: 1 / -1; }
.dash-section { display: flex; flex-direction: column; gap: 16px; }
.section-title { font-size: 18px; font-weight: 600; color: #334155; display: flex; align-items: center; gap: 8px; }

.card-group { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.card-group.two-cols { grid-template-columns: repeat(2, 1fr); }
.mt-4 { margin-top: 16px; }

.stat-card {
    background: #fff; border-radius: 20px; padding: 24px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
    display: flex; flex-direction: column; transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--card-shadow); }
.stat-label { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 12px; }
.stat-value { font-size: 36px; font-weight: 800; color: var(--text-primary); line-height: 1; letter-spacing: -1px; }
.unit { font-size: 16px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; }
.stat-sub { font-size: 13px; color: #94a3b8; margin-top: 8px; }

.highlight-card { background: var(--brand-gradient); color: #fff; }
.highlight-card .stat-label, .highlight-card .stat-value, .highlight-card .stat-sub { color: #fff; }
.highlight-card .stat-sub { opacity: 0.8; }

.warning-card { background: linear-gradient(135deg, #f59e0b, #d97706); }
.warning-card .stat-label, .warning-card .stat-value { color: #fff; }

.large-card { padding: 40px 32px; align-items: center; justify-content: center; text-align: center; }
.large-card .stat-value { font-size: 56px; color: #0f172a; }

.outline-card { border: 2px dashed #e2e8f0; box-shadow: none; background: transparent; }

.script-list { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.script-list li { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #f8fafc; border-radius: 12px; overflow: hidden; }
.script-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 70%; }
.script-count { background: #e0f2fe; color: #0369a1; padding: 4px 10px; border-radius: 20px; font-size: 13px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }

@media (max-width: 1400px) {
    .card-group { grid-template-columns: repeat(2, 1fr); }
    .card-group.two-cols { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .card-group { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .card-group { grid-template-columns: 1fr; }
    .card-group.two-cols { grid-template-columns: 1fr; }
    .topbar { flex-direction: column; gap: 12px; padding: 12px; }
    .topbar-left, .topbar-right { width: 100%; justify-content: center; flex-wrap: wrap; }
    .tabs { flex-wrap: wrap; justify-content: center; width: 100%; }
    .dashboard-main { padding: 16px; }
    .stat-value { font-size: 28px; }
    .nav-time { display: none; }
}

/* Tabs */
.tabs { display: flex; gap: 8px; background: #f1f5f9; padding: 4px; border-radius: 12px; }
.tab-btn { padding: 8px 16px; border: none; background: transparent; border-radius: 8px; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: all 0.2s; }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { background: #fff; color: var(--brand-primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Panels and Tables */
.panel { background: #fff; border-radius: 20px; padding: 24px; box-shadow: var(--card-shadow); }
.panel-header { margin-bottom: 24px; }
.panel-header h2 { font-size: 20px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.panel-header p { font-size: 14px; color: var(--text-secondary); }

.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th { padding: 16px; font-size: 13px; font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid #f1f5f9; white-space: nowrap; }
.data-table td { padding: 16px; border-bottom: 1px solid #f1f5f9; font-size: 14px; color: var(--text-primary); vertical-align: middle; }
.data-table tr:hover td { background: #f8fafc; }

.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }
.font-bold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-gray { color: var(--text-secondary); }
.text-red { color: #ef4444; }

.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; display: inline-block; }
.badge-active { background: #e0f2fe; color: #0369a1; }
.badge-completed { background: #dcfce3; color: #166534; }

.session-cell { max-width: 300px; }
.session-tag { display: inline-block; padding: 4px 8px; background: #f1f5f9; border-radius: 6px; font-size: 12px; margin: 2px; border: 1px solid #e2e8f0; }

.pagination { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 24px; }
.btn-sec { padding: 8px 16px; border: 1px solid #e2e8f0; background: #fff; border-radius: 8px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.btn-sec:hover:not(:disabled) { border-color: var(--brand-primary); color: var(--brand-primary); }
.btn-sec:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==========================================
   ==== Tab 4: 剧本工坊 (Playbook Workshop) ====
   ========================================== */
.workflow-panel {
    background: #fff;
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* 步骤进度条 */
.step-progress-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 20px 0;
    margin-bottom: 20px;
}

.step-progress-bar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 40px;
    right: 40px;
    height: 3px;
    background: #e2e8f0;
    z-index: 1;
    transform: translateY(-50%);
}

.step-item {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #fff;
    padding: 0 10px;
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.3s ease;
    border: 3px solid #fff;
    box-shadow: 0 0 0 1px #e2e8f0;
}

.step-label {
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    transition: all 0.3s ease;
}

/* 步骤状态激活 */
.step-item.active .step-num {
    background: var(--brand-gradient);
    color: #fff;
    box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.2);
    transform: scale(1.1);
}

.step-item.active .step-label {
    color: var(--brand-primary);
    font-weight: 700;
}

/* 步骤状态完成 */
.step-item.completed .step-num {
    background: #dcfce3;
    color: #166534;
    box-shadow: 0 0 0 1px #166534;
}

.step-item.completed .step-label {
    color: #166534;
}

/* 内容布局与表单 */
.workflow-content-box {
    background: #f8fafc;
    border-radius: 16px;
    padding: 24px;
    border: 1px solid #e2e8f0;
    min-height: 300px;
}

.step-view {
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

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

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}

.form-group label .required {
    color: #ef4444;
    margin-left: 2px;
}

.form-group input[type="text"],
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: all 0.2s;
}

.form-group input[type="text"]:focus,
.form-group select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 10px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--brand-gradient);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.25);
}

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

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

/* 结果展示区 */
.divider {
    border: 0;
    height: 1px;
    background: #cbd5e1;
    margin: 24px 0;
}

.subsection-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.help-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.long-textarea {
    width: 100%;
    height: 150px;
    padding: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    resize: vertical;
    outline: none;
    background: #fff;
    line-height: 1.6;
    font-family: inherit;
}

.long-textarea:focus {
    border-color: var(--brand-primary);
}

/* 角色映射网格 */
.char-mapping-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 12px;
}

@media (max-width: 640px) {
    .char-mapping-grid {
        grid-template-columns: 1fr;
    }
}

.char-map-row {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    gap: 8px;
}

.char-map-row input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 13px;
    padding: 2px 0;
}

.map-arrow {
    color: var(--text-secondary);
    font-weight: bold;
    user-select: none;
}

/* 骨架表格专用 input */
#skeleton-tbody input {
    background: transparent;
    border: none;
    outline: none;
    width: 100%;
    padding: 4px;
    font-size: 13px;
    border-radius: 4px;
    transition: all 0.2s;
}

#skeleton-tbody input:focus {
    background: #fff;
    box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

/* 切片进度与微波进度条 */
.loading-workflow {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 16px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.progress-bar-container {
    width: 100%;
    max-width: 400px;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar-fill {
    height: 100%;
    background: var(--brand-gradient);
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* 拼接路书展示卡片 */
.playbook-nodes-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 16px;
    max-height: 500px;
    overflow-y: auto;
    padding-right: 8px;
}

.playbook-node-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.node-card-header {
    background: #f1f5f9;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
    gap: 12px;
}

.node-card-idx {
    background: var(--text-primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
}

.node-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    flex: 1;
}

.node-card-anchor {
    font-size: 11px;
    color: var(--brand-primary);
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    padding: 2px 8px;
    border-radius: 20px;
}

.node-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.node-detail-section h5 {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-detail-section p {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.node-detail-section .english-passage {
    background: #fafafa;
    border-left: 3px solid var(--brand-primary);
    padding: 8px 12px;
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #334155;
    line-height: 1.6;
}

.node-detail-section .summon-quote {
    color: #0369a1;
    font-weight: 500;
    background: #f0f9ff;
    padding: 8px 12px;
    border-radius: 8px;
}

/* 审计批注 */
.audit-comments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.audit-comment-item {
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.audit-comment-item.error-plot {
    background: #fff5f5;
    border-left-color: #ef4444;
}

.audit-comment-item.error-npc {
    background: #fffbeb;
    border-left-color: #f59e0b;
}

.audit-comment-item.error-legal {
    background: #f0fdf4;
    border-left-color: #22c55e;
}

.audit-comment-meta {
    display: flex;
    gap: 8px;
}

.badge-error-type {
    font-size: 11px;
    background: rgba(0,0,0,0.06);
    color: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
}

.badge-node-idx {
    font-size: 11px;
    background: var(--text-primary);
    color: #fff;
    padding: 2px 6px;
    border-radius: 4px;
}

.audit-comment-text {
    font-size: 13px;
    color: #334155;
    line-height: 1.5;
}

.audit-pass-banner {
    display: flex;
    align-items: center;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 20px;
    border-radius: 12px;
}

/* 最终导出与代码 */
.success-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 20px;
    border-radius: 12px;
}

.success-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #22c55e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.success-text h4 {
    color: #166534;
    font-size: 15px;
    margin-bottom: 2px;
}

.success-text p {
    color: #1e293b;
    font-size: 13px;
}

.code-export-box {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    background: #0f172a;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.code-header {
    background: #1e293b;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #cbd5e1;
    font-size: 13px;
    border-bottom: 1px solid #334155;
}

.code-actions {
    display: flex;
    gap: 8px;
}

.code-pre {
    padding: 20px;
    margin: 0;
    max-height: 600px;
    overflow: auto;
}

#md-code-output, #js-code-output, #code-output {
    color: #f8fafc; /* 针对暗色背景的极高对比度亮色，确保运营人员能够极清晰阅读 */
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-all;
}
