:root {
  --bg: #f2f5f4;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --surface-3: #eef2f1;
  --line: #dde3e1;
  --line-2: #c8d2cf;
  --ink: #16211f;
  --ink-2: #46534f;
  --ink-3: #5f6d6a;
  --accent: #0f6157;
  --accent-ink: #0b4a43;
  --accent-weak: #e4f0ee;
  --accent-2: #3b4f86;
  --warn: #9a5608;
  --warn-weak: #fdf2e2;
  --danger: #a02a1e;
  --danger-weak: #fceceb;
  --ok: #1d6b3c;
  --ok-weak: #e7f3ea;
  --radius: 6px;
  /* 全站统一的左右留白：顶栏、KPI 条与内容面板共用同一条基准线 */
  --gutter: 16px;
  --shadow: 0 1px 2px rgba(18, 32, 30, .06), 0 1px 1px rgba(18, 32, 30, .04);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.sprite { display: none; }

.ic {
  width: 15px;
  height: 15px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------ 布局 */
.app {
  display: grid;
  grid-template-columns: 218px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  background: #12211f;
  color: #cfe0dd;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { color: #fff; font-size: 14px; }
.brand-text span { font-size: 11px; color: #7f9a95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: #b6c9c6;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .ic { opacity: .9; }

.side-foot {
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.side-stat { display: flex; justify-content: space-between; font-size: 11px; color: #7f9a95; }
.side-stat strong { color: #cfe0dd; font-weight: 500; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* 页面主体：宽屏时居中限宽，保证顶栏、KPI 条与内容区左右对齐 */
.main-inner {
  width: 100%;
  max-width: 1680px;
  margin: 0 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px var(--gutter) 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar-title p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-3); }
.btn-ghost:hover { border-color: var(--line-2); color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn-icon { width: 24px; height: 24px; padding: 0; justify-content: center; }
.btn-icon.danger:hover { border-color: var(--danger); color: var(--danger); }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.kpi {
  background: var(--surface);
  padding: 11px 16px 12px;
  min-width: 0;
}

.kpi-label { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 5px; }
.kpi-value {
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 3px;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-sub { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.kpi-value.ok { color: var(--ok); }
.kpi-value.warn { color: var(--warn); }
.kpi-value.danger { color: var(--danger); }

.content { padding: 16px var(--gutter) 48px; display: flex; flex-direction: column; gap: 14px; }

/* 允许网格/弹性子项收缩到内容宽度以下，避免长表格撑破窄屏 */
.content > *, .grid-2 > *, .grid-3 > *, .params > *, .kpis > *, .panel-body > * { min-width: 0; }

/* ------------------------------------------------------------ 区块 */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.panel-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-weight: 600;
  font-size: 13.5px;
  min-width: 0;
  flex: 1 1 240px;
}
.panel-title > span { white-space: nowrap; }
.panel-title small { font-weight: 400; font-size: 11.5px; color: var(--ink-3); min-width: 0; }
.panel-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 0 1 auto; }
.panel-body { padding: 12px 14px; }
.panel-body.flush { padding: 0; }

/* 录入条：表格上方的「选人员 + 填金额 + 事由 + 添加」一行 */
.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.inline-form select.cell-input { width: 190px; }
.inline-form input.cell-input { width: 140px; }
.inline-form input.cell-input.wide { width: 260px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }

/* ------------------------------------------------------------ 参数条 */
.params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 14px;
  padding: 12px 14px;
}

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field label { font-size: 11.5px; color: var(--ink-3); }
.field .hint { font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }

input[type="text"], input[type="number"], select {
  height: 28px;
  width: 100%;
  min-width: 0;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

input[type="number"] { text-align: right; }
input:focus, select:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
input.num-override { border-color: var(--warn); background: var(--warn-weak); }
input:disabled { background: var(--surface-3); color: var(--ink-3); }

/* ------------------------------------------------------------ 表格 */
.table-wrap { overflow: auto; max-height: 70vh; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-variant-numeric: tabular-nums; }

th, td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-3);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 11.5px;
  border-bottom: 1px solid var(--line-2);
}

td.txt, th.txt { text-align: left; }
td.mid, th.mid { text-align: center; }
tbody tr:hover td { background: #f7faf9; }
tbody tr.total td { background: var(--surface-3); font-weight: 600; border-top: 1px solid var(--line-2); }
tbody tr.group-row td { background: var(--accent-weak); font-weight: 600; }

.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--surface); }
th.sticky-col { z-index: 3; background: var(--surface-3); }
tbody tr:hover .sticky-col { background: #f7faf9; }
tbody tr.total .sticky-col { background: var(--surface-3); }

.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.ok { color: var(--ok); }
.warn { color: var(--warn); }
.danger { color: var(--danger); }
.strong { font-weight: 600; }
.pill {
  display: inline-block;
  padding: 0 6px;
  height: 18px;
  line-height: 18px;
  white-space: nowrap;
  border-radius: 9px;
  font-size: 11px;
  background: var(--surface-3);
  color: var(--ink-2);
}
.pill.warn { background: var(--warn-weak); color: var(--warn); }
.pill.danger { background: var(--danger-weak); color: var(--danger); }
.pill.ok { background: var(--ok-weak); color: var(--ok); }
.pill.accent { background: var(--accent-weak); color: var(--accent-ink); }

/* 表格内输入 */
input.cell-input, select.cell-input {
  height: 24px;
  padding: 0 6px;
  font-size: 12px;
}

td input.cell-input, td select.cell-input { width: 100%; min-width: 62px; }
input.name-input { min-width: 92px; }
td .btn-icon { vertical-align: middle; }

.sub-head {
  margin: 14px 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.grid-3 > .kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------ 分段控件 */
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius); overflow: hidden; }
.seg button {
  border: 0;
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: 12.5px;
  height: 28px;
  padding: 0 12px;
  cursor: pointer;
  border-right: 1px solid var(--line);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { background: var(--surface-3); }
.seg button.active { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------ 提示 */
.note {
  display: flex;
  gap: 8px;
  padding: 9px 11px;
  border-radius: var(--radius);
  font-size: 12px;
  line-height: 1.55;
  border: 1px solid transparent;
}
.note .ic { margin-top: 1px; }
.note.info { background: var(--accent-weak); color: var(--accent-ink); border-color: #cfe3df; }
.note.warn { background: var(--warn-weak); color: var(--warn); border-color: #f0dcc0; }
.note.danger { background: var(--danger-weak); color: var(--danger); border-color: #f2d5d1; }
.note.ok { background: var(--ok-weak); color: var(--ok); border-color: #cfe4d6; }

.issue-list { display: flex; flex-direction: column; gap: 6px; }
.issue {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.issue .ic { margin-top: 2px; }
.issue h4 { margin: 0 0 2px; font-size: 12.5px; font-weight: 600; }
.issue p { margin: 0; font-size: 11.5px; color: var(--ink-2); line-height: 1.55; }
.issue .issue-tag { font-size: 11px; white-space: nowrap; }

/* ------------------------------------------------------------ 弹层 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(16, 26, 24, .42);
  display: grid;
  place-items: center;
  z-index: 60;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--surface);
  border-radius: 8px;
  width: min(860px, 100%);
  max-height: 84vh;
  overflow: auto;
  box-shadow: 0 18px 48px rgba(12, 24, 22, .22);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 14px; }
.modal-body { padding: 14px 16px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #12211f;
  color: #fff;
  padding: 9px 14px;
  border-radius: var(--radius);
  font-size: 12.5px;
  box-shadow: 0 8px 24px rgba(12, 24, 22, .24);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: none; }

/* ------------------------------------------------------------ 响应式 */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav-item { white-space: nowrap; }
  .side-foot { display: none; }
  .topbar { flex-direction: column; }
  .content { padding: 12px var(--gutter) 40px; }
  .table-wrap { max-height: none; }
}

/* ------------------------------------------------------------ 对照页提示条 */
.compare-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  background: var(--accent-weak);
  border-bottom: 1px solid #cfe3df;
  color: var(--accent-ink);
  font-size: 12px;
}

.compare-banner strong { display: block; font-size: 13px; }
.compare-banner span { color: var(--ink-2); }

@media (max-width: 640px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:last-child:nth-child(odd) { grid-column: span 2; }
  .kpi-value { font-size: 16px; }
  .params { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
