: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;
}

.panel-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.compact-action {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

.trend-heading-actions {
  display: flex;
  flex-wrap: wrap;
  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;
}

.panel-actions .status-error {
  color: #b42318;
  font-weight: 700;
}

.inline-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.inline-filter select {
  min-width: 120px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.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;
}

.decline-panel {
  border-color: rgba(194, 65, 59, 0.22);
}

.decline-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.decline-card {
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
}

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

.decline-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1;
}

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

.decline-table-wrap {
  max-height: 520px;
}

.decline-table {
  min-width: 1320px;
}

.priority-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

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

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

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

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

.negative {
  color: var(--red);
  font-weight: 800;
}

.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,
  .panel-actions,
  .panel-actions button {
    width: 100%;
  }

  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions {
    align-items: stretch;
  }

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

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-actions a {
  text-decoration: none;
}

.root-cause-page {
  width: min(100% - 48px, 1500px);
  margin: 0 auto;
  padding: 22px 0 40px;
}

.root-cause-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.2fr) minmax(180px, 0.8fr) minmax(180px, 0.8fr) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.root-cause-toolbar .field {
  display: grid;
  gap: 6px;
}

.root-cause-toolbar span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.root-cause-toolbar input,
.root-cause-toolbar select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 10px;
  background: #fff;
  color: var(--text);
}

.root-cause-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}

.root-cause-metric {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.root-cause-metric span,
.root-cause-metric small {
  color: var(--muted);
}

.root-cause-metric strong {
  color: var(--text);
  font-size: 24px;
}

.root-cause-table-panel {
  margin-top: 0;
}

.root-cause-table {
  min-width: 1380px;
}

.root-cause-table td:nth-child(9) {
  text-align: left;
}

.muted-inline {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.positive {
  color: var(--primary-strong);
}

.tag-blue {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.tag-orange {
  background: rgba(217, 119, 6, 0.14);
  color: #b45309;
}

.tag-muted {
  background: rgba(100, 116, 139, 0.14);
  color: #475569;
}

.empty-state {
  padding: 40px 0;
  color: var(--muted);
  text-align: center !important;
}

@media (max-width: 960px) {
  .root-cause-page {
    width: min(100% - 20px, 1500px);
  }

  .root-cause-toolbar,
  .root-cause-summary {
    grid-template-columns: 1fr;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

.action-dashboard-header {
  width: min(100% - 48px, 1500px);
  margin: 0 auto;
}

.action-dashboard-page {
  width: min(100% - 48px, 1500px);
  margin: 0 auto;
  padding: 22px 0 40px;
}

.action-dashboard-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.action-dashboard-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.action-dashboard-controls label {
  display: grid;
  gap: 6px;
  min-width: 170px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.action-dashboard-controls select {
  padding: 0 10px;
}

.action-summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.action-section {
  margin-top: 14px;
}

.operator-board-list {
  display: grid;
  gap: 14px;
}

.operator-action-board {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.operator-board-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.operator-board-header h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.operator-board-header p,
.muted-text {
  color: var(--muted);
  font-size: 13px;
}

.operator-metric-groups {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.operator-metric-group {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.operator-metric-group h4 {
  margin: 0 0 10px;
  color: var(--primary-strong);
  font-size: 14px;
}

.operator-metric-grid {
  display: grid;
  gap: 8px;
}

.action-metric {
  min-height: 82px;
  padding: 11px;
  border: 1px solid #e4ece9;
  border-radius: 8px;
  background: var(--surface);
}

.action-metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.action-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 21px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.action-metric small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.trend-up {
  color: var(--primary-strong);
  font-weight: 900;
}

.trend-down {
  color: var(--red);
  font-weight: 900;
}

.trend-flat {
  color: var(--muted);
  font-weight: 900;
}

.metric-with-trend {
  display: inline-flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
}

.metric-with-trend strong {
  color: var(--text);
  font-weight: 800;
}

.metric-with-trend .trend-up,
.metric-with-trend .trend-down,
.metric-with-trend .trend-flat {
  font-size: 11px;
}

.action-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

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

.action-detail-wrap {
  max-height: 560px;
}

.action-detail-table {
  min-width: 2060px;
  border-collapse: separate;
  border-spacing: 0;
}

.action-detail-table th:nth-child(1),
.action-detail-table td:nth-child(1) {
  position: sticky;
  left: 0;
  z-index: 4;
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  background: var(--surface);
  box-sizing: border-box;
}

.action-detail-table th:nth-child(2),
.action-detail-table td:nth-child(2) {
  position: sticky;
  left: 64px;
  z-index: 4;
  width: 94px;
  min-width: 94px;
  max-width: 94px;
  background: var(--surface);
  box-sizing: border-box;
}

.action-detail-table th:nth-child(3),
.action-detail-table td:nth-child(3) {
  position: sticky;
  left: 158px;
  z-index: 4;
  width: 88px;
  min-width: 88px;
  max-width: 88px;
  background: var(--surface);
  box-sizing: border-box;
  box-shadow: 10px 0 14px -14px rgba(15, 23, 42, 0.45);
}

.action-detail-table thead th:nth-child(-n + 3) {
  z-index: 7;
}

.action-detail-table td:nth-child(3) strong {
  white-space: nowrap;
}

.action-detail-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}

.action-detail-table th[data-sort]:hover {
  color: var(--primary-strong);
}

.note-input,
.note-display {
  width: 180px;
  min-height: 42px;
  max-height: 96px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  line-height: 1.35;
}

.note-display {
  background: #f6f8f7;
  color: var(--muted);
}

.note-input:focus {
  outline: 2px solid rgba(22, 115, 95, 0.18);
  border-color: var(--primary);
}

.feedback-cell {
  width: 250px;
  display: grid;
  gap: 4px;
  white-space: normal;
  line-height: 1.35;
}

.feedback-cell strong {
  color: var(--primary-strong);
  font-size: 12px;
}

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

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

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

@media (max-width: 760px) {
  .action-dashboard-header,
  .action-dashboard-page {
    width: min(100% - 20px, 1500px);
  }

  .action-dashboard-intro,
  .operator-board-header {
    align-items: stretch;
    flex-direction: column;
  }

  .action-dashboard-controls,
  .action-dashboard-controls label,
  .action-dashboard-controls select {
    width: 100%;
  }

  .action-summary-grid,
  .operator-metric-groups {
    grid-template-columns: 1fr;
  }
}
