﻿:root {
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f7fafc;
  --line: #b8c4d2;
  --text: #202a35;
  --muted: #617083;
  --blue: #1687f5;
  --blue-dark: #0e5eaf;
  --green: #16a34a;
  --amber: #e67e22;
  --red: #d83a42;
  --gray: #768292;
  --shadow: 0 8px 22px rgba(36, 52, 71, 0.08);
}

* {
  box-sizing: border-box;
}

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

html.auth-pending .app-shell {
  display: none;
}

body.auth-locked .app-shell {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-width: 1120px;
  padding: 4px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  font-weight: 650;
}

.topbar p,
.panel-note,
.detail-head p {
  color: var(--muted);
  font-size: 13px;
}

.view-tabs,
.drill-control,
.segmented {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.drill-control {
  position: relative;
}

.drill-calendar-toggle {
  min-height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.drill-calendar-toggle:hover,
.drill-calendar-toggle[aria-expanded="true"] {
  border-color: var(--blue);
  color: var(--blue-dark);
  background: #eef6ff;
}

.week-calendar-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  width: min(560px, calc(100vw - 20px));
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-shadow: var(--shadow);
}

.week-calendar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
  color: var(--text);
  font-size: 12px;
}

.week-calendar-head span {
  color: var(--muted);
  font-weight: 400;
}

.week-calendar-table-wrap {
  max-height: 280px;
  overflow: auto;
}

.week-calendar-table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 12px;
}

.week-calendar-table th,
.week-calendar-table td {
  padding: 6px 7px;
  border-bottom: 1px solid #e1e8f0;
  text-align: left;
  white-space: nowrap;
}

.week-calendar-table th {
  position: sticky;
  top: 0;
  background: #eef4fa;
  color: var(--muted);
  font-weight: 600;
}

.week-calendar-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  font-weight: 700;
}

.week-calendar-link:hover { text-decoration: underline; }

.week-calendar-empty {
  padding: 18px 7px !important;
  color: var(--muted);
  text-align: center !important;
}

.tab,
.drill,
.sort-toggle {
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.tab.is-active,
.drill.is-active,
.sort-toggle.is-active {
  background: var(--blue);
  color: #fff;
}

.slicer-band {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr)) 160px 160px 150px 110px 96px;
  gap: 6px;
  margin: 6px 0;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.slicer-grid {
  display: contents;
}

.slicer,
.date-control,
.number-control {
  position: relative;
  min-width: 0;
}

.slicer-button,
.date-control input,
.number-control input,
.ghost-button,
.primary-button,
.danger-button {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.slicer-button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  padding: 5px 10px;
  text-align: left;
}

.slicer-button span,
.date-control span,
.number-control span {
  color: var(--muted);
  font-size: 12px;
}

.slicer-button strong {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
}

.slicer-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 30;
  width: 260px;
  max-height: 360px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 16px 36px rgba(23, 40, 58, 0.22);
}

.slicer-menu input[type="search"] {
  width: 100%;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.slicer-options {
  max-height: 250px;
  margin-top: 8px;
  overflow: auto;
}

.slicer-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 3px;
  font-size: 13px;
}

.slicer-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}

.date-control,
.number-control {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.date-control input,
.number-control input {
  min-height: 36px;
  padding: 0 8px;
}

.drill-control {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 3px;
  min-width: 156px;
  white-space: nowrap;
}

.drill-control .drill {
  flex: 1 1 0;
  min-width: 0;
  padding: 0 10px;
}

.ghost-button {
  padding: 0 12px;
  background: var(--surface-soft);
}

.primary-button {
  padding: 0 16px;
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.danger-button {
  padding: 0 16px;
  border-color: var(--red);
  background: #fff4f4;
  color: var(--red);
}
.view {
  display: none;
}

.view.is-active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(130px, 1fr));
  gap: 4px;
  margin-bottom: 4px;
}

.kpi-grid.compact {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.kpi {
  min-height: 50px;
  padding: 5px 7px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.kpi strong {
  display: block;
  margin-top: 2px;
  font-size: 21px;
}

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

.kpi.good {
  background: #fff4ba;
}

.kpi.neutral {
  background: #e5e7eb;
}

.kpi.warn {
  border-color: var(--red);
  background: #fff5f5;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(390px, 1.08fr) minmax(350px, 1fr);
  grid-auto-rows: minmax(214px, auto);
  gap: 6px;
}

.dashboard-grid .alert-panel {
  grid-row: span 2;
}

.alert-list {
  max-height: 430px;
  overflow: auto;
}

.dashboard-grid .panel:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.dashboard-grid .panel:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.dashboard-grid .product-rank-panel {
  grid-column: 3;
  grid-row: 2;
}

.dashboard-grid .panel:nth-child(4):not(.product-rank-panel) {
  grid-column: 3;
  grid-row: 1;
}

.detail-grid {
  grid-template-columns: 1.4fr 0.8fr 0.8fr;
}

.panel {
  min-height: 178px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid #586575;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

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

.detail-grid .panel.wide {
  grid-column: span 1;
}

.panel-head,
.detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.detail-head {
  min-height: 70px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.alert-list,
.action-list,
.defect-list,
.records-table {
  display: grid;
  gap: 8px;
}

.alert-card,
.action-card,
.station-card,
.record-row {
  padding: 9px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 6px;
  background: #fff;
}

.alert-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.alert-card.red,
.station-card.red {
  border-left-color: var(--red);
}

.alert-card.orange,
.station-card.orange {
  border-left-color: var(--amber);
}

.alert-card.unset,
.station-card.unset {
  border-left-color: var(--gray);
}

.alert-card button,
.link-button {
  border: 0;
  background: transparent;
  color: var(--blue-dark);
  font-weight: 700;
}

.metric-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e8f3ff;
  color: var(--blue-dark);
  font-size: 12px;
}

.badge.red {
  background: #ffe8e9;
  color: var(--red);
}

.badge.orange {
  background: #fff0df;
  color: #9a5200;
}

.badge.gray {
  background: #eef0f3;
  color: var(--gray);
}

canvas {
  width: 100%;
  max-width: 100%;
}

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

.station-card h3 {
  margin: 0;
  font-size: 15px;
}

.station-defects {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  margin: 6px 0;
}

.defect-chip {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 4px 5px;
  border-radius: 5px;
  background: #eef6ff;
  color: #1b3552;
  font-size: 12px;
}

.defect-chip strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.defect-chip span {
  color: var(--muted);
}

.mini-bars {
  display: grid;
  gap: 4px;
}

.bar-line {
  display: grid;
  grid-template-columns: 72px 1fr 70px;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.bar-track {
  height: 14px;
  background: #e8eef5;
  border-radius: 999px;
  overflow: hidden;
}

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


.station-board-panel {
  min-height: 0;
}

.station-board-head,
.station-row {
  display: grid;
  grid-template-columns: minmax(380px, 1.18fr) minmax(360px, 0.84fr) minmax(320px, 0.98fr);
  gap: 8px;
  align-items: stretch;
}

.station-board-head {
  margin-bottom: 6px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.station-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.station-row {
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--gray);
  border-radius: 7px;
  background: #fff;
  min-height: 460px;
}

.station-row.red {
  border-left-color: var(--red);
}

.station-row.orange {
  border-left-color: var(--amber);
}

.station-row.normal {
  border-left-color: var(--green);
}

.station-summary,
.station-top-defects,
.station-actions {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.station-title-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.station-title-line h3 {
  margin: 0;
  font-size: 21px;
  line-height: 1.1;
}

.station-mini-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.station-mini-kpis div {
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid #c9d6e4;
  border-radius: 5px;
  background: #f7fbff;
}

.station-mini-kpis div:nth-child(2) {
  background: #fff6c8;
}

.station-mini-kpis div:nth-child(3) {
  background: #fff3f3;
}

.station-mini-kpis div:nth-child(4) {
  background: #edf5ff;
}

.station-mini-kpis span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.station-mini-kpis strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.station-yield-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 7px 0;
  color: var(--muted);
  font-size: 14px;
}

.station-yield-line strong {
  color: #4d6d90;
}

.warn-text {
  color: var(--red);
  font-weight: 700;
}

.good-text {
  color: var(--green);
  font-weight: 700;
}

.compact-defects {
  margin: 6px 0;
}

.station-section-title {
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 700;
}

.station-defect-list,
.station-action-list {
  display: grid;
  gap: 8px;
}

.station-top-defects .station-defect-list {
  display: grid;
  gap: 6px;
  align-content: stretch;
}

.station-top-defects .defect-action-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 7px;
}

.station-actions .station-action-list {
  flex: 1 1 auto;
  align-content: stretch;
}

.defect-action-card,
.observation-card {
  border-left-color: var(--blue);
  padding: 8px;
}

.defect-action-card .primary-button {
  min-height: 32px;
  margin-top: 6px;
}

.defect-action-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.defect-action-head span {
  color: var(--blue-dark);
  font-weight: 700;
}

.defect-sparkline {
  margin-top: 0;
  padding: 3px 5px 2px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #f8fbff;
  color: var(--blue);
}

.defect-sparkline svg {
  display: block;
  width: 100%;
  height: 38px;
}

.spark-labels {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  color: var(--muted);
  font-size: 10px;
}

.defect-spark-empty {
  margin-top: 6px;
  padding: 9px;
  border: 1px dashed var(--line);
  border-radius: 5px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.observation-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.compact-empty {
  min-height: 94px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 13px;
}

.empty-mini {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
}
.record-row {
  display: grid;
  grid-template-columns: 1.1fr 0.8fr 0.8fr 0.8fr 0.7fr 1.5fr auto;
  align-items: center;
  gap: 8px;
  border-left-color: var(--blue);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(10, 22, 36, 0.44);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.auth-gate {
  background: rgba(10, 22, 36, 0.72);
}

.modal-backdrop.auth-gate .auth-modal {
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.modal {
  width: min(860px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 14px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}

.icon-button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  font-size: 22px;
  line-height: 1;
}

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

.form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
}

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

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 180px;
  color: var(--muted);
  text-align: center;
}

.import-panel label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.import-panel input {
  min-height: 38px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.import-status {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.import-status.is-ok {
  color: var(--green);
}
.import-status.is-error {
  color: var(--red);
}

.import-panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

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

.import-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.import-diff-panel {
  margin-top: 10px;
  padding: 12px;
}

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

.import-diff-kpi {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--muted);
  background: #fff;
}

.import-diff-kpi span,
.import-diff-kpi strong {
  white-space: nowrap;
}

.import-diff-kpi span { color: var(--muted); font-size: 12px; }
.import-diff-kpi strong { color: var(--text); font-size: 18px; }
.import-diff-kpi.is-positive { border-left-color: var(--green); }
.import-diff-kpi.is-warning { border-left-color: #d98a16; }
.import-diff-kpi.is-danger { border-left-color: var(--red); }

.import-diff-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .9fr);
  gap: 10px;
}

.import-diff-columns > section {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  background: #fbfdff;
}

.import-diff-columns h3 {
  margin: 0 0 7px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
}

.import-diff-list {
  display: grid;
  gap: 5px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 2px;
}

.import-diff-item {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid #e1e9f1;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.import-diff-item strong {
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.import-diff-item small { color: var(--muted); font-size: 11px; }
.import-diff-item div { display: flex; flex-wrap: wrap; gap: 3px 10px; }
.import-diff-item div span { white-space: nowrap; }
.import-diff-item b { color: #315d87; font-weight: 500; }
.import-diff-item.is-danger { border-color: #f0caca; background: #fffafa; }
.import-diff-empty { padding: 18px 8px; color: var(--muted); text-align: center; }

.import-diff-decision { color: var(--muted); font-size: 12px; }
.import-diff-decision.is-warning { color: #a65f00; }
.import-diff-decision.is-positive { color: var(--green); }

.import-diff-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

@media (max-width: 760px) {
  .import-file-grid,
  .import-diff-summary,
  .import-diff-columns { grid-template-columns: 1fr; }
  .import-diff-footer { align-items: stretch; flex-direction: column; }
}







.icon-action-button {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 0 9px;
  border: 1px solid var(--blue);
  border-radius: 5px;
  background: #eaf4ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.icon-action-button:hover {
  background: var(--blue);
  color: #fff;
}


.trend-warning-list {
  display: grid;
  gap: 6px;
  max-height: 154px;
  overflow: auto;
}

.trend-warning-card {
  display: grid;
  grid-template-columns: 0.8fr 0.7fr 0.9fr;
  gap: 4px 8px;
  align-items: center;
  padding: 7px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--amber);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
}

.trend-warning-card.high {
  border-left-color: var(--red);
}

.trend-warning-card strong,
.trend-warning-card div,
.trend-warning-card small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend-warning-card small {
  grid-column: 1 / -1;
  color: var(--muted);
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

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

.kanban-head,
.kanban-card-head,
.kanban-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kanban-head {
  margin-bottom: 8px;
  color: var(--text);
}

.kanban-head span {
  min-width: 24px;
  min-height: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e8f3ff;
  color: var(--blue-dark);
  text-align: center;
  font-size: 12px;
}

.kanban-list {
  display: grid;
  gap: 7px;
}

.kanban-card {
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 7px;
  background: #fff;
  font-size: 12px;
}

.kanban-card p {
  display: -webkit-box;
  margin: 7px 0;
  overflow: hidden;
  color: var(--text);
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.effect-line {
  padding: 6px;
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  line-height: 1.45;
}

.effect-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}

.effect-badge.good {
  background: #e8f7ee;
  color: var(--green);
}

.effect-badge.bad {
  background: #ffe8e9;
  color: var(--red);
}

.effect-badge.flat {
  background: #fff0df;
  color: #9a5200;
}

.effect-badge.watch {
  background: #eef0f3;
  color: var(--gray);
}

@media (max-width: 1240px) {
  .app-shell {
    min-width: 0;
  }

  .slicer-band {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

  .drill-control {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .kpi-grid,
  .kpi-grid.compact {
    grid-template-columns: repeat(3, minmax(130px, 1fr));
  }

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

  .panel.wide,
  .detail-grid .panel.wide {
    grid-column: span 1;
  }

  .station-cards {
    grid-template-columns: 1fr;
  }

  .station-board-head {
    display: none;
  }

  .station-row {
    grid-template-columns: 1fr;
    min-height: 0;
  }

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

  .record-row,
  .trend-warning-card {
    grid-template-columns: 1fr;
  }
}



.target-coverage {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.coverage-good {
  background: #e8f7ee;
  color: var(--green);
}

.coverage-warn {
  background: #fff0df;
  color: #9a5200;
}

.coverage-bad {
  background: #ffe8e9;
  color: var(--red);
}


.alert-station-summary,
.warning-type-summary {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #d8e5f2;
}

.summary-title {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.summary-pill {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #c9d6e4;
  border-left: 4px solid var(--red);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.summary-pill strong,
.summary-pill span,
.summary-pill em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-pill span,
.summary-pill em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

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

.warning-type-card {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px;
  border: 1px solid #c9d6e4;
  border-radius: 6px;
  background: #f8fbff;
}

.warning-type-card strong,
.warning-type-card span,
.warning-type-card em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.warning-type-card span {
  color: var(--red);
  font-size: 18px;
  font-weight: 800;
}

.warning-type-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.alert-panel {
  display: flex;
  flex-direction: column;
}

.alert-list {
  flex: 1 1 auto;
  min-height: 0;
}

.station-row.unset .station-summary:only-child {
  grid-column: 1 / -1;
}

.station-pareto {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #d8e5f2;
}

.pareto-card {
  padding: 6px 0 0;
}

.pareto-bars {
  display: grid;
  gap: 5px;
}

.pareto-row {
  display: grid;
  grid-template-columns: 88px 1fr 56px 52px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.pareto-row span,
.pareto-row strong,
.pareto-row em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pareto-row em {
  color: var(--muted);
  font-style: normal;
  text-align: right;
}

.pareto-track {
  height: 14px;
  background: #e8eef5;
  border-radius: 999px;
  overflow: hidden;
}

.pareto-fill {
  height: 100%;
  background: linear-gradient(90deg, #2f8fe6 0%, #4da3f1 100%);
}


.product-rank-panel canvas { min-height: 202px; }


.pareto-row strong { color: #1f3552; }
.pareto-row span { color: #4d5c6f; font-weight: 700; }


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

.trend-card {
  min-width: 0;
  padding: 10px 10px 8px;
  border: 1px solid #d8e5f2;
  border-radius: 8px;
  background: #fbfdff;
}

.trend-card-head {
  display: grid;
  grid-template-columns: minmax(70px, auto) 1fr auto;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.trend-card-head strong {
  color: var(--text);
  font-size: 15px;
}

.trend-card-head span,
.trend-card-head em {
  font-style: normal;
  white-space: nowrap;
}

.trend-card-canvas {
  display: block;
  width: 100%;
  min-height: 190px;
}

.pareto-chart-wrap {
  width: 100%;
  padding: 2px 0 0;
}

.pareto-canvas {
  display: block;
  width: 100%;
  min-height: 88px;
}






.station-top-defects .station-defect-list {
  display: grid;
  gap: 6px;
  align-content: stretch;
}

.station-top-defects .defect-action-card {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 6px 7px;
}

.station-actions .station-action-list {
  flex: 1 1 auto;
  align-content: stretch;
}




.station-top-defects .metric-line {
  margin-top: 0;
}

.defect-action-head {
  align-items: flex-start;
}

.defect-action-head strong {
  flex: 1 1 auto;
  line-height: 1.25;
}

.defect-sparkline {
  margin-top: 0;
  padding: 3px 5px 2px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #f8fbff;
  color: var(--blue);
}

.station-top-defects .defect-sparkline {
  margin-top: 0;
  padding: 3px 5px 2px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #f8fbff;
  color: var(--blue);
}

.station-top-defects .defect-sparkline svg {
  height: 44px;
}

.station-top-defects .spark-labels {
  margin-top: 1px;
  font-size: 10px;
}

.product-rank-wrap {
  display: grid;
  grid-template-rows: 148px minmax(0, 1fr);
  gap: 6px;
  min-height: 100%;
}

.product-rank-list {
  display: grid;
  gap: 5px;
  align-content: stretch;
}

.product-rank-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 4px 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid #d8e5f2;
  border-radius: 7px;
  background: #fbfdff;
  color: var(--text);
  text-align: left;
}

.product-rank-row strong,
.product-rank-row em,
.product-rank-row small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-rank-row strong {
  font-size: 13px;
}

.product-rank-row em,
.product-rank-row small {
  font-style: normal;
  color: var(--muted);
  font-size: 12px;
}

.product-rank-row em {
  text-align: right;
}

.product-rank-row small {
  grid-column: 2 / 4;
}

.product-rank-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e8f3ff;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.warning-type-card b {
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 700;
}

.station-top-defects .defect-sparkline {
  margin-top: 0;
  padding: 3px 5px 2px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #f8fbff;
  color: var(--blue);
}

.station-top-defects .defect-sparkline svg {
  height: 44px;
}

.station-top-defects .defect-sparkline text {
  fill: #5f7694;
  font-size: 3.9px;
  font-weight: 400;
}

.station-top-defects .station-section-title {
  margin-bottom: 2px;
}

.station-top-defects .metric-line span {
  font-size: 12px;
  font-weight: 400;
}

.product-rank-panel {
  display: flex;
  flex-direction: column;
}

.product-rank-panel .panel-head {
  margin-bottom: 4px;
}


.defect-sparkline-layered {
  padding: 2px 4px 1px;
}

.defect-sparkline-layered svg {
  display: block;
  width: 100%;
  height: 46px;
}

.spark-divider {
  display: none;
}

.spark-main-line {
  fill: none;
  stroke: #2a80df;
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-volume-line {
  display: none;
}

.station-top-defects .spark-labels {
  margin-top: 1px;
  font-size: 10px;
}

.station-top-defects .defect-action-head strong {
  font-weight: 600;
}

.defect-sparkline-clean {
  padding: 2px 4px 1px;
}

.defect-sparkline-clean svg {
  display: block;
  width: 100%;
  height: 46px;
}

.station-top-defects .defect-action-head strong {
  font-weight: 600;
}

/* Final compact station detail layout */
.station-board-head,
.station-row {
  grid-template-columns: minmax(360px, 1.02fr) minmax(330px, 0.82fr) minmax(330px, 0.9fr);
  align-items: start;
}

.station-row {
  min-height: 0;
  padding: 7px;
}

.station-summary,
.station-top-defects,
.station-actions {
  align-self: start;
}

.station-pareto {
  margin-top: 6px;
  padding-top: 6px;
}

.pareto-chart-wrap {
  height: 132px;
  overflow: hidden;
}

.pareto-canvas {
  display: block;
  width: 100%;
  height: 132px;
  min-height: 132px;
}

.station-top-defects .station-defect-list {
  display: grid;
  grid-template-rows: none;
  gap: 6px;
  align-content: stretch;
}

.station-top-defects .defect-action-card {
  min-height: 0;
  padding: 6px 7px;
}

.station-top-defects .defect-sparkline,
.defect-sparkline-clean {
  padding: 2px 4px 1px;
}

.station-top-defects .defect-sparkline svg,
.defect-sparkline-clean svg {
  height: 44px;
}

.station-top-defects .defect-sparkline text {
  fill: #5f7694;
  font-size: 3.8px;
  font-weight: 400;
}

.spark-main-line {
  stroke-width: 1.2;
}

.spark-volume-line,
.spark-divider {
  display: none;
}

/* 20260628 final station layout tuning */
.summary-title-with-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.summary-title-with-note small {
  color: #617083;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.station-board-head,
.station-row {
  grid-template-columns: minmax(390px, 1.08fr) minmax(360px, 0.96fr) minmax(320px, 0.88fr);
  gap: 8px;
  align-items: start;
}

.station-row {
  min-height: 0;
  padding: 7px;
}

.station-summary,
.station-top-defects,
.station-actions {
  min-width: 0;
  align-self: start;
}

.station-section-title {
  margin-bottom: 4px;
  font-size: 13px;
  line-height: 1.2;
}

.station-pareto {
  margin-top: 6px;
  padding-top: 6px;
}

.pareto-chart-wrap {
  height: 124px;
  overflow: hidden;
}

.pareto-canvas {
  display: block;
  width: 100%;
  height: 124px;
  min-height: 124px;
}

.station-top-defects .station-defect-list {
  display: grid;
  grid-template-rows: repeat(3, minmax(78px, auto));
  gap: 7px;
  align-content: stretch;
}

.station-top-defects .defect-action-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 78px;
  padding: 6px 7px 5px;
  border-left-color: var(--blue);
}

.station-top-defects .defect-action-head {
  display: grid;
  grid-template-columns: minmax(88px, 1fr) auto auto;
  align-items: center;
  gap: 6px;
}

.station-top-defects .defect-action-head strong {
  min-width: 0;
  overflow: hidden;
  color: #1f3552;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
}

.defect-action-meta {
  color: #4d5c6f;
  font-size: 11px;
  font-weight: 400;
  white-space: nowrap;
}

.compact-register-button {
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 11px;
  line-height: 22px;
}

.station-top-defects .defect-sparkline,
.defect-sparkline-clean {
  margin-top: 0;
  padding: 1px 3px 0;
  border-color: #d8e5f2;
  background: #f8fbff;
}

.station-top-defects .defect-sparkline svg,
.defect-sparkline-clean svg {
  display: block;
  width: 100%;
  height: 36px;
}

.station-top-defects .defect-sparkline text {
  fill: #667b94;
  font-size: 3.35px;
  font-weight: 400;
}

.spark-main-line {
  fill: none;
  stroke: currentColor;
  stroke-width: 0.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.station-top-defects .spark-labels {
  margin-top: 0;
  gap: 2px;
  color: #617083;
  font-size: 9.5px;
  line-height: 1;
}

.station-actions .station-action-list {
  gap: 6px;
  align-content: stretch;
}

.station-actions .observation-card {
  padding: 7px;
}

@media (max-width: 1180px) {
  .station-board-head,
  .station-row {
    grid-template-columns: 1fr;
  }

  .station-top-defects .station-defect-list {
    grid-template-rows: none;
  }
}

/* 20260628 action grouping and blank-space fix */
.station-row {
  align-items: stretch;
}

.station-summary,
.station-top-defects,
.station-actions {
  height: 100%;
}

.station-top-defects,
.station-actions {
  display: flex;
  flex-direction: column;
}

.station-actions .station-action-list {
  flex: 1 1 auto;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 3px;
  scrollbar-width: thin;
}

.station-actions .station-action-list::-webkit-scrollbar {
  width: 6px;
}

.station-actions .station-action-list::-webkit-scrollbar-thumb {
  background: #b8c8da;
  border-radius: 99px;
}

.grouped-observation-card {
  gap: 4px;
  padding: 6px 7px;
}

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

.observation-head strong {
  min-width: 0;
  overflow: hidden;
  color: #1f3552;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
}

.observation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 10px;
  color: #617083;
  font-size: 12px;
  line-height: 1.25;
}

.observation-effect {
  overflow: hidden;
  color: #4d5c6f;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.3;
}

.observation-actions {
  display: flex;
  justify-content: flex-start;
  line-height: 1;
}

.observation-detail {
  margin-top: 1px;
  border-top: 1px solid #edf2f7;
  padding-top: 3px;
}

.observation-detail summary {
  cursor: pointer;
  color: #1268c4;
  font-size: 12px;
  line-height: 1.3;
}

.action-mini-row {
  display: grid;
  grid-template-columns: 70px 1fr 46px;
  width: 100%;
  margin-top: 3px;
  padding: 3px 4px;
  border: 1px solid #d8e5f2;
  border-radius: 4px;
  background: #f8fbff;
  color: #4d5c6f;
  font: inherit;
  font-size: 11px;
  text-align: left;
}

.action-mini-row strong,
.action-mini-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-action-summary {
  flex: 1 1 auto;
  min-height: 82px;
  margin-top: 7px;
  padding: 7px;
  border: 1px solid #d8e5f2;
  border-radius: 6px;
  background: #f8fbff;
}

.top-action-title,
.empty-top-action-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.top-action-title strong,
.empty-top-action-summary strong {
  color: #1f3552;
  font-size: 12px;
  font-weight: 600;
}

.top-action-title span,
.empty-top-action-summary span {
  color: #617083;
  font-size: 11px;
}

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

.top-action-pill {
  min-width: 0;
  padding: 5px 6px;
  border: 1px solid #c9d9ea;
  border-radius: 5px;
  background: #fff;
  color: #253143;
  text-align: left;
  cursor: pointer;
}

.top-action-pill strong,
.top-action-pill span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-action-pill strong {
  color: #1f3552;
  font-size: 12px;
  font-weight: 600;
}

.top-action-pill span {
  color: #617083;
  font-size: 11px;
}

.action-empty {
  min-height: 160px;
}

@media (max-width: 1180px) {
  .station-actions .station-action-list {
    max-height: 260px;
  }
}

/* 20260628 slicer overflow and one-station-page fill */
.slicer-band {
  grid-template-columns: repeat(7, minmax(118px, 1fr)) minmax(150px, 1.2fr) minmax(150px, 1.2fr) minmax(138px, 0.9fr) minmax(118px, 0.75fr) minmax(72px, 0.55fr);
  align-items: stretch;
  overflow: visible;
}

.slicer-button,
.date-control input,
.number-control input,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 34px;
}

.slicer-button {
  padding: 4px 8px;
}

.date-control,
.number-control {
  padding: 4px 8px;
}

.date-control input,
.number-control input {
  min-width: 0;
  padding: 0;
  font-size: 16px;
}

.drill-control {
  min-width: 0;
}

.drill-control button,
.view-tabs button,
.segmented button {
  padding: 0 14px;
}

#resetFilters {
  padding: 0 8px;
  font-size: 12px;
}

#kpiGrid[hidden] {
  display: none !important;
}

#detailView .station-board {
  gap: 10px;
}

#detailView .station-row {
  min-height: calc(100vh - 208px);
  grid-template-columns: minmax(390px, 1.08fr) minmax(360px, 0.96fr) minmax(320px, 0.88fr);
  align-items: stretch;
}

#detailView .station-summary,
#detailView .station-top-defects,
#detailView .station-actions {
  height: 100%;
}

#detailView .station-summary {
  display: flex;
  flex-direction: column;
}

#detailView .station-pareto {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#detailView .pareto-chart-wrap {
  flex: 1 1 auto;
  min-height: 170px;
  height: auto;
}

#detailView .pareto-canvas {
  height: 100%;
  min-height: 170px;
}

#detailView .station-top-defects .station-defect-list {
  flex: 0 0 auto;
}

#detailView .top-action-summary {
  flex: 1 1 auto;
  min-height: 120px;
}

#detailView .station-actions .station-action-list {
  max-height: none;
  min-height: 0;
  height: 100%;
}

@media (max-width: 1500px) {
  .slicer-band {
    grid-template-columns: repeat(7, minmax(94px, 1fr)) minmax(128px, 1.15fr) minmax(128px, 1.15fr) minmax(112px, 0.85fr) minmax(88px, 0.7fr) minmax(64px, 0.5fr);
    gap: 4px;
  }

  .date-control input,
  .number-control input {
    font-size: 14px;
  }

  .drill-control button,
  .view-tabs button,
  .segmented button {
    padding: 0 9px;
  }

  .drill-control {
    min-width: 148px;
  }
}

@media (max-width: 1280px) {
  .slicer-band {
    grid-template-columns: repeat(6, minmax(116px, 1fr));
  }

  .slicer-grid {
    display: contents;
  }
}

@media (max-width: 1180px) {
  #detailView .station-row {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  #detailView .station-actions .station-action-list {
    max-height: 280px;
  }
}


/* 20260628 fill Top3 column proportionally on detail page */
#detailView .station-top-defects {
  display: grid;
  grid-template-rows: auto minmax(0, 3fr) minmax(120px, 1.35fr);
  gap: 8px;
  min-height: 0;
}

#detailView .station-top-defects .station-section-title {
  margin-bottom: 0;
}

#detailView .station-top-defects .station-defect-list {
  display: grid;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-height: 0;
  align-content: stretch;
}

#detailView .station-top-defects .defect-action-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  padding: 7px 8px 6px;
}

#detailView .station-top-defects .defect-sparkline,
#detailView .station-top-defects .defect-sparkline-clean {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding: 3px 5px 2px;
}

#detailView .station-top-defects .defect-sparkline svg,
#detailView .station-top-defects .defect-sparkline-clean svg {
  height: 100%;
  min-height: 72px;
}

#detailView .station-top-defects .defect-sparkline text {
  font-size: 3px;
}

#detailView .station-top-defects .spark-labels {
  padding-top: 2px;
}

#detailView .top-action-summary {
  display: flex;
  flex-direction: column;
  min-height: 0;
  margin-top: 0;
}

#detailView .top-action-grid {
  flex: 1 1 auto;
  grid-auto-rows: minmax(42px, auto);
  align-content: stretch;
  overflow-y: auto;
  padding-right: 2px;
}

#detailView .empty-top-action-summary {
  min-height: 0;
  align-items: flex-start;
}

@media (max-width: 1180px) {
  #detailView .station-top-defects {
    display: flex;
  }

  #detailView .station-top-defects .station-defect-list {
    grid-template-rows: none;
  }

  #detailView .station-top-defects .defect-sparkline svg,
  #detailView .station-top-defects .defect-sparkline-clean svg {
    min-height: 44px;
  }
}

/* 20260628 approved PDF layout implementation */
:root {
  --app-chrome-height: 132px;
}

.topbar {
  min-height: 34px;
  padding-top: 4px;
  padding-bottom: 4px;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.05;
}

.topbar p {
  font-size: 12px;
  line-height: 1.15;
}

.slicer-band {
  margin: 4px 0;
  padding: 5px;
}

.slicer-button,
.date-control input,
.number-control input,
.ghost-button,
.primary-button,
.danger-button {
  min-height: 32px;
}

/* Dashboard: three useful columns only - alerts, trends, ranks. */
#dashboardView .dashboard-grid {
  height: calc(100vh - var(--app-chrome-height));
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(330px, 0.86fr) minmax(430px, 1.05fr) minmax(380px, 1fr);
  grid-template-rows: minmax(0, 1fr) minmax(0, 0.72fr);
  gap: 6px;
  overflow: hidden;
}

#dashboardView .dashboard-grid > .panel {
  min-height: 0;
  overflow: hidden;
}

#dashboardView .alert-panel {
  grid-column: 1;
  grid-row: 1 / span 2;
}

#dashboardView .dashboard-grid .panel:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

#dashboardView .dashboard-grid .anomaly-panel {
  grid-column: 2;
  grid-row: 2;
}

#dashboardView .dashboard-grid .panel:nth-child(4):not(.product-rank-panel) {
  grid-column: 3;
  grid-row: 1;
}

#dashboardView .dashboard-grid .product-rank-panel {
  grid-column: 3;
  grid-row: 2;
}

#dashboardView .alert-panel,
#dashboardView .anomaly-panel,
#dashboardView .product-rank-panel,
#dashboardView .dashboard-grid .panel:nth-child(2),
#dashboardView .dashboard-grid .panel:nth-child(4):not(.product-rank-panel) {
  display: flex;
  flex-direction: column;
}

#dashboardView .alert-list,
#dashboardView .trend-warning-list,
#dashboardView .product-rank-list {
  min-height: 0;
  overflow-y: auto;
}

#dashboardView .alert-list {
  flex: 1 1 auto;
  max-height: none;
}

#dashboardView .alert-station-summary,
#dashboardView .warning-type-summary {
  flex: 0 0 auto;
}

#dashboardView .trend-cards {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  overflow-y: auto;
}

#dashboardView .trend-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 170px;
  padding: 7px;
}

#dashboardView .trend-card-canvas {
  min-height: 0;
  height: 100%;
}

#dashboardView #stationChart,
#dashboardView #productChart {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#dashboardView .product-rank-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(120px, 0.45fr) minmax(0, 1fr);
}

/* Detail: one station row must fit 100% browser zoom viewport. */
#detailView {
  height: calc(100vh - var(--app-chrome-height));
  min-height: 620px;
  overflow: hidden;
}

#detailView .detail-head {
  min-height: 34px;
  padding: 4px 6px;
  margin-bottom: 4px;
}

#detailView .detail-head > button {
  width: auto;
  flex: 0 0 auto;
  white-space: nowrap;
}

#detailView .detail-head > div {
  min-width: 0;
  flex: 1 1 auto;
}

#detailView .detail-head h2 {
  font-size: 16px;
  line-height: 1.1;
}

#detailView .detail-head p {
  display: none;
}

#detailView .station-board-panel {
  height: calc(100% - 42px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#detailView .station-board-panel > .panel-head {
  flex: 0 0 32px;
  margin-bottom: 2px;
}

#detailView .station-board-head {
  flex: 0 0 18px;
  margin-bottom: 2px;
}

#detailView .station-board {
  flex: 1 1 auto;
  min-height: 0;
  gap: 6px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
}

#detailView .station-row {
  height: 100%;
  min-height: 0;
  max-height: 100%;
  scroll-snap-align: start;
  grid-template-columns: minmax(380px, 1.05fr) minmax(360px, 0.92fr) minmax(330px, 0.86fr);
  gap: 7px;
  padding: 6px;
  overflow: hidden;
}

#detailView .station-summary,
#detailView .station-top-defects,
#detailView .station-actions {
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

#detailView .station-title-line h3 {
  font-size: 21px;
  line-height: 1.05;
}

#detailView .station-mini-kpis div {
  padding: 4px 6px;
}

#detailView .station-yield-line {
  margin: 5px 0;
  gap: 6px;
  font-size: 13px;
}

#detailView .station-defects.compact-defects {
  margin: 4px 0;
}

#detailView .mini-bars {
  flex: 0 0 auto;
}

#detailView .station-pareto {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 4px;
  padding-top: 4px;
}

#detailView .pareto-chart-wrap {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

#detailView .pareto-canvas {
  height: 100%;
  min-height: 120px;
}

#detailView .station-top-defects {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(72px, 0.24fr);
  gap: 6px;
}

#detailView .station-top-defects .station-defect-list {
  min-height: 0;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

#detailView .station-top-defects .defect-action-card {
  min-height: 0;
  padding: 6px 7px 5px;
}

#detailView .station-top-defects .defect-action-head {
  gap: 5px;
}

#detailView .station-top-defects .defect-action-head strong {
  font-size: 12px;
}

#detailView .defect-action-meta {
  font-size: 11px;
}

#detailView .compact-register-button {
  min-height: 22px;
  line-height: 20px;
}

#detailView .station-top-defects .defect-sparkline,
#detailView .station-top-defects .defect-sparkline-clean {
  min-height: 0;
  padding: 2px 4px 1px;
}

#detailView .station-top-defects .defect-sparkline svg,
#detailView .station-top-defects .defect-sparkline-clean svg {
  height: 100%;
  min-height: 48px;
}

#detailView .station-top-defects .defect-sparkline text {
  fill: #315d87;
  font-size: 3.3px;
  font-weight: 400;
  stroke: none;
}

#detailView .top-action-summary {
  min-height: 0;
  padding: 6px;
  overflow: hidden;
}

#detailView .top-action-grid {
  min-height: 0;
  overflow-y: auto;
  grid-auto-rows: minmax(28px, auto);
  gap: 4px;
}

#detailView .station-actions .station-action-list {
  height: 100%;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

#detailView .grouped-observation-card {
  padding: 6px 7px;
}

#detailView .observation-head strong {
  font-size: 13px;
}

#detailView .observation-meta,
#detailView .observation-effect {
  font-size: 11px;
}

@media (max-width: 1500px) {
  :root {
    --app-chrome-height: 124px;
  }

  #dashboardView .dashboard-grid {
    height: calc(100vh - 188px);
  }

  #detailView .station-row {
    grid-template-columns: minmax(360px, 1fr) minmax(330px, 0.9fr) minmax(310px, 0.84fr);
  }

  #detailView .station-title-line h3 {
    font-size: 19px;
  }

  #detailView .station-top-defects .defect-sparkline svg,
  #detailView .station-top-defects .defect-sparkline-clean svg {
    min-height: 42px;
  }
}

@media (max-width: 1180px) {
  #dashboardView .dashboard-grid,
  #detailView {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  #dashboardView .dashboard-grid,
  #detailView .station-row {
    grid-template-columns: 1fr;
  }

  #dashboardView .dashboard-grid {
    grid-template-rows: none;
    grid-auto-rows: minmax(240px, auto);
  }

  #detailView .station-row {
    height: auto;
    max-height: none;
    overflow: visible;
  }
}

/* 20260628 station paging correction: one department/process per viewport page. */
#detailView .station-board {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  padding-right: 2px;
}

#detailView .station-row {
  height: 100%;
  min-height: 100%;
  max-height: 100%;
  margin-bottom: 8px;
  box-sizing: border-box;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

#detailView .station-row:last-child {
  margin-bottom: 0;
}

@media (max-width: 1180px) {
  #detailView .station-board {
    display: grid;
    overflow-y: visible;
    scroll-snap-type: none;
    padding-right: 0;
  }

  #detailView .station-row {
    height: auto;
    min-height: 0;
    max-height: none;
    margin-bottom: 0;
    scroll-snap-align: none;
  }
}

/* 20260628 dashboard polish: top filter band and product-rank panel */
.slicer-band {
  grid-template-columns: repeat(7, minmax(104px, 1fr)) minmax(138px, 1.08fr) minmax(138px, 1.08fr) minmax(126px, 0.92fr) minmax(110px, 0.78fr) minmax(104px, 0.72fr);
  align-items: end;
}

#resetFilters {
  min-width: 0;
  padding: 0 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#dashboardView .product-rank-panel {
  min-height: 0;
}

#dashboardView .product-rank-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(182px, 0.62fr) minmax(0, 0.38fr);
  gap: 8px;
  overflow: hidden;
}

#dashboardView #productChart {
  display: block;
  width: 100%;
  min-height: 182px;
}

#dashboardView .product-rank-list {
  display: grid;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
  gap: 6px;
  padding-right: 2px;
}

#dashboardView .product-rank-row {
  padding: 6px 8px;
}


.action-insight-panel {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #d8e5f2;
  border-radius: 6px;
  background: #f8fbff;
}

.action-insight-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.action-insight-head strong {
  display: block;
  font-size: 14px;
  color: #1f3552;
}

.action-insight-head span {
  color: #617083;
  font-size: 12px;
}

.action-insight-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(220px, 0.9fr);
  gap: 10px;
  align-items: stretch;
}

.action-insight-chart .defect-sparkline-clean,
.action-insight-chart .defect-sparkline {
  height: 100%;
  min-height: 110px;
}

.action-insight-chart .defect-sparkline-clean svg,
.action-insight-chart .defect-sparkline svg {
  height: 72px;
}

.action-insight-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.action-insight-metrics div {
  padding: 8px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #fff;
}

.action-insight-metrics span {
  display: block;
  color: #617083;
  font-size: 12px;
}

.action-insight-metrics strong {
  display: block;
  margin-top: 3px;
  color: #1f3552;
  font-size: 13px;
  line-height: 1.35;
}

.action-insight-summary {
  padding: 8px 10px;
  border-radius: 5px;
  background: #fff;
  color: #4d5c6f;
  font-size: 12px;
  line-height: 1.45;
}

.action-insight-note {
  padding: 5px 8px;
  border-left: 2px solid #b8c9dc;
  color: #6b7a8c;
  font-size: 11px;
  line-height: 1.4;
}


/* 20260628 chart and action polish */
#dashboardView .trend-cards {
  grid-auto-rows: minmax(188px, auto);
  align-content: start;
}

#dashboardView .trend-card {
  min-height: 188px;
  padding: 6px 7px;
}

#dashboardView .trend-card-head {
  margin-bottom: 4px;
  gap: 6px;
}

#dashboardView .trend-card-canvas {
  min-height: 168px;
  height: 168px;
}

#detailView .mini-bars {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
}

#detailView .bar-line {
  min-height: 22px;
}

#detailView .station-pareto {
  flex: 0 0 auto;
  min-height: 220px;
}

#detailView .pareto-chart-wrap {
  min-height: 190px;
}

.observation-head {
  align-items: flex-start;
}

.observation-head .effect-badge {
  flex: 0 0 auto;
  align-self: flex-start;
  margin-top: 1px;
}

.action-insight-chart .defect-sparkline text,
.action-insight-chart .defect-sparkline-clean text {
  font-size: 3.2px;
}

.action-insight-chart .spark-labels {
  padding-top: 2px;
  font-size: 11px;
}

.defect-spark-single {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px solid #d8e5f2;
  border-radius: 5px;
  background: #f8fbff;
  text-align: center;
}

.defect-spark-single strong {
  color: #0b4f9f;
  font-size: 28px;
  line-height: 1;
  font-weight: 700;
}

.defect-spark-single span {
  margin-top: 4px;
  color: #4d5c6f;
  font-size: 12px;
}

.defect-spark-single small {
  margin-top: 3px;
  color: #7a8ba0;
  font-size: 11px;
}

/* 20260628 product-rank panel compact fill */
#dashboardView .dashboard-grid {
  grid-template-rows: minmax(0, 1fr) minmax(260px, 0.54fr);
}

#dashboardView .product-rank-panel {
  min-height: 260px;
}

#dashboardView .product-rank-wrap {
  grid-template-rows: minmax(210px, 1fr);
  gap: 0;
  align-content: start;
}

#dashboardView .product-rank-list {
  display: none;
}

#dashboardView #productChart {
  min-height: 210px;
  height: 100%;
}


/* 20260628 auth and formal deploy mode */
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.auth-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.auth-summary {
  min-width: 170px;
  max-width: 260px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-button {
  width: auto;
  min-width: 84px;
  padding: 0 12px;
}

.auth-modal {
  width: min(420px, calc(100vw - 32px));
}

.auth-form-grid {
  display: grid;
  gap: 10px;
}

.auth-form-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.auth-form-grid input {
  min-height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.auth-status {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-status.error,
.import-status.error {
  color: var(--red);
}

.auth-status.success,
.import-status.success {
  color: var(--green);
}

@media (max-width: 1420px) {
  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .auth-panel {
    width: 100%;
    justify-content: space-between;
  }
}


/* user administration */
.user-admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(320px, 1.2fr);
  gap: 12px;
  margin-bottom: 12px;
}

@media (max-width: 720px) {
  .app-shell {
    min-width: 0;
    padding: 3px;
  }

  .topbar,
  .topbar-actions {
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    flex-direction: column;
  }

  .view-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
  }

  .tab {
    min-width: 0;
    padding: 0 6px;
    font-size: 12px;
  }

  .slicer-band {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .slicer-grid {
    display: contents;
  }

  .drill-control,
  #resetFilters {
    grid-column: span 2;
  }

  .date-control input,
  .number-control input,
  .slicer-button,
  .ghost-button,
  .primary-button {
    min-width: 0;
  }

  #dashboardView .dashboard-grid {
    height: auto;
    min-height: 0;
    grid-auto-rows: minmax(220px, auto);
  }
}

/* Desktop slicers stay on one line; narrower screens keep the responsive wrap above. */
@media (min-width: 1181px) {
  .slicer-band {
    grid-template-columns: repeat(7, minmax(82px, 0.9fr)) repeat(2, minmax(115px, 1.25fr)) minmax(124px, 1.1fr) minmax(105px, 0.95fr) minmax(92px, 0.8fr);
    gap: 5px;
    padding: 5px;
  }

  .slicer-band .slicer-button,
  .slicer-band .date-control input,
  .slicer-band .number-control input,
  .slicer-band .drill-control,
  .slicer-band #resetFilters {
    min-height: 34px;
  }

  .slicer-band .slicer-button {
    padding-right: 6px;
    padding-left: 6px;
  }

  .slicer-band .slicer-button span,
  .slicer-band .date-control span,
  .slicer-band .number-control span {
    font-size: 11px;
  }

  .slicer-band .slicer-button strong {
    font-size: 12px;
  }

  .slicer-band .drill {
    padding-right: 5px;
    padding-left: 5px;
  }
}

/* Action archive and validated countermeasure handbook. */
.action-archive-panel,
.countermeasure-handbook-panel {
  min-height: 0;
  margin-top: 10px;
}

.archive-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.archive-filters select {
  min-width: 112px;
  max-width: 180px;
  min-height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.action-archive-list,
.handbook-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

#actionsView > .records-table > .empty-state {
  min-height: 92px;
}

.action-archive-list > .empty-state,
.handbook-list > .empty-state {
  grid-column: 1 / -1;
  min-height: 56px;
}

.archive-item,
.handbook-item {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid #7b8794;
  border-radius: 5px;
  background: #fff;
}

.archive-item-head,
.handbook-item-head,
.archive-item-meta,
.handbook-item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.archive-item-head strong,
.handbook-item-head strong {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.archive-item-head span,
.handbook-item-head span,
.archive-item-meta,
.handbook-item-meta {
  color: var(--muted);
  font-size: 11px;
}

.archive-item-meta,
.handbook-item-meta {
  margin-top: 5px;
}

.archive-item p {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.handbook-item {
  border-left-color: var(--green);
}

.handbook-item .link-button {
  margin-top: 6px;
  padding: 0;
  font-size: 11px;
}

@media (max-width: 820px) {
  .action-archive-list,
  .handbook-list {
    grid-template-columns: 1fr;
  }

  .archive-filters {
    width: 100%;
  }

  .archive-filters select {
    flex: 1 1 140px;
    max-width: none;
  }
}

.action-recommendations {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid #bad2e8;
  border-radius: 5px;
  background: #f4f9fe;
}

.action-recommendation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.action-recommendation-head strong {
  color: var(--text);
  font-size: 13px;
}

.action-recommendation-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.action-recommendation-list article {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 5px;
  min-width: 0;
  padding: 7px;
  border: 1px solid #d4e2ef;
  border-radius: 4px;
  background: #fff;
}

.action-recommendation-list article > div {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.action-recommendation-list b {
  flex: 0 0 auto;
  color: var(--blue-dark);
  font-size: 11px;
}

.action-recommendation-list strong {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.action-recommendation-list small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}

.action-recommendation-list .link-button {
  justify-self: end;
  padding: 0;
  font-size: 11px;
}

@media (max-width: 820px) {
  .action-recommendation-list {
    grid-template-columns: 1fr;
  }
}

/* Keep improvement-trend labels compact and crisp at 100% zoom. */
.action-insight-chart .defect-sparkline-clean svg text,
.action-insight-chart .defect-sparkline svg text {
  fill: #244b73;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  font-size: 4.2px;
  font-weight: 400;
  letter-spacing: 0;
  stroke: none;
  text-rendering: geometricPrecision;
}

.action-insight-chart .defect-sparkline-clean {
  padding: 4px 7px 2px;
  overflow-x: auto;
}

.action-insight-chart .defect-sparkline-clean svg {
  height: 78px;
  min-width: max(100%, calc(var(--spark-points, 1) * 48px));
}

.action-insight-chart .defect-sparkline-clean .spark-labels {
  min-width: max(100%, calc(var(--spark-points, 1) * 48px));
}

/* Long detail ranges scroll inside the chart instead of hiding periods. */
#detailView .station-top-defects .defect-sparkline-clean {
  overflow-x: auto;
}

#detailView .station-top-defects .defect-sparkline-clean svg,
#detailView .station-top-defects .defect-sparkline-clean .spark-labels {
  min-width: max(100%, calc(var(--spark-points, 1) * 48px));
}

/* Keep the seven basic improvement fields on one compact desktop row. */
@media (min-width: 1181px) {
  #actionForm > .form-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 7px;
  }

  #actionForm > .form-grid > label {
    min-width: 0;
    gap: 4px;
    font-size: 11px;
  }

  #actionForm > .form-grid > label:nth-child(n + 8) {
    grid-column: 1 / -1;
  }

  #actionForm > .form-grid input,
  #actionForm > .form-grid select {
    min-width: 0;
    padding: 6px;
    font-size: 12px;
  }
}
.user-form { display: grid; gap: 10px; align-content: start; }
.user-form label { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.user-form input, .user-form select { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; background: var(--surface); color: var(--text); }
.permission-check { display: flex !important; grid-template-columns: none !important; align-items: center; gap: 7px !important; }
.permission-check input { min-height: auto; width: 16px; height: 16px; }
.password-input-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: stretch; }
.password-input-wrap input { min-width: 0; min-height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); }
.password-toggle { position: relative; min-width: 38px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-soft); color: var(--muted); cursor: pointer; }
.password-toggle::before { content: ""; position: absolute; left: 50%; top: 50%; width: 15px; height: 9px; border: 1.5px solid currentColor; border-radius: 10px 2px; transform: translate(-50%, -50%) rotate(45deg); }
.password-toggle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: currentColor; transform: translate(-50%, -50%); }
.password-toggle:hover { color: var(--accent); border-color: var(--accent); }
.scope-field { min-width: 0; }
.scope-source-note { color: var(--muted); font-size: 11px; line-height: 1.35; }
.scope-picker { display: flex; flex-wrap: wrap; gap: 5px; min-height: 34px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.scope-picker:empty::before { content: attr(data-empty); color: var(--muted); padding: 3px 4px; }
.scope-chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid #b8cbe2; border-radius: 4px; padding: 3px 7px; background: #edf5ff; color: var(--text); font-size: 12px; cursor: pointer; }
.scope-picker-open { width: 100%; min-height: 26px; border: 1px dashed #9db7d4; border-radius: 4px; background: transparent; color: var(--accent); cursor: pointer; }
.scope-picker-modal { width: min(520px, calc(100vw - 24px)); }
.scope-picker-toolbar { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; margin: 10px 0 8px; }
.scope-picker-toolbar input { min-height: 34px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 9px; }
.scope-picker-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; max-height: 280px; overflow: auto; padding: 4px; border: 1px solid var(--line-soft); border-radius: 6px; background: #fbfdff; }
.scope-option { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 7px 6px; color: var(--text); font-size: 13px; cursor: pointer; }
.scope-option span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scope-picker-options .empty-state { grid-column: 1 / -1; }
.user-list { display: grid; gap: 8px; }
.user-row { display: grid; grid-template-columns: minmax(180px, 1fr) auto minmax(120px, 1.2fr) repeat(7, auto); align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.user-permission { font-size: 12px; }
.user-row button { width: auto; min-height: 30px; padding: 0 9px; white-space: nowrap; }
.user-row strong, .user-row span { display: block; }
.user-row strong { color: var(--text); }
.user-row div span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.user-status { font-size: 12px; }
.user-status.is-active { color: #16803c; }
.user-status.is-disabled { color: #b42318; }
@media (max-width: 840px) {
  .user-admin-grid { grid-template-columns: 1fr; }
  .user-row { grid-template-columns: 1fr auto; }
  .user-row .panel-note { grid-column: 1 / -1; }
  .user-row button { width: 100%; }
  .user-status { grid-column: 2; grid-row: 1; }
}

/* 20260628 audit page */
.audit-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.92fr) minmax(420px, 1.08fr);
  gap: 8px;
}

.audit-import-panel,
.audit-log-panel {
  min-height: 620px;
  display: flex;
  flex-direction: column;
}

.audit-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}

.audit-card {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.audit-card.is-error {
  border-left: 4px solid var(--red);
  background: #fff8f8;
}

.audit-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.audit-card-head strong {
  color: #1f3552;
  font-size: 13px;
}

.audit-card-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.audit-card p {
  margin: 6px 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
}

.audit-detail {
  margin: 6px 0 0;
  padding: 7px 8px;
  border-radius: 5px;
  background: #f7fafc;
  color: #4d5c6f;
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.audit-error-text {
  margin-top: 6px;
  color: var(--red);
  font-size: 12px;
  line-height: 1.4;
}

.action-history-panel {
  max-height: 150px;
  overflow-y: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #f8fafc;
}

.action-history-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
}

.action-history-title span,
.action-history-item span {
  color: var(--muted);
  font-weight: 400;
}

.action-history-item {
  padding: 6px 0;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
}

.action-history-item > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.action-history-item p {
  margin: 3px 0 0;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .audit-grid {
    grid-template-columns: 1fr;
  }

  .audit-list {
    max-height: none;
  }
}


.audit-toolbar {
  display: grid;
  grid-template-columns: 180px minmax(260px, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.audit-control {
  display: grid;
  gap: 4px;
}

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

.audit-control select,
.audit-control input {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.audit-search-control {
  min-width: 0;
}

@media (max-width: 1180px) {
  .audit-toolbar {
    grid-template-columns: 1fr;
  }
}

/* Yield target overview: dense, filter-linked reference table. */
.target-settings-toolbar {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.settings-search {
  display: grid;
  grid-template-columns: auto minmax(180px, 260px);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.settings-search input {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.target-settings-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.target-settings-table-wrap {
  min-height: 0;
  max-height: calc(100vh - 205px);
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

.target-settings-table {
  width: 100%;
  min-width: 1060px;
  border-collapse: collapse;
  font-size: 12px;
  color: var(--text);
}

.target-settings-table th,
.target-settings-table td {
  height: 34px;
  padding: 5px 8px;
  border-bottom: 1px solid #dbe3ec;
  border-right: 1px solid #e4eaf1;
  text-align: center;
  white-space: nowrap;
}

.target-settings-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eaf1f8;
  color: #243b53;
  font-weight: 600;
}

.target-settings-table tbody tr:nth-child(even) {
  background: #f8fbfe;
}

.target-settings-table tbody tr:hover {
  background: #eef6ff;
}

.target-settings-table td.is-negative {
  color: #bd3d38;
  font-weight: 600;
}

.target-status {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  border-radius: 4px;
  font-size: 11px;
}

.target-status.is-matched {
  color: #1f6a46;
  background: #e6f4ec;
}

.target-status.is-unmatched {
  color: #697586;
  background: #eef1f4;
}

.target-source {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border: 1px solid #9fc4e8;
  border-radius: 3px;
  color: #285f91;
  background: #eef6fd;
  font-size: 10px;
  font-weight: 400;
  vertical-align: middle;
}

.table-icon-button {
  min-width: 44px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid #a9bfd4;
  border-radius: 4px;
  color: #285f91;
  background: #fff;
  font-size: 11px;
}

.table-icon-button:hover {
  border-color: #4d8fc7;
  background: #eef6fd;
}

.target-setting-actions {
  display: inline-flex;
  gap: 4px;
  white-space: nowrap;
}

.target-setting-modal {
  width: min(620px, calc(100vw - 32px));
}

.target-setting-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.target-setting-form-grid label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.target-setting-form-grid input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--text);
  background: #fff;
}

.target-setting-form-grid input[readonly] {
  color: #5f6f80;
  background: #f2f5f8;
}

.target-setting-modal .modal-actions .import-status {
  margin: 0 auto 0 0;
}

.table-empty {
  height: 100px !important;
  color: var(--muted);
}

@media (max-width: 720px) {
  .target-settings-toolbar {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .settings-search {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .target-settings-table-wrap {
    max-height: calc(100vh - 265px);
  }

  .target-setting-form-grid {
    grid-template-columns: 1fr;
  }
}

/* Keep all twelve slicer controls inside a 100% browser viewport. */
@media (max-width: 1400px) and (min-width: 1181px) {
  .slicer-band {
    grid-template-columns: repeat(7, minmax(82px, 0.85fr)) repeat(2, minmax(112px, 1.15fr)) minmax(112px, 1fr) minmax(92px, 0.8fr) minmax(78px, 0.7fr);
  }
}

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

/* 20260827: stable page chrome and readable improvement observations. */
:root {
  --topbar-sticky-height: 72px;
}

.topbar {
  position: sticky;
  top: 4px;
  z-index: 40;
}

.slicer-band {
  top: calc(var(--topbar-sticky-height) + 8px);
  z-index: 35;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: stretch;
  margin-top: 6px;
}

.slicer-band .slicer-button,
.slicer-band .date-control input,
.slicer-band .number-control input,
.slicer-band .drill-control,
.slicer-band #resetFilters {
  min-height: 38px;
}

.slicer-band .slicer-button {
  min-width: 0;
  padding: 4px 8px;
}

.slicer-band .slicer-button strong {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slicer-band .drill-control {
  min-width: 0;
  justify-content: center;
}

.slicer-band .drill {
  min-width: 0;
  flex: 1 1 0;
  padding: 0 8px;
}

.slicer-band .date-control,
.slicer-band .number-control {
  display: grid;
  grid-template-rows: 12px 1fr;
  gap: 2px;
}

.slicer-band .date-control span,
.slicer-band .number-control span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.observation-facts {
  display: grid;
  gap: 4px;
  margin-top: 6px;
  padding: 6px 7px;
  border: 1px solid #dfe7ef;
  border-radius: 4px;
  background: #f8fbfd;
  font-size: 11px;
  line-height: 1.35;
}

.observation-facts > div {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 5px;
  min-width: 0;
}

.observation-facts span,
.observation-judgement span {
  color: var(--muted);
}

.observation-facts strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 400;
}

.observation-judgement {
  display: grid;
  grid-template-columns: 38px auto minmax(0, 1fr);
  align-items: baseline;
  gap: 5px;
  margin-top: 5px;
  font-size: 11px;
}

.observation-judgement strong {
  color: var(--text);
  font-weight: 600;
}

.observation-judgement small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}

#detailView .station-top-defects .spark-labels {
  padding-right: 3%;
  padding-left: 3%;
}

@media (max-width: 1420px) and (min-width: 1181px) {
  :root {
    --topbar-sticky-height: 104px;
  }
}

@media (max-width: 1180px) {
  .topbar,
  .slicer-band {
    position: static;
  }

  .slicer-band {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .observation-judgement {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .observation-judgement small {
    grid-column: 2;
  }
}

/* Final desktop override: keep all slicers on one compact row. */
@media (min-width: 1181px) {
  .slicer-band {
    grid-template-columns: repeat(7, minmax(82px, 0.9fr)) repeat(2, minmax(115px, 1.25fr)) minmax(124px, 1.1fr) minmax(105px, 0.95fr) minmax(92px, 0.8fr);
    gap: 5px;
    padding: 5px;
  }

  .slicer-band .slicer-button,
  .slicer-band .date-control input,
  .slicer-band .number-control input,
  .slicer-band .drill-control,
  .slicer-band #resetFilters {
    min-height: 34px;
  }

  .slicer-band .slicer-button {
    padding-right: 6px;
    padding-left: 6px;
  }

  .slicer-band .slicer-button span,
  .slicer-band .date-control span,
  .slicer-band .number-control span {
    font-size: 11px;
  }

  .slicer-band .slicer-button strong {
    font-size: 12px;
  }

  .slicer-band .drill {
    padding-right: 5px;
    padding-left: 5px;
  }
}
