:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #657287;
  --border: #dbe3ee;
  --border-strong: #c7d2df;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #e7f5f3;
  --blue: #2563eb;
  --amber: #d97706;
  --amber-soft: #fff7df;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 8px;
  --row-h: 36px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-frame {
  height: 100vh;
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  background: var(--bg);
}

.app-nav {
  width: 178px;
  height: 100vh;
  min-height: 100vh;
  position: sticky;
  top: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  padding: 14px 12px;
  background: #0f172a;
  color: #e5edf6;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.nav-brand .brand-mark {
  width: 34px;
  height: 34px;
  background: #0f766e;
}

.nav-brand strong,
.nav-brand span {
  display: block;
}

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

.nav-brand span {
  margin-top: 2px;
  color: #9fb0c6;
  font-size: 12px;
}

.nav-menu {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.nav-item {
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #cbd5e1;
  padding: 0 10px;
  text-align: left;
}

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

.nav-item.active {
  box-shadow: inset 3px 0 0 #2dd4bf;
}

.nav-footer {
  display: grid;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.22);
}

.nav-footer small {
  color: #9fb0c6;
  line-height: 1.35;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  color: #dbeafe;
  font-size: 12px;
  font-weight: 700;
}

.status-pill.online {
  background: rgba(45, 212, 191, 0.18);
  color: #99f6e4;
}

.status-pill.error {
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
}

.app-shell {
  min-width: 0;
  height: 100vh;
  min-height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 250px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.brand h1,
.brand p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.2;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.version-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
  min-width: 0;
}

.version-picker select,
.search-input,
.form-grid input,
.modal input,
.modal select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  outline: none;
}

.version-picker select:focus,
.search-input:focus,
.form-grid input:focus,
.modal input:focus,
.modal select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.main-grid {
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 260px minmax(420px, 1fr) 300px;
  gap: 14px;
  padding: 14px;
  overflow: hidden;
}

.side-rail,
.workspace,
.exception-panel {
  min-height: 0;
  min-width: 0;
}

.side-rail,
.exception-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.side-rail {
  overflow: auto;
}

body[data-route="cockpit"] .main-grid,
body[data-route="inventory"] .main-grid,
body[data-route="sales"] .main-grid,
body[data-route="price"] .main-grid,
body[data-route="arrival"] .main-grid,
body[data-route="ordering"] .main-grid,
body[data-route="arrivalRules"] .main-grid,
body[data-route="customers"] .main-grid {
  grid-template-columns: minmax(0, 1fr);
}

body[data-route="import"] .main-grid {
  grid-template-columns: minmax(280px, 360px) minmax(360px, 1fr);
}

body[data-route="cockpit"] .side-rail,
body[data-route="cockpit"] .exception-panel,
body[data-route="cockpit"] .kpi-strip,
body[data-route="cockpit"] .table-panel,
body[data-route="inventory"] .side-rail,
body[data-route="inventory"] .exception-panel,
body[data-route="inventory"] .cockpit-panel,
body[data-route="sales"] .side-rail,
body[data-route="sales"] .exception-panel,
body[data-route="sales"] .cockpit-panel,
body[data-route="price"] .side-rail,
body[data-route="price"] .exception-panel,
body[data-route="price"] .cockpit-panel,
body[data-route="arrival"] .side-rail,
body[data-route="arrival"] .exception-panel,
body[data-route="arrival"] .cockpit-panel,
body[data-route="ordering"] .side-rail,
body[data-route="ordering"] .exception-panel,
body[data-route="ordering"] .cockpit-panel,
body[data-route="ordering"] .kpi-strip,
body[data-route="ordering"] .table-panel,
body[data-route="arrivalRules"] .side-rail,
body[data-route="arrivalRules"] .exception-panel,
body[data-route="arrivalRules"] .cockpit-panel,
body[data-route="customers"] .side-rail,
body[data-route="customers"] .exception-panel,
body[data-route="customers"] .cockpit-panel,
body[data-route="customers"] .kpi-strip,
body[data-route="import"] .workspace {
  display: none;
}

body[data-route="cockpit"] .workspace,
body[data-route="inventory"] .workspace,
body[data-route="sales"] .workspace,
body[data-route="price"] .workspace,
body[data-route="arrival"] .workspace,
body[data-route="ordering"] .workspace,
body[data-route="arrivalRules"] .workspace,
body[data-route="customers"] .workspace {
  grid-column: 1 / -1;
}

body[data-route="cockpit"] .workspace {
  grid-template-rows: auto;
  overflow: auto;
}

body[data-route="inventory"] .workspace,
body[data-route="sales"] .workspace,
body[data-route="price"] .workspace,
body[data-route="arrival"] .workspace,
body[data-route="arrivalRules"] .workspace,
body[data-route="customers"] .workspace {
  grid-template-rows: auto minmax(0, 1fr);
}

body[data-route="ordering"] .main-grid {
  align-content: start;
  overflow: auto;
}

body[data-route="ordering"] .workspace {
  grid-template-rows: auto;
  overflow: visible;
}

body[data-route="import"] .exception-panel {
  min-height: 0;
}

.rail-section,
.table-panel,
.exception-panel,
.kpi-card {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.rail-section {
  padding: 14px;
}

.section-title,
.exception-header,
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title {
  margin-bottom: 12px;
  font-weight: 700;
}

.section-title small {
  color: var(--muted);
  font-weight: 500;
}

.import-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  padding: 10px;
  margin-top: 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  text-align: left;
}

.import-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.primary-import {
  border-color: rgba(15, 118, 110, 0.35);
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--accent);
  font-weight: 800;
}

.import-btn strong,
.import-btn em {
  display: block;
  min-width: 0;
}

.import-btn em {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.button-stack {
  display: grid;
  gap: 8px;
}

.ghost-btn,
.solid-btn,
.danger-btn,
.danger-ghost,
.icon-btn {
  min-height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 0 12px;
}

.ghost-btn:hover {
  border-color: var(--border-strong);
  background: var(--surface-soft);
}

.ghost-btn:disabled,
.solid-btn:disabled,
.danger-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.solid-btn {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.solid-btn:hover {
  background: var(--accent-strong);
}

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

.danger-ghost {
  color: var(--red);
  border-color: rgba(220, 38, 38, 0.28);
}

.danger-ghost:hover {
  background: var(--red-soft);
}

.icon-btn {
  width: 34px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
}

.form-grid {
  display: grid;
  gap: 8px;
}

.form-grid.compact input {
  width: 100%;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.formula-list {
  max-height: 150px;
  overflow: auto;
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.formula-item {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.formula-item strong {
  display: block;
  font-size: 13px;
}

.formula-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.formula-item button {
  margin-top: 6px;
  color: var(--red);
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
}

.ordering-panel {
  min-width: 0;
  display: none;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

body[data-route="ordering"] .ordering-panel {
  display: grid;
}

.ordering-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.ordering-head h2,
.ordering-head p {
  margin: 0;
}

.ordering-head h2 {
  font-size: 18px;
  line-height: 1.25;
}

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

.ordering-head-actions,
.ordering-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ordering-entry-view {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.ordering-entry-toolbar {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.ordering-entry-toolbar label {
  min-width: 180px;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ordering-entry-toolbar input,
.ordering-entry-toolbar select,
.ordering-grid-table input,
.ordering-grid-table select,
.ordering-output {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.ordering-entry-toolbar input,
.ordering-entry-toolbar select,
.ordering-grid-table input,
.ordering-grid-table select {
  height: 36px;
  min-width: 0;
  padding: 0 9px;
}

.ordering-grid-wrap {
  min-width: 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ordering-grid-table {
  width: 100%;
  min-width: 1260px;
  border-collapse: collapse;
  table-layout: fixed;
}

.ordering-grid-table th,
.ordering-grid-table td {
  height: 50px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

.ordering-grid-table th {
  height: 40px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ordering-grid-table th:nth-child(1) { width: 54px; text-align: center; }
.ordering-grid-table th:nth-child(2) { width: 250px; }
.ordering-grid-table th:nth-child(3) { width: 110px; }
.ordering-grid-table th:nth-child(4) { width: 100px; }
.ordering-grid-table th:nth-child(5) { width: 210px; }
.ordering-grid-table th:nth-child(6) { width: 230px; }
.ordering-grid-table th:nth-child(7) { width: 190px; }
.ordering-grid-table th:nth-child(8) { width: 110px; }
.ordering-grid-table th:nth-child(9) { width: 52px; }

.ordering-grid-index,
.ordering-grid-remove-cell {
  text-align: center !important;
  color: var(--muted);
}

.ordering-grid-table input:focus,
.ordering-grid-table select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(12, 132, 120, 0.12);
  outline: none;
}

.ordering-cell-attention input,
.ordering-cell-attention select {
  border-color: #e9b949;
  background: #fffaf0;
}

.ordering-grid-readonly {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.ordering-cell-attention .ordering-grid-readonly {
  color: #b26a00;
}

.ordering-row-error input,
.ordering-row-error select {
  border-color: var(--red);
}

.ordering-grid-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ordering-grid-status.mapped {
  color: var(--accent);
  font-weight: 700;
}

.ordering-grid-status.warning {
  color: #b26a00;
  font-weight: 700;
}

.ordering-grid-remove {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.ordering-grid-remove:hover {
  background: #fff0f0;
  color: var(--red);
}

.ordering-grid-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.ordering-grid-footer > span {
  color: var(--muted);
  font-size: 13px;
}

.ordering-suggestion-menu {
  position: fixed;
  z-index: 1200;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(17, 30, 52, 0.18);
}

.ordering-suggestion-item {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ordering-suggestion-item:last-child {
  border-bottom: 0;
}

.ordering-suggestion-item.active,
.ordering-suggestion-item:hover {
  background: var(--accent-soft);
}

.ordering-suggestion-item span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ordering-suggestion-item small {
  color: var(--muted);
  white-space: nowrap;
}

.ordering-output {
  min-height: 180px;
  resize: vertical;
  padding: 10px;
  line-height: 1.55;
  white-space: pre;
}

.ordering-mapping-view {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.ordering-mapping-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.ordering-mapping-editor-head,
.ordering-mapping-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ordering-mapping-editor-grid {
  display: grid;
  grid-template-columns: minmax(230px, 1.4fr) minmax(130px, 0.7fr) minmax(90px, 0.5fr) minmax(230px, 1.3fr) minmax(130px, 0.7fr) minmax(210px, 1.2fr);
  gap: 10px;
}

.ordering-mapping-editor-grid label {
  min-width: 0;
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ordering-mapping-editor-grid input,
.ordering-mapping-editor-grid select {
  width: 100%;
  height: 36px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.ordering-mapping-editor-grid input[readonly] {
  background: #f3f6f9;
  color: var(--muted);
}

.ordering-reference-field {
  position: relative;
}

.ordering-reference-options {
  position: absolute;
  top: 58px;
  left: 0;
  right: 0;
  z-index: 30;
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(17, 30, 52, 0.16);
}

.ordering-reference-options button {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.ordering-reference-options button:hover {
  background: var(--accent-soft);
}

.ordering-reference-options button small,
.ordering-reference-empty {
  color: var(--muted);
}

.ordering-reference-empty {
  padding: 10px;
  font-size: 12px;
}

.ordering-mapping-toolbar {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(280px, 1fr);
  gap: 10px;
}

.ordering-mapping-toolbar label,
.ordering-mapping-footer label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ordering-mapping-toolbar input,
.ordering-mapping-toolbar select,
.ordering-mapping-footer select,
.ordering-mapping-table input,
.ordering-mapping-table select {
  height: 36px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.ordering-mapping-note {
  color: var(--muted);
  font-size: 12px;
}

.ordering-mapping-table-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ordering-mapping-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  table-layout: fixed;
}

.ordering-mapping-table th,
.ordering-mapping-table td {
  height: 48px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ordering-mapping-table th {
  height: 42px;
  background: var(--surface-soft);
  font-size: 12px;
}

.ordering-mapping-table th:nth-child(1) { width: 120px; }
.ordering-mapping-table th:nth-child(2) { width: 190px; }
.ordering-mapping-table th:nth-child(3) { width: 100px; }
.ordering-mapping-table th:nth-child(4) { width: 130px; }
.ordering-mapping-table th:nth-child(5) { width: 190px; }
.ordering-mapping-table th:nth-child(6) { width: 230px; }
.ordering-mapping-table th:nth-child(7) { width: 110px; }
.ordering-mapping-table th:nth-child(8) { width: 90px; }

.ordering-mapping-table input,
.ordering-mapping-table select {
  width: 100%;
}

.ordering-mapping-code {
  font-variant-numeric: tabular-nums;
}

.ordering-mapping-name {
  font-weight: 700;
}

.ordering-mapping-status {
  color: var(--muted);
  font-size: 12px;
}

.ordering-mapping-status.mapped {
  color: var(--accent);
  font-weight: 700;
}

.ordering-mapping-empty {
  height: 160px !important;
  color: var(--muted);
  text-align: center !important;
}

.ordering-mapping-footer {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
}

.ordering-mapping-footer > span {
  margin-right: auto;
  align-self: center;
  color: var(--muted);
  font-size: 13px;
}

.ordering-mapping-footer label {
  grid-template-columns: auto 84px;
  align-items: center;
}

.ordering-records-view {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.ordering-records-toolbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 190px)) minmax(260px, 1fr);
  gap: 10px;
}

.ordering-records-toolbar label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.ordering-records-toolbar input,
.ordering-records-toolbar select,
.ordering-records-footer select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

.ordering-records-table-wrap {
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.ordering-records-table,
.ordering-record-detail-table {
  width: 100%;
  min-width: 1050px;
  border-collapse: collapse;
  table-layout: fixed;
}

.ordering-records-table th,
.ordering-records-table td,
.ordering-record-detail-table th,
.ordering-record-detail-table td {
  height: 44px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.ordering-records-table th,
.ordering-record-detail-table th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.ordering-records-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.ordering-records-footer > span {
  margin-right: auto;
  color: var(--muted);
}

.ordering-records-footer select {
  width: 88px;
}

.ordering-record-detail {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.ordering-record-detail-table {
  overflow: auto;
}

.ordering-record-detail-head > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ordering-record-detail-head small {
  color: var(--muted);
}

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

.ordering-record-detail-wrap {
  overflow: auto;
}

.cockpit-panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.cockpit-head,
.ops-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.cockpit-head h2,
.cockpit-head p,
.ops-panel-head h3 {
  margin: 0;
}

.cockpit-head h2 {
  font-size: 18px;
  line-height: 1.25;
}

.cockpit-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.cockpit-actions {
  display: flex;
  gap: 8px;
  white-space: nowrap;
}

.cockpit-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(112px, 1fr));
  gap: 10px;
}

.ops-kpi {
  min-height: 86px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

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

.ops-kpi strong {
  display: block;
  margin: 7px 0 5px;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.ops-kpi.warning strong {
  color: var(--amber);
}

.ops-kpi.danger strong {
  color: var(--red);
}

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

.ops-panel {
  min-width: 0;
  min-height: 142px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.ops-panel.wide {
  grid-column: 1 / -1;
}

.ops-panel-head {
  align-items: center;
}

.ops-panel-head h3 {
  font-size: 14px;
}

.ops-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 6px;
}

.ops-list .empty-state {
  padding: 18px 8px;
}

.ops-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.ops-group {
  display: grid;
  gap: 4px;
}

.ops-item-button {
  width: 100%;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.ops-item-button:hover {
  border-color: var(--teal);
}

.ops-detail-list {
  display: grid;
  gap: 3px;
  margin-left: 10px;
  padding: 6px 8px;
  border-left: 2px solid var(--border);
}

.ops-detail-row {
  display: grid;
  grid-template-columns: minmax(100px, auto) minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.ops-detail-row span {
  color: var(--text);
  font-weight: 700;
}

.ops-detail-row small,
.ops-detail-more {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-detail-more {
  color: var(--muted);
  font-size: 12px;
}

.ops-list-footer {
  display: flex;
  justify-content: center;
  padding: 2px 0 4px;
}

.ops-list-footer .compact {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.ops-item strong,
.ops-item span,
.ops-item small {
  min-width: 0;
}

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

.ops-item small {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ops-value {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ops-value.warning {
  color: var(--amber);
}

.ops-value.danger {
  color: var(--red);
}

.road-goods-panel {
  min-height: 260px;
}

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

.road-summary,
.road-bucket {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.road-summary {
  background: #f8fafc;
}

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

.road-section-head strong {
  font-size: 13px;
}

.road-section-head small {
  color: var(--muted);
  font-size: 12px;
}

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

.road-product-list {
  display: grid;
  gap: 6px;
}

.road-product-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.road-product-item strong,
.road-product-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.road-product-item strong {
  font-size: 13px;
}

.road-product-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.road-product-item span {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .road-bucket-grid {
    grid-template-columns: 1fr;
  }
}

.ops-action-value {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.ops-action-value:hover {
  text-decoration: underline;
}

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

.kpi-card {
  padding: 13px 14px;
}

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

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

.kpi-card.alert strong {
  color: var(--red);
}

.table-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.table-toolbar {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: flex-start;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

body[data-route="arrivalRules"] .tabs,
body[data-route="customers"] .tabs {
  display: none;
}

.tab {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  padding: 0 12px;
}

.tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.toolbar-actions button {
  flex: 0 0 auto;
  white-space: nowrap;
}

.search-input {
  width: min(320px, 32vw);
  min-width: 180px;
  flex: 1 1 220px;
}

.filter-bar {
  min-height: 0;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 6px 0 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
}

.filter-chip button {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
}

.quick-filter-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 8px 0 0;
}

.quick-filter-group span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.selection-quick-controls small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.quick-filter {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.quick-filter.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.highlight-legend {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  color: var(--muted);
  font-size: 12px;
}

.highlight-legend span {
  font-weight: 800;
  color: #64748b;
}

.highlight-legend em {
  width: 16px;
  height: 10px;
  border: 1px solid var(--border);
  border-radius: 3px;
  font-style: normal;
}

.highlight-legend em.danger {
  background: var(--red-soft);
}

.highlight-legend em.warning {
  background: var(--amber-soft);
}

.highlight-legend em.positive {
  background: #ecfdf5;
}

.highlight-legend em.muted {
  background: #f8fafc;
}

.highlight-legend small {
  font-size: 12px;
}

.table-scroll {
  min-height: 0;
  overflow: auto;
  position: relative;
}

.table-pager {
  min-height: 46px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.pager-meta strong {
  color: var(--text);
}

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

.selection-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 0;
  color: var(--muted);
}

.compact-control {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.pager-actions label,
.pager-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.pager-actions select {
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 8px;
  background: #fff;
  color: var(--text);
}

table {
  min-width: 900px;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

th,
td {
  height: var(--row-h);
  padding: 0 10px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-soft);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
  overflow: visible;
}

th .th-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.th-inner .sort-trigger,
.th-inner .sort-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sort-trigger {
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: inherit;
}

.sort-label {
  color: inherit;
  font-weight: inherit;
}

.filter-trigger {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--muted);
  padding: 0;
  font-size: 11px;
}

.sticky-cell {
  position: sticky;
  z-index: 2;
  background: #fff;
  box-shadow: 1px 0 0 var(--border);
  background-clip: padding-box;
}

th.sticky-cell {
  z-index: 4;
  background: var(--surface-soft);
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.negative-row td {
  background: var(--red-soft);
}

.negative-row .sticky-cell {
  background: var(--red-soft);
}

.warning-row td {
  background: var(--amber-soft);
}

.warning-row .sticky-cell {
  background: var(--amber-soft);
}

.positive-row td {
  background: #ecfdf5;
}

.positive-row .sticky-cell {
  background: #ecfdf5;
}

.gift-row td {
  color: var(--muted);
}

.muted-row td {
  color: var(--muted);
  background: #f8fafc;
}

.muted-row .sticky-cell {
  background: #f8fafc;
}

.row-check {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 8;
}

.col-resizer::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 3px;
  width: 1px;
  background: transparent;
}

.col-resizer:hover::after {
  background: var(--accent);
}

.group-row td {
  background: #eef6ff;
  color: #1d4ed8;
  font-weight: 800;
}

.group-toggle {
  border: 0;
  background: transparent;
  color: #1d4ed8;
  padding: 0;
  font-weight: 800;
}

.row-link {
  min-width: 0;
  max-width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 0;
  font-weight: 800;
  text-align: left;
}

.row-link:hover {
  text-decoration: underline;
}

.edited-badge {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.arrival-detail {
  display: grid;
  gap: 12px;
}

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

.arrival-detail-head .summary-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.arrival-detail-head span,
.arrival-edit-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.arrival-detail-head strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrival-bulk-edit {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
}

.arrival-bulk-edit input {
  width: 170px;
}

.arrival-edit-grid {
  display: grid;
  gap: 8px;
}

.arrival-edit-row {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) minmax(120px, 0.8fr) minmax(86px, 0.6fr) 150px;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.arrival-edit-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-table-wrap {
  max-height: 420px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

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

.detail-table th,
.detail-table td {
  height: 34px;
  font-size: 13px;
}

.arrival-rule-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

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

.arrival-rule-stock span {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.arrival-rule-stock strong {
  color: var(--text);
  font-size: 16px;
}

.compact-empty {
  padding: 16px;
}

.bulk-selection-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 150px;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.bulk-selection-preview span {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font-size: 12px;
}

.arrival-rule-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-soft);
}

.arrival-rule-row strong,
.arrival-rule-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.exception-panel {
  padding: 14px;
  overflow: hidden;
}

.exception-header {
  align-items: flex-start;
}

.exception-header h2,
.exception-header p {
  margin: 0;
}

.exception-header h2 {
  font-size: 17px;
}

.exception-header p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.pending-card {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
  color: var(--muted);
}

.pending-card strong {
  color: var(--text);
}

.exception-groups {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.exception-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}

.exception-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  padding: 10px;
  background: var(--surface-soft);
  font-size: 13px;
}

.batch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.mini-btn {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  font-size: 12px;
}

.exception-item {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.exception-item:first-of-type {
  border-top: 0;
}

.exception-item p {
  margin: 0;
  line-height: 1.45;
}

.exception-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.exception-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.resolved {
  opacity: 0.55;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.32);
}

.modal {
  width: min(920px, 96vw);
  max-height: 88vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: #fff;
  box-shadow: var(--shadow);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  overflow: auto;
  padding: 14px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

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

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

.modal-grid label span {
  font-weight: 700;
}

.compare-grid {
  display: grid;
  gap: 14px;
}

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

.security-grid section {
  min-height: 110px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.security-grid h3,
.security-grid p {
  margin: 0;
}

.security-grid h3 {
  font-size: 14px;
}

.security-grid p {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.55;
}

.security-grid code {
  color: var(--accent-strong);
}

.compact-security {
  margin-top: 10px;
}

.compact-security input,
.compact-security select {
  width: 100%;
}
.password-input-wrap {
  position: relative;
  display: block;
  width: 100%;
}
.password-input-wrap input {
  width: 100%;
  padding-right: 56px;
}
.password-visibility-toggle {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 48px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #087a70;
}
.security-email-state {
  align-self: end;
  margin: 0 0 10px !important;
  color: #64748b;
  font-size: 13px;
}

.version-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
}

.version-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.version-card strong {
  display: block;
}

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

.version-card .version-actions {
  display: flex;
  gap: 6px;
}

.filter-popover {
  position: fixed;
  z-index: 40;
  width: 300px;
  max-height: 380px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  padding: 8px;
}

.filter-bulk-actions,
.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.filter-actions {
  justify-content: flex-end;
}

.filter-values {
  overflow: auto;
  display: grid;
  gap: 4px;
  margin: 8px 0;
}

.filter-value-option {
  min-height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 5px;
  background: #fff;
  text-align: left;
  padding: 0 8px;
  cursor: pointer;
}

.filter-value-option:hover {
  background: var(--surface-soft);
}

.progress-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.76);
}

.progress-box {
  width: min(420px, 90vw);
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.progress-track {
  height: 8px;
  overflow: hidden;
  margin: 12px 0;
  border-radius: 999px;
  background: var(--border);
}

#progressBar {
  width: 15%;
  height: 100%;
  background: var(--accent);
  transition: width 0.2s ease;
}

.progress-box p {
  margin: 0;
  color: var(--muted);
}

.progress-cancel {
  width: 100%;
  margin-top: 14px;
}

.toast-host {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 8px;
}

.toast {
  width: min(360px, 88vw);
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.toast.success {
  border-color: rgba(15, 118, 110, 0.35);
}

.toast.error {
  border-color: rgba(220, 38, 38, 0.35);
}

.flash-row td {
  animation: flashRow 1.4s ease;
}

@keyframes flashRow {
  0%,
  100% {
    background: #fff;
  }
  25%,
  70% {
    background: #dcfce7;
  }
}

@media (max-width: 1180px) {
  .app-frame {
    height: auto;
    flex-direction: column;
    overflow: visible;
  }

  .app-nav {
    width: 100%;
    height: auto;
    min-height: auto;
    position: relative;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
    align-items: center;
  }

  .app-shell {
    height: auto;
    min-height: 0;
  }

  .nav-menu {
    display: flex;
    overflow: auto;
  }

  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .nav-footer {
    padding: 0;
    border-top: 0;
    justify-items: end;
  }

  .main-grid {
    grid-template-columns: 250px minmax(480px, 1fr);
    overflow: visible;
  }

  body[data-route="import"] .main-grid {
    grid-template-columns: 250px minmax(480px, 1fr);
  }

  .exception-panel {
    grid-column: 1 / -1;
    min-height: 360px;
  }

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

  .ops-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .ops-panel.wide {
    grid-row: auto;
    grid-column: 1 / -1;
  }

}

@media (max-width: 820px) {
  .app-nav {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .nav-footer {
    justify-items: start;
  }

  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    overflow: visible;
  }

  .brand {
    min-width: 0;
  }

  .brand h1 {
    font-size: 18px;
    line-height: 1.3;
  }

  .toolbar-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .top-actions {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    overflow: hidden;
  }

  .ordering-head {
    display: grid;
  }

  .ordering-head-actions {
    justify-content: flex-start;
  }

  .ordering-entry-toolbar { align-items: stretch; }
  .ordering-entry-toolbar label { min-width: min(100%, 220px); }

  .ordering-mapping-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .ordering-mapping-editor-grid,
  .ordering-records-toolbar {
    grid-template-columns: minmax(0, 1fr);
  }

  .ordering-mapping-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .ordering-mapping-footer > span {
    margin-right: 0;
  }

  .ordering-mapping-footer label {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ordering-grid-footer { align-items: stretch; flex-direction: column; }
  .ordering-grid-footer .ordering-actions-row { justify-content: flex-start; }

  .top-actions .version-picker {
    grid-column: 1 / -1;
  }

  .top-actions button,
  .top-actions select {
    width: 100%;
    min-width: 0;
  }

  .top-actions button {
    padding: 0 8px;
    font-size: 13px;
  }

  .version-picker {
    justify-content: space-between;
  }

  .version-picker select {
    flex: 1 1 auto;
    width: auto;
  }

  .main-grid {
    grid-template-columns: 1fr;
    overflow: hidden;
  }

  .cockpit-head,
  .cockpit-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .cockpit-kpis,
  .ops-grid,
  .security-grid {
    grid-template-columns: 1fr;
  }

  .kpi-strip {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .search-input {
    width: 100%;
  }

  .arrival-detail-head,
  .arrival-edit-row,
  .arrival-rule-stock {
    grid-template-columns: 1fr;
  }

  .arrival-bulk-edit {
    align-items: stretch;
    flex-direction: column;
  }

  .arrival-bulk-edit input {
    width: 100%;
  }
}
