:root {
  --ink: #172026;
  --muted: #66737d;
  --line: #dce4e8;
  --soft: #f5f7f8;
  --panel: #ffffff;
  --nav: #11262d;
  --nav-2: #193842;
  --red: #d71920;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b7791f;
  --green: #16803c;
  --shadow: 0 12px 36px rgba(23, 32, 38, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  color: var(--ink);
  background: #eef3f5;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  letter-spacing: 0;
}

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

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

label input,
label select {
  color: var(--ink);
  font-size: 14px;
}

button {
  cursor: pointer;
}

a.primary-btn {
  text-decoration: none;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #eef7f7;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  width: 54px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  border-radius: 4px;
  box-shadow: inset 0 -8px 18px rgba(0, 0, 0, 0.18);
}

.brand-block strong,
.brand-block span,
.role-card span,
.role-card small {
  display: block;
}

.brand-block strong {
  font-size: 15px;
}

.brand-block span {
  margin-top: 2px;
  color: #a9c0c6;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  color: #dce9ed;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
}

.nav-item[hidden] {
  display: none !important;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.side-subnav {
  display: grid;
  gap: 4px;
  margin: -2px 0 4px 34px;
  padding-left: 10px;
  border-left: 1px solid rgba(141, 211, 203, 0.26);
}

.side-subnav[hidden] {
  display: none !important;
}

.side-subitem {
  min-height: 34px;
  padding: 7px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #bad0d5;
  text-align: left;
}

.side-subitem.active {
  background: rgba(215, 25, 32, 0.18);
  color: #fff;
}

.side-subitem em {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--red);
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 800;
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  color: #8dd3cb;
}

.role-card {
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  flex: 0 0 auto;
}

.role-card span,
.role-card small {
  color: #adc3c8;
  font-size: 12px;
}

.role-card strong {
  display: block;
  margin: 5px 0;
}

.role-action {
  width: 100%;
  margin-top: 10px;
  min-height: 32px;
  color: #dff7f6;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
}

.main {
  min-width: 0;
}

.topbar {
  height: 88px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.breadcrumb {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 12px;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.global-search {
  display: grid;
  grid-template-columns: 280px 96px;
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #7aa7ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.view-root {
  padding: 24px 28px 36px;
}

.dashboard-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.dashboard-toolbar strong,
.dashboard-toolbar span {
  display: block;
}

.dashboard-toolbar strong {
  font-size: 18px;
}

.dashboard-toolbar span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(23, 32, 38, 0.02);
}

.segmented button {
  min-width: 64px;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #2563eb;
  color: #fff;
}

.return-batch-tabs {
  flex-wrap: wrap;
  gap: 2px;
  margin: 4px 0 14px;
}

.empty-return-batches {
  padding: 20px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.toolbar,
.filter-row,
.form-grid,
.split,
.three-col,
.kpi-grid {
  display: grid;
  gap: 14px;
}

.toolbar {
  grid-template-columns: 1fr auto auto;
  align-items: center;
  margin-bottom: 16px;
}

.filter-row {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  margin-bottom: 16px;
}

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

.export-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.export-filter-grid label {
  margin: 0;
}

.export-filter-grid .wide-field {
  grid-column: span 2;
}

.split {
  grid-template-columns: minmax(0, 1.5fr) minmax(360px, 0.8fr);
}

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

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

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.dashboard-bottom {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.4fr);
  gap: 14px;
  margin-top: 14px;
}

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

.panel,
.metric,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(23, 32, 38, 0.02);
}

.panel {
  padding: 18px;
  margin-bottom: 16px;
}

.role-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  color: #14532d;
  background: #ecfdf3;
  border-color: #bbebc9;
}

.role-notice span {
  color: #276749;
  font-size: 13px;
}

.inline-notice {
  margin: 10px 0 12px;
  padding: 10px 12px;
}

.wide-field {
  grid-column: 1 / -1;
}

.checkbox-line {
  display: flex;
  align-items: center;
  flex-direction: row;
  gap: 8px;
  min-height: 42px;
  color: var(--text);
}

.checkbox-line input {
  width: auto;
  margin: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 20, 28, 0.42);
}

.modal-panel {
  width: min(960px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(10, 20, 28, 0.24);
}

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

.panel-title h2 {
  margin: 0;
  font-size: 17px;
}

.panel-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.compact-title {
  margin-top: 12px;
  margin-bottom: 8px;
}

.compact-title h2 {
  font-size: 14px;
}

.metric {
  padding: 16px;
  min-height: 118px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 27px;
}

.metric small {
  color: var(--green);
}

.metric.warn small {
  color: var(--amber);
}

.metric.danger small {
  color: var(--red);
}

.kpi-card {
  min-height: 112px;
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 14px;
  align-items: center;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.kpi-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  color: #fff;
  border-radius: 10px;
  font-weight: 900;
  font-size: 22px;
}

.kpi-card.blue .kpi-icon { background: #2f76ff; }
.kpi-card.green .kpi-icon { background: #22b981; }
.kpi-card.orange .kpi-icon { background: #ff9233; }
.kpi-card.purple .kpi-icon { background: #7d66e8; }
.kpi-card.red .kpi-icon { background: #ef4b5f; }

.kpi-card span,
.kpi-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.kpi-card strong {
  display: block;
  margin: 7px 0 6px;
  font-size: 24px;
}

.trend-chart {
  height: 188px;
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  padding: 14px 12px 8px;
  background:
    linear-gradient(#e7eef2 1px, transparent 1px) 0 25% / 100% 25%,
    linear-gradient(180deg, #fff, #f9fbfc);
  border: 1px solid #edf2f4;
  border-radius: 8px;
}

.trend-day {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr 20px;
  gap: 6px;
  align-items: end;
}

.trend-bars {
  height: 100%;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 5px;
}

.trend-bars i,
.trend-bars b {
  width: 10px;
  min-height: 8px;
  border-radius: 999px 999px 3px 3px;
}

.trend-bars i {
  background: linear-gradient(180deg, #4f8dff, #2563eb);
}

.trend-bars b {
  background: linear-gradient(180deg, #46d6ad, #22b981);
}

.trend-day span {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
}

.blue-swatch { background: #2563eb; }
.green-swatch { background: #22b981; }

.donut-wrap {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 16px;
  align-items: center;
}

.donut {
  width: 150px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at center, #fff 0 48%, transparent 49%), conic-gradient(#2f76ff 0 36%, #31c19a 36% 60%, #ffc35a 60% 76%, #ef5b6f 76% 86%, #4c6287 86% 100%);
}

.donut strong,
.donut span {
  grid-area: 1 / 1;
}

.donut strong {
  margin-top: 22px;
  font-size: 18px;
}

.donut span {
  margin-top: -28px;
  color: var(--muted);
  font-size: 12px;
}

.donut-legend .bar-row {
  grid-template-columns: 72px 1fr 48px;
}

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

.mini-stat-grid div {
  padding: 10px;
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-stat-grid span,
.query-stats small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.mini-stat-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
}

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

.query-stats div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 8px;
  align-items: center;
}

.query-stats span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #eef7ff;
  color: #2563eb;
}

.query-stats strong {
  display: block;
  font-size: 17px;
}

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

.activity-list div {
  display: grid;
  grid-template-columns: 18px 1fr 74px;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.activity-list time {
  color: var(--muted);
  font-size: 12px;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.activity-dot.green { background: #22b981; }
.activity-dot.orange { background: #ff9233; }
.activity-dot.red { background: #ef4b5f; }
.activity-dot.purple { background: #7d66e8; }
.activity-dot.blue { background: #2f76ff; }

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

.mobile-layout {
  display: grid;
  gap: 16px;
}

.mobile-split {
  margin-top: 14px;
  grid-template-columns: minmax(260px, 0.72fr) minmax(360px, 1fr);
}

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

.mode-card,
.requirement-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfe;
}

.mode-card {
  display: grid;
  gap: 8px;
}

.mode-card.active {
  border-color: rgba(215, 25, 32, 0.3);
  background: #fff7f7;
}

.mode-card span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--red), #f97316);
  font-weight: 800;
}

.mode-card small,
.requirement-grid span {
  color: var(--muted);
  line-height: 1.55;
}

.sn-rule-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sn-plan {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid #d5e3ea;
  border-radius: 8px;
  background: #f8fbfc;
}

.sn-plan div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sn-plan span,
.sn-plan small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sn-plan strong {
  display: block;
  margin: 5px 0;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.station-control {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #d5e3ea;
  border-radius: 8px;
  background: #f8fbfc;
}

.control-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

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

.compact-form {
  grid-template-columns: 1.6fr repeat(3, minmax(0, 1fr));
}

.sn-rule-strip div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sn-rule-strip span,
.sn-rule-strip small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.sn-rule-strip strong {
  display: block;
  margin: 5px 0;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.phone-frame {
  width: min(320px, 100%);
  margin: 0 auto;
  padding: 12px;
  border-radius: 30px;
  background: #14242c;
  box-shadow: 0 18px 40px rgba(20, 36, 44, 0.18);
}

.phone-speaker {
  width: 66px;
  height: 5px;
  margin: 2px auto 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.28);
}

.phone-screen {
  min-height: 520px;
  padding: 16px;
  border-radius: 22px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef4f8 100%);
  display: grid;
  align-content: start;
  gap: 14px;
}

.phone-top,
.phone-task {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.phone-top span,
.phone-task small {
  color: var(--muted);
  font-size: 12px;
}

.phone-task {
  display: grid;
  justify-content: stretch;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.camera-box {
  min-height: 210px;
  border: 1px dashed #8eb2c4;
  border-radius: 8px;
  background:
    linear-gradient(rgba(15, 118, 110, 0.06), rgba(15, 118, 110, 0.06)),
    repeating-linear-gradient(90deg, transparent 0 11px, rgba(17, 38, 45, 0.06) 12px 13px);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 16px;
}

.camera-box span {
  color: var(--red);
  font-weight: 800;
}

.camera-box strong {
  font-size: 18px;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.camera-box em {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.phone-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.phone-actions button,
.phone-result {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.phone-actions button.active,
.phone-result {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.capture-panel {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocr-empty {
  margin-top: 12px;
  padding: 22px;
  border: 1px dashed #b7c5cf;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.ocr-result-card {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.ocr-result-card.ok {
  border-color: #a7dfba;
  background: #f3fbf6;
}

.ocr-result-card.warn {
  border-color: #ead28a;
  background: #fffbec;
}

.ocr-result-card.bad {
  border-color: #f2b8b5;
  background: #fff5f4;
}

.ocr-result-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.ocr-result-head span,
.ocr-meta small {
  color: var(--muted);
}

.ocr-result-head strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
  overflow-wrap: anywhere;
}

.confidence {
  height: 8px;
  margin: 12px 0;
  border-radius: 999px;
  overflow: hidden;
  background: #e3e9ee;
}

.confidence span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), #27b08e);
}

.ocr-meta {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px;
}

.char-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.char-warn,
.char-ok {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
}

.char-warn {
  color: #8a4b00;
  background: #fff2d6;
  border: 1px solid #f1ce8a;
}

.char-ok {
  color: #106b39;
  background: #eaf8ef;
  border: 1px solid #bfe9cf;
}

.ocr-pipeline {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.ocr-pipeline div {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  display: grid;
  align-content: start;
  gap: 8px;
}

.ocr-pipeline span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #fff;
  background: #1f5aaa;
  font-weight: 800;
}

.module-tile {
  min-height: 76px;
  display: grid;
  place-items: center;
  gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
}

.module-tile span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  color: #fff;
  background: #2f76ff;
  border-radius: 8px;
}

.module-tile strong {
  font-size: 12px;
}

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

.process-step {
  position: relative;
  min-height: 128px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.process-step span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf7ff;
  color: #2563eb;
}

.process-step strong {
  font-size: 13px;
}

.process-step small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.primary-btn,
.ghost-btn,
.secondary-btn,
.danger-btn,
.mini-btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 38px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.primary-btn {
  background: var(--red);
  color: #fff;
}

.ghost-btn {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-btn {
  background: #f3f7f9;
  color: var(--ink);
  border-color: var(--line);
}

.danger-btn {
  background: #fff5f5;
  color: var(--red);
  border-color: #f2b7b7;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  background: #f7fafb;
  border-color: var(--line);
  color: var(--ink);
}

.icon-mini {
  font-weight: 700;
}

.compact-meta {
  margin-top: 12px;
}

.batch-import-panel {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfc;
}

.batch-import-panel > div:first-child {
  display: grid;
  gap: 3px;
  margin-bottom: 10px;
}

.batch-import-panel textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}

@media (max-height: 820px) and (min-width: 901px) {
  .sidebar {
    gap: 10px;
    padding: 14px 12px;
  }

  .brand-block {
    padding-bottom: 10px;
  }

  .brand-block span {
    display: none;
  }

  .nav-list {
    gap: 4px;
  }

  .nav-item {
    min-height: 34px;
    padding: 7px 10px;
  }

  .side-subitem {
    min-height: 28px;
    padding: 5px 8px;
  }

  .role-card {
    padding: 10px;
  }

  .role-card small {
    display: none;
  }
}

.color-allocation {
  margin-top: 14px;
  border: 1px solid #d5e3ea;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.allocation-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: #f8fbfc;
  border-bottom: 1px solid var(--line);
}

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

.inline-number,
.inline-text {
  width: 120px;
  min-height: 32px;
  padding: 6px 8px;
}

.inline-text {
  width: min(220px, 100%);
}

.paste-zone {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 92px;
  margin-top: 12px;
  padding: 18px;
  text-align: center;
  border: 1px dashed #9fb6c3;
  border-radius: 8px;
  background: #f8fbfc;
  outline: none;
}

.paste-zone:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

.work-order-table-scroll {
  max-height: 520px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.work-order-table-scroll table {
  margin: 0;
}

.work-order-table-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafb;
}

.work-order-table-scroll td {
  overflow-wrap: anywhere;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f8fafb;
}

tr:hover td {
  background: #fbfcfc;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid transparent;
}

.status.ok {
  color: #106b39;
  background: #eaf8ef;
  border-color: #bfe9cf;
}

.status.info {
  color: #1f5aaa;
  background: #edf4ff;
  border-color: #caddff;
}

.status.warn {
  color: #915f00;
  background: #fff6dd;
  border-color: #efd389;
}

.status.bad {
  color: #b42318;
  background: #fff0ef;
  border-color: #fac5c0;
}

.trace-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.sn-card {
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(215, 25, 32, 0.11), transparent 35%),
    linear-gradient(135deg, #ffffff, #f7fbfb);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.sn-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

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

.meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 10px;
  width: 2px;
  background: #cfdbe0;
}

.event {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 10px;
  align-items: start;
  position: relative;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--teal);
  border: 4px solid #e6f6f4;
  z-index: 1;
}

.event strong {
  display: block;
  margin-bottom: 3px;
}

.event p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.event time {
  color: var(--muted);
  font-size: 12px;
}

.chart-bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 54px;
  gap: 10px;
  align-items: center;
  font-size: 13px;
}

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

.bar {
  height: 100%;
  background: linear-gradient(90deg, var(--teal), #3b82f6);
}

.work-progress {
  margin-top: 12px;
  padding: 12px;
  background: #f8fbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.progress-head span {
  color: var(--blue);
  font-weight: 800;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.progress-grid span {
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.progress-grid strong {
  color: var(--ink);
}

.scan-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.scanner-workbar {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) minmax(320px, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin: 14px 0;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scanner-workbar strong {
  display: block;
  color: var(--text);
  font-size: 15px;
}

.scanner-workbar span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.scanner-workbar input {
  height: 44px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0;
}

.select-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

.select-add .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--danger);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.inline-extra {
  margin-top: 8px;
}

#factoryScan {
  font-family: "Courier New", monospace;
  font-weight: 700;
  text-transform: uppercase;
}

.scan-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.scan-hint span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
}

.scan-result {
  margin-top: 12px;
  padding: 12px;
  min-height: 76px;
  background: #f8fafb;
  border: 1px dashed #b9c8ce;
  border-radius: 8px;
}

.mini-list {
  margin-top: 10px;
  border: 1px solid #dbe4e8;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.mini-list > div {
  display: grid;
  grid-template-columns: minmax(150px, 220px) 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-bottom: 1px solid #e5ecef;
  font-size: 12px;
}

.mini-list > div:last-child {
  border-bottom: 0;
}

.mini-list strong {
  color: #0f2537;
}

.mini-list span {
  color: #5b7080;
}

.mini-list time {
  color: #8a9aaa;
  white-space: nowrap;
}

.scan-result.compact {
  min-height: auto;
  margin-bottom: 14px;
  padding: 10px 12px;
}

.scan-result.preline {
  white-space: pre-line;
  line-height: 1.7;
}

.batch-scan-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.batch-scan-box textarea {
  min-height: 82px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.batch-scan-box .ghost-btn {
  min-width: 132px;
}

.service-stats {
  margin-bottom: 12px;
}

.sla-board {
  display: grid;
  gap: 10px;
}

.sla-board div {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 70px auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.sla-board span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.sla-board b {
  color: var(--ink);
}

.flow-map {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  align-items: center;
}

.flow-step {
  min-height: 84px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
}

.flow-step strong {
  display: block;
  margin-bottom: 6px;
}

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

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed #b9c8ce;
  border-radius: 8px;
  background: #fbfcfc;
}

.login-screen {
  min-height: calc(100vh - 150px);
  display: grid;
  place-items: center;
}

.login-panel {
  width: min(460px, 100%);
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
}

.login-panel .brand-mark {
  width: 62px;
  height: 40px;
}

.login-panel h2,
.login-panel p {
  margin: 0;
}

.login-panel p,
.login-panel small {
  color: var(--muted);
}

.carton-label {
  padding: 12px;
  color: #111827;
  background: #fff;
  border: 2px solid #111827;
  border-radius: 6px;
  overflow: hidden;
}

.carton-label-brand {
  display: flex;
  align-items: flex-start;
  height: 30px;
}

.carton-label-brand img {
  display: block;
  width: 72px;
  height: auto;
}

.carton-label-id {
  display: block;
  min-width: 0;
  padding: 3px 0 7px;
  border-bottom: 1px solid #111827;
  white-space: nowrap;
  text-align: center;
  letter-spacing: -0.2px;
}

.carton-label span,
.carton-label small {
  color: #374151;
}

.label-highlight {
  display: grid;
  gap: 5px;
  margin: 8px 0 10px;
  padding: 8px 10px;
  border: 1px solid #111827;
  border-radius: 4px;
  background: #f8fafc;
}

.label-highlight span {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: #111827;
}

.label-highlight b {
  font-size: 14px;
}

.barcode {
  margin: 10px 0;
  padding: 8px;
  text-align: center;
  font-family: "Courier New", monospace;
  font-size: 13px;
  letter-spacing: 1px;
  color: #111827;
  border: 1px solid #111827;
}

.code128-wrap svg {
  display: block;
  width: 100%;
  height: 46px;
  fill: #111827;
}

.code128-wrap span {
  display: block;
  margin-top: 6px;
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-bottom: 8px;
  font-size: 12px;
}

.carton-label-sn {
  display: block;
  margin-top: 10px;
  max-height: 54px;
  overflow: hidden;
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

.carton-label-sn span {
  display: block;
}

.print-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.carton-side-panel {
  position: sticky;
  top: 86px;
  align-self: start;
  max-height: calc(100vh - 108px);
  overflow: auto;
}

.sealed-carton-scroll {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}

.sealed-carton-scroll table {
  margin: 0;
}

.sealed-carton-scroll thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
}

.print-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-row {
  background: #fff7ed;
}

.danger-mini {
  color: #b91c1c;
  border-color: #fecaca;
  background: #fff1f2;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 360px;
  padding: 12px 14px;
  background: #172026;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 900px) {
  body {
    min-width: 0;
    background: #f3f6f7;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 10px 12px 8px;
    gap: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }

  .brand-block {
    padding: 0 2px 8px;
    border-bottom: 0;
  }

  .brand-mark {
    width: 44px;
    height: 30px;
  }

  .brand-block strong {
    font-size: 14px;
  }

  .brand-block span {
    font-size: 11px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 0 4px;
    scrollbar-width: none;
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    flex: 0 0 82px;
    min-height: 58px;
    padding: 7px 6px;
    display: grid;
    place-items: center;
    gap: 3px;
    text-align: center;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.2;
  }

  .side-subnav {
    flex: 0 0 auto;
    display: flex;
    margin: 0;
    padding: 0;
    border-left: 0;
    gap: 8px;
  }

  .side-subnav[hidden] {
    display: none !important;
  }

  .side-subitem {
    min-width: 92px;
    min-height: 58px;
    display: grid;
    place-items: center;
    text-align: center;
  }

  .nav-icon {
    width: 22px;
    height: 20px;
  }

  .role-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    margin-top: 0;
    padding: 8px 10px;
  }

  .role-card span,
  .role-card small {
    display: none;
  }

  .role-card strong {
    margin: 0;
    font-size: 13px;
  }

  .role-action {
    width: auto;
    margin-top: 0;
    padding: 0 10px;
  }

  .topbar,
  .trace-header {
    display: grid;
    height: auto;
  }

  .topbar {
    position: static;
    padding: 14px 14px 10px;
    gap: 12px;
    background: #fff;
  }

  .breadcrumb {
    font-size: 11px;
  }

  h1 {
    font-size: 18px;
  }

  .view-root {
    padding: 12px 12px 28px;
  }

  .panel {
    padding: 14px;
    margin-bottom: 12px;
  }

  .panel-title {
    align-items: flex-start;
    display: grid;
    gap: 8px;
  }

  .panel-title h2 {
    font-size: 16px;
  }

  .global-search,
  .kpi-grid,
  .dashboard-grid,
  .dashboard-bottom,
  .filter-row,
  .form-grid,
  .split,
  .three-col,
  .meta-grid,
  .flow-map,
  .sla-board div {
    grid-template-columns: 1fr;
  }

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

  .module-grid,
  .process-flow,
  .mini-stat-grid,
  .query-stats,
  .sn-rule-strip,
  .sn-plan {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .segmented button {
    flex: 1 0 auto;
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .scan-box {
    grid-template-columns: 1fr;
  }

  .button-row,
  .print-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .primary-btn,
  .ghost-btn,
  .danger-btn,
  .mini-btn,
  .secondary-btn {
    width: 100%;
    justify-content: center;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  th,
  td {
    min-width: 96px;
  }

  .kpi-card {
    grid-template-columns: 46px 1fr;
    padding: 14px;
    min-height: 96px;
  }

  .kpi-icon {
    width: 40px;
    height: 40px;
  }

  .kpi-card strong {
    font-size: 21px;
  }

  .trend-chart {
    height: 160px;
    overflow-x: auto;
  }

  .process-flow {
    overflow-x: auto;
  }

  .phone-frame {
    width: min(100%, 340px);
  }

  .phone-screen {
    min-height: 460px;
  }

  .carton-label {
    min-width: 0;
  }

  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    max-width: none;
  }
}

@media (max-width: 640px) {
  .brand-block {
    gap: 9px;
  }

  .global-search {
    gap: 8px;
  }

  .module-grid,
  .process-flow,
  .mini-stat-grid,
  .query-stats,
  .sn-rule-strip,
  .sn-plan,
  .tab-row {
    grid-template-columns: 1fr;
  }

  .mode-grid,
  .requirement-grid,
  .export-filter-grid,
  .sn-rule-strip,
  .ocr-pipeline {
    grid-template-columns: 1fr;
  }

  .export-filter-grid .wide-field {
    grid-column: 1;
  }

  .phone-actions {
    grid-template-columns: 1fr;
  }

  .ocr-meta {
    grid-template-columns: 1fr;
  }

  .label-grid {
    grid-template-columns: 1fr;
  }

  .sn-card {
    padding: 14px;
  }

  .sn-card h2,
  .ocr-result-head strong,
  .camera-box strong {
    font-size: 16px;
  }
}
