:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1f2533;
  --muted: #6b7280;
  --line: #e5e8ef;
  --brand: #3b5bdb;
  --brand-soft: #e7ecff;
  --ok: #2f9e44;
  --warn: #e8590c;
  --shadow: 0 2px 10px rgba(20,30,60,.06);
  --radius: 12px;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 14px; }
a { color: var(--brand); }
/* 确保带 hidden 属性的元素（弹窗遮罩 / 提示条）真正隐藏，避免被类样式 display 覆盖 */
[hidden] { display: none !important; }

/* 登录 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #4c6ef5, #7048e8); }
.login-card { background: #fff; width: 340px; padding: 32px 28px; border-radius: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.2); text-align: center; }
.login-logo { font-size: 44px; }
.login-card h1 { margin: 6px 0 2px; font-size: 22px; }
.login-sub { color: var(--muted); margin: 0 0 18px; }
.login-card label { display: block; text-align: left; margin: 12px 0; color: var(--muted); font-size: 13px; }
.login-card input { width: 100%; margin-top: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.err { color: #e03131; min-height: 18px; font-size: 13px; margin: 8px 0 0; }
.login-tip { margin-top: 18px; font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 8px; padding: 10px; line-height: 1.7; }

/* 顶栏 */
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.brand { font-weight: 700; font-size: 16px; }
.user-box { display: flex; align-items: center; gap: 12px; color: var(--muted); }
#who { font-size: 13px; }

/* 布局 */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidenav { width: 188px; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; flex-shrink: 0; }
.sidenav button { display: block; width: 100%; text-align: left; border: none; background: transparent; padding: 11px 14px; border-radius: 9px; color: var(--ink); font-size: 14px; cursor: pointer; margin-bottom: 4px; }
.sidenav button:hover { background: var(--bg); }
.sidenav button.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.content { flex: 1; padding: 20px 24px; overflow: auto; }

/* 通用 */
h2.page-title { margin: 0 0 4px; font-size: 19px; }
.page-desc { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.btn { background: var(--brand); color: #fff; border: none; padding: 9px 16px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn:hover { filter: brightness(1.05); }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); padding: 7px 12px; border-radius: 8px; cursor: pointer; }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: #e03131; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
label.fld { display: block; margin: 10px 0; color: var(--muted); font-size: 13px; }
input, select, textarea { width: 100%; margin-top: 5px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; }
.fld select[multiple] { min-height: 132px; padding: 4px; }
.fld select[multiple] option { padding: 4px 6px; border-radius: 4px; }
input[type="date"] { color: var(--ink); background: var(--panel); cursor: pointer; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13px; }
th { background: var(--bg); color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* 状态徽章 */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; }
.badge.todo { background: #fff0e6; color: var(--warn); }
.badge.doing { background: var(--brand-soft); color: var(--brand); }
.badge.done { background: #e6fcf0; color: var(--ok); }

/* 甘特图 */
.gantt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--line); border-radius: 20px; cursor: pointer; font-size: 13px; background: var(--panel); user-select: none; }
.chip input { width: auto; margin: 0; }
.chip .dot { width: 10px; height: 10px; border-radius: 3px; }
.gantt-scroll { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.gantt-inner { position: relative; }
.gantt-header { display: flex; position: sticky; top: 0; background: var(--bg); border-bottom: 1px solid var(--line); z-index: 5; }
.gantt-head-label { width: 220px; flex-shrink: 0; padding: 10px 12px; font-weight: 600; color: var(--muted); border-right: 1px solid var(--line); }
.gantt-months { position: relative; height: 38px; }
.gantt-month { position: absolute; top: 0; height: 38px; border-left: 1px solid var(--line); padding: 10px 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.gantt-row { display: flex; border-bottom: 1px solid var(--line); }
.gantt-row:hover { background: #fafbff; }
.gantt-label { width: 220px; flex-shrink: 0; padding: 10px 12px; border-right: 1px solid var(--line); position: sticky; left: 0; background: var(--panel); z-index: 4; cursor: pointer; }
.gantt-label:hover { background: var(--brand-soft); }
.gantt-row:hover .gantt-label { background: #fafbff; }
.gantt-label .t { font-weight: 600; }
.gantt-label .s { color: var(--muted); font-size: 12px; margin-top: 3px; }
.gantt-track { position: relative; }
.gantt-bar { position: absolute; top: 9px; height: 26px; border-radius: 7px; color: #fff; font-size: 12px; display: flex; align-items: center; padding: 0 8px; cursor: pointer; white-space: nowrap; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.gantt-bar:hover { filter: brightness(1.06); }
.month-line { position: absolute; top: 0; bottom: 0; border-left: 1px dashed #eef0f5; }

/* 工作流甘特图 - 日历日期 / 周末 / 节假日 */
.gantt-months { position: relative; height: 52px; }
.wf-t { display: block; font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.3; }
.wf-d { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }
.wf-holiday { background: #fff5f5 !important; }
.wf-holiday .wf-t, .wf-holiday .wf-d { color: #c92a2a; }
.wf-weekend { background: #f8f9fa !important; }
.wf-weekend .wf-t, .wf-weekend .wf-d { color: #adb5bd; }
.wf-holiday-line { position: absolute; top: 0; bottom: 0; border-left: 2px solid #ffc9c9; background: rgba(255,200,200,.08); width: 100%; }
.wf-weekend-line { position: absolute; top: 0; bottom: 0; border-left: 1px solid #e9ecef; background: rgba(0,0,0,.02); width: 100%; }

/* 工作流甘特图：按月翻页 + 紧凑行高 */
.wf-mode .gantt-row { min-height: 40px; border-bottom: 1px solid var(--line); }
.wf-mode .gantt-label { padding: 6px 12px; }
.wf-mode .gantt-label .t { font-size: 13px; font-weight: 600; }
.wf-mode .gantt-label .s { margin-top: 2px; font-size: 11px; }
.wf-mode .gantt-label .wf-del { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: 0; color: #e03131; cursor: pointer; padding: 2px 4px; }
.wf-mode .gantt-label:hover .wf-del { opacity: 1; }
.wf-mode .gantt-label .wf-del:hover { color: #b32525; }
.wf-mode .gantt-bar { top: 7px; height: 22px; font-size: 11px; padding: 0 6px; border-radius: 6px; line-height: 22px; }
.wf-mode .gantt-bar:hover { filter: brightness(1.12); box-shadow: 0 3px 10px rgba(0,0,0,.28); transform: translateY(-1px); }
.wf-mode .gantt-months, .wf-mode .gantt-month { height: 46px; }
.wf-mode .gantt-month { padding: 2px 1px; text-align: center; overflow: hidden; }
.wf-mode .gantt-month .wf-dow { display: block; font-size: 10px; color: var(--muted); line-height: 1.1; }
.wf-mode .gantt-month .wf-d { display: block; font-size: 11px; margin-top: 1px; }
.wf-mode .gantt-month .wf-t { display: block; font-size: 10px; color: var(--text); margin-top: 1px; }
.wf-month-nav { display: inline-flex; align-items: center; gap: 8px; }
.wf-month-nav strong { min-width: 96px; text-align: center; }

/* 作品网格 */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.thumb { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.thumb img { width: 100%; height: 130px; object-fit: cover; display: block; }
.thumb .meta { padding: 8px; font-size: 12px; color: var(--muted); }
.chapter-block { margin-bottom: 22px; }
.chapter-block h3 { border-left: 4px solid var(--brand); padding-left: 8px; margin: 0 0 10px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(20,28,50,.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-box { background: #fff; width: 460px; max-width: 92vw; max-height: 88vh; overflow: auto; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-x { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 18px; }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); background: #1f2533; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

/* 剧本/分镜 文档 */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.doc-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.doc-thumb { height: 140px; background: #f0f2f7; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.ver-badge { display: inline-block; font-size: 11px; font-weight: 600; color: var(--brand); background: var(--brand-soft); padding: 1px 7px; border-radius: 10px; vertical-align: middle; margin-left: 4px; }
.hist-list { display: flex; flex-direction: column; }
.hist-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.hist-row:last-child { border-bottom: none; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-file { padding: 20px; color: var(--brand); font-weight: 600; }
.doc-meta { padding: 10px; font-size: 12px; }
.doc-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }

/* 美术参考 */
.refs-layout { display: flex; gap: 16px; align-items: flex-start; }
.board-side { width: 220px; flex-shrink: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.board-head { display: flex; justify-content: space-between; align-items: center; font-weight: 600; margin-bottom: 10px; }
.board-list { display: flex; flex-direction: column; gap: 6px; }
.board-item { padding: 9px 11px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.board-item:hover { background: var(--bg); }
.board-item.active { background: var(--brand-soft); color: var(--brand); border-color: #c7d2fe; font-weight: 600; }
.board-main { flex: 1; min-width: 0; }
.board-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.board-item { position: relative; }
.board-item[draggable="true"] { cursor: grab; }
.board-item[draggable="true"]:active { cursor: grabbing; }
.board-item.dragging { opacity: .4; }
.board-item.drag-over { background: var(--brand-soft); border-color: var(--brand); outline: 1px dashed var(--brand); }
.board-item .bi-edit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: 0; color: var(--brand); cursor: pointer; padding: 2px 4px; }
.board-item:hover .bi-edit { opacity: 1; }
.board-item .bi-del { position: absolute; right: 26px; top: 50%; transform: translateY(-50%); font-size: 12px; opacity: 0; color: #e03131; cursor: pointer; padding: 2px 4px; }
.board-item:hover .bi-del { opacity: 1; }
.board-item .bi-del:hover { color: #b32525; }
.bi-input { font: inherit; padding: 2px 6px; border: 1px solid var(--brand); border-radius: 6px; width: 80%; background: var(--panel); color: var(--ink); }
.board-item.board-root { color: var(--muted); border: 1px dashed var(--line); font-size: 12px; text-align: center; }
.board-item.board-root.drag-over { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }

/* ===== Excel 项目甘特时间轴（改写梁祝） ===== */
.xg-sheet { margin-bottom: 26px; }
.xg-title { font-weight: 600; font-size: 15px; margin: 2px 0 8px; color: var(--ink); }
.xg-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); padding: 6px; }
.xg-grid { display: inline-block; min-width: 100%; }
.xg-head { display: flex; align-items: stretch; border-bottom: 2px solid var(--line); margin-bottom: 4px; }
.xg-row { display: flex; align-items: center; height: 34px; }
.xg-headlabel, .xg-label { width: 184px; min-width: 184px; flex: 0 0 184px; box-sizing: border-box; padding: 4px 8px; }
.xg-headlabel { font-weight: 600; color: #374151; }
.xg-label { border-right: 1px solid #f0f0f0; }
.xg-label .t { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xg-label .s { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xg-col { min-width: 26px; flex: 0 0 26px; box-sizing: border-box; text-align: center; font-size: 10px; color: var(--muted); padding: 2px 0; }
.xg-col .md { font-weight: 600; color: #374151; }
.xg-col .dw { font-size: 9px; }
.xg-weekend { background: #f3f4f6; border-radius: 3px; }
.xg-track { position: relative; height: 30px; }
.xg-bar { position: absolute; top: 4px; height: 22px; border-radius: 5px; color: #fff; font-size: 11px; display: flex; align-items: center; padding: 0 6px; box-sizing: border-box; white-space: nowrap; overflow: hidden; }
.xg-nobar { color: #9ca3af; font-size: 12px; padding-left: 6px; }
.xg-mark { position: absolute; top: -15px; font-size: 10px; color: #b45309; background: #fffbeb; border: 1px solid #fde68a; border-radius: 4px; padding: 0 3px; white-space: nowrap; }
.xg-axis { position: relative; flex: 0 0 auto; height: 26px; }
.xg-tick { position: absolute; top: 0; transform: translateX(-50%); text-align: center; white-space: nowrap; border-left: 1px dashed var(--line); height: 100%; display: flex; flex-direction: column; justify-content: center; padding-left: 3px; }
.xg-tick b { font-size: 10px; color: var(--brand); line-height: 1.15; font-weight: 600; }
.xg-tick small { font-size: 8px; color: var(--muted); line-height: 1.15; }
.xg-baseinfo { font-size: 11px; color: var(--muted); margin: 2px 0 8px; }

/* 循环甘特排期（避节假日）：严格按源表，横轴自然日、纵轴周期 C1-C12 */
.xg-da-legend { margin: 6px 0 10px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.xg-da-leg { display: inline-flex; align-items: center; }
.xg-da-leg i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 5px; }
.xg-da-inner { display: inline-block; min-width: 100%; position: relative; }
.xg-da-mlines { position: absolute; top: 0; bottom: 0; z-index: 0; pointer-events: none; }
.xg-da-mline { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #94a3b8; }
.xg-da-months { position: relative; height: 16px; padding-left: 48px; }
.xg-da-mtag { position: absolute; top: 0; font-size: 10px; font-weight: 600; color: var(--muted); border-left: 2px solid #94a3b8; padding-left: 3px; line-height: 16px; white-space: nowrap; }
.xg-da-dates { position: relative; height: 14px; margin-bottom: 2px; }
.xg-da-date { position: absolute; top: 0; text-align: center; font-size: 8px; color: #9ca3af; line-height: 14px; box-sizing: border-box; }
.xg-da-date.d1 { color: var(--brand); font-weight: 700; }
.xg-da-row { position: relative; height: 22px; border-bottom: 1px solid #f0f0f0; }
.xg-da-row:hover { background: var(--brand-soft); }
.xg-da-rlabel { position: absolute; left: 0; top: 0; bottom: 0; width: 48px; min-width: 48px; box-sizing: border-box; padding: 0 8px; display: flex; align-items: center; font-weight: 600; font-size: 13px; color: var(--ink); border-right: 1px solid var(--line); background: var(--panel); z-index: 2; }
.xg-da-track { position: absolute; top: 0; bottom: 0; }
.xg-da-col { position: absolute; top: 0; bottom: 0; }
.xg-da-col.we { background: #f3f4f6; }
.xg-da-col.hol { background: #fdecec; }
.xg-da-bar { position: absolute; top: 3px; height: 16px; border-radius: 4px; color: #fff; font-size: 8px; line-height: 16px; padding: 0 3px; box-sizing: border-box; white-space: nowrap; overflow: hidden; cursor: default; box-shadow: 0 1px 2px rgba(0,0,0,.15); display: flex; align-items: center; justify-content: center; }
