:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-strong: #eef4f2;
  --text: #17211f;
  --muted: #66736f;
  --line: #d8e1de;
  --primary: #16735f;
  --primary-strong: #0f5a4b;
  --blue: #3366cc;
  --amber: #b7791f;
  --red: #c2413b;
  --shadow: 0 14px 34px rgba(22, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 88px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.15;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

.data-actions,
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.file-button,
button,
select,
input[type="date"],
input[type="search"] {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.file-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

button:hover {
  background: var(--primary-strong);
}

.file-button input {
  display: none;
}

.filters {
  align-items: end;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.filters label {
  display: grid;
  gap: 7px;
  min-width: 148px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.filters select,
.filters input {
  width: 100%;
  padding: 0 10px;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.kpi-card {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin-top: 12px;
  font-size: clamp(22px, 2.3vw, 34px);
  line-height: 1;
}

.kpi-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-wide {
  grid-column: span 2;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 12px;
}

.trend-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.segmented-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.segmented-control button {
  min-width: 42px;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}

.segmented-control button:hover,
.segmented-control button.active {
  background: var(--primary);
  color: #fff;
}

.line-chart {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(22px, 1fr));
  align-items: end;
  gap: 8px;
  height: 250px;
  padding: 12px 6px 0;
  border-bottom: 1px solid var(--line);
}

.trend-chart {
  min-height: 250px;
}

.trend-chart-month {
  grid-template-columns: repeat(var(--cols), minmax(42px, 1fr));
  gap: 10px;
}

.trend-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: end;
  height: 100%;
  gap: 8px;
  min-width: 0;
}

.trend-value {
  min-height: 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
}

.trend-bar {
  width: 100%;
  max-width: 96px;
  min-width: 20px;
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #1f8f75, #85b8a8);
}

.trend-label {
  min-height: 32px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  overflow-wrap: anywhere;
}

.trend-chart-day {
  display: block;
  padding: 6px 0 0;
  border-bottom: 0;
}

.trend-svg {
  display: block;
  width: 100%;
  height: 250px;
}

.trend-area {
  fill: rgba(31, 143, 117, 0.14);
}

.trend-line {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-dot {
  fill: #fff;
  stroke: var(--primary);
  stroke-width: 2;
}

.trend-dot.is-muted {
  opacity: 0.35;
}

.trend-axis {
  stroke: var(--line);
  stroke-width: 1;
}

.trend-grid {
  stroke: #edf3f1;
  stroke-width: 1;
}

.trend-x-label,
.trend-y-label {
  fill: var(--muted);
  font-size: 12px;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-strong);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.bucket-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.bucket {
  padding: 14px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-strong);
  color: var(--text);
  text-align: left;
}

.bucket strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
}

.bucket-button:hover {
  background: #dcebe6;
  color: var(--text);
}

.inventory-mix {
  display: grid;
  gap: 12px;
}

.mix-item {
  padding: 14px;
  border-left: 4px solid var(--primary);
  background: var(--surface-strong);
  border-radius: 6px;
}

.mix-item:nth-child(2) {
  border-color: var(--amber);
}

.mix-item strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.table-panel {
  margin-top: 14px;
}

.product-grid {
  grid-template-columns: 1.25fr 1fr;
}

.compact-table-wrap {
  max-height: 420px;
}

.compact-table {
  min-width: 760px;
}

.risk-table {
  min-width: 680px;
}

.compact-table th,
.compact-table td {
  padding: 9px 8px;
  font-size: 12px;
}

.detail-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

.detail-tools label {
  display: grid;
  gap: 6px;
  min-width: 180px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-tools input {
  width: 100%;
  padding: 0 10px;
  background: var(--surface);
}

.secondary-button {
  background: var(--surface);
  color: var(--text);
  border-color: var(--line);
}

.secondary-button:hover {
  background: var(--surface-strong);
}

.operator-panel {
  border-color: rgba(22, 115, 95, 0.28);
}

.operator-table-wrap {
  max-height: none;
}

.operator-table {
  min-width: 1520px;
}

.operator-table th,
.operator-table td {
  padding: 14px 12px;
  font-size: 14px;
}

.operator-table td:first-child strong {
  font-size: 16px;
}

.operator-table td:nth-child(4),
.operator-table td:nth-child(6),
.operator-table td:nth-child(10) {
  font-weight: 800;
}

.target-good,
.target-watch,
.target-risk {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 74px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
}

.target-good {
  background: rgba(22, 115, 95, 0.12);
  color: var(--primary-strong);
}

.target-watch {
  background: rgba(183, 121, 31, 0.14);
  color: var(--amber);
}

.target-risk {
  background: rgba(194, 65, 59, 0.12);
  color: var(--red);
}

.table-wrap {
  overflow: auto;
  max-height: 460px;
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2),
th:nth-child(3),
td:nth-child(3) {
  text-align: left;
}

.empty {
  padding: 36px 0;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 14px;
  }

  .topbar,
  .status-row {
    align-items: stretch;
    flex-direction: column;
  }

  .data-actions,
  .data-actions > *,
  .filters label,
  .detail-tools label,
  .detail-tools button {
    width: 100%;
  }

  .kpi-grid,
  .dashboard-grid,
  .bucket-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: auto;
  }
}
.is-hidden {
  display: none !important;
}
