/*
 * B9 成本、利润与月结页面样式（frontend/costing.js 专用）。
 *
 * 只新增 cost- 前缀类，不改 styles.css / planning.css / outsource.css 的既有语义；
 * 基础控件（.panel / .field / .input / .btn / .badge / .view-head）仍走 styles.css。
 *
 * 响应式要求：1366x900 与 360x800 均可用，表格窄屏下横向滚动由 .cost-table-wrap
 * 自身承担，不让整页产生横向溢出。
 */

/* ---------- 页签 ---------- */

.cost-root {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.cost-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 8px;
  min-width: 0;
}

.cost-tab {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #fff;
  color: #374151;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}

.cost-tab:hover {
  background: #f3f4f6;
}

.cost-tab.is-active {
  background: #1f2937;
  border-color: #1f2937;
  color: #fff;
}

.cost-body,
.cost-stack,
.cost-list,
.cost-tab-host {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* ---------- 面板内元素 ---------- */

.cost-panel {
  min-width: 0;
}

.cost-sub-title {
  margin: 12px 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.cost-panel .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.cost-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

/* ---------- 键值概览 ---------- */

.cost-kv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px 16px;
  margin-bottom: 12px;
}

.cost-kv-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cost-kv-label {
  font-size: 12px;
  color: #6b7280;
}

.cost-kv-value {
  font-size: 14px;
  color: #111827;
  word-break: break-word;
}

/* ---------- 合计行（服务端值原样显示，浏览器不求和） ---------- */

.cost-total-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed #e5e7eb;
}

.cost-total {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  min-width: 120px;
}

.cost-total-label {
  font-size: 12px;
  color: #6b7280;
}

.cost-total-value {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
}

.cost-total-value.is-masked {
  color: #9ca3af;
  letter-spacing: 1px;
}

/* ---------- 表格：窄屏由本容器横向滚动 ---------- */

.cost-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.cost-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 13px;
}

.cost-table th,
.cost-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #f3f4f6;
  text-align: left;
  vertical-align: top;
  word-break: break-word;
}

.cost-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
}

.cost-table .cost-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cost-empty {
  padding: 16px;
  border: 1px dashed #e5e7eb;
  border-radius: 8px;
  color: #6b7280;
}

/* ---------- 行级告警：缺单重标红 / 无产量 / 待处理 ---------- */

.cost-row-missing > td {
  background: #fef2f2;
  color: #b91c1c;
}

.cost-row-missing > td:first-child {
  box-shadow: inset 3px 0 0 #dc2626;
}

.cost-row-warn > td {
  background: #fffbeb;
}

.cost-fifo-drawer[hidden] { display: none; }
.cost-fifo-drawer {
  position: fixed;
  z-index: 1000;
  inset: 0 0 0 auto;
  width: min(760px, 94vw);
  height: 100vh;
  overflow: auto;
  padding: 16px;
  background: #fff;
  border-left: 1px solid #d1d5db;
  box-shadow: -12px 0 30px #1118272e;
}
.cost-fifo-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

/* ---------- 缺单重按件单列面板 ---------- */

.cost-missing {
  margin-top: 12px;
  padding: 10px 12px;
  border: 2px solid #dc2626;
  border-radius: 8px;
  background: #fef2f2;
}

.cost-missing-title {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  color: #b91c1c;
}

.cost-missing-hint {
  margin: 0 0 8px;
  font-size: 12px;
  color: #7f1d1d;
}

.cost-missing .cost-table-wrap {
  background: #fff;
}

/* ---------- 表单 ---------- */

.cost-form,
.cost-inline-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.cost-form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 14px;
}

.cost-month-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.cost-form .field {
  min-width: 0;
}

.cost-field-error {
  margin: 0;
  font-size: 12px;
  color: #b91c1c;
  min-height: 1em;
  word-break: break-word;
}

.cost-field-ok {
  margin: 0;
  font-size: 12px;
  color: #166534;
  word-break: break-word;
}

/* ---------- 提示 / 错误块 ---------- */

.cost-hint {
  margin: 8px 0 0;
  font-size: 12px;
  line-height: 1.6;
  word-break: break-word;
}

.cost-hint-info {
  color: #374151;
  background: #f3f4f6;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #6b7280;
}

.cost-hint-warn {
  color: #92400e;
  background: #fffbeb;
  padding: 8px 10px;
  border-radius: 6px;
  border-left: 3px solid #f59e0b;
}

.cost-hint-muted {
  color: #6b7280;
}

.cost-error {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
}

.cost-error-main {
  margin: 0;
  font-size: 13px;
  color: #b91c1c;
}

.cost-error-code {
  margin: 4px 0 0;
  font-size: 12px;
  color: #7f1d1d;
}

/* ---------- 窄屏（360x800）：单列堆叠，去掉横向溢出 ---------- */

@media (max-width: 640px) {
  .cost-kv {
    grid-template-columns: 1fr;
  }

  .cost-form-row {
    grid-template-columns: 1fr;
  }

  .cost-total {
    min-width: 0;
    flex: 1 1 100%;
  }

  .cost-tabs {
    gap: 4px;
  }

  .cost-tab {
    padding: 5px 10px;
    font-size: 12px;
  }

  /* 表格仍可横向滚动查看，但不让页面整体溢出 */
  .cost-table-wrap {
    overflow-x: auto;
  }

  .cost-actions .btn {
    flex: 1 1 auto;
  }
}

/* ================================================================== *
 * 工业现代风 · 作用域化设计系统（.cost-root 范围内生效）
 *
 * 目标：
 *  - 现代紧凑页签条（segmented strip）；
 *  - 面板 / 筛选器 / 表格统一 12px 圆角、#e2e8f0 描边、柔和阴影；
 *  - KPI 大号等宽数字（tabular-nums），金额与数量纵向对齐；
 *  - 表格吸顶表头、悬浮反馈、语义化徽标状态；
 *  - 390 宽度下控件 40px 高、表格在容器内横向滚动、整页无横向溢出。
 *
 * 设计令牌（仅 .cost-root 内定义，不污染全局）：
 *  --cost-blue:#2563eb  --cost-slate:#0f172a  --cost-bg:#f8fafc  --cost-line:#e2e8f0
 * ================================================================== */

.cost-root {
  --cost-blue: #2563eb;
  --cost-blue-dark: #1d4ed8;
  --cost-blue-soft: #eff6ff;
  --cost-slate: #0f172a;
  --cost-text: #1e293b;
  --cost-muted: #64748b;
  --cost-bg: #f8fafc;
  --cost-line: #e2e8f0;
  --cost-line-soft: #eef2f7;
  --cost-radius: 12px;
  --cost-radius-sm: 8px;
  --cost-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.05);
  --cost-shadow-lift: 0 2px 4px rgba(15, 23, 42, 0.05), 0 10px 24px rgba(15, 23, 42, 0.08);
  --cost-kpi-num: 26px;
  gap: 16px;
  color: var(--cost-text);
  background: var(--cost-bg);
}

/* ---------------- 页签条 ---------------- */

.cost-root .cost-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius);
  background: #fff;
  box-shadow: var(--cost-shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.cost-root .cost-tab {
  flex: 0 0 auto;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--cost-radius-sm);
  background: transparent;
  color: var(--cost-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.cost-root .cost-tab:hover {
  background: var(--cost-bg);
  color: var(--cost-slate);
}

.cost-root .cost-tab:focus-visible {
  outline: 2px solid var(--cost-blue);
  outline-offset: 1px;
}

.cost-root .cost-tab.is-active {
  background: var(--cost-blue);
  border-color: var(--cost-blue);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.28);
}

.cost-root .cost-tab.is-active:hover {
  background: var(--cost-blue-dark);
  border-color: var(--cost-blue-dark);
  color: #fff;
}

/* ---------------- 面板 ---------------- */

.cost-root .panel,
.cost-root .cost-panel {
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius);
  background: #fff;
  box-shadow: var(--cost-shadow);
  min-width: 0;
}

.cost-root .panel-head {
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cost-line-soft);
}

.cost-root .panel-title {
  color: var(--cost-slate);
  font-weight: 700;
  letter-spacing: .01em;
}

.cost-root .cost-sub-title {
  color: var(--cost-slate);
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 0;
}

.cost-root .cost-stack,
.cost-root .cost-list,
.cost-root .cost-body,
.cost-root .cost-tab-host {
  gap: 14px;
}

/* ---------------- 筛选器 / 表单 ---------------- */

.cost-root .cost-form,
.cost-root .cost-inline-form,
.cost-root .cost-run-form,
.cost-root .cost-expense-form,
.cost-root .cost-recalc-form,
.cost-root .cost-reopen-form,
.cost-root .cost-item-form {
  padding: 12px 14px;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius);
  background: #fff;
  box-shadow: var(--cost-shadow);
}

.cost-root .field {
  gap: 5px;
  min-width: 0;
}

.cost-root .field label,
.cost-root .field-label {
  color: var(--cost-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cost-root .input,
.cost-root select,
.cost-root textarea {
  min-height: 36px;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius-sm);
  background: #fff;
  color: var(--cost-slate);
  font-variant-numeric: tabular-nums;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.cost-root .input:focus,
.cost-root select:focus,
.cost-root textarea:focus {
  outline: none;
  border-color: var(--cost-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.cost-root .btn {
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--cost-radius-sm);
  border: 1px solid var(--cost-line);
  background: #fff;
  color: var(--cost-text);
  font-weight: 600;
  font-size: 13px;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.cost-root .btn:hover:not(:disabled) {
  border-color: #cbd5e1;
  background: var(--cost-bg);
}

.cost-root .btn-primary {
  background: var(--cost-blue);
  border-color: var(--cost-blue);
  color: #fff;
}

.cost-root .btn-primary:hover:not(:disabled) {
  background: var(--cost-blue-dark);
  border-color: var(--cost-blue-dark);
  color: #fff;
}

.cost-root .btn:focus-visible {
  outline: 2px solid var(--cost-blue);
  outline-offset: 2px;
}

/* 保留既有按钮语义变体（危险 / 幽灵 / 次要 / 小号），不被基础按钮样式压平。 */
.cost-root .btn-danger,
.cost-root .btn-void,
.cost-root .btn-reverse {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff;
}

.cost-root .btn-danger:hover:not(:disabled) {
  color: #991b1b;
  background: #fef2f2;
  border-color: #fca5a5;
}

.cost-root .btn-secondary {
  color: #334155;
  background: #fff;
  border-color: #cbd5e1;
}

.cost-root .btn-secondary:hover:not(:disabled) {
  color: #1d4ed8;
  background: #f8fafc;
  border-color: #93c5fd;
}

.cost-root .btn-ghost {
  color: var(--cost-blue-dark);
  background: transparent;
  border-color: transparent;
}

.cost-root .btn-ghost:hover:not(:disabled) {
  background: var(--cost-blue-soft);
}

.cost-root .btn-link {
  color: var(--cost-blue-dark);
  background: transparent;
  border-color: transparent;
  text-decoration: underline;
}

.cost-root .btn-small {
  min-height: 30px;
  padding: 6px 11px;
  font-size: 13px;
}

.cost-root .btn-mini {
  min-height: 26px;
  padding: 2px 8px;
  font-size: 12px;
}

.cost-root .btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ---------------- KPI 大号等宽数字 ---------------- */

.cost-root .cost-kpis,
.cost-root .cost-kpi-row,
.cost-root .cost-period-summary,
.cost-root .cost-profit-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 12px;
  min-width: 0;
}

.cost-root .cost-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius);
  background: #fff;
  box-shadow: var(--cost-shadow);
}

.cost-root .cost-kpi-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cost-muted);
}

.cost-root .cost-kpi-value,
.cost-root .cost-kpi-num {
  font-size: var(--cost-kpi-num);
  line-height: 1.15;
  font-weight: 700;
  color: var(--cost-slate);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}

.cost-root .cost-kpi-hint {
  font-size: 12px;
  color: var(--cost-muted);
}

.cost-root .cost-kpi.is-accent {
  border-color: #bfdbfe;
  background: var(--cost-blue-soft);
}

.cost-root .cost-kpi.is-danger {
  border-color: #fecaca;
  background: #fef2f2;
}

.cost-root .cost-kpi.is-danger .cost-kpi-value {
  color: #b91c1c;
}

.cost-root .cost-kpi.is-warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.cost-root .cost-kpi.is-warn .cost-kpi-value {
  color: #92400e;
}

/* 键值概览：数值大号等宽，标签小字大写 */
.cost-root .cost-kv {
  gap: 10px 16px;
}

.cost-root .cost-kv-item {
  gap: 3px;
  padding: 10px 12px;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius-sm);
  background: var(--cost-bg);
}

.cost-root .cost-kv-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cost-muted);
}

.cost-root .cost-kv-value {
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--cost-slate);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

/* 合计行 */
.cost-root .cost-total-row {
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--cost-line);
}

.cost-root .cost-total {
  gap: 3px;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius-sm);
  box-shadow: var(--cost-shadow);
  min-width: 140px;
}

.cost-root .cost-total-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cost-muted);
}

.cost-root .cost-total-value {
  font-size: 20px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--cost-slate);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.cost-root .cost-total-value.is-masked {
  color: var(--cost-muted);
}

/* ---------------- 表格：吸顶表头 + 悬浮 ---------------- */

.cost-root .cost-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--cost-line);
  border-radius: var(--cost-radius);
  background: #fff;
  box-shadow: var(--cost-shadow);
  max-height: min(70vh, 720px);
  overflow-y: auto;
}

.cost-root .cost-table {
  min-width: 640px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
}

.cost-root .cost-table th,
.cost-root .cost-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--cost-line-soft);
  vertical-align: middle;
  text-align: left;
  white-space: nowrap;
}

.cost-root .cost-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid var(--cost-line);
  color: var(--cost-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.cost-root .cost-table tbody tr {
  transition: background .12s ease;
}

.cost-root .cost-table tbody tr:hover {
  background: var(--cost-blue-soft);
}

.cost-root .cost-table tbody tr:last-child td {
  border-bottom: none;
}

.cost-root .cost-table .cost-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
}

/* 行级告警：缺单 / 无产量 / 待处理 */
.cost-root .cost-row-missing > td {
  background: #fef2f2;
  color: #b91c1c;
}

.cost-root .cost-row-missing:hover > td {
  background: #fee2e2;
}

.cost-root .cost-row-missing > td:first-child {
  box-shadow: inset 3px 0 0 #dc2626;
}

.cost-root .cost-row-warn > td {
  background: #fffbeb;
}

.cost-root .cost-row-warn:hover > td {
  background: #fef3c7;
}

.cost-root .cost-empty {
  border: 1px dashed var(--cost-line);
  border-radius: var(--cost-radius-sm);
  background: var(--cost-bg);
  color: var(--cost-muted);
}

/* ---------------- 抽屉 / 缺单面板 ---------------- */

.cost-root .cost-fifo-drawer {
  border-left: 1px solid var(--cost-line);
  box-shadow: var(--cost-shadow-lift);
  background: #fff;
}

.cost-root .cost-fifo-drawer-head {
  padding-bottom: 10px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--cost-line-soft);
}

.cost-root .cost-missing {
  border: 1px solid #fca5a5;
  border-left-width: 4px;
  border-radius: var(--cost-radius);
  background: #fef2f2;
}

.cost-root .cost-missing-title {
  color: #b91c1c;
}

.cost-root .cost-missing-hint {
  color: #7f1d1d;
}

/* ---------------- 提示 / 错误块 ---------------- */

.cost-root .cost-hint {
  border-radius: var(--cost-radius-sm);
}

.cost-root .cost-hint-info {
  color: var(--cost-text);
  background: var(--cost-bg);
  border-left: 3px solid var(--cost-muted);
  border: 1px solid var(--cost-line);
  border-left: 3px solid var(--cost-muted);
}

.cost-root .cost-hint-warn {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-left: 3px solid #f59e0b;
}

.cost-root .cost-error {
  border: 1px solid #fecaca;
  border-radius: var(--cost-radius-sm);
  background: #fef2f2;
}

.cost-root .cost-field-error {
  color: #b91c1c;
}

.cost-root .cost-field-ok {
  color: #166534;
}

/* ---------------- 语义徽标状态 ---------------- */

.cost-root .badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.cost-root .badge-ok,
.cost-root .badge-effective,
.cost-root .badge-normal {
  color: #166534;
  background: #dcfce7;
  border-color: #bbf7d0;
}

.cost-root .badge-pending,
.cost-root .badge-warning {
  color: #92400e;
  background: #fef3c7;
  border-color: #fde68a;
}

.cost-root .badge-bad,
.cost-root .badge-error {
  color: #991b1b;
  background: #fee2e2;
  border-color: #fecaca;
}

.cost-root .badge-neutral,
.cost-root .badge-muted {
  color: #475569;
  background: #f1f5f9;
  border-color: var(--cost-line);
}

.cost-root .badge-info,
.cost-root .badge-primary {
  color: #1d4ed8;
  background: #dbeafe;
  border-color: #bfdbfe;
}

/* ---------------- 手机 390×844 ---------------- */

@media (max-width: 640px) {
  .cost-root {
    --cost-kpi-num: 22px;
    gap: 12px;
  }

  .cost-root .cost-tabs {
    gap: 2px;
    padding: 3px;
    border-radius: 10px;
  }

  .cost-root .cost-tab {
    padding: 9px 10px;
    font-size: 12px;
  }

  /* 390 下控件统一 40px 高 */
  .cost-root .input,
  .cost-root select,
  .cost-root textarea,
  .cost-root .btn,
  .cost-root .cost-actions .btn,
  .cost-root .cost-form .btn,
  .cost-root .cost-inline-form .btn {
    min-height: 40px;
  }

  .cost-root .cost-kpis,
  .cost-root .cost-kpi-row,
  .cost-root .cost-period-summary,
  .cost-root .cost-profit-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .cost-root .cost-kpi {
    padding: 10px 12px;
  }

  .cost-root .cost-kv {
    grid-template-columns: 1fr;
  }

  .cost-root .cost-kv-value {
    font-size: 17px;
  }

  .cost-root .cost-total {
    min-width: 0;
    flex: 1 1 100%;
  }

  /* 表格在自身容器内滚动，页面本身不横向溢出 */
  .cost-root .cost-table-wrap {
    max-height: none;
    overflow-x: auto;
    overflow-y: visible;
  }

  .cost-root .cost-table {
    min-width: 600px;
  }

  .cost-root .panel {
    padding: 12px;
  }
}

@media (max-width: 400px) {
  .cost-root .cost-kpis,
  .cost-root .cost-kpi-row,
  .cost-root .cost-period-summary,
  .cost-root .cost-profit-summary {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cost-root .cost-table th { background:#f1f5f9; color:#334155; font-size:12px; }
