:root {
  color-scheme: light;
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
  font-synthesis: none;
  --page: #f3f6f9;
  --surface: #ffffff;
  --surface-muted: #edf2f6;
  --border: #d1d9e2;
  --border-strong: #aebbc8;
  --text: #111820;
  --text-muted: #617184;
  --primary: #009fe3;
  --primary-strong: #006da8;
  --accent: #173b63;
  --success: #087aa8;
  --warning: #8a6300;
  --danger: #b42318;
  --sidebar: #101820;
  --focus: #38bdf8;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--page);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
a {
  outline: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  box-shadow: 0 0 0 3px rgb(56 189 248 / 28%);
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--primary);
}

h1,
h2,
p,
strong,
span {
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.3;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.button {
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
}

.button.is-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.button.is-primary:hover {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
}

.button.is-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: #25364a;
}

.button.is-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.text-button {
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: #d5dee8;
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.text-button:hover {
  color: #ffffff;
}

.field {
  display: grid;
  gap: 7px;
}

.field > span {
  color: #344256;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.bulk-actions select {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
}

.field input::placeholder {
  color: #8492a3;
}

.field.is-compact {
  gap: 5px;
}

.field.is-compact input,
.field.is-compact select {
  min-height: 38px;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background: var(--page);
  box-shadow: inset 30vw 0 var(--sidebar);
}

.auth-panel {
  width: min(420px, 100%);
  padding: 32px;
  border: 1px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgb(15 23 42 / 14%);
}

.auth-brand,
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brand {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

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

.auth-brand > div > span,
.brand-block > div > span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 13px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  display: block;
  flex: 0 0 46px;
  object-fit: contain;
}

.brand-logo.is-auth {
  width: 64px;
  height: 64px;
  flex-basis: 64px;
}

.auth-heading {
  margin: 28px 0 22px;
}

.login-form {
  display: grid;
  gap: 17px;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-left: 3px solid var(--danger);
  background: #fff0ef;
  color: #8b1d14;
  font-size: 13px;
  line-height: 1.5;
}

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

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  background: var(--sidebar);
  color: #ffffff;
}

.brand-block {
  padding: 0 8px 24px;
  border-bottom: 1px solid #2c3f51;
}

.brand-block > div > span {
  color: #aebdcb;
}

nav {
  display: grid;
  gap: 4px;
  margin-top: 20px;
}

.nav-item {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-left: 3px solid transparent;
  color: #cbd5df;
  text-decoration: none;
  font-size: 14px;
}

a.nav-item:hover,
a.nav-item:focus-visible {
  background: #182b3d;
  color: #ffffff;
}

.nav-item.is-active {
  border-left-color: var(--primary);
  background: #173b63;
  color: #ffffff;
}

.nav-item.is-disabled {
  color: #718096;
  cursor: not-allowed;
}

.sidebar-user {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding: 18px 8px 0;
  border-top: 1px solid #2c3f51;
}

.sidebar-user strong {
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user span {
  overflow: hidden;
  color: #a9b8c7;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  padding: 26px clamp(18px, 3vw, 42px) 42px;
}

.topbar,
.page,
.message {
  width: min(100%, 1560px);
  margin-right: auto;
  margin-left: auto;
}

.topbar {
  margin-bottom: 22px;
}

.page-description {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.message {
  margin-bottom: 16px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--surface);
  font-size: 13px;
  line-height: 1.5;
}

.message.is-info {
  border-left-color: var(--focus);
}

.message.is-success {
  border-left-color: var(--success);
  background: #e8f6fc;
  color: #075f84;
}

.message.is-warning {
  border-left-color: var(--warning);
  background: #fff8e6;
  color: #735000;
}

.message.is-danger {
  border-left-color: var(--danger);
  background: #fff1f0;
  color: #8f2118;
}

.section {
  margin-bottom: 18px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.section-heading,
.toolbar-row,
.bulk-band,
.save-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.section-heading p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.heading-actions,
.toolbar-actions,
.bulk-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  background: var(--surface);
}

.status-table-wrap {
  margin-top: 20px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface-muted);
  color: #3d4c5d;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.status-badge,
.mapping-state {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.is-neutral {
  background: #e7ecf1;
  color: #526274;
}

.status-badge.is-success,
.mapping-state.is-mapped {
  background: #dff3fb;
  color: var(--success);
}

.status-badge.is-warning {
  background: #fff0c2;
  color: var(--warning);
}

.status-badge.is-danger {
  background: #fee4e2;
  color: var(--danger);
}

.mapping-state.is-unmapped {
  background: #e8edf2;
  color: #566678;
}

.status-text {
  font-weight: 700;
}

.status-text.is-success {
  color: var(--success);
}

.status-text.is-warning {
  color: var(--warning);
}

.status-text.is-danger {
  color: var(--danger);
}

.route-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 0;
  margin: 20px 0 0;
  padding: 0;
  list-style: none;
}

.route-list li {
  min-height: 86px;
  padding: 14px;
  border-top: 3px solid var(--primary);
  border-right: 1px solid var(--border);
  background: #f8fafc;
  font-size: 14px;
  font-weight: 650;
}

.route-list li:last-child {
  border-right: 0;
  border-top-color: var(--accent);
}

.route-list span {
  display: block;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: 12px;
}

.mapping-toolbar,
.filter-band,
.bulk-band,
.mapping-table-section,
.save-bar {
  border: 1px solid var(--border);
  background: var(--surface);
}

.mapping-toolbar {
  border-radius: 6px 6px 0 0;
}

.toolbar-row {
  padding: 16px 18px;
}

.bom-field {
  width: min(620px, 100%);
}

.summary-strip {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) repeat(3, minmax(100px, 0.65fr)) minmax(190px, 1fr);
  border-top: 1px solid var(--border);
  background: #f8fafc;
}

.summary-strip > div {
  min-width: 0;
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}

.summary-strip > div:last-child {
  border-right: 0;
}

.summary-strip span,
.summary-strip strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-strip span {
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
}

.summary-strip strong {
  font-size: 14px;
}

.filter-band {
  padding: 14px 18px;
  border-top: 0;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.bulk-band {
  min-height: 62px;
  padding: 10px 18px;
  border-top: 0;
}

.bulk-band > div:first-child {
  display: grid;
  gap: 2px;
}

.bulk-band strong {
  font-size: 14px;
}

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

.bulk-actions select {
  width: min(340px, 44vw);
  min-height: 40px;
}

.mapping-table-section {
  min-height: 240px;
  border-top: 0;
}

.mapping-table-wrap {
  max-height: calc(100vh - 320px);
  min-height: 240px;
  border: 0;
}

.mapping-table {
  min-width: 1480px;
}

.mapping-table thead {
  position: sticky;
  z-index: 4;
  top: 0;
}

.mapping-table th {
  height: 42px;
  box-shadow: inset 0 -1px var(--border-strong);
  white-space: nowrap;
}

.mapping-table td {
  height: 70px;
}

.mapping-table tr.is-unmapped td:first-child {
  box-shadow: inset 3px 0 #9aa8b6;
}

.mapping-table tr.is-mapped td:first-child {
  box-shadow: inset 3px 0 var(--success);
}

.mapping-table tbody tr:hover {
  background: #f5f9fc;
}

.select-cell,
.boolean-cell {
  width: 52px;
  text-align: center;
}

.group-cell {
  width: 220px;
}

.material-cell {
  width: 260px;
}

.quantity-cell {
  width: 110px;
  white-space: nowrap;
}

.station-cell {
  width: 260px;
}

.expected-cell {
  width: 128px;
}

.unit-cell {
  width: 92px;
}

.group-cell strong,
.material-cell strong,
.cell-secondary {
  display: block;
}

.group-cell strong,
.material-cell strong {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.cell-secondary {
  max-width: 250px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-control {
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.quantity-control {
  text-align: right;
}

.loading-state,
.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  padding: 30px;
  color: var(--text-muted);
  text-align: center;
}

.save-bar {
  position: sticky;
  z-index: 5;
  bottom: 0;
  min-height: 68px;
  padding: 12px 18px;
  border-top: 2px solid var(--border-strong);
  border-radius: 0 0 6px 6px;
  box-shadow: 0 -6px 18px rgb(15 23 42 / 9%);
}

.save-bar > div {
  display: grid;
  gap: 3px;
}

.save-bar strong {
  font-size: 14px;
}

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

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

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

  .summary-strip {
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    overflow-x: auto;
  }
}

@media (max-width: 860px) {
  .app-shell {
    width: 100%;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: auto;
    height: auto;
    padding: 14px 16px;
  }

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

  nav {
    display: flex;
    overflow-x: auto;
    margin-top: 12px;
  }

  .nav-item {
    flex: 0 0 auto;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }

  .nav-item.is-active {
    border-bottom-color: var(--primary);
  }

  .sidebar-user {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 12px;
    padding-top: 12px;
  }

  .sidebar-user span {
    grid-column: 1;
  }

  .sidebar-user .text-button {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .workspace {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 22px 14px 32px;
  }

  .topbar,
  .page,
  .message {
    width: 100%;
    max-width: 100%;
  }

  .mapping-table-wrap {
    max-height: 620px;
  }

  .route-list {
    grid-template-columns: 1fr;
  }

  .route-list li {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 620px) {
  .auth-view {
    padding: 18px 12px;
    background: var(--page);
    box-shadow: none;
  }

  .auth-panel {
    padding: 24px 20px;
  }

  h1 {
    font-size: 24px;
  }

  .section-heading,
  .toolbar-row,
  .bulk-band,
  .save-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .heading-actions,
  .toolbar-actions,
  .bulk-actions {
    width: 100%;
  }

  .heading-actions .button,
  .toolbar-actions .button,
  .bulk-actions .button,
  .save-bar .button {
    flex: 1;
  }

  .section {
    padding: 16px;
  }

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

  .search-field {
    grid-column: auto;
  }

  .bulk-actions select {
    width: 100%;
  }

  .save-bar {
    position: static;
  }
}

.nav-item svg,
.button svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  stroke-width: 2;
}

.nav-item {
  gap: 10px;
}

.button.has-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.demo-toolbar {
  margin-bottom: 14px;
  border-radius: 6px;
}

.code-generator-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.code-generator {
  min-width: 0;
  padding: 18px;
}

.code-generator + .code-generator {
  border-left: 1px solid var(--border);
}

.code-prefix {
  display: inline-grid;
  min-width: 38px;
  min-height: 30px;
  place-items: center;
  border: 1px solid #86cbed;
  border-radius: 4px;
  background: #e7f6fc;
  color: var(--primary);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 750;
}

.code-prefix.is-sub {
  border-color: #9aafc5;
  background: #e9eef5;
  color: var(--accent);
}

.code-form-grid {
  display: grid;
  grid-template-columns: minmax(110px, 0.8fr) minmax(190px, 1.4fr) minmax(95px, 0.55fr);
  gap: 12px;
  margin-top: 18px;
}

.code-form-grid.is-sub {
  grid-template-columns: minmax(110px, 0.7fr) minmax(250px, 1.7fr);
}

.code-form-grid .button {
  grid-column: 1 / -1;
  justify-self: start;
}

.generated-codes-section,
.demo-label-section,
.tracking-table-section {
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.generated-codes-section .label-grid {
  margin-top: 16px;
}

.demo-filter-band,
.tracking-filter-band {
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
}

.demo-filter-band {
  padding-top: 16px;
}

.demo-filter-grid {
  grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(190px, 1fr));
  margin-top: 14px;
}

.filter-heading {
  align-items: end;
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px;
}

.code-label {
  min-width: 0;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 5px;
  background: #ffffff;
}

.code-label.is-body {
  border-left-color: var(--primary);
}

.code-label.is-sub {
  border-left-color: var(--accent);
}

.code-label.is-material {
  border-left-color: var(--accent);
}

.qr-code {
  width: 112px;
  height: 112px;
  display: grid;
  place-items: center;
  padding: 5px;
  border: 1px solid var(--border);
  background: #ffffff;
}

.qr-code img,
.qr-code svg {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

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

.label-copy strong,
.label-copy span {
  display: block;
}

.label-kind {
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.label-code {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.35;
}

.label-description {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.4;
}

.label-meta {
  margin-top: 8px;
  color: #344256;
  font-size: 11px;
}

.barcode-wrap {
  grid-column: 1 / -1;
  min-width: 0;
  overflow: hidden;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.barcode-wrap svg {
  width: 100%;
  max-height: 58px;
}

.tracking-filter-grid {
  grid-template-columns: minmax(220px, 1.5fr) repeat(4, minmax(150px, 1fr));
}

.tracking-filter-actions,
.pagination-bar,
.detail-backbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tracking-filter-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.tracking-filter-actions > span {
  color: var(--text-muted);
  font-size: 13px;
}

.tracking-table-section {
  padding: 0;
  border-top: 0;
  border-radius: 0 0 6px 6px;
}

.tracking-table-section > .table-wrap {
  border: 0;
}

.tracking-table {
  min-width: 1040px;
}

.tracking-table tbody tr {
  cursor: pointer;
}

.tracking-table tbody tr:hover,
.tracking-table tbody tr:focus-within {
  background: #eef7fc;
}

.tracking-table td {
  height: 68px;
}

.tracking-body-code {
  color: var(--primary-strong);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
}

.table-primary,
.table-secondary {
  display: block;
}

.table-secondary {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 11px;
}

.variance-line {
  display: flex;
  gap: 7px;
  white-space: nowrap;
}

.variance-line span {
  font-size: 11px;
  font-weight: 700;
}

.variance-line .is-missing {
  color: var(--danger);
}

.variance-line .is-extra {
  color: var(--warning);
}

.pagination-bar {
  min-height: 62px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}

.pagination-bar > span {
  color: var(--text-muted);
  font-size: 13px;
}

.detail-backbar {
  margin-bottom: 14px;
}

.tracking-hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 28px;
  margin-bottom: 12px;
  padding: 20px;
  border: 1px solid #274c72;
  border-radius: 6px;
  background: #173b63;
  color: #ffffff;
}

.tracking-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tracking-title-row h2 {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 24px;
}

.tracking-hero-band p {
  margin: 7px 0 0;
  color: #ccdae8;
  font-size: 13px;
}

.detail-meta-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  gap: 0;
  margin: 0;
}

.detail-meta-list > div {
  padding: 4px 16px;
  border-left: 1px solid #46698d;
}

.detail-meta-list dt {
  color: #afc4d8;
  font-size: 10px;
  text-transform: uppercase;
}

.detail-meta-list dd {
  margin: 5px 0 0;
  font-size: 13px;
  font-weight: 650;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}

.metric-item {
  padding: 13px 16px;
  border-right: 1px solid var(--border);
}

.metric-item:last-child {
  border-right: 0;
}

.metric-item span,
.metric-item strong {
  display: block;
}

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

.metric-item strong {
  margin-top: 3px;
  font-size: 20px;
}

.metric-item.is-success strong {
  color: var(--success);
}

.metric-item.is-danger strong {
  color: var(--danger);
}

.metric-item.is-warning strong {
  color: var(--warning);
}

.tracking-detail-section {
  padding: 18px;
}

.tracking-timeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(180px, 1fr));
  gap: 0;
  margin: 18px 0 0;
  padding: 2px 0 8px;
  overflow-x: auto;
  list-style: none;
}

.timeline-step {
  min-width: 180px;
  padding: 0 14px 12px 0;
}

.timeline-step:last-child {
  padding-right: 0;
}

.timeline-track {
  --timeline-axis-y: 57px;
  position: relative;
  height: 78px;
  display: flex;
  align-items: flex-end;
  padding-bottom: 5px;
}

.timeline-track::after {
  position: absolute;
  z-index: 0;
  top: var(--timeline-axis-y);
  bottom: auto;
  right: -1px;
  left: 34px;
  height: 3px;
  background: var(--border);
  content: "";
  transform: translateY(-50%);
}

.timeline-step:last-child .timeline-track::after {
  display: none;
}

.timeline-step.is-sent-out .timeline-track::after,
.timeline-step.is-completed .timeline-track::after,
.timeline-step.is-waiting-next-station .timeline-track::after {
  background: var(--primary-strong);
}

.timeline-node {
  position: relative;
  z-index: 1;
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 32px;
  place-items: center;
  border: 3px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
}

.timeline-work-duration,
.timeline-wait-duration {
  position: absolute;
  z-index: 2;
  top: 2px;
  display: grid;
  gap: 1px;
  color: var(--text-muted);
  font-size: 9px;
  line-height: 1.25;
  white-space: nowrap;
}

.timeline-work-duration {
  left: 0;
  width: 74px;
  color: var(--accent);
}

.timeline-wait-duration {
  top: var(--timeline-axis-y);
  right: auto;
  bottom: auto;
  left: calc(50% + 17px);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border: 1px solid #86cbed;
  border-radius: 999px;
  background: #e7f6fc;
  box-shadow: 0 2px 6px rgb(0 109 168 / 12%);
  color: var(--primary-strong);
  line-height: 1;
  text-align: center;
  transform: translate(-50%, -50%);
}

.timeline-work-duration strong,
.timeline-wait-duration strong {
  font-size: 10px;
  font-weight: 700;
}

.timeline-work-duration strong {
  color: var(--primary-strong);
}

.timeline-wait-duration strong {
  color: var(--primary-strong);
}

.timeline-wait-duration::after {
  display: none;
}

.timeline-node svg {
  width: 16px;
  height: 16px;
  stroke-width: 2.5;
}

.timeline-step.is-sent-out .timeline-node,
.timeline-step.is-completed .timeline-node,
.timeline-step.is-waiting-next-station .timeline-node {
  border-color: var(--primary-strong);
  background: var(--primary-strong);
  color: #ffffff;
}

.timeline-step.is-in-station .timeline-node {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: 0 0 0 5px rgb(0 159 227 / 18%);
  color: #ffffff;
}

.timeline-content {
  padding-right: 12px;
}

.timeline-sequence {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 750;
}

.timeline-step h3 {
  min-height: 40px;
  margin: 5px 0 8px;
  font-size: 13px;
  line-height: 1.5;
}

.timeline-step p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.4;
}

.sub-job-table {
  min-width: 920px;
}

#sub-job-table-wrap {
  margin-top: 16px;
}

.expand-cell {
  width: 52px;
  text-align: center;
}

.icon-button {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--accent);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--primary);
  background: #e7f6fc;
  color: var(--primary-strong);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.sub-job-row.is-expanded {
  background: #eef7fc;
}

.sub-scan-detail-row > td {
  padding: 0;
  background: #f7fafc;
}

.sub-scan-panel {
  padding: 14px 16px 18px 28px;
  border-bottom: 1px solid var(--border);
}

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

.sub-scan-heading strong {
  font-size: 13px;
}

.sub-scan-heading span,
.sub-scan-empty {
  color: var(--text-muted);
  font-size: 12px;
}

.sub-scan-empty {
  margin: 0;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  text-align: center;
}

.sub-scan-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
}

.sub-scan-table {
  min-width: 760px;
}

.sub-scan-table th,
.sub-scan-table td {
  padding: 9px 11px;
}

.empty-inline {
  margin-top: 16px;
  padding: 18px;
  border: 1px dashed var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

.material-trace-heading {
  align-items: flex-end;
}

.segmented-control {
  display: flex;
  overflow-x: auto;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
}

.segmented-control button {
  min-height: 34px;
  padding: 6px 11px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-active {
  background: var(--primary);
  color: #ffffff;
}

.material-station-group {
  margin-top: 16px;
  border: 1px solid var(--border);
}

.material-station-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  background: var(--surface-muted);
}

.material-station-heading h3 {
  margin: 0;
  font-size: 13px;
}

.material-station-heading span {
  color: var(--text-muted);
  font-size: 11px;
}

.material-trace-table {
  min-width: 960px;
}

.material-status {
  font-weight: 700;
}

.material-status.is-scanned,
.material-status.is-substituted {
  color: var(--success);
}

.material-status.is-missing {
  color: var(--danger);
}

.material-status.is-extra {
  color: var(--warning);
}

.cost-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 0;
  margin-top: 18px;
  border: 1px solid var(--border);
}

.cost-item {
  padding: 12px;
  border-right: 1px solid var(--border);
}

.cost-item:last-child {
  border-right: 0;
}

.cost-item span,
.cost-item strong {
  display: block;
}

.cost-item span {
  color: var(--text-muted);
  font-size: 10px;
}

.cost-item strong {
  margin-top: 5px;
  font-size: 14px;
}

.status-badge.is-info {
  background: #e1f2fa;
  color: #0c668e;
}

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

  .code-generator + .code-generator {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .tracking-filter-grid {
    grid-template-columns: repeat(3, minmax(170px, 1fr));
  }

  .tracking-hero-band {
    grid-template-columns: 1fr;
  }

  .detail-meta-list > div:first-child {
    border-left: 0;
    padding-left: 0;
  }

  .cost-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
  }

  .cost-item:nth-child(3) {
    border-right: 0;
  }

  .cost-item:nth-child(n + 4) {
    border-top: 1px solid var(--border);
  }
}

@media (max-width: 720px) {
  .code-form-grid,
  .code-form-grid.is-sub,
  .demo-filter-grid,
  .tracking-filter-grid {
    grid-template-columns: 1fr;
  }

  .code-form-grid .button {
    width: 100%;
  }

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

  .code-label {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .qr-code {
    width: 96px;
    height: 96px;
  }

  .tracking-hero-band {
    padding: 16px;
  }

  .tracking-title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .detail-meta-list,
  .metric-strip,
  .cost-grid {
    grid-template-columns: 1fr 1fr;
  }

  .detail-meta-list > div:nth-child(3) {
    grid-column: 1 / -1;
    border-top: 1px solid #46698d;
    border-left: 0;
    padding-top: 12px;
    padding-left: 0;
  }

  .metric-item:nth-child(2),
  .metric-item:nth-child(4),
  .cost-item:nth-child(even) {
    border-right: 0;
  }

  .metric-item:nth-child(n + 3),
  .cost-item:nth-child(n + 3) {
    border-top: 1px solid var(--border);
  }

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

  .segmented-control {
    width: 100%;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: #ffffff;
  }

  .sidebar,
  .topbar,
  .message,
  .demo-toolbar,
  .code-generator-band,
  .demo-filter-band,
  #status-page,
  #mapping-page,
  #tracking-page,
  #clear-generated-codes {
    display: none !important;
  }

  .app-shell,
  .workspace,
  #demo-page {
    display: block !important;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .generated-codes-section,
  .demo-label-section {
    display: block;
    padding: 0;
    border: 0;
  }

  .generated-codes-section .section-heading {
    margin-bottom: 5mm;
  }

  .label-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4mm;
  }

  .code-label {
    break-inside: avoid;
    page-break-inside: avoid;
    box-shadow: none;
  }
}
