/* ──────────────────────────────────────
   全局样式
   ────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --success-hover: #15803d;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-light: #64748b;
    --text-lighter: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.1);
    --radius: 8px;
    --radius-sm: 4px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ──────────────────────────────────────
   按钮
   ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-family: inherit;
    transition: all .15s;
    white-space: nowrap;
}
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 10px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-hover); }
.btn-warn { background: #f59e0b; color: #fff; }
.btn-warn:hover { background: #d97706; }
.btn-default { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-default:hover { background: #f1f5f9; }
.btn-info { background: #0ea5e9; color: #fff; }
.btn-info:hover { background: #0284c7; }
.btn-ai { background: linear-gradient(135deg, #7c3aed, #a855f7); color: #fff; border-color: transparent; }
.btn-ai:hover { opacity: .92; }
/* 生成中：灰调禁用，覆盖渐变背景，一眼可辨 */
.btn-ai:disabled { background: #cbd5e1 !important; color: #64748b; border-color: #cbd5e1; opacity: 1; cursor: not-allowed; box-shadow: none; }

/* 查看弹框内的 markdown 文档容器（标签样式复用 .md-preview） */
.doc-view { padding: 4px 16px 16px; max-height: 78vh; overflow: auto; }

/* ──────────────────────────────────────
   项目列表页
   ────────────────────────────────────── */
.page-projects {
    max-width: 1920px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── AI 任务弹窗列表 ── */
.ai-task-modal-body {
    padding: 12px 16px;
    max-height: calc(100% - 0px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── 优化备注弹窗 ── */
.remark-modal {
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
}
.remark-textarea {
    flex: 1 1 auto;
    width: 100%;
    min-height: 240px;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
    color: var(--text);
    outline: none;
    box-sizing: border-box;
}
.remark-textarea:focus {
    border-color: var(--primary);
}
.remark-status {
    margin-top: 8px;
    font-size: 12px;
    min-height: 16px;
    color: var(--text-lighter);
}
.remark-status.saving { color: var(--text-light); }
.remark-status.saved { color: #16a34a; }
.remark-status.error { color: #dc2626; }

/* ── CodeAgent 设备选择框 / 提示语模态 ── */
.worker-select { padding: 16px 18px; }
.worker-hint { margin: 0 0 12px; color: var(--text-light); font-size: 13px; line-height: 1.5; }
.worker-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.worker-opt {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; transition: border-color .15s, background .15s; user-select: none;
}
.worker-opt:hover { border-color: var(--primary); }
.worker-opt input { width: 16px; height: 16px; accent-color: var(--primary); flex: 0 0 auto; }
.worker-opt.selected,
.worker-opt:has(input:checked) { border-color: var(--primary); background: rgba(37, 99, 235, .06); }
.worker-meta { display: flex; flex-direction: column; gap: 2px; }
.worker-name { font-weight: 600; color: var(--text); }
.worker-id { font-size: 12px; color: var(--text-lighter); }
.worker-pick { margin-bottom: 10px; font-size: 13px; color: var(--text-light); }
.worker-pick b { color: var(--text); }

/* ── 任务表（codeagent 派发记录）── */
.ca-task-list { padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; max-height: 70vh; overflow-y: auto; }
.ca-task-item {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.ca-task-item:hover { border-color: var(--primary); background: rgba(37, 99, 235, .04); }
.ca-task-row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ca-task-action {
    font-weight: 600; color: #fff; background: var(--primary);
    padding: 2px 10px; border-radius: 999px; font-size: 12px;
}
.ca-task-worker { font-size: 12px; color: var(--text-lighter); }
.ca-task-prompt {
    margin: 8px 0 6px; font-size: 13px; color: var(--text);
    line-height: 1.5; word-break: break-all;
}
.ca-task-meta { font-size: 12px; color: var(--text-lighter); }
.ca-detail { padding: 16px 18px; max-height: 74vh; overflow-y: auto; }
.ca-detail-field { margin-bottom: 14px; }
.ca-detail-field > label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-light);
    margin-bottom: 4px;
}
.ca-detail-field > div { font-size: 13px; color: var(--text); line-height: 1.5; }
.ca-pre {
    margin: 0; padding: 10px 12px; background: #f8fafc; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.6; color: var(--text);
    white-space: pre-wrap; word-break: break-all; max-height: 38vh; overflow: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.ai-task-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    background: #fff;
}
.ai-task-row1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.ai-task-kind {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
}
.ai-task-status {
    font-size: 12px;
    color: var(--text-light);
}
.ai-task-proj {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
    word-break: break-all;
}
.ai-task-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-lighter);
    margin-bottom: 10px;
}
.ai-task-actions {
    display: flex;
    justify-content: flex-end;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-header h1 {
    font-size: 24px;
    font-weight: 700;
}

/* ── 状态 tab ── */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
}
.tab {
    padding: 8px 18px;
    border: 1px solid var(--border);
    background: #fff;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    color: var(--text-light);
    transition: all .15s;
}
.tab:hover { color: var(--text); }
.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}
.tab-count {
    font-size: 12px;
    opacity: .8;
}

/* ── 状态徽章 ── */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}
.status-badge.active {
    background: #dcfce7;
    color: #15803d;
}
.status-badge.coding {
    background: #dbeafe;
    color: #1d4ed8;
}
.status-badge.done {
    background: #e2e8f0;
    color: #64748b;
}
.status-badge.abandoned {
    background: #fee2e2;
    color: #b91c1c;
}

.table-wrap {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    background: #f1f5f9;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.data-table tr:hover { background: #f8fafc; }
.empty-row {
    text-align: center;
    color: var(--text-lighter);
    padding: 40px !important;
}

/* 放弃原因列：默认隐藏，仅「放弃」tab（表格加 .show-reason）显示 */
.col-reason { display: none; }
#projectTable.show-reason .col-reason { display: table-cell; }
#projectTable.show-reason th.col-reason { background: #f1f5f9; }

.action-cell {
    display: flex;
    gap: 6px;
}

/* ──────────────────────────────────────
   弹窗
   ────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: #fff;
    border-radius: var(--radius);
    width: 90%;
    max-width: 480px;
    box-shadow: var(--shadow-md);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    cursor: pointer;
    font-size: 24px;
    color: var(--text-lighter);
    line-height: 1;
}
.modal-body { padding: 20px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 13px;
}
.form-group .req { color: var(--danger); }
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus,
.form-group textarea:focus { border-color: var(--primary); }

/* ──────────────────────────────────────
   管理页面
   ────────────────────────────────────── */
.manage-app {
    height: 100vh;
    height: 100dvh; /* 移动端地址栏动态高度，避免底部被遮挡 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.manage-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    height: 52px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.back-link {
    color: var(--text-light);
    text-decoration: none;
    font-size: 13px;
    transition: color .15s;
}
.back-link:hover { color: var(--primary); }
.header-sep { color: var(--border); }
.header-title { font-weight: 600; font-size: 15px; }
.header-right { display: flex; gap: 8px; align-items: center; }

/* 目录下拉选择：桌面端隐藏，手机端（media query 内）显示，替代左侧目录栏 */
.section-select {
    display: none;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    outline: none;
    max-width: 180px;
}
.section-select:focus { border-color: var(--primary); }

.manage-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ──────────────────────────────────────
   左侧目录
   ────────────────────────────────────── */
.sidebar {
    width: 200px;
    background: #fff;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.sidebar-title {
    padding: 16px 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-lighter);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.nav-list {
    list-style: none;
    flex: 1;
}
.nav-item {
    padding: 12px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-light);
    border-left: 3px solid transparent;
    transition: all .15s;
}
.nav-item:hover {
    background: #f8fafc;
    color: var(--text);
}
.nav-item.active {
    background: #eff6ff;
    color: var(--primary);
    border-left-color: var(--primary);
    font-weight: 600;
}
.nav-icon { font-size: 16px; }

/* ──────────────────────────────────────
   右侧操作区
   ────────────────────────────────────── */
.content-area {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.section-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-title {
    font-weight: 600;
    font-size: 15px;
}
.toolbar-actions {
    display: flex;
    gap: 6px;
}
.sub-toolbar { padding: 6px 12px; }

.item-name-input {
    flex: 1;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    outline: none;
    max-width: 300px;
}
.item-name-input:focus { border-color: var(--primary); }

/* ──────────────────────────────────────
   编辑器
   ────────────────────────────────────── */
.editor-wrap {
    flex: 1;
    overflow: hidden;
    display: flex;
}
.md-editor {
    flex: 1;
    border: none;
    outline: none;
    padding: 16px 20px;
    font-family: "Fira Code", "Consolas", "Courier New", monospace;
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    background: var(--bg);
    color: var(--text);
    tab-size: 4;
}
.md-editor::placeholder { color: var(--text-lighter); }

/* ──────────────────────────────────────
   分栏布局
   ────────────────────────────────────── */
.split-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}
.split-left {
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.split-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
}

.item-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}
.item-entry {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .15s;
}
.item-entry:hover { background: #f8fafc; }
.item-entry.active {
    background: #eff6ff;
    border-left-color: var(--primary);
}
.item-entry .item-entry-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.item-entry .del-btn {
    opacity: 0;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    transition: opacity .15s;
}
.item-entry:hover .del-btn { opacity: 1; }

.empty-list-hint {
    text-align: center;
    color: var(--text-lighter);
    padding: 20px;
    font-size: 13px;
}

/* ──────────────────────────────────────
   @提及下拉框
   ────────────────────────────────────── */
.mention-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 280px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 9999;
}
.mention-search-hint {
    padding: 6px 12px;
    font-size: 11px;
    color: var(--text-lighter);
    border-bottom: 1px solid var(--border);
}
.mention-group {
    font-size: 11px;
    color: var(--text-lighter);
    padding: 4px 12px;
    background: #f8fafc;
    font-weight: 600;
}
.mention-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    transition: background .1s;
}
.mention-item:hover,
.mention-item.selected {
    background: #eff6ff;
    color: var(--primary);
}

/* ──────────────────────────────────────
   Toast
   ────────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #1e293b;
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    z-index: 10000;
    box-shadow: var(--shadow-md);
    animation: toastIn .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ──────────────────────────────────────
   Markdown 预览
   ────────────────────────────────────── */
.md-preview {
    flex: 1;
    padding: 20px 28px;
    overflow-y: auto;
    background: #fff;
    line-height: 1.8;
    font-size: 14px;
}
.md-preview h1 { font-size: 1.6em; margin: 18px 0 10px; font-weight: 700; border-bottom: 2px solid var(--border); padding-bottom: 6px; }
.md-preview h2 { font-size: 1.35em; margin: 16px 0 8px; font-weight: 600; }
.md-preview h3 { font-size: 1.15em; margin: 12px 0 6px; font-weight: 600; }
.md-preview h4 { font-size: 1em; margin: 10px 0 4px; font-weight: 600; }
.md-preview p  { margin: 8px 0; }
.md-preview pre { background: #f1f5f9; padding: 12px 14px; border-radius: 6px; overflow-x: auto; margin: 10px 0; }
.md-preview code { background: #f1f5f9; padding: 2px 6px; border-radius: 3px; font-family: "Fira Code","Consolas",monospace; font-size: .9em; }
.md-preview pre code { background: none; padding: 0; }
.md-preview table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.md-preview th, .md-preview td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.md-preview th { background: #f8fafc; font-weight: 600; }
.md-preview ul, .md-preview ol { padding-left: 24px; margin: 8px 0; }
.md-preview li { margin: 4px 0; }
.md-preview blockquote { border-left: 3px solid var(--primary); padding-left: 14px; color: var(--text-light); margin: 10px 0; }
.md-preview hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-preview a { color: var(--primary); text-decoration: none; }
.md-preview strong { font-weight: 600; }
/* Mermaid 图表容器：居中、限宽、浅底，渲染失败时仍可读 */
.md-preview .mermaid {
    text-align: center;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
}

/* ──────────────────────────────────────
   Layui layer 表单
   ────────────────────────────────────── */
.layer-form { padding: 20px; }
.layer-form .form-group { margin-bottom: 16px; }
.layer-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 13px; color: var(--text); }
.layer-form .req { color: var(--danger); }
.layer-form input,
.layer-form textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: 4px; font-size: 14px; outline: none; font-family: inherit;
    transition: border-color .15s; box-sizing: border-box;
}
.layer-form input:focus,
.layer-form textarea:focus { border-color: var(--primary); }

/* 模板 4-tab 模态编辑器 */
.tpl-editor { display: flex; flex-direction: column; height: 100%; padding: 0; }
.tpl-tabs {
    display: flex; gap: 0; border-bottom: 1px solid var(--border);
    background: #f8fafc; padding: 0 12px; flex-shrink: 0;
}
.tpl-tab {
    padding: 12px 18px; cursor: pointer; font-size: 14px; color: var(--text-light);
    border-bottom: 2px solid transparent; transition: all .15s; user-select: none;
}
.tpl-tab:hover { color: var(--primary); }
.tpl-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tpl-textarea {
    flex: 1; width: 100%; border: none; outline: none; resize: none;
    padding: 16px 18px; font-size: 14px; line-height: 1.7;
    font-family: "Fira Code", "Consolas", "Microsoft YaHei", monospace;
    box-sizing: border-box; color: var(--text);
}
.tpl-status {
    flex-shrink: 0; padding: 6px 18px; font-size: 12px; color: var(--text-light);
    border-top: 1px solid var(--border); background: #f8fafc; min-height: 28px;
}

/* 通用表单控件（select 复用） */
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    transition: border-color .15s;
    box-sizing: border-box;
    background: #fff;
    color: var(--text);
}
.form-control:focus { border-color: var(--primary); }

/* ──────────────────────────────────────
   滚动条
   ────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ──────────────────────────────────────
   需求变更页（/require/<pid>）
   ────────────────────────────────────── */
.require-app { background: var(--bg); }

/* 顶部沿用工作机徽标 */
.worker-badge {
    display: inline-flex;
    align-items: center;
    max-width: 260px;
    padding: 4px 10px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--primary);
    background: rgba(37, 99, 235, .08);
    border: 1px solid rgba(37, 99, 235, .25);
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.worker-badge.empty {
    color: var(--text-light);
    background: #f1f5f9;
    border-color: var(--border);
}

/* 左侧目录加宽，容纳状态与列表 */
.require-sidebar { width: 240px; }
.require-sidebar .req-status {
    padding: 10px 16px;
    margin: 0 12px 6px;
    font-size: 12px;
    color: var(--text-light);
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    line-height: 1.5;
}
.require-sidebar .req-list {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px 12px;
}

/* 需求变更列表项（复用 nav-item 视觉） */
.req-item {
    padding: 11px 12px;
    margin-bottom: 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    border-radius: var(--radius-sm);
    border-left: 3px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
}
.req-item:hover { background: #f8fafc; }
.req-item.active {
    background: #eff6ff;
    border-left-color: var(--primary);
}
.req-item-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.req-item.active .req-item-title { color: var(--primary); }
.req-item-sub {
    font-size: 11.5px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 右侧面板 */
.req-panel { background: transparent; }
.save-hint {
    font-size: 12px;
    color: var(--text-light);
    margin-right: 4px;
    white-space: nowrap;
}

/* 历史详情 */
.hist-detail {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.hist-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.hist-label {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.hist-content {
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
}
.hist-result {
    font-family: "Fira Code", "Consolas", "Courier New", monospace;
    font-size: 12.5px;
    background: #0f172a;
    color: #e2e8f0;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    max-height: 360px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.hist-status {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    background: #f1f5f9;
    color: var(--text-light);
}
.hist-status.st-waiting { background: #f1f5f9; color: #64748b; }
.hist-status.st-running { background: rgba(37, 99, 235, .1); color: var(--primary); }
.hist-status.st-done    { background: rgba(22, 163, 74, .12); color: var(--success); }
.hist-status.st-failed,
.hist-status.st-error   { background: rgba(220, 38, 38, .12); color: var(--danger); }

/* ──────────────────────────────────────
   移动端适配（≤768px：手机 / 小平板竖屏）
   ────────────────────────────────────── */
@media (max-width: 768px) {
    /* 所有 layer 弹窗在手机上不超过视口宽度，避免溢出 */
    .layui-layer { max-width: calc(100vw - 16px) !important; }
    .layui-layer-page .layui-layer-content { width: 100% !important; }

    /* 列表页：收窄留白 */
    .page-projects { padding: 16px 12px; }
    .page-header { flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
    .page-header h1 { font-size: 20px; }
    /* 行内 flex 按钮组允许换行，避免溢出 */
    .page-header > div[style*="display:flex"] { flex-wrap: wrap; width: 100%; }
    .page-header .btn { flex: 1 1 auto; justify-content: center; }

    /* tab 行可换行 */
    .tabs { flex-wrap: wrap; }
    .tabs .tab { flex: 1 1 auto; text-align: center; }

    /* ── 列表页：窄屏由表格转「卡片」，一行一张卡，避免横向滚动 ── */
    .table-wrap { overflow: visible; background: transparent; box-shadow: none; border-radius: 0; }
    .data-table { border-collapse: separate; }
    .data-table thead { display: none; }              /* 表头隐藏，字段名改由每格 data-label 显示 */
    .data-table, .data-table tbody { display: block; width: 100%; }
    .data-table tr {
        display: flex;
        flex-direction: column;
        background: var(--card-bg);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: var(--shadow);
        margin-bottom: 14px;
        overflow: hidden;
    }
    .data-table tr:hover { background: var(--card-bg); }
    /* 卡片头部：项目名称（标题）+ 状态（徽标）置顶 */
    .data-table td[data-label="项目名称"] {
        order: 1;
        background: #f8fafc;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
        font-weight: 600;
    }
    .data-table td[data-label="项目名称"]::before { display: none; }
    .data-table td[data-label="状态"] {
        order: 2;
        border-bottom: 1px solid var(--border);
        justify-content: flex-end;
    }
    .data-table td[data-label="状态"]::before { display: none; }
    .data-table td {
        order: 5;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: 9px 14px;
        border-bottom: 1px dashed var(--border);
        white-space: normal;
        text-align: right;
        word-break: break-word;
    }
    .data-table td[data-label="ID"] { display: none; }   /* 移动端卡片隐藏 ID 列，更清爽 */
    .data-table td::before {
        content: attr(data-label);
        flex: 0 0 auto;
        font-size: 12px;
        font-weight: 600;
        color: var(--text-light);
        text-align: left;
    }
    /* 放弃原因列：默认隐藏，仅「放弃」tab 显示 */
    #projectTable .col-reason { display: none; }
    #projectTable.show-reason .col-reason { display: flex; }
    /* 操作列：不显示字段名，按钮换行铺满一整行 */
    .data-table td.cell-actions { order: 9; flex-direction: column; align-items: stretch; border-bottom: none; }
    .data-table td.cell-actions::before { display: none; }
    .action-cell { flex-wrap: wrap; gap: 6px; }
    .action-cell .btn { flex: 1 1 auto; justify-content: center; }
    /* 空状态：保持整行居中 */
    .data-table td.empty-row { display: block; text-align: center; order: 5; }
    .data-table td.empty-row::before { display: none; }

    /* 弹窗底部按钮换行 */
    .modal-footer { flex-wrap: wrap; }
    .modal-footer .btn { flex: 1 1 auto; justify-content: center; }

    /* 管理页：左侧竖栏 → 顶部横向 tab 条 */
    .manage-header { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 8px; }
    .manage-header .header-right { flex-wrap: wrap; }
    .manage-header .btn { flex: 1 1 auto; justify-content: center; }

    .manage-body { flex-direction: column; }

    /* 目录：手机端隐藏左侧栏，改用顶部右上角下拉选择 */
    .sidebar { display: none; }
    .section-select { display: block; flex: 1 1 100%; max-width: none; order: -1; }
    .content-area { min-height: 0; }

    /* 需求变更页：左侧列表在手机端转为顶部横向可滚条（不能隐藏，否则丢失入口） */
    .require-sidebar {
        display: flex;
        width: 100%;
        flex-direction: row;
        align-items: stretch;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow: visible;
        flex-shrink: 0;
    }
    .require-sidebar .sidebar-title,
    .require-sidebar .req-status { display: none; }
    .require-sidebar .req-list {
        display: flex;
        flex-direction: row;
        flex: 1;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 8px;
        gap: 8px;
    }
    .require-sidebar .req-item {
        min-width: 132px;
        margin-bottom: 0;
    }
    .require-app .panel-toolbar { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
    .require-app .panel-title { flex: 1 1 100%; }
    .require-app .toolbar-actions { width: 100%; flex-wrap: wrap; }
    .require-app .toolbar-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* 区块工具栏：标题占满一行，按钮换行到下一行 */
    .panel-toolbar { flex-wrap: wrap; gap: 6px; padding: 10px 12px; }
    .panel-title { flex: 1 1 100%; }
    .toolbar-actions { width: 100%; flex-wrap: wrap; }
    .toolbar-actions .btn { flex: 1 1 auto; justify-content: center; }

    /* 编辑器字号 ≥16px，避免 iOS 聚焦时自动放大 */
    .md-editor { font-size: 16px; padding: 12px 14px; }

    /* 模板编辑器内输入框占满 */
    .item-name-input { max-width: 100%; }

    /* 编辑页 tab（模板 4-tab）：自动换行 + 平分宽度，不再横向滚动 */
    .tpl-tabs { flex-wrap: wrap; padding: 0 6px; }
    .tpl-tab {
        flex: 1 1 auto;
        text-align: center;
        padding: 10px 8px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* markdown 预览收窄内边距 */
    .md-preview { padding: 16px; font-size: 14px; }
    .md-preview h1 { font-size: 1.5em; }
    .doc-view { padding: 4px 12px 12px; }
}

/* 超小屏（≤480px）进一步收敛 */
@media (max-width: 480px) {
    .page-header h1 { font-size: 18px; }
    .md-editor { font-size: 16px; }
}

