:root {
  --bg: #f3f5f9;
  --panel: #ffffff;
  --line: #e3e8f0;
  --text: #1f2a3d;
  --muted: #74809a;
  --brand: #2350c4;
  --brand-2: #16408f;
  --accent: #1d9e74;
  --danger: #d64545;
  --warn: #d98a1f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 32, 64, 0.08), 0 4px 16px rgba(16, 32, 64, 0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
}

/* ---------- 整体布局：左侧导航 + 右侧内容 ---------- */
.app-layout { display: flex; min-height: 100vh; align-items: stretch; }
.sidebar {
  width: 220px; flex: 0 0 220px;
  background: #fff; border-right: 1px solid var(--line);
  padding: 16px 12px 24px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto; box-sizing: border-box;
  z-index: 40;
}
.sidebar .brand { margin-bottom: 18px; padding: 0 4px; }
.sidebar .brand h1 { font-size: 15px; letter-spacing: 0; }
.ver-tag { font-size: 11px; color: var(--muted); padding: 0 6px 12px; }
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  background: linear-gradient(115deg, #173a8e 0%, #2350c4 55%, #2f6ad8 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 10px rgba(16, 32, 64, 0.22);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: #fff; color: var(--brand);
  display: grid; place-items: center;
  font-size: 22px; font-weight: 800; flex: none;
}
.brand h1 { margin: 0; font-size: 18px; letter-spacing: 1px; white-space: nowrap; }
.brand .sub { margin: 0; font-size: 11px; opacity: 0.8; letter-spacing: 2px; }
.topbar-right { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; justify-content: flex-end; }
.undo-btn {
  background: rgba(255, 255, 255, 0.16) !important;
  border: 1px solid rgba(255, 255, 255, 0.35) !important;
  color: #fff !important;
  border-radius: 8px !important;
  white-space: nowrap;
}
.undo-btn:hover { background: rgba(255, 255, 255, 0.28) !important; color: #fff !important; }
.search-wrap { flex: 1; max-width: 420px; min-width: 140px; position: relative; }
#globalSearch {
  width: 100%; padding: 8px 14px; border: none; border-radius: 20px;
  background: rgba(255, 255, 255, 0.16); color: #fff; outline: none;
  font-size: 13px;
}
#globalSearch::placeholder { color: rgba(255, 255, 255, 0.65); }
#globalSearch:focus { background: rgba(255, 255, 255, 0.26); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 80;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(16, 32, 64, 0.18); overflow: hidden; color: var(--text);
}
.search-results.hidden { display: none; }
.sr-item { padding: 9px 12px; border-bottom: 1px solid #f0f2f7; cursor: pointer; }
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: #f2f6ff; }
.sr-t { font-size: 13px; font-weight: 600; }
.sr-m { font-size: 11px; color: var(--muted); margin-top: 2px; }
.sr-empty { padding: 14px; text-align: center; color: var(--muted); font-size: 13px; }
.presence { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.presence .chip {
  background: rgba(255, 255, 255, 0.18); border-radius: 14px;
  padding: 3px 10px; font-size: 12px; display: inline-flex; align-items: center; gap: 5px;
}
.presence .chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #56e39f; }
.me { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.me input {
  width: 110px; padding: 6px 10px; border: none; border-radius: 8px;
  background: rgba(255, 255, 255, 0.16); color: #fff; outline: none; font-size: 13px;
}
.me input::placeholder { color: rgba(255, 255, 255, 0.6); }

/* ---------- 导航 ---------- */
.nav {
  display: flex; flex-direction: column; gap: 18px; padding: 0;
  overflow: visible;
}
.nav-group { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.nav-group-label {
  font-size: 11px; color: var(--muted); letter-spacing: 2px;
  padding: 0 8px 4px; user-select: none; white-space: nowrap;
}
.nav-group + .nav-group { padding-top: 14px; border-top: 1px solid var(--line); }
.nav button {
  border: 1px solid transparent; background: transparent; color: var(--text);
  padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: all 0.15s; white-space: nowrap; text-align: left; width: 100%;
}
.nav button:hover { background: #eef2fb; color: var(--brand); }
.nav button.active {
  background: var(--brand); color: #fff; border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(35, 80, 196, 0.28);
}
#permTip {
  display: none;
  max-width: none;
  margin: 10px 24px 0;
  padding: 10px 14px;
  background: #fff7e6;
  border: 1px solid #f0c36d;
  border-radius: 10px;
  color: #7a5a00;
  font-size: 13px;
  line-height: 1.6;
}
.me-name { font-weight: 700; color: var(--brand); }
.login-mask {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #eef3ff, #f7f9ff);
  display: flex; align-items: center; justify-content: center;
}
.login-mask.hidden { display: none; }
.login-box {
  width: 340px; background: #fff; border-radius: 16px; padding: 34px 32px 28px;
  box-shadow: 0 16px 50px rgba(35, 80, 196, .16); text-align: center;
}
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px;
  background: var(--brand); color: #fff; font-size: 26px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.login-box h2 { margin: 0 0 4px; font-size: 20px; }
.login-box .desc { color: var(--muted); font-size: 12.5px; margin: 0 0 18px; }
.login-box input {
  width: 100%; box-sizing: border-box; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.login-box input:focus { outline: none; border-color: var(--brand); }
.login-err { color: #d64545; font-size: 12.5px; min-height: 18px; margin-bottom: 6px; }
.login-btn { width: 100%; justify-content: center; padding: 10px; font-size: 15px; }
.proj-list {
  max-height: 180px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px;
}
.proj-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; font-size: 13px; cursor: pointer; border-bottom: 1px solid #f0f2f7;
}
.proj-opt:last-child { border-bottom: none; }
.proj-opt:hover { background: #eef2fb; }
.proj-opt.sel { background: #e8f0ff; color: var(--brand); font-weight: 700; }
.proj-opt .desc { font-size: 11px; color: var(--muted); flex: none; }
.todo-hl { background: #fff7d6 !important; box-shadow: inset 3px 0 0 #f0c36d; }

/* ---------- 使用帮助 ---------- */
.help-hero {
  background: linear-gradient(120deg, #173a8e 0%, #2f6ad8 100%);
  color: #fff; border-radius: 14px; padding: 26px 28px; margin-bottom: 18px;
  box-shadow: 0 8px 24px rgba(35, 80, 196, .2);
}
.help-hero h2 { margin: 0 0 8px; font-size: 24px; }
.help-hero .sub { opacity: .92; font-size: 13.5px; line-height: 1.7; max-width: 760px; }
.help-quick { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
.help-quick .q {
  background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 10px; padding: 12px 14px; flex: 1; min-width: 170px;
}
.help-quick .q b { display: block; font-size: 14px; margin-bottom: 4px; }
.help-quick .q span { font-size: 12px; opacity: .92; line-height: 1.6; }
.help-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.help-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  cursor: pointer; transition: all .15s; display: flex; flex-direction: column;
}
.help-card:hover { border-color: var(--brand); box-shadow: 0 6px 18px rgba(35, 80, 196, .12); transform: translateY(-2px); }
.help-card .ic { font-size: 28px; }
.help-card h4 { margin: 8px 0 5px; font-size: 15px; }
.help-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.65; flex: 1; }
.help-card .more { display: inline-block; margin-top: 10px; font-size: 12px; color: var(--brand); font-weight: 700; }
.help-section-title { margin: 24px 0 10px; font-size: 17px; }
.help-faq details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px; }
.help-faq summary { cursor: pointer; font-weight: 700; font-size: 14px; }
.help-faq .a { margin-top: 8px; font-size: 13px; color: var(--text); line-height: 1.75; }
.help-steps { list-style: none; margin: 0; padding: 0; }
.help-steps li { display: flex; gap: 10px; margin-bottom: 9px; font-size: 13.5px; line-height: 1.65; }
.help-steps .n {
  flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 2px;
}
.help-tip { background: #fff7e6; border: 1px solid #f0c36d; border-radius: 8px; padding: 9px 12px; font-size: 12.5px; color: #7a5a00; line-height: 1.65; margin-top: 12px; }

.pie-row { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.pie-wrap { width: 180px; height: 180px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.pie { width: 160px; height: 160px; border-radius: 50%; box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.pie-legend { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.pie-legend-item {
  display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px;
  padding: 6px 10px; border-radius: 8px; transition: background .15s;
}
.pie-legend-item:hover { background: #eef2fb; }
.pie-legend-item i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- 主区域 ---------- */
.main { width: 100%; max-width: none; padding: 18px 24px 60px; }
.view-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.view-title h2 { margin: 0; font-size: 20px; }
.view-title .desc { color: var(--muted); font-size: 12px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar select, .toolbar input[type="text"], .toolbar input[type="search"] {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13px; outline: none;
}
.toolbar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.mselect { position: relative; }
.mselect-btn {
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; font-size: 13px; cursor: pointer; color: var(--text);
}
.mselect-btn .ms-cnt { color: var(--brand); font-weight: 700; }
.mselect-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  min-width: 220px; max-height: 330px; overflow-y: auto; padding: 8px;
}
.mselect-menu.hidden { display: none; }
.mselect-tools { display: flex; gap: 6px; margin-bottom: 6px; }
.mselect-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; border-top: 1px solid var(--line); padding-top: 8px; }
.ms-opt {
  display: flex; align-items: center; gap: 6px; padding: 4px 6px;
  font-size: 13px; cursor: pointer; border-radius: 6px;
}
.ms-opt:hover { background: #f2f6ff; }
.chip-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.type-chip.on, .type-chip.chip-on { background: var(--brand); border-color: var(--brand); color: #fff; }
.type-legend { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.type-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.legend-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
.legend-panel.hidden { display: none; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: all 0.15s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: #fff5f5; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- 仪表盘 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; border-left: 4px solid var(--brand);
}
.stat-card .num { font-size: 30px; font-weight: 800; margin-top: 4px; }
.stat-card .lbl { color: var(--muted); font-size: 12px; }
.stat-card.c-green { border-left-color: var(--accent); }
.stat-card.c-orange { border-left-color: var(--warn); }
.stat-card.c-red { border-left-color: var(--danger); }
.stat-card.c-blue { border-left-color: #3f8cff; }

.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
@media (max-width: 1100px) { .dash-grid { grid-template-columns: 1fr; } }
.panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px;
}
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 44px; gap: 10px; align-items: center; margin-bottom: 8px; cursor: pointer; }
.bar-row .name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: #eef1f7; border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s; }
.bar-row .cnt { font-size: 13px; font-weight: 700; text-align: right; }
.kv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.kv { background: #f7f9fc; border-radius: 8px; padding: 8px 12px; }
.kv .k { color: var(--muted); font-size: 11px; }
.kv .v { font-size: 13px; font-weight: 600; margin-top: 2px; word-break: break-all; }

/* ---------- 看板 ---------- */
.board-wrap { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-col {
  background: #eaeef6; border-radius: 12px; padding: 10px; width: 268px; flex: none;
  min-height: 120px; max-height: calc(100vh - 190px); display: flex; flex-direction: column;
  transition: background 0.15s;
}
.board-col.drag-over { background: #dce6ff; outline: 2px dashed var(--brand); }
.board-col.done { opacity: 0.82; }
.board-col .col-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 10px; }
.col-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,0.12); }
.col-name { font-weight: 700; font-size: 14px; }
.col-cnt { margin-left: auto; background: #fff; border-radius: 10px; padding: 1px 9px; font-size: 12px; color: var(--muted); }
.col-cards { overflow-y: auto; flex: 1; min-height: 40px; }
.card {
  background: #fff; border-radius: 9px; box-shadow: 0 1px 2px rgba(16,32,64,0.1);
  padding: 10px 12px; margin-bottom: 9px; cursor: grab; border-left: 4px solid var(--brand);
  transition: transform 0.12s, box-shadow 0.12s;
}
.card:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,32,64,0.12); }
.card.dragging { opacity: 0.45; }
.card .t { font-weight: 600; font-size: 13px; margin-bottom: 5px; line-height: 1.35; }
.card .badges { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.card .req {
  font-size: 12px; color: #4a5872; background: #f5f7fc; border-radius: 6px;
  padding: 4px 8px; margin-bottom: 6px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card .card-note {
  font-size: 11.5px; color: #8a6d1a; background: #fdf8e7; border-radius: 6px;
  padding: 3px 8px; margin-bottom: 6px; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.badge {
  font-size: 11px; padding: 1px 8px; border-radius: 10px; background: #eef2fb; color: #3b4c76;
  border: 1px solid #dbe4f5; white-space: nowrap;
}
.badge.gray { background: #f0f2f5; color: #5b6472; border-color: #e2e6ec; }
.card .m { font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 210px); }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 640px; }
table.grid th {
  position: sticky; top: 0; background: #f5f7fc; color: #4b5870; text-align: left;
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; font-weight: 600; z-index: 2;
}
table.grid td { padding: 8px 12px; border-bottom: 1px solid #f0f2f7; vertical-align: top; }
table.grid td.nowrap { white-space: nowrap; }
table.grid tr:hover td { background: #f7faff; }
table.grid tr { cursor: pointer; }
/* OA 信息表（项目详情页）：每行 3 组「标签 + 值」，共 8 行；纯展示，不可点击 */
table.oa-grid { min-width: 0; }
table.oa-grid tr, table.oa-grid tr:hover td { cursor: default; }
table.oa-grid tr:hover td { background: transparent; }
table.oa-grid th {
  position: static; width: 92px; max-width: 92px; text-align: right; background: #f7f9fc;
  color: var(--muted); font-weight: 600; white-space: normal; padding: 8px 8px 8px 10px;
  border-bottom: 1px solid #eef1f7; border-right: 1px solid #eef1f7; z-index: auto;
}
table.oa-grid td { padding: 8px 12px 8px 10px; border-bottom: 1px solid #eef1f7; font-weight: 600; word-break: break-all; }
table.oa-grid tr:last-child th, table.oa-grid tr:last-child td { border-bottom: none; }
.col-grip {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 5;
}
.col-grip:hover { background: rgba(35, 80, 196, 0.18); }
.node-tag {
  display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 11px;
  border: 1px solid rgba(0,0,0,0.1); white-space: nowrap;
}
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- 周报 ---------- */
.weekly-group { margin-bottom: 18px; }
.weekly-group h3 {
  font-size: 15px; margin: 0 0 10px; padding: 8px 14px; background: var(--panel);
  border-radius: 8px; box-shadow: var(--shadow); display: flex; align-items: center; gap: 8px;
}
.weekly-row {
  background: var(--panel); border-radius: 10px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.weekly-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; resize: vertical; min-height: 58px; outline: none;
}
.weekly-row textarea:focus { border-color: var(--brand); }
.weekly-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }

/* ---------- 动态 ---------- */
.feed { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px 0; }
.feed-item { display: flex; gap: 12px; padding: 11px 18px; border-bottom: 1px solid #f0f2f7; align-items: baseline; }
.feed-item:last-child { border-bottom: none; }
.feed-actor { font-weight: 700; color: var(--brand); white-space: nowrap; }
.feed-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.feed-detail { flex: 1; }
.feed-actions { display: inline-flex; gap: 6px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 26, 46, 0.45); z-index: 100;
  display: grid; place-items: center; padding: 20px; animation: fadeIn 0.15s;
}
.modal {
  background: #fff; border-radius: 14px; box-shadow: 0 16px 60px rgba(0,0,0,0.28);
  width: min(920px, 96vw); max-height: 92vh; display: flex; flex-direction: column;
  animation: popIn 0.16s;
}
.modal-sm { width: min(520px, 94vw); }
.modal-lg { width: min(1100px, 96vw); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.modal-foot .right { display: flex; gap: 10px; margin-left: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 14px; }
.form-item { display: flex; flex-direction: column; gap: 4px; }
.form-item.wide { grid-column: 1 / -1; }
.form-item label { font-size: 12px; color: var(--muted); }
.form-item input, .form-item select, .form-item textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font: inherit; outline: none;
}
.form-item textarea { min-height: 64px; resize: vertical; }
.form-item input:focus, .form-item select:focus, .form-item textarea:focus { border-color: var(--brand); }
.form-section { margin-bottom: 20px; }
.form-section h4 {
  margin: 0 0 12px; font-size: 13px; color: var(--brand);
  border-left: 3px solid var(--brand); padding-left: 9px; line-height: 1.3;
}
.close-x { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.close-x:hover { color: var(--text); }
.meta-line { color: var(--muted); font-size: 12px; }

/* ---------- 甘特图 ---------- */
.gantt-box {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto; max-height: calc(100vh - 210px); overflow-y: auto;
}
.gantt-head, .g-row { display: flex; min-width: 900px; border-bottom: 1px solid #f0f2f7; }
.gantt-head { position: sticky; top: 0; background: #f5f7fc; z-index: 5; font-weight: 700; }
.g-name-col {
  width: 320px; flex: none; padding: 8px 14px; border-right: 1px solid var(--line);
  position: sticky; left: 0; background: inherit; z-index: 3; overflow: hidden; text-overflow: ellipsis;
}
.g-track-col { position: relative; flex: 1; height: 52px; min-height: 52px; }
.g-row { cursor: pointer; }
.g-row:hover { background: #f7faff; }
.g-row .g-name-col { line-height: 1.3; }
.g-week {
  position: absolute; top: 4px; transform: translateX(-50%); font-size: 10px; color: var(--muted);
  white-space: nowrap;
}
.g-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: #eef1f7; }
.g-bar {
  position: absolute; top: 16px; height: 26px; border-radius: 6px; min-width: 12px;
  font-size: 11px; color: #26324a; padding: 3px 8px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; border: 1px solid rgba(0,0,0,0.12); cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.g-bar:hover { z-index: 4; outline: 2px solid var(--brand); }
.g-overdue { position: absolute; }
.g-today {
  position: absolute; top: 0; bottom: 0; width: 2px; background: #e03131; z-index: 4;
}
.gantt-head .g-today { top: 0; }
.gantt-head .g-week { top: 8px; }
.g-group {
  background: #f0f3f9; font-weight: 700; padding: 7px 16px; position: sticky; left: 0;
  border-bottom: 1px solid var(--line); min-width: 900px;
}
.g-no-start { position: absolute; top: 22px; left: 0; font-size: 11px; color: var(--muted); }
.g-drop-hint { position: absolute; right: 8px; bottom: 2px; font-size: 10px; color: #aab2c5; pointer-events: none; }

/* ---------- 矩阵甘特图 ---------- */
.gantt-scroll2 { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; max-height: calc(100vh - 240px); }
table.gmatrix { border-collapse: collapse; font-size: 11px; min-width: 900px; }
.gmatrix th, .gmatrix td { border: 1px solid #eef1f7; padding: 3px 2px; text-align: center; min-width: 26px; }
.gmatrix th { position: sticky; top: 0; background: #f5f7fc; z-index: 3; font-weight: 600; line-height: 1.25; }
.gmatrix .gm-rowh { text-align: left; min-width: 220px; max-width: 300px; position: sticky; left: 0; background: #fff; z-index: 2; padding: 6px 10px; }
.gmatrix th.gm-rowh { top: 0; background: #f5f7fc; z-index: 4; }
.gcell { cursor: pointer; position: relative; height: 34px; }
.gcell:hover { outline: 2px solid var(--brand); }
.gcell-wknd { background: #f0f1f4; }
.gcell-today { background: #e3edff; }
.gblock { height: 22px; margin: 4px 1px; border-radius: 4px; }
.gflag { position: absolute; right: 1px; top: 0; color: var(--danger); font-size: 10px; }
.gm-legend { display: flex; gap: 16px; align-items: center; padding: 10px 4px; font-size: 12px; color: var(--muted); }
.gm-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: middle; }
.gflag-inline { color: var(--danger); margin-right: 3px; }
.gcell-today-inline, .gcell-wknd-inline { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin: 0 4px; vertical-align: middle; }
.gcell-today-inline { background: #e3edff; border: 1px solid var(--brand); }
.gcell-wknd-inline { background: #f0f1f4; border: 1px solid #dde1e8; }

/* ---------- 日历 ---------- */
.cal2 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal2-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal2-day { min-height: 62px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 5px; }
.cal2-day.off { background: #f6f7fa; }
.cal2-day.hol { background: #fdf0f0; }
.cal2-day.hol .cal2-num { color: #c0392b; }
.cal2-day.today { outline: 2px solid var(--brand); }
.cal2-num { font-size: 12px; font-weight: 700; margin-bottom: 4px; }
.cal2-due { color: var(--danger); font-size: 10px; margin-left: 4px; }
.cal2-conflict { color: #fff; background: #d64545; font-size: 9px; border-radius: 3px; padding: 1px 4px; margin-left: 4px; font-weight: 700; }
.cal2-task { font-size: 10px; color: #fff; border-radius: 4px; padding: 2px 5px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal2-more { font-size: 10px; color: var(--muted); padding-left: 4px; }
.note-insight { margin-top: 12px; background: #fdf8e7; border: 1px solid #f0dfa0; border-radius: 10px; padding: 10px 14px; font-size: 12.5px; color: #7a6500; line-height: 1.8; }

/* ---------- 单页甘特图 ---------- */
.g-single { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.g-left { width: 320px; flex: none; border-right: 1px solid var(--line); background: #fff; max-height: calc(100vh - 280px); overflow-y: auto; }
.g-left-head { position: sticky; top: 0; background: #f5f7fc; font-weight: 700; padding: 9px 12px; border-bottom: 1px solid var(--line); z-index: 2; }
.g-row2 { padding: 8px 12px; border-bottom: 1px solid #f0f2f7; cursor: pointer; }
.g-row2:hover { background: #f7faff; }
.g-timeline { flex: 1; overflow-x: auto; max-height: calc(100vh - 280px); overflow-y: auto; min-width: 720px; }
.g-tl-head { position: sticky; top: 0; background: #f5f7fc; height: 34px; border-bottom: 1px solid var(--line); z-index: 3; }
.g-week2 { position: absolute; top: 10px; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.g-track { position: relative; height: 68px; border-bottom: 1px solid #f0f2f7; cursor: crosshair; }
.g-track:hover { background-color: #fafcff; }
.g-grid2 { position: absolute; top: 0; bottom: 0; width: 1px; background: transparent; }
.g-grid2.wknd { background: #eef0f6; }
.g-grid2.hol { background: #fdeaea; }
.g-weekline { position: absolute; top: 0; bottom: 0; width: 1px; background: #e8ecf3; z-index: 1; }
.g-day2 {
  position: absolute; top: 24px;
  width: 26px; text-align: center; font-size: 10px; color: #9aa4b8; line-height: 16px;
  box-sizing: border-box;
}
.gtl-th .g-day2.wknd { background: #e5e9f2; }
.gtl-th .g-day2.hol { background: #fbd8d8; color: #c0392b; font-weight: 700; }
.gbar { position: absolute; top: 21px; height: 26px; border-radius: 6px; font-size: 11px; color: #fff; padding: 3px 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: grab; box-shadow: 0 1px 3px rgba(0,0,0,.18); z-index: 2; }
.gbar.dragging { opacity: .5; }
.gbar-empty {
  position: absolute; top: 21px; height: 26px; border-radius: 6px; font-size: 11px;
  color: #8a94ad; background: repeating-linear-gradient(45deg, #f2f4f9, #f2f4f9 6px, #e7eaf2 6px, #e7eaf2 12px);
  border: 1px dashed #c3cad8; padding: 3px 8px; cursor: pointer; z-index: 2; left: 0; width: 90px;
}
.g-flag2 { position: absolute; top: 48px; color: var(--danger); font-size: 12px; z-index: 2; }
.g-today2 { position: absolute; top: 0; bottom: 0; width: 2px; background: #e03131; z-index: 4; }
.g-tl-head .g-today2 { top: 0; height: 34px; }
.g-today-inline { display: inline-block; width: 14px; height: 14px; border-radius: 3px; background: #e03131; margin: 0 4px; vertical-align: middle; }

/* ---------- 单容器同步滚动甘特图 ---------- */
.gtable-wrap { overflow: auto; max-height: calc(100vh - 300px); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
table.gtable { border-collapse: collapse; min-width: 100%; }
.gtable th, .gtable td { border-bottom: 1px solid #f0f2f7; text-align: left; }
.gtable thead th { position: sticky; top: 0; background: #f5f7fc; z-index: 5; padding: 0; }
.gtable .gname-th, .gtable .gname-td { position: sticky; left: 0; width: 320px; min-width: 320px; max-width: 320px; background: #fff; z-index: 4; border-right: 1px solid var(--line); padding: 8px 12px; }
.gtable thead .gname-th { z-index: 6; background: #f5f7fc; height: 36px; line-height: 36px; padding: 0 12px; }
.gtable .gtl-th { height: 36px; padding: 0; }
.gtable .gtl-td { height: 74px; padding: 0; position: relative; }
.gtable tbody tr:hover td { background: #f7faff; }
.gtable tbody tr:hover .gname-td { background: #f7faff; }
.gtl-inner { position: relative; height: 100%; min-width: 1400px; }
.gtable .gbar { top: 24px; }
.gtable .g-flag2 { top: 54px; }

/* ---------- 周报表格 ---------- */
.weekly-table textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; resize: vertical; min-height: 54px; outline: none; background: #fff;
}
.weekly-table textarea:focus { border-color: var(--brand); }
.weekly-table td { vertical-align: top; }

/* ---------- Toast ---------- */
.toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.notify-root { position: fixed; right: 18px; top: 70px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: 360px; }
.notify-toast {
  background: #fff; border: 1px solid #f0c36d; border-left: 4px solid #e0a32e;
  border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14);
}
.notify-toast .n-title { font-weight: 700; font-size: 14px; color: #7a5a00; margin-bottom: 4px; }
.notify-toast .n-msg { font-size: 13px; color: var(--text); line-height: 1.5; }
.notify-toast .n-by { color: var(--muted); font-size: 12px; }
.notify-toast .n-actions { display: flex; gap: 8px; margin-top: 10px; }
.toast {
  background: #22304a; color: #fff; border-radius: 10px; padding: 10px 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25); font-size: 13px; max-width: 380px;
  animation: slideIn 0.2s;
}
.toast.info { background: var(--brand); }
.toast.warn { background: var(--warn); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--accent); }

@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(0.96); opacity: 0; } }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } }

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .topbar-right { width: 100%; justify-content: flex-start; }
  .search-wrap { max-width: none; }
  .me input { width: 90px; }
  .board-col { width: 240px; }
}

/* ---------- 通知中心 ---------- */
.notify-btn { position: relative; background: rgba(255,255,255,0.16) !important; border: 1px solid rgba(255,255,255,0.35) !important; color: #fff !important; border-radius: 8px !important; white-space: nowrap; }
.notify-btn:hover { background: rgba(255,255,255,0.28) !important; }
.notify-badge {
  position: absolute; top: -7px; right: -7px; min-width: 18px; height: 18px; padding: 0 5px;
  background: #e43d3d; color: #fff; border-radius: 9px; font-size: 11px; line-height: 18px;
  font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.notify-badge.hidden { display: none; }
.notify-mask { position: fixed; inset: 0; background: rgba(16,32,64,0.28); z-index: 210; }
.notify-mask.hidden { display: none; }
.notify-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 400px; max-width: 92vw;
  background: #fff; z-index: 220; box-shadow: -8px 0 30px rgba(16,32,64,0.18);
  display: flex; flex-direction: column;
}
.notify-drawer.hidden { display: none; }
.notify-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.notify-drawer-head h3 { margin: 0; font-size: 16px; }
.notify-drawer-btns { display: flex; gap: 8px; }
.notify-list { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.notify-item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #f0f6ff; }
.notify-item.read { background: #fff; opacity: 0.82; }
.notify-item-head { display: flex; align-items: center; gap: 7px; }
.notify-kind { font-size: 15px; }
.notify-title { font-weight: 700; font-size: 13px; flex: 1; min-width: 0; }
.notify-time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.notify-body { font-size: 12.5px; color: var(--text); line-height: 1.55; margin-top: 6px; }
.notify-by { color: var(--muted); font-size: 11px; }
.notify-actions { display: flex; gap: 8px; margin-top: 8px; }

/* ---------- AI 智能体（独立页面） ---------- */
.ai-page-panel { display: flex; flex-direction: column; min-height: calc(100vh - 150px); }
.ai-log { flex: 1; min-height: 420px; max-height: calc(100vh - 310px); overflow-y: auto; background: #f7f8fb; border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 88%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.ai-msg.me { align-self: flex-end; background: #dfe9ff; border-color: #b9cdf5; }
.ai-msg.ai { align-self: flex-start; background: #fff; }
.ai-msg-by { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.ai-answer { white-space: normal; line-height: 1.65; }
.ai-think { margin: 0 0 8px; border: 1px dashed #c6cfe4; border-radius: 8px; background: #fafbfe; }
.ai-think summary { cursor: pointer; padding: 6px 10px; font-size: 12px; color: #5b6a8c; user-select: none; }
.ai-think-body { padding: 4px 12px 10px; font-size: 12.5px; color: #4a5670; line-height: 1.6; border-top: 1px dashed #e0e5f0; }
.ai-token { margin-top: 8px; padding-top: 6px; border-top: 1px solid #eef1f7; font-size: 11px; color: #8a94ad; }
.ai-input-row { display: flex; gap: 10px; margin-top: 12px; align-items: flex-end; }
.ai-input-row textarea { flex: 1; resize: vertical; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; min-height: 52px; }
.ai-input-btns { display: flex; gap: 8px; }
.ai-quick { margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- AI 输出表格与标题 ---------- */
.ai-table-wrap { overflow-x: auto; margin: 8px 0; border: 1px solid var(--line); border-radius: 8px; }
.ai-table { width: 100%; border-collapse: collapse; font-size: 12.5px; background: #fff; }
.ai-table th { background: #eef3ff; color: #16356e; font-weight: 700; padding: 7px 10px; border: 1px solid #dbe3f5; white-space: nowrap; }
.ai-table td { padding: 6px 10px; border: 1px solid #e5eaf4; line-height: 1.55; vertical-align: top; }
.ai-table tbody tr:nth-child(even) { background: #f7f9fe; }
.ai-table tbody tr:hover { background: #eef4ff; }
.ai-heading { font-weight: 700; color: #16356e; margin: 10px 0 4px; }
.ai-heading.h1 { font-size: 15px; }
.ai-heading.h2 { font-size: 14px; }
.ai-heading.h3 { font-size: 13px; }
.ai-heading.h4 { font-size: 12.5px; }


/* ---------- AI 多任务布局 ---------- */
.ai-layout { display: flex; gap: 12px; align-items: stretch; height: calc(100vh - 145px); min-height: 480px; }
.ai-side { width: 280px; flex: none; display: flex; flex-direction: column; overflow: hidden; }
.ai-side-head { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.ai-side-head .btn { width: 100%; }
.ai-task-list { flex: 1; overflow-y: auto; margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.ai-task-item { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: #fff; transition: background .15s, border-color .15s; }
.ai-task-item:hover { background: #f2f6ff; }
.ai-task-item.active { background: #dfe9ff; border-color: #b9cdf5; }
.ai-task-title { font-size: 13px; font-weight: 600; color: #22304d; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-task-preview { font-size: 11px; color: #7a849e; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-task-meta { font-size: 10px; color: var(--muted); margin-top: 4px; display: flex; justify-content: space-between; gap: 6px; }
.ai-chat { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.ai-chat-head { display: flex; align-items: center; gap: 8px; padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.ai-chat-head .title { flex: 1; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ai-msg-time { float: right; margin-left: 10px; font-size: 10px; color: #98a2ba; font-weight: 400; }
.ai-log { flex: 1; min-height: 300px; max-height: none; }

/* ---------- 可搜索下拉组件 ---------- */
.sselect { position: relative; display: inline-block; width: 100%; }
.sselect-trigger { display:flex; align-items:center; justify-content:space-between; width:100%; padding:6px 10px; border:1px solid var(--line); border-radius:6px; background:#fff; cursor:pointer; min-height:34px; font-size:13px; }
.sselect-trigger:hover { border-color:#94a3b8; }
.sselect-trigger .placeholder { color:#9aa3b7; }
.sselect-trigger .arrow { color:#94a3b8; font-size:10px; margin-left:8px; }
.sselect-dropdown { position:absolute; top:100%; left:0; right:0; background:#fff; border:1px solid var(--line); border-radius:6px; box-shadow:0 4px 16px rgba(0,0,0,.12); margin-top:2px; z-index:100; max-height:280px; display:flex; flex-direction:column; }
.sselect-search { padding:6px; border-bottom:1px solid var(--line); }
.sselect-search input { width:100%; padding:6px 8px; border:1px solid var(--line); border-radius:4px; font-size:12px; box-sizing:border-box; outline:none; }
.sselect-search input:focus { border-color:#5b8def; }
.sselect-search input, .msearch, #globalSearch, #peopleSearch, #dProjSearch, #loginName, #loginPw, .ai-input-row textarea { direction: ltr !important; text-align: left !important; unicode-bidi: normal !important; }
.sselect-list { flex:1; overflow-y:auto; padding:4px 0; }
.sselect-opt { padding:6px 10px; cursor:pointer; font-size:13px; display:flex; justify-content:space-between; align-items:center; gap:8px; }
.sselect-opt:hover { background:#f2f6ff; }
.sselect-opt.empty { color:#9aa3b7; cursor:default; }
.sselect-opt.empty:hover { background:transparent; }
.sselect-opt .meta { color:#9aa3b7; font-size:11px; }
.sselect-opt mark { background:#fff3a0; color:inherit; padding:0 1px; border-radius:2px; }
.sselect-clear { padding:4px 10px; border-top:1px solid var(--line); display:flex; gap:6px; font-size:11px; }
.sselect-clear button { padding:3px 8px; border:1px solid var(--line); border-radius:4px; background:#f8fafc; cursor:pointer; }
.sselect-clear button:hover { background:#eef2f7; }

/* ---------- AI 多任务 发起人标签 ---------- */
.ai-task-creator { display:inline-block; padding:1px 6px; border-radius:4px; background:#e8eef9; color:#3a4f7c; font-size:10px; margin-left:6px; vertical-align:middle; }
.ai-task-creator.me { background:#ddf3e3; color:#1d7a4f; }

/* ---------- 截止日期色彩提示 ---------- */
.due-red { color: #d64545; font-weight: 700; }
.due-yellow { color: #c08400; font-weight: 700; }
.due-red .badge, .due-yellow .badge { font-weight: 600; }

/* ---------- 打印页眉（仅打印时显示） ---------- */
.print-header { display: none; }

/* ---------- 行高亮（点击关联合同跳转后短暂提示） ---------- */
.row-highlight { animation: rowFlash 2.2s ease-out; }
@keyframes rowFlash {
  0%   { background: #fff3a0; }
  60%  { background: #fff3a0; }
  100% { background: transparent; }
}

/* ---------- 浏览器打印样式 ---------- */
@media print {
  /* 隐藏非内容元素 */
  .sidebar, .topbar, .modal-mask, .modal-root, #toastRoot, .notify-mask, .notify-drawer,
  .login-mask, .toolbar, .view-title > .toolbar, .btn, .sselect-dropdown,
  .form-section .form-grid, .modal-toolbar, .modal-foot, #permTip { display: none !important; }
  /* 打印时去掉背景色与阴影，避免浪费墨水 */
  body, .main, .table-wrap, .panel { background: #fff !important; box-shadow: none !important; }
  /* 打印页眉显示 */
  .print-header { display: block !important; font-size: 14px; font-weight: 600; padding: 6px 0 10px; border-bottom: 1px solid #2350c4; color: #2350c4; margin-bottom: 12px; }
  /* 主区域全宽 */
  .app-layout, .main-area, .main { display: block !important; max-width: 100% !important; padding: 8px 12px !important; }
  /* 表格优化 */
  .table-wrap { max-height: none !important; overflow: visible !important; }
  table.grid { font-size: 11px; page-break-inside: auto; border-collapse: collapse; }
  table.grid thead { display: table-header-group; }
  table.grid tr { page-break-inside: avoid; }
  table.grid th, table.grid td { padding: 4px 6px !important; border: 1px solid #cbd2e0 !important; }
  /* 隐藏角标底色 */
  .badge { border: 1px solid #888 !important; background: transparent !important; color: #000 !important; }
  /* 隐藏只读空数据 */
  .empty { color: #888 !important; }
  /* 打印时颜色简化 */
  * { color: #000 !important; }
  h2, h3, h4 { color: #000 !important; }
  /* 防止侧边栏残留空白 */
  .app-layout { grid-template-columns: 1fr !important; }
}

/* ============================================================
   响应式断点：平板 / 移动端 / 小屏
   ============================================================ */

/* 平板：≤1024px */
@media (max-width: 1024px) {
  .sidebar { width: 180px; flex: 0 0 180px; padding: 14px 10px 20px; }
  .sidebar .brand h1 { font-size: 14px; }
  .sidebar .brand .sub { display: none; }
  .topbar { padding: 8px 14px; }
  .main { padding: 14px 18px 50px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .num { font-size: 22px; }
  .modal { width: min(960px, 96vw); }
  .modal-lg { width: min(1000px, 96vw); }
}

/* 移动端：≤768px */
@media (max-width: 768px) {
  /* 顶栏：紧凑、出现汉堡按钮 */
  .topbar { padding: 6px 10px; gap: 8px; }
  .topbar-right { gap: 8px; }
  .topbar-right .search-wrap { max-width: none; min-width: 0; flex: 1; }
  .topbar-right #globalSearch { font-size: 13px; padding: 4px 8px; }
  .topbar-right #undoBtn, .topbar-right #notifyBtn { padding: 4px 8px; font-size: 12px; }
  .topbar-right .me .me-name { display: none; }
  .topbar-right .me #changePwBtn, .topbar-right .me #logoutBtn { padding: 3px 6px; font-size: 11px; }
  .nav-toggle { display: inline-flex !important; }

  /* 侧边栏：变抽屉，默认隐藏 */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 240px; flex: 0 0 240px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 100;
    box-shadow: 4px 0 18px rgba(16, 32, 64, 0.18);
  }
  .sidebar.open { transform: translateX(0); }
  /* 抽屉打开时的遮罩 */
  body.nav-open::before {
    content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.36);
    z-index: 99;
  }
  .sidebar .brand h1 { font-size: 16px; }
  .sidebar .brand .sub { display: block; }

  /* 顶栏汉堡按钮 */
  .nav-toggle {
    background: rgba(255, 255, 255, 0.15); color: #fff; border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 6px; padding: 5px 10px; font-size: 18px; line-height: 1; cursor: pointer;
    align-items: center; justify-content: center;
  }
  .nav-toggle:hover { background: rgba(255, 255, 255, 0.25); }

  /* 主区更紧凑 */
  .main { padding: 12px 12px 60px; }
  .view-title h2 { font-size: 17px; }
  .view-title .desc { font-size: 12px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 10px 12px; }
  .stat-card .num { font-size: 20px; }
  .stat-card .lbl { font-size: 11px; }

  /* 表格：横向滚动 */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.grid { font-size: 12px; }
  table.grid th, table.grid td { padding: 5px 6px !important; white-space: nowrap; }
  table.grid th { font-size: 11px; }

  /* 模态框：全屏 */
  /* 用 flex 而不是 grid：grid 的 auto 轨道会被内部宽表格（min-width:640px）撑到 900 多 px，
     导致弹窗整体超宽、右侧按钮被挤出屏幕 */
  .modal-mask { padding: 0; align-items: stretch; display: flex; }
  .modal {
    width: 100% !important; max-width: 100vw !important; min-width: 0; flex: 1 1 auto;
    height: 100vh; height: 100dvh; max-height: 100vh; max-height: 100dvh; border-radius: 0;
  }
  .modal-sm, .modal-lg { width: 100% !important; }
  .modal-head, .modal-toolbar, .modal-body, .modal-foot { min-width: 0; }
  /* 内部宽表格改为在弹窗体里横向滚动，不允许把弹窗撑宽 */
  .modal-body { padding: 12px 14px; overflow: auto; }
  .modal-head { padding: 10px 14px; }
  /* 底部操作栏：始终固定在弹窗底部（不要放进滚动区），并避开 iPhone 安全区 */
  .modal-foot {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff; box-shadow: 0 -4px 12px rgba(16, 32, 64, 0.06); z-index: 6;
  }
  /* 提示条抬高，避免遮住弹窗底部固定操作栏 */
  .toast-root { right: 10px; bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .form-grid { grid-template-columns: 1fr !important; }
  .form-item.wide { grid-column: 1 / -1; }

  /* 工具栏：换行 + 紧凑 */
  .toolbar { flex-wrap: wrap; gap: 6px; }
  .toolbar .btn, .toolbar .mselect { font-size: 12px; padding: 4px 8px; }
  .toolbar input[type="search"], .toolbar select { font-size: 12px; padding: 4px 8px; min-width: 0; }

  /* 看板 / 甘特图：横向滚动 */
  .kanban-board, .gantt-row { overflow-x: auto; }
  .panel { padding: 10px 12px; }
  .panel h3 { font-size: 14px; }
  .help-faq summary { font-size: 13px; }

  /* AI 智能体：紧凑输入框 */
  .ai-input-row textarea { font-size: 13px; }
  .ai-msg .ai-answer { font-size: 13px; }
}

/* 小屏手机：≤480px */
@media (max-width: 480px) {
  .topbar { padding: 5px 8px; }
  .logo { width: 32px; height: 32px; font-size: 18px; border-radius: 7px; }
  .brand h1 { font-size: 15px; }
  .brand .sub { display: none; }
  .nav-toggle { font-size: 16px; padding: 4px 8px; }
  .main { padding: 8px 8px 60px; }
  .view-title h2 { font-size: 15px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .num { font-size: 18px; }
  table.grid { font-size: 11px; }
  table.grid th, table.grid td { padding: 4px 4px !important; }
  .btn { font-size: 12px; padding: 4px 8px; }
  .modal-foot .right { display: flex; gap: 6px; flex-wrap: wrap; }
  .modal-foot { flex-wrap: wrap; gap: 6px; }
  .modal-foot > .btn { flex: 1 1 40%; }
  .modal-foot .right { width: 100%; margin-left: 0; }
  .modal-foot .right .btn { flex: 1; }
  /* 工具栏堆叠 */
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; }
}
