:root {
  --ink: #16202e;
  --ink-2: #3c4a5d;
  --muted: #75849b;
  --faint: #9aa8bd;
  --line: #e5eaf2;
  --line-strong: #d3dbe8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --navy: #15263c;
  --blue: #2559d6;
  --blue-soft: #eef3fd;
  --amber: #b4700a;
  --red: #c9403f;
  --green: #1d7557;
  --shadow-sm: 0 1px 2px rgba(21, 38, 60, 0.05);
  --shadow-md: 0 8px 24px rgba(21, 38, 60, 0.08);
  --shadow-lg: 0 24px 60px rgba(15, 26, 42, 0.22);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.no-scroll { overflow: hidden; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }

.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 13px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, #1d3557, #0f1f33);
  color: #fff;
  display: grid; place-items: center;
  font-size: 17px; font-weight: 700;
  letter-spacing: 1px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 4px 12px rgba(15,31,51,.28);
}
.brand-text h1 { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.brand-text p { font-size: 12px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.sync {
  display: flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted);
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcfe;
  white-space: nowrap;
}
.sync .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #37a06f;
  box-shadow: 0 0 0 3px rgba(55, 160, 111, 0.14);
}
.sync.warn .dot { background: #d99a22; box-shadow: 0 0 0 3px rgba(217,154,34,.16); }
.sync.err .dot { background: #cf4b4a; box-shadow: 0 0 0 3px rgba(207,75,74,.16); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  font-size: 13px; font-weight: 500;
  transition: .16s ease;
}
.btn.ghost {
  background: #fff; border-color: var(--line-strong); color: var(--ink-2);
}
.btn.ghost:hover { border-color: #b9c5d8; color: var(--ink); background: #fafbfe; }
.btn.primary {
  background: linear-gradient(180deg, #2a60e0, #1f4fc4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 89, 214, .24);
}
.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:disabled { opacity: .6; cursor: default; filter: none; }
.btn.ghost svg { opacity: .65; }

/* ---------- 页面 ---------- */
.page { max-width: 1460px; margin: 0 auto; padding: 22px 28px 40px; }

/* ---------- KPI ---------- */
.kpis {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.kpi::after {
  content: "";
  position: absolute; inset: 0 auto 0 0;
  width: 3px;
  background: var(--accent, #cbd6e6);
}
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: var(--muted); letter-spacing: .2px;
}
.kpi-value {
  margin-top: 8px;
  font-size: 27px; font-weight: 620; letter-spacing: -.5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.kpi-value .unit { font-size: 12px; font-weight: 400; color: var(--faint); margin-left: 4px; letter-spacing: 0; }
.kpi-foot { margin-top: 7px; font-size: 12px; color: var(--faint); }
.kpi-foot b { color: var(--ink-2); font-weight: 600; }
.kpi.tone-red { --accent: #d9584f; }
.kpi.tone-red .kpi-value { color: #b83a39; }
.kpi.tone-amber { --accent: #e0a23a; }
.kpi.tone-amber .kpi-value { color: #a9690c; }
.kpi.tone-green { --accent: #39a37c; }
.kpi.tone-green .kpi-value { color: #1c7457; }
.kpi.tone-blue { --accent: #2f63d8; }
.kpi.tone-navy { --accent: #35507a; }

/* ---------- 交期分布 ---------- */
.dist-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px 12px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.dist-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.dist-title { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.dist-hint { font-size: 11.5px; color: var(--faint); }
.dist-bar {
  display: flex;
  height: 10px;
  margin-top: 11px;
  border-radius: 999px;
  overflow: hidden;
  background: #eef1f6;
}
.dist-bar span { display: block; height: 100%; transition: width .5s ease; }
.dist-legend { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 9px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-item i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.legend-item b { color: var(--ink-2); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- 预警条 ---------- */
.alert {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  margin-bottom: 14px;
  background: #fdf4f2;
  border: 1px solid #f3d7d1;
  border-radius: 12px;
  font-size: 13px;
  color: #8c342f;
}
.alert strong { font-weight: 650; }
.alert .alert-link {
  margin-left: auto;
  border: 1px solid #e7c2bc;
  background: #fff;
  color: #a2433c;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12.5px;
  white-space: nowrap;
}
.alert .alert-link:hover { background: #fff7f5; }

/* ---------- 面板 & 工具条 ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: #f2f5fa; padding: 3px; border-radius: 10px; }
.tab {
  border: 0; background: transparent;
  padding: 6px 13px;
  border-radius: 8px;
  font-size: 13px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  transition: .15s ease;
}
.tab:hover { color: var(--ink-2); }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(21,38,60,.12); font-weight: 550; }
.tab .cnt {
  font-size: 11px; color: var(--faint);
  background: #e9eef7; border-radius: 999px; padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}
.tab.active .cnt { background: var(--blue-soft); color: var(--blue); }
.tools { display: flex; align-items: center; gap: 10px; }
.search-wrap {
  display: flex; align-items: center; gap: 7px;
  background: #f7f9fc;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0 10px;
  height: 34px;
  color: var(--faint);
}
.search-wrap:focus-within { border-color: #b9c9ea; background: #fff; box-shadow: 0 0 0 3px rgba(37,89,214,.08); }
.search-wrap input {
  border: 0; background: transparent; outline: none;
  width: 220px; height: 100%;
}
.select {
  height: 34px;
  border: 1px solid var(--line);
  background: #f7f9fc;
  border-radius: 9px;
  padding: 0 10px;
  color: var(--ink-2);
  outline: none;
}
.select:focus { border-color: #b9c9ea; background: #fff; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; min-width: 1040px; }
.grid thead th {
  position: sticky; top: 0;
  background: #fafbfd;
  border-bottom: 1px solid var(--line);
  padding: 9px 14px;
  font-size: 11.5px; font-weight: 600;
  color: var(--muted);
  letter-spacing: .4px;
  text-align: left;
  white-space: nowrap;
  z-index: 2;
}
.grid thead th.c-num { text-align: right; }
.grid thead th.c-status, .grid thead th.c-comm { text-align: center; }
.grid tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid #f0f3f8;
  vertical-align: middle;
}
.grid tbody tr { transition: background .12s ease; cursor: pointer; }
.grid tbody tr:hover { background: #f8fafd; }
.grid tbody tr:last-child td { border-bottom: 0; }
.c-num { text-align: right; white-space: nowrap; }
.c-status, .c-comm { text-align: center; white-space: nowrap; }
.c-go { width: 34px; color: #c3cddc; text-align: center; }
.grid tbody tr:hover .c-go { color: var(--blue); }

.sup-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.sup-avatar {
  flex: 0 0 30px;
  width: 30px; height: 30px;
  border-radius: 9px;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
  background: #eef3fb; color: #3d5c8a;
  overflow: hidden;
}
.sup-avatar.hot { background: #fdeeec; color: #b7453f; }
.sup-name { font-weight: 550; color: var(--ink); letter-spacing: .1px; }
.sup-meta { font-size: 11.5px; color: var(--faint); margin-top: 2px; display: flex; gap: 6px; align-items: center; }
.qty-main { font-weight: 600; font-variant-numeric: tabular-nums; }
.qty-sub { font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.date-cell { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.date-cell .revised-flag {
  display: inline-block; margin-left: 6px;
  font-size: 10.5px; padding: 1px 5px; border-radius: 4px;
  background: var(--blue-soft); color: var(--blue);
  vertical-align: 1px;
}
.date-cell .over-text { color: #bd4a45; }
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px;
  border-radius: 7px;
  font-size: 12px; font-weight: 550;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.pill.over { background: #fdeceb; color: #b93b38; }
.pill.today { background: #fdf1e2; color: #a9690c; }
.pill.soon { background: #fbf5e0; color: #8f6c06; }
.pill.ok { background: #eaf5f0; color: #1d7557; }
.pill.muted { background: #f1f4f9; color: var(--muted); }
.comm-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 7px;
  border-radius: 6px;
  background: #f1f4f9; color: var(--ink-2);
  font-size: 11.5px; font-variant-numeric: tabular-nums;
}
.comm-badge.has { background: var(--blue-soft); color: var(--blue); font-weight: 600; }

.table-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--muted);
  background: #fcfdff;
}
.foot-note { color: var(--faint); }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 26px; color: #b9d6c9; margin-bottom: 6px; }

.page-foot {
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--faint);
  text-align: center;
  line-height: 1.7;
}

/* ---------- 抽屉 ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(18, 29, 45, 0.36);
  backdrop-filter: blur(1.5px);
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(760px, 100vw);
  z-index: 60;
  background: #fff;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.32,.72,0,1);
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-size: 18px; font-weight: 650; letter-spacing: .1px; }
.drawer-head p { margin-top: 4px; font-size: 12px; color: var(--muted); }
.icon-btn {
  width: 30px; height: 30px; flex: 0 0 30px;
  border: 1px solid var(--line);
  background: #fff; border-radius: 8px;
  color: var(--muted); font-size: 18px; line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:hover { background: #f5f7fb; color: var(--ink); }

.dw-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.dw-stat { background: #fbfcfe; padding: 11px 16px; }
.dw-stat span { display: block; font-size: 11.5px; color: var(--muted); }
.dw-stat b { display: block; margin-top: 3px; font-size: 17px; font-weight: 620; font-variant-numeric: tabular-nums; }
.dw-stat b.red { color: #b83a39; }

.dw-tabs { display: flex; gap: 22px; padding: 0 22px; border-bottom: 1px solid var(--line); }
.dw-tab {
  border: 0; background: transparent;
  padding: 11px 1px;
  font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.dw-tab.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--navy); }

.dw-body { flex: 1; overflow-y: auto; background: #fcfdff; }
.dw-pane { display: none; }
.dw-pane.active { display: block; }
.dw-filter {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 14px;
  padding: 11px 22px;
  background: rgba(252, 253, 255, .96);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.dw-filter input[type="search"] {
  flex: 1; height: 32px;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 0 10px; outline: none; background: #fff;
}
.dw-filter input[type="search"]:focus { border-color: #b9c9ea; box-shadow: 0 0 0 3px rgba(37,89,214,.08); }
.mini-check { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.dw-list { padding: 12px 22px 28px; }

.ln {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 9px;
  transition: border-color .14s ease, box-shadow .14s ease;
}
.ln:hover { border-color: #cdd9ea; box-shadow: var(--shadow-sm); }
.ln.overdue { border-left: 3px solid #dd6b62; }
.ln-top { display: flex; align-items: flex-start; gap: 10px; }
.ln-top > div:first-child { flex: 1; min-width: 0; }
.ln-name { font-weight: 550; font-size: 13.5px; line-height: 1.45; }
.ln-code { font-size: 11.5px; color: var(--faint); margin-top: 2px; font-variant-numeric: tabular-nums; }
.ln-spec { font-size: 11.5px; color: var(--muted); margin-top: 5px; line-height: 1.5; }
.ln-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 8px 14px;
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
.ln-cell span { display: block; font-size: 11px; color: var(--faint); }
.ln-cell b { display: block; font-size: 12.5px; font-weight: 550; margin-top: 1px; font-variant-numeric: tabular-nums; }
.ln-cell b.red { color: #b83a39; }
.ln-cell b.blue { color: var(--blue); }
.ln-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.btn-mini {
  height: 27px; padding: 0 10px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-2);
  font-size: 12px;
  white-space: nowrap;
}
.btn-mini:hover { border-color: #a9bcd8; color: var(--blue); background: #f8fbff; }
.ln-note {
  margin-top: 8px; font-size: 12px; color: var(--ink-2);
  background: #f6f9fd; border-radius: 7px; padding: 7px 9px;
  line-height: 1.55;
}
.ln-note span { color: var(--faint); margin-right: 6px; }

.rec {
  display: flex; gap: 12px;
  padding: 13px 2px;
  border-bottom: 1px solid #eef2f8;
}
.rec:last-child { border-bottom: 0; }
.rec-rail { position: relative; width: 10px; flex: 0 0 10px; display: flex; justify-content: center; }
.rec-rail::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--blue); margin-top: 6px;
  box-shadow: 0 0 0 3px rgba(37,89,214,.12);
}
.rec-main { flex: 1; min-width: 0; }
.rec-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rec-arrow { font-size: 12.5px; color: var(--muted); }
.rec-arrow b { color: var(--ink); }
.rec-tag {
  font-size: 10.5px; padding: 1px 6px; border-radius: 4px;
  background: #f1f4f9; color: var(--muted);
}
.rec-note { margin-top: 5px; font-size: 12.5px; color: var(--ink-2); line-height: 1.55; }
.rec-foot { margin-top: 5px; font-size: 11.5px; color: var(--faint); display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: rgba(18, 29, 45, 0.42);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(520px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: pop .2s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 12px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 16px; font-weight: 620; }
.modal-body { padding: 16px 22px 20px; }
.form-meta {
  background: #f7f9fd;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
  margin-bottom: 14px;
}
.form-meta b { font-weight: 600; }
.form-meta .dim { color: var(--muted); }
.form-row { margin-bottom: 13px; }
.form-row label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.form-row label em { color: #c9403f; font-style: normal; }
.form-row input[type="date"], .form-row input[type="text"], .form-row textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 8px 11px;
  outline: none;
  background: #fff;
}
.form-row input:focus, .form-row textarea:focus { border-color: #a9bfe8; box-shadow: 0 0 0 3px rgba(37,89,214,.09); }
.form-row textarea { resize: vertical; min-height: 72px; line-height: 1.55; }
.segments { display: flex; gap: 6px; flex-wrap: wrap; }
.segments button {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: #fff; border-radius: 8px;
  color: var(--ink-2); font-size: 12.5px;
}
.segments button.active { background: var(--blue-soft); border-color: #b7cbef; color: var(--blue); font-weight: 550; }
.form-error { color: #b93b38; font-size: 12.5px; margin: 2px 0 10px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; z-index: 100;
  transform: translateX(-50%);
  background: #15263c; color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(15, 26, 42, .3);
  animation: toastIn .2s ease;
}
.toast.err { background: #a43a37; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  .topbar { padding: 10px 14px; flex-wrap: wrap; }
  .brand-text p { display: none; }
  .page { padding: 14px 14px 30px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 13px 14px; }
  .kpi-value { font-size: 23px; }
  .toolbar { padding: 11px 12px; }
  .tools { width: 100%; }
  .search-wrap { flex: 1; }
  .search-wrap input { width: 100%; }
  .select { flex: 0 0 auto; }
  .dist-legend { gap: 12px; }
  .table-foot { flex-direction: column; align-items: flex-start; gap: 4px; }
  .drawer { width: 100vw; }
  .dw-stats { grid-template-columns: repeat(2, 1fr); }
  .ln-grid { grid-template-columns: repeat(2, 1fr); }
  .dw-filter { padding: 10px 14px; }
  .dw-list { padding: 10px 14px 24px; }
  .drawer-head { padding: 16px 16px 12px; }
}
