:root {
  --bg: #eef1f8;
  --bg-grad: radial-gradient(1200px 500px at 80% -10%, #e7edff 0%, rgba(231,237,255,0) 60%), #eef1f8;
  --card: #ffffff;
  --line: #e7ebf3;
  --line-strong: #d8deea;
  --text: #161b26;
  --muted: #717c92;
  --muted-2: #9aa3b5;
  --primary: #3667ff;
  --primary-soft: #eaf0ff;
  --primary-dark: #2550e0;
  --success: #15a866;
  --success-soft: #e2f6ec;
  --warn: #ec9a13;
  --warn-soft: #fcf0d8;
  --danger: #e5484d;
  --danger-soft: #fde4e4;
  --violet: #6a4bd6;
  --violet-soft: #ece7fb;
  --shadow: 0 1px 2px rgba(20,27,45,.04), 0 6px 18px rgba(20,27,45,.05);
  --shadow-md: 0 2px 6px rgba(20,27,45,.06), 0 12px 28px rgba(20,27,45,.08);
  --shadow-lg: 0 20px 60px rgba(20,27,45,.22);
  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 16px;
  --lane-w: 168px;          /* 左侧人名列宽 */
  --lane-h: 52px;           /* 泳道高 */
  --c-install: #3667ff;
  --c-complaint: #e5484d;
  --c-rectify: #6a4bd6;
  --c-other: #717c92;
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  background: var(--bg-grad); background-attachment: fixed; color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
  /* 调度台整体撑满视口：表头冻结、泳道区独立滚动，页面本身不滚 */
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
}
/* 顶栏/概览/筛选条：固定高度，不参与滚动 */
.topbar, .overview, .rangebar { flex: 0 0 auto; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
::selection { background: rgba(54,103,255,.18); }

/* ===== 顶栏 ===== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 62px; padding: 0 22px;
  background: rgba(255,255,255,.85); backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px;
  background: linear-gradient(140deg, #3667ff, #5a8bff 55%, #36b9ff); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 19px; box-shadow: 0 6px 16px rgba(54,103,255,.35);
}
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.date-nav { display: flex; align-items: center; gap: 4px; background: #f3f5fa; padding: 3px; border-radius: 11px; }
.icon-btn { border: 0; background: #fff; width: 30px; height: 30px; border-radius: 8px; font-size: 18px; color: var(--muted); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.icon-btn:hover { color: var(--primary); }

/* ===== 按钮 / 输入 ===== */
.btn { border: 1px solid var(--line-strong); background: #fff; color: var(--text); border-radius: 10px; padding: 9px 16px; font-size: 13px; font-weight: 500; display: inline-flex; align-items: center; gap: 7px; transition: all .14s; box-shadow: 0 1px 1.5px rgba(20,27,45,.04); }
.btn:hover { background: #f7f9fc; border-color: #c8d0df; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #3b6cff, #2f63f5); color: #fff; border-color: transparent; box-shadow: 0 6px 16px rgba(54,103,255,.28); }
.btn-primary:hover { background: linear-gradient(135deg, #2f63f5, #2550e0); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.btn-ghost:hover { background: #eef1f7; color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); box-shadow: none; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.input { border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; padding: 8px 11px; font-size: 13px; outline: none; transition: border-color .14s, box-shadow .14s; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input-date { padding: 7px 9px; border: 0; background: transparent; font-weight: 600; }
.input-sm { padding: 7px 10px; font-size: 12.5px; }

/* ===== KPI 概览条 ===== */
.overview { display: flex; gap: 12px; flex-wrap: wrap; padding: 16px 22px 4px; max-width: 1500px; margin: 0 auto; }
.ov-card { flex: 1; min-width: 104px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 13px 16px; position: relative; overflow: hidden; }
.ov-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, #46506a); }
.ov-card .ov-val { font-size: 24px; font-weight: 800; line-height: 1; color: var(--c, #2a3550); }
.ov-card .ov-val small { font-size: 13px; color: var(--muted-2); font-weight: 600; }
.ov-card .ov-label { font-size: 12px; color: var(--muted); margin-top: 5px; font-weight: 600; }
.ov-card.ov-total { --c: #46506a; }
.ov-card.ov-cover { --c: #15a866; }
.ov-card.ov-hours { --c: #ec9a13; }

/* ===== 范围筛选条 ===== */
.rangebar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 14px 22px 10px; max-width: 1500px; margin: 0 auto; }
.seg-tabs { display: flex; gap: 4px; background: #eef1f7; padding: 4px; border-radius: 11px; flex-wrap: wrap; }
.seg-tab { border: 0; background: transparent; color: var(--muted); padding: 7px 15px; font-size: 13.5px; font-weight: 600; border-radius: 8px; transition: all .14s; white-space: nowrap; }
.seg-tab:hover { color: var(--text); }
.seg-tab.active { background: #fff; color: var(--primary); box-shadow: 0 2px 6px rgba(54,103,255,.18); }
.rangebar-right { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend { display: flex; gap: 12px; }
.legend .lg { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }
.legend .lg i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* ===== 时间轴主板 ===== */
/* 调度板外层：占满剩余视口高度，自身不滚（滚动交给内部泳道区） */
.board-wrap { flex: 1 1 auto; min-height: 0; max-width: 1500px; width: 100%; margin: 0 auto; padding: 6px 22px 16px; display: flex; flex-direction: column; }
/* 调度板：上下结构 = 冻结表头 + 可滚泳道区 */
.board { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
/* 泳道区：唯一的纵向滚动容器（横向也可滚，给窄屏） */
.board-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }

/* 表头：人名列 + 时间刻度 */
/* 冻结表头：作为 board 的固定顶部行，不再随页面 sticky（泳道区独立滚动） */
.board-head { flex: 0 0 auto; display: flex; z-index: 20; background: linear-gradient(180deg, #fbfcff, #f6f8fd); border-bottom: 1px solid var(--line-strong); }
.lane-name-head { width: var(--lane-w); flex: 0 0 auto; padding: 11px 16px; font-size: 12.5px; font-weight: 700; color: var(--muted); border-right: 1px solid var(--line-strong); }
.track-head { flex: 1; display: flex; height: 40px; }
.track-head .hour-cell { flex: 1; border-left: 1px solid var(--line); display: flex; align-items: center; }
.track-head .hour-cell:first-child { border-left: 0; }
.track-head .hour-cell span { font-size: 11.5px; color: var(--muted-2); font-weight: 600; padding-left: 6px; }
.track-head .hour-cell.lunch span { color: #c08a2a; }
.hour-tick-end { display: none; }

/* 泳道分组标题 */
.lane-group { display: flex; align-items: center; gap: 7px; padding: 9px 16px; font-size: 12.5px; font-weight: 700; color: #46506a; background: #f4f7fc; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 12; }
.lane-group small { color: var(--muted-2); font-weight: 600; }
.lane-group-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

/* 泳道 */
.lane { display: flex; height: var(--lane-h); border-bottom: 1px solid var(--line); }
.lane:last-child { border-bottom: 0; }
.lane:hover { background: #fafbfe; }
.lane.idle { background: #fbfcfe; }
.lane-name { width: var(--lane-w); flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 0 14px; border-right: 1px solid var(--line-strong); }
.avatar { width: 30px; height: 30px; flex: 0 0 auto; border-radius: 9px; background: linear-gradient(140deg, #3b6cff, #5a8bff); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.lane-name-meta { display: flex; flex-direction: column; min-width: 0; gap: 1px; }
.lane-worker { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lane-stat { font-size: 11px; color: var(--muted); }
.lane-stat .idle-tag { color: #ac2727; font-style: normal; font-weight: 700; }

/* 轨道（时间区） */
.track { flex: 1; position: relative; cursor: copy; }
.gridline { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--line); }
.gridline.lunch-edge { background: #f0d9ad; }
.lunch-band { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #f8f4ea, #f8f4ea 6px, #fbf8f0 6px, #fbf8f0 12px); }
.track-idle-hint { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 11.5px; color: var(--muted-2); pointer-events: none; }

/* 工作色块 */
.block {
  position: absolute; top: 7px; bottom: 7px; border: 0; border-radius: 8px; padding: 0 9px; overflow: hidden;
  background: var(--bc, #3667ff); color: #fff; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; justify-content: center; gap: 1px; min-width: 18px;
  box-shadow: 0 2px 6px rgba(20,27,45,.18); transition: transform .12s, box-shadow .12s, filter .12s;
}
.block:hover { transform: translateY(-1px) scale(1.01); box-shadow: 0 5px 14px rgba(20,27,45,.28); filter: brightness(1.05); z-index: 5; }
.block-label { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.block-sub { font-size: 10.5px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ===== hover 预览 ===== */
.hover-pop { position: fixed; z-index: 300; background: #1d2740; color: #fff; border-radius: 12px; padding: 11px 13px; box-shadow: var(--shadow-lg); max-width: 260px; font-size: 12.5px; pointer-events: none; animation: fade .12s ease; }
.hp-time { font-size: 12px; opacity: .8; margin-bottom: 4px; }
.hp-biz { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--bc, #3667ff); margin-bottom: 7px; }
.hp-row { line-height: 1.6; }
.hp-row b { font-weight: 700; }
.hp-row.hp-muted { opacity: .7; font-size: 11.5px; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== 空态 ===== */
.empty { text-align: center; padding: 70px 20px; color: var(--muted-2); }
.empty-icon { font-size: 44px; opacity: .6; margin-bottom: 10px; }
.empty p { font-size: 14px; }

/* ===== 弹窗 ===== */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.42); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 18px; animation: fade .15s ease; }
.modal { background: #fff; border-radius: var(--radius-lg); width: 560px; max-width: 100%; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .14s ease-out; }
.modal.modal-xl { width: 1080px; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: scale(1); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fbfcff, #fff); }
.modal-head h3 { font-size: 16.5px; font-weight: 700; }
.modal-close { border: 0; background: #f1f3f9; width: 32px; height: 32px; border-radius: 9px; font-size: 20px; color: var(--muted); line-height: 1; }
.modal-close:hover { background: #e6e9f2; color: var(--text); }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 10px; background: #fbfcff; }
.modal-foot-right { display: flex; gap: 10px; margin-left: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-field > span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.form-field > span i { color: var(--danger); font-style: normal; }
.form-field input, .form-field select, .form-field textarea { border: 1px solid var(--line-strong); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; font-family: inherit; transition: border .14s, box-shadow .14s; width: 100%; background: #fff; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-hint { font-weight: 600; font-size: 11px; color: var(--muted-2); margin-left: 6px; }
.field-hint.ok { color: var(--success); }
.field-hint.warn { color: #c08a2a; }
/* 资管小区可检索下拉 */
.combo { position: relative; }
.combo-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 50;
  background: #fff; border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: var(--shadow-lg); max-height: 248px; overflow-y: auto; overscroll-behavior: contain;
}
.combo-item { padding: 9px 12px; font-size: 13.5px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; border-bottom: 1px solid var(--line); }
.combo-item:last-child { border-bottom: 0; }
.combo-item:hover, .combo-item.active { background: var(--primary-soft); }
.combo-item .ci-name { font-weight: 600; color: var(--text); }
.combo-item .ci-name b { color: var(--primary); font-weight: 800; }
.combo-item .ci-meta { font-size: 11px; color: var(--muted-2); }
.combo-empty { padding: 12px; font-size: 12.5px; color: var(--muted-2); text-align: center; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.seg-btn { border: 1px solid var(--line-strong); background: #fff; border-radius: 10px; padding: 11px 6px; font-size: 14px; font-weight: 600; color: var(--muted); transition: all .14s; }
.seg-btn:hover { border-color: var(--primary); color: var(--text); }
.seg-btn.active { background: linear-gradient(135deg, #3b6cff, #2f63f5); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(54,103,255,.25); }
.seg-sub .seg-btn.active { background: linear-gradient(135deg, #7c5cf0, #6a4bd6); box-shadow: 0 4px 12px rgba(106,75,214,.25); }

/* ===== 统计中心 ===== */
.stat-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.stat-filters .field { display: flex; flex-direction: column; gap: 5px; }
.stat-filters .field label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.stat-filters .field select, .stat-filters .field input { border: 1px solid var(--line-strong); border-radius: 9px; padding: 8px 11px; font-size: 13px; outline: none; min-width: 118px; }
.stat-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent, var(--primary)); }
.kpi .kpi-val { font-size: 28px; font-weight: 800; line-height: 1; }
.kpi .kpi-label { font-size: 13px; color: var(--muted); margin-top: 7px; font-weight: 600; }
.kpi .kpi-ico { position: absolute; right: 14px; top: 14px; font-size: 22px; opacity: .22; }
.kpi.k-total { --accent: #46506a; }
.kpi.k-install { --accent: var(--c-install); } .kpi.k-install .kpi-val { color: var(--c-install); }
.kpi.k-dismantle { --accent: #0ea5b7; } .kpi.k-dismantle .kpi-val { color: #0ea5b7; }
.kpi.k-complaint { --accent: var(--c-complaint); } .kpi.k-complaint .kpi-val { color: var(--c-complaint); }
.kpi.k-rectify { --accent: var(--c-rectify); } .kpi.k-rectify .kpi-val { color: var(--c-rectify); }
.stat-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card.stat-card-full { grid-column: 1 / -1; }
.stat-card-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.stat-sub { font-size: 11.5px; font-weight: 600; color: var(--muted-2); }
.stat-canvas-wrap { height: 240px; position: relative; }
.stat-canvas-wrap.stat-canvas-tall { height: 320px; }

/* ===== FAB / Toast ===== */
.fab { position: fixed; right: 20px; bottom: 22px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #3b6cff, #2f63f5); color: #fff; border: 0; font-size: 28px; font-weight: 300; line-height: 1; box-shadow: 0 10px 26px rgba(54,103,255,.45); z-index: 40; display: none; }
.fab:active { transform: scale(.94); }
#toast-host { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #1d2740; color: #fff; padding: 11px 18px; border-radius: 11px; font-size: 14px; box-shadow: var(--shadow-md); animation: fade .2s ease; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--success); }

/* ===== 响应式（手机：缩小人名列 + 横向滚动保留时间轴） ===== */
@media (max-width: 860px) {
  :root { --lane-w: 116px; --lane-h: 50px; }
  .topbar { height: auto; flex-wrap: wrap; gap: 9px; padding: 9px 13px; }
  .brand-sub { display: none; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
  .overview { padding: 12px 13px 2px; gap: 8px; }
  .ov-card { min-width: 84px; padding: 10px 12px; }
  .ov-card .ov-val { font-size: 20px; }
  .rangebar { padding: 12px 13px 8px; }
  .legend { display: none; }
  .board-wrap { padding: 4px 10px 10px; }
  /* 窄屏：board 横向滚动（表头+泳道同宽 720，同步左右滚）；纵向滚仍在 board-body */
  .board { overflow-x: auto; }
  .board-head, .board-body, .lane, .lane-group { min-width: 720px; }
  #btn-add-top { display: none; }
  .fab { display: grid; place-items: center; }
  .stat-kpis { grid-template-columns: 1fr 1fr; }
  .stat-charts { grid-template-columns: 1fr; }
  .stat-card.stat-card-full { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .seg { grid-template-columns: 1fr 1fr; }
  .modal { border-radius: 16px 16px 0 0; align-self: flex-end; max-height: 94vh; }
  .modal.modal-xl { width: 100%; }
  .modal-mask { align-items: flex-end; padding: 0; }
}
