/* ============================================================
   深蓝供应链数据看板 - 样式
   布局对齐截图: 深蓝横幅 / 白色卡片 / 浅灰底 / 绿黄红三级预警色
   排版优化: 卡片与栅格间距加大、表格分区限高滚动、数值呼吸感
   ============================================================ */
:root {
  --navy-1: #0a2a66;
  --navy-2: #10409e;
  --blue: #2563eb;
  --blue-soft: #dbe7ff;
  --bg: #eef2f8;
  --card: #ffffff;
  --line: #e3e9f2;
  --txt: #1f2937;
  --txt-2: #6b7280;
  --ok: #16a34a;
  --ok-bg: #e8f7ee;
  --warn: #f59e0b;
  --warn-bg: #fdf3e0;
  --risk: #dc2626;
  --risk-bg: #fdeaea;
  --info-bg: #e8f0fe;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(15, 40, 90, .08);
  --gap: 18px; /* 全局统一模块间隙: 所有栅格/堆叠容器共用，保证各模块间距一致 */
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--txt); font-size: 13.5px;
}

/* ---------------- 头部 ---------------- */
.hero {
  background: linear-gradient(120deg, var(--navy-1) 0%, var(--navy-2) 55%, #1d5cc4 100%);
  color: #fff; padding: 18px 26px;
}
.hero-inner { display: flex; justify-content: space-between; align-items: center; gap: 20px; row-gap: var(--gap); flex-wrap: wrap; }
.hero h1 { font-size: 24px; letter-spacing: 2px; }
.hero-sub { font-size: 12.5px; opacity: .85; margin-top: 5px; letter-spacing: 2px; }
.hero-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }

.hero-meta { display: flex; gap: 16px; font-size: 11.5px; opacity: .92; }
.engine-chip { background: rgba(255,255,255,.18); padding: 1px 9px; border-radius: 10px; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; }
.filter-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.filter-item label { opacity: .85; white-space: nowrap; }
.filter-item select {
  border: none; border-radius: 7px; padding: 6px 10px; font-size: 12px;
  background: rgba(255,255,255,.95); color: var(--txt); min-width: 96px; outline: none;
}

/* ---------------- 工具条 ---------------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 26px 0; }
.toolbar-left { display: flex; gap: 9px; }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--txt);
  border-radius: 8px; padding: 7px 16px; font-size: 12.5px; cursor: pointer; transition: .15s;
}
.btn:hover { border-color: var(--blue); color: var(--blue); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #1d4fd0; color: #fff; }
#engineStatus { font-size: 12px; color: var(--txt-2); }

/* ---------------- 布局 ---------------- */
.board { padding: var(--gap) 26px 32px; display: flex; flex-direction: column; gap: var(--gap); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.kpi-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1.65fr; gap: var(--gap); }
.kpi-row > *, .line-row > *, .split-row > * { min-width: 0; } /* 防止宽表格内容把栅格列撑开造成挤压重叠 */
.kpi-wide { grid-column: span 1; }

/* 模块标题: 色带卡片式，模块划分一目了然 */
.section-title {
  font-size: 16px; font-weight: 700; color: #0f2f6e;
  background: linear-gradient(90deg, #e7effd 0%, #f6f9fe 70%, rgba(246,249,254,0) 100%);
  border-left: 4px solid var(--blue);
  border-radius: 0 9px 9px 0;
  padding: 9px 14px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.section-title em { font-style: normal; font-size: 12px; color: var(--txt-2); font-weight: 400; }
.section-title.compact { font-size: 14px; }
.legend { font-size: 11.5px; color: var(--txt-2); font-weight: 400; margin-left: auto; display: flex; align-items: center; gap: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-left: 8px; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.risk { background: var(--risk); }

/* ---------------- KPI 卡（主数值 | 分隔线 | 明细区） ---------------- */
.kpi-card { display: flex; flex-direction: column; gap: 10px; min-height: 168px; }
.kpi-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; color: #0f2f6e; }
.kpi-ico {
  width: 27px; height: 27px; border-radius: 7px; background: var(--blue-soft);
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px; flex: none;
}
.kpi-body { display: flex; align-items: center; gap: 16px; flex: 1; min-height: 0; }
.kpi-main { display: flex; flex-direction: column; gap: 6px; min-width: 118px; }
.kpi-divider { width: 1px; align-self: stretch; background: var(--line); flex: none; }
.kpi-side { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.kpi-row2 { display: flex; justify-content: space-between; align-items: baseline; font-size: 12px; color: var(--txt-2); }
.kpi-row2 b { color: var(--txt); font-size: 14.5px; }
.blt { width: 8px; height: 8px; border-radius: 2.5px; display: inline-block; margin-right: 7px; vertical-align: 1px; }
.stack-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: #edf1f7; margin: 1px 0 3px; }
.stack-bar i { display: block; height: 100%; }
.stack-bar i.g { background: var(--ok); }
.stack-bar i:not(.g) { background: var(--warn); }
.kpi-big { font-size: 38px; font-weight: 800; color: #0f2f6e; line-height: 1; }
.kpi-big small { font-size: 14px; font-weight: 600; color: var(--txt-2); margin-left: 5px; }
.kpi-trend { font-size: 11.5px; color: var(--ok); }

/* 需求柱状图 (纯 CSS, 峰值柱加深) */
.demand-chart { flex: 1; display: flex; align-items: flex-end; gap: 26px; padding: 6px 10px 0; min-height: 104px; }
.demand-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.demand-val { font-size: 12px; font-weight: 700; color: #0f2f6e; }
.demand-bar {
  width: 62%; border-radius: 6px 6px 2px 2px; min-height: 8px;
  background: linear-gradient(180deg, #7aa5f2 0%, #3f76e0 100%);
}
.demand-bar.peak { background: linear-gradient(180deg, #2f6ae0 0%, #1d4fd0 100%); }
.demand-mon { font-size: 11.5px; color: var(--txt-2); }

/* ---------------- 产品线卡 ---------------- */
.line-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); }
.line-card { display: flex; flex-direction: column; gap: 12px; }
.line-head { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; color: #0f2f6e; }
.line-head .arr { margin-left: auto; color: #b6c2d6; }
.gauge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 6px; }
.gauge { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.gauge svg { transform: rotate(-90deg); }
.gauge .track { stroke: #edf1f7; }
.gauge .val { transition: stroke-dashoffset .6s ease; }
.gauge-lbl { font-size: 10.5px; color: var(--txt-2); line-height: 1.3; }
.gauge-sub { font-size: 10.5px; color: var(--txt-2); line-height: 1.6; display: flex; flex-direction: column; }
.gauge-sub b { color: var(--txt); }
.gauge-sub .neg { color: var(--risk); }

/* ---------------- 表格 ---------------- */
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table-scroll.scroll-lg { max-height: 330px; overflow-y: auto; }
.table-scroll.scroll-sm { max-height: 252px; overflow-y: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; white-space: nowrap; }
/* 表头双层强调: 组名深蓝白字 / 列名浅蓝深字 */
table.grid th {
  background: #dfe9fb; color: #10306e; font-weight: 700; font-size: 12.5px;
  letter-spacing: .5px; padding: 9px 12px;
  border-bottom: 2px solid #b9ccec; border-right: 1px solid #cfdcef;
  text-align: center; position: sticky; top: 33px; z-index: 2;
}
table.grid th.group {
  background: #0f2f6e; color: #fff; font-weight: 700; letter-spacing: 1.5px;
  border-bottom: none; border-right: 1px solid #2a4c96;
  padding: 8px 12px; top: 0; z-index: 3;
}
/* 单行表头表（底部双表）: 无组名行，表头直接贴顶 */
table.grid.plain th { top: 0; }
table.grid td {
  padding: 8.5px 12px; border-bottom: 1px solid #f0f3f9; border-right: 1px solid #f5f7fb;
  text-align: center; color: var(--txt);
}
table.grid tr:hover td { background: #f7faff; }
td.line-cell { font-weight: 700; color: #0f2f6e; background: #f8faff; }
td.left { text-align: left; }

/* 数值等级色块 */
.lv { display: inline-block; min-width: 46px; padding: 2.5px 8px; border-radius: 5px; font-weight: 700; }
.lv.ok   { background: var(--ok-bg);   color: var(--ok); }
.lv.warn { background: var(--warn-bg); color: #b45309; }
.lv.risk { background: var(--risk-bg); color: var(--risk); }

/* 齐套点阵 */

/* 进度条（数值外置右侧，对齐截图） */
.pbar-wrap { display: inline-flex; align-items: center; gap: 6px; }
.pbar { position: relative; background: #edf1f7; border-radius: 6px; height: 13px; width: 64px; overflow: hidden; }
.pbar > i { position: absolute; inset: 0 auto 0 0; border-radius: 6px; background: linear-gradient(90deg, #5b8def, #2f6ae0); }
.pbar-val { font-size: 11.5px; color: #10306e; font-weight: 700; min-width: 34px; }

/* 状态徽标 */
.chip { display: inline-block; padding: 2.5px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.chip.run  { background: var(--info-bg); color: var(--blue); }
.chip.done { background: var(--ok-bg); color: var(--ok); }
.chip.delay { background: var(--risk-bg); color: var(--risk); }
.chip.ontime { background: var(--ok-bg); color: var(--ok); }

/* Tab 组（明细表产品线切换） */
.tab-group { display: flex; margin-left: 12px; font-weight: 400; }
.tab-group button {
  border: 1px solid var(--line); background: #fff; padding: 5px 16px; font-size: 12px;
  cursor: pointer; color: var(--txt-2);
}
.tab-group button:first-child { border-radius: 7px 0 0 7px; }
.tab-group button:last-child { border-radius: 0 7px 7px 0; }
.tab-group button + button { border-left: none; }
.tab-group button.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }

/* 底部双表迷你筛选（对齐截图下拉框） */
.mini-filters { display: flex; gap: 10px; margin-left: auto; font-weight: 400; flex-wrap: wrap; }
.mini-filter { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--txt-2); }
.mini-filter select {
  border: 1px solid var(--line); border-radius: 6px; padding: 3.5px 6px;
  font-size: 11.5px; color: var(--txt); background: #fff; outline: none; min-width: 66px;
}

/* 底部双表: 左右栅格 + 统一间隙 + 等高卡片 */
.split-row { display: grid; grid-template-columns: 1.05fr 1fr; gap: var(--gap); align-items: stretch; }
.split-col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.split-col .table-card { flex: 1; display: flex; flex-direction: column; }
.split-col .table-scroll { flex: 1; }

.foot { text-align: center; color: var(--txt-2); font-size: 11px; }

/* ---------------- 模态框 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(10, 25, 55, .45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
/* 关键: display:flex 会覆盖 hidden 属性的默认 display:none，必须显式还原 */
.modal-mask[hidden] { display: none !important; }
.modal { background: #fff; border-radius: 14px; width: 580px; max-width: 92vw; max-height: 84vh; overflow: auto; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 15px;
}
.modal-close { border: none; background: none; font-size: 15px; cursor: pointer; color: var(--txt-2); }
.modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.drop-zone {
  border: 2px dashed #b9c8e6; border-radius: 12px; padding: 26px 16px;
  text-align: center; color: var(--txt-2); display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.drop-zone.drag { border-color: var(--blue); background: #f5f9ff; }
.hint { font-size: 11.5px; color: var(--txt-2); line-height: 1.7; }
.hint code { background: #f0f3f9; padding: 0 5px; border-radius: 4px; }
.file-label input { display: none; }
.import-log { font-size: 12px; max-height: 180px; overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.import-log .ok { color: var(--ok); } .import-log .err { color: var(--risk); } .import-log .info { color: var(--blue); }
.tpl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tpl-item {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 12px; font-size: 12.5px;
}
.tpl-item small { display: block; color: var(--txt-2); margin-top: 2px; }

/* 响应式 */
@media (max-width: 1180px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .line-row { grid-template-columns: 1fr; }
  .split-row { grid-template-columns: 1fr; }
}
