:root {
  color-scheme: light;
  --ink: #102033;
  --muted: #5d6d80;
  --line: #d7e1ec;
  --paper: #ffffff;
  --canvas: #eef3f8;
  --primary: #1b63c7;
  --primary-dark: #12488d;
  --sidebar: #08111f;
  --success: #15803d;
  --warning: #d97706;
  --danger: #dc2626;
  --green: var(--primary);
  --green-2: var(--primary-dark);
  --green-soft: #e9f1ff;
  --orange: var(--warning);
  --orange-soft: #fff7ed;
  --red: var(--danger);
  --red-soft: #fef2f2;
  --shadow: 0 18px 38px rgba(21, 48, 78, 0.08), 0 2px 7px rgba(21, 48, 78, 0.05);
  --shadow-soft: 0 9px 22px rgba(21, 48, 78, 0.07), 0 1px 3px rgba(21, 48, 78, 0.04);
  --radius: 18px;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 24% 0%, rgba(31, 99, 243, 0.08), transparent 32%),
    linear-gradient(180deg, #f7faff 0%, var(--canvas) 48%, #eef3f9 100%);
}

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

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.22);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 268px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  color: #fff;
  background:
    radial-gradient(circle at 20% 0%, rgba(61, 111, 255, 0.35), transparent 34%),
    linear-gradient(180deg, #0b1730 0%, var(--sidebar) 54%, #050b14 100%);
  display: flex;
  flex-direction: column;
  gap: 28px;
  box-shadow: 18px 0 45px rgba(15, 23, 42, 0.16);
}

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

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.32);
}

.brand h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.brand p {
  margin: 3px 0 0;
  color: #98a7bd;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 8px;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 0;
  border-radius: 13px;
  padding: 12px 14px;
  text-align: left;
  color: #c9d3e3;
  background: transparent;
  font-weight: 650;
}

.nav button:hover,
.nav button.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.34), rgba(37, 99, 235, 0.18));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.ui-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-foot {
  margin-top: auto;
}

.role-card {
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(12px);
}

.role-card label {
  display: block;
  margin-bottom: 8px;
  color: #b9d0c8;
  font-size: 12px;
}

.role-card select {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 9px 10px;
  color: var(--ink);
  background: #fff;
}

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

.account-card span {
  margin-top: 4px;
  color: #cbd5e1;
  font-size: 12px;
}

.account-card small {
  margin-top: 10px;
  color: #93c5fd;
}

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

.account-actions button {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 7px;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 35%),
    var(--canvas);
}

.login-card,
.loading-card {
  width: min(430px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand > span {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
}

.login-brand h1,
.login-brand p,
.login-copy h2,
.login-copy p {
  margin: 0;
}

.login-brand h1 {
  font-size: 17px;
}

.login-brand p,
.login-copy p,
.login-card > small {
  color: var(--muted);
}

.login-copy {
  margin: 28px 0 20px;
}

.login-copy h2 {
  margin-bottom: 7px;
  font-size: 26px;
}

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

.login-submit {
  min-height: 46px;
  justify-content: center;
}

.login-card > small {
  display: block;
  margin-top: 16px;
  text-align: center;
}

.login-message {
  margin-bottom: 16px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 13px;
}

.filing-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  line-height: 1.6;
}

.filing-footer a {
  color: var(--muted);
  text-decoration: none;
}

.filing-footer a:hover,
.filing-footer a:focus-visible {
  color: var(--primary);
  text-decoration: underline;
}

.main {
  min-width: 0;
  padding: 30px clamp(20px, 4vw, 54px) 64px;
  max-width: 1700px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
  padding: 4px 0 2px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.page-head h2 {
  margin: 0;
  font-size: clamp(25px, 3vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.page-head .subtitle {
  max-width: 640px;
  margin: 10px 0 0;
  color: var(--muted);
}

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

.btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 16px;
  color: var(--ink);
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover {
  border-color: #bfd0e5;
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.btn.primary {
  border-color: var(--primary);
  color: #fff;
  background: linear-gradient(135deg, #2f73ff 0%, var(--primary-dark) 100%);
  box-shadow: 0 12px 22px rgba(31, 99, 243, 0.18);
}

.btn.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.btn.danger {
  border-color: #fecaca;
  color: var(--red);
  background: linear-gradient(180deg, #fff 0%, var(--red-soft) 100%);
}

.btn.small {
  padding: 7px 10px;
  font-size: 12px;
}

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

.stat,
.panel,
.order-card,
.product-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.stat {
  min-height: 128px;
  padding: 22px;
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto 18px 0;
  height: 3px;
  border-radius: 999px 999px 0 0;
  background: linear-gradient(90deg, rgba(31, 99, 243, 0.12), rgba(31, 99, 243, 0.42));
}

.stat .label {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 14px;
  font-size: 32px;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat small {
  color: var(--muted);
}

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

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.55fr);
  gap: 18px;
}

.panel {
  border-radius: var(--radius);
  padding: 24px;
}

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

.panel h3 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.02em;
}

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

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

.recycle-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.recycle-card h3,
.recycle-card p {
  margin: 0;
}

.recycle-card p,
.recycle-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.search-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.74);
}

.search-button {
  min-height: 43px;
}

.order-card {
  width: 100%;
  border-radius: 16px;
  padding: 18px;
  text-align: left;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

button.order-card:hover {
  border-color: #bfdbfe;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.order-top,
.product-head,
.process-top,
.history-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.order-card h4,
.product-card h3 {
  margin: 0;
}

.order-meta,
.muted {
  color: var(--muted);
}

.order-meta {
  margin-top: 6px;
  font-size: 13px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

.chip,
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
}

.chip {
  padding: 6px 9px;
  color: var(--green);
  background: var(--green-soft);
}

.badge {
  padding: 5px 8px;
  color: var(--muted);
  background: #eceeea;
}

.badge.warn {
  color: #9a531c;
  background: var(--orange-soft);
}

.badge.success {
  color: var(--success);
  background: #f0fdf4;
}

.badge.danger {
  color: var(--red);
  background: var(--red-soft);
}

.exceptions {
  display: grid;
  gap: 10px;
}

.exception {
  padding: 12px 13px;
  border-left: 3px solid var(--red);
  border-radius: 0 10px 10px 0;
  background: var(--red-soft);
}

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

.exception span {
  color: #7a4b46;
  font-size: 12px;
}

.empty {
  padding: 44px 20px;
  border: 1px dashed #c7d3e2;
  border-radius: 15px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.6);
}

.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--ink);
}

.back-link {
  display: inline-flex;
  margin-bottom: 18px;
  border: 0;
  padding: 0;
  color: var(--green-2);
  background: transparent;
  font-weight: 750;
}

.product-stack {
  display: grid;
  gap: 20px;
}

.production-report {
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.timeline-stack {
  display: grid;
  gap: 20px;
}

.product-selector {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.selector-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.selector-head h3 {
  margin: 0;
}

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

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

.product-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.product-list-head {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) minmax(100px, 0.7fr) minmax(100px, 0.7fr) minmax(130px, 0.9fr) 92px 150px;
  gap: 14px;
  padding: 10px 14px;
  color: var(--muted);
  background: #f4f7fb;
  border: 1px solid var(--line);
  border-radius: 14px 14px 0 0;
  font-size: 12px;
  font-weight: 750;
}

.product-list-head.folder-list-head,
.product-options.compact .product-option.sku-folder-row {
  grid-template-columns: minmax(190px, 1.5fr) minmax(100px, 0.7fr) minmax(100px, 0.7fr) minmax(130px, 0.9fr) 110px;
}

.product-options.compact {
  display: block;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  overflow: hidden;
}

.product-options.compact .product-option {
  display: grid;
  grid-template-columns: minmax(190px, 1.5fr) minmax(100px, 0.7fr) minmax(100px, 0.7fr) minmax(130px, 0.9fr) 92px 150px;
  align-items: center;
  gap: 14px;
  min-height: 66px;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.product-options.compact .product-option:last-child {
  border-bottom: 0;
}

.product-options.compact .product-option:hover {
  transform: none;
  box-shadow: none;
  background: #f8fbff;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:active {
  background: #eff6ff;
}

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

.row-actions .link-button {
  width: auto;
  padding: 0;
  font-weight: 750;
}

.product-identity strong,
.product-identity small {
  display: block;
}

.product-identity small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.product-number {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.product-completion > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 750;
}

.product-completion i {
  display: block;
  width: 100%;
  height: 5px;
  border-radius: 99px;
  overflow: hidden;
  background: #e8edf4;
}

.product-completion b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.open-flow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

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

.order-summary article {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

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

.order-summary strong {
  display: block;
  margin: 8px 0 3px;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.order-summary article.alert strong {
  color: var(--danger);
}

.outsource-order-list,
.outsource-product-list,
.outsource-process-list,
.inventory-list {
  display: grid;
  gap: 12px;
}

.outsource-order-card,
.outsource-product-row,
.inventory-row {
  display: grid;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 76px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  text-align: left;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.outsource-order-card {
  grid-template-columns: minmax(190px, 1.4fr) repeat(4, minmax(100px, 0.65fr)) 105px;
}

.outsource-product-row {
  grid-template-columns: minmax(170px, 1.1fr) minmax(180px, 1.2fr) repeat(3, minmax(100px, 0.7fr)) 125px;
}

.inventory-row {
  grid-template-columns: minmax(180px, 1.25fr) repeat(6, minmax(88px, 0.65fr)) minmax(210px, 1fr);
}

.outsource-process-row {
  grid-template-columns: minmax(220px, 1.3fr) repeat(3, minmax(110px, 0.7fr)) 130px;
}

.inventory-style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.inventory-style-card {
  display: grid;
  gap: 16px;
  min-height: 188px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.inventory-style-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 18px 42px rgba(15, 23, 42, 0.09);
  transform: translateY(-1px);
}

.inventory-style-card.abnormal {
  border-color: #fecaca;
  background: #fff7f7;
}

.inventory-style-main strong {
  display: block;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0.02em;
}

.inventory-style-main small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.inventory-style-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.inventory-style-stats span {
  padding: 10px;
  border-radius: 12px;
  background: #eef5ff;
}

.inventory-style-stats small,
.inventory-style-stats b {
  display: block;
}

.inventory-style-stats small {
  color: var(--muted);
  font-size: 11px;
}

.inventory-style-stats b {
  margin-top: 4px;
  font-size: 18px;
}

.ledger-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.ledger-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-soft);
}

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

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

.ledger-card strong {
  margin: 8px 0 5px;
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

.ledger-card small {
  color: var(--muted);
  line-height: 1.45;
}

.ledger-card.factory {
  background: #fff7ed;
}

.ledger-card.warehouse {
  background: #eff6ff;
}

.ledger-card.titanium {
  background: #f5f3ff;
}

.ledger-card.shipped {
  background: #ecfdf5;
}

.inventory-ledger-section {
  padding: 0 20px 18px;
}

.ledger-table {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.ledger-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(105px, 0.65fr));
  align-items: center;
  min-width: 780px;
  border-bottom: 1px solid var(--line);
}

.ledger-row:last-child {
  border-bottom: 0;
}

.ledger-row span {
  padding: 12px 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.ledger-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.ledger-head {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
}

.ledger-start {
  background: #fff7ed;
}

.ledger-empty {
  color: var(--muted);
}

.outsource-order-card:hover,
.outsource-product-row:hover,
.inventory-row:hover {
  border-color: #bfdbfe;
  background: #f8fbff;
  transform: translateY(-1px);
}

.outsource-order-card strong,
.outsource-order-card small,
.outsource-product-row strong,
.outsource-product-row small,
.inventory-row strong,
.inventory-row small {
  display: block;
}

.outsource-order-card small,
.outsource-product-row small,
.inventory-row small {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.outsource-order-main strong {
  font-size: 16px;
}

.inventory-main strong {
  font-size: 16px;
}

.inventory-row-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 7px;
}

.outsource-order-main small {
  margin-top: 5px;
}

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

.inventory-summary article {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  box-shadow: var(--shadow-soft);
}

.inventory-summary span,
.inventory-summary strong {
  display: block;
}

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

.inventory-summary strong {
  margin-top: 6px;
  font-size: 23px;
}

.inventory-summary article.alert strong,
.inventory-row.abnormal strong,
.inventory-warning {
  color: var(--danger);
}

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

.muted-action {
  color: var(--muted);
}

.danger-zone {
  margin-top: 18px;
  padding: 14px;
  border: 1px solid #fecaca;
  border-radius: 14px;
  background: #fff7f7;
}

.danger-zone strong {
  display: block;
  color: var(--danger);
}

.danger-zone p {
  margin: 6px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.inventory-warning {
  padding: 12px 20px;
  border-top: 1px solid #fecaca;
  background: var(--red-soft);
  font-weight: 800;
}

.inventory-history {
  padding: 14px 20px 20px;
}

.section-title {
  margin: 22px 20px 12px;
  color: var(--ink);
  font-size: 17px;
}

.outsource-batch-list {
  display: grid;
  gap: 14px;
  padding: 0 20px 8px;
}

.outsource-batch-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  overflow: hidden;
}

.outsource-batch-card.abnormal {
  border-color: #fecaca;
  background: #fff7f7;
}

.outsource-batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.outsource-batch-head strong,
.outsource-batch-head small {
  display: block;
}

.outsource-batch-head small {
  margin-top: 4px;
  color: var(--muted);
}

.outsource-batch-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.outsource-batch-totals span {
  padding: 13px 16px;
  background: #fff;
}

.outsource-batch-totals small,
.outsource-batch-totals b {
  display: block;
}

.outsource-batch-totals small {
  color: var(--muted);
  font-size: 12px;
}

.outsource-batch-totals b {
  margin-top: 4px;
  font-size: 22px;
}

.outsource-ledger-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 14px 16px 16px;
}

.outsource-ledger-columns h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.outsource-ledger-columns ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.outsource-ledger-columns li {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, auto);
  gap: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(236, 242, 247, 0.72);
}

.outsource-ledger-columns li span,
.outsource-ledger-columns li small {
  color: var(--muted);
}

.outsource-ledger-columns li small {
  grid-column: 1 / -1;
}

.outstanding-value strong,
.outstanding-value:not(:has(strong)) {
  color: var(--warning);
}

.outsource-process-panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.outsource-process-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.outsource-process-head h3 {
  margin: 8px 0 0;
  font-size: 20px;
}

.outsource-totals {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.outsource-totals div {
  padding: 18px 20px;
  background: #f8fbff;
}

.outsource-totals span,
.outsource-totals strong {
  display: block;
}

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

.outsource-totals strong {
  margin-top: 6px;
  font-size: 24px;
}

.outsource-totals .outstanding strong {
  color: var(--warning);
}

.factory-breakdown {
  padding: 12px 20px 20px;
}

.factory-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.5fr) repeat(3, minmax(100px, 0.7fr));
  align-items: center;
  gap: 14px;
  min-height: 58px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.factory-row.abnormal {
  border-color: #fecaca;
  background: #fff7f7;
}

.factory-row.abnormal strong,
.factory-row.abnormal .outstanding-value {
  color: var(--red);
}

.factory-row:last-child {
  border-bottom: 0;
}

.factory-row span {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.factory-row small {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.compact-empty {
  padding: 26px 16px;
}

.sheet-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.sheet-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.sheet-open {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.sheet-open strong,
.sheet-open small {
  display: block;
}

.sheet-open small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.sheet-file-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: var(--primary);
  background: #eff6ff;
}

.sheet-card-meta {
  display: flex;
  gap: 8px;
  margin: 15px 0;
  color: var(--muted);
  font-size: 12px;
}

.sheet-card-meta span {
  padding: 4px 8px;
  border-radius: 6px;
  background: #f1f5f9;
}

.sheet-card-actions {
  display: flex;
  gap: 7px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.save-state {
  display: inline-flex;
  align-items: center;
  color: var(--success);
  font-size: 13px;
  font-weight: 750;
}

.save-state::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--success);
}

.sheet-workspace {
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  box-shadow: var(--shadow);
}

.sheet-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

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

.sheet-grid-wrap {
  max-height: calc(100vh - 275px);
  overflow: auto;
}

.sheet-grid {
  min-width: max-content;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.sheet-grid th,
.sheet-grid td {
  height: 44px;
  padding: 0;
  border-right: 1px solid #dfe5ec;
  border-bottom: 1px solid #dfe5ec;
  background: #fff;
}

.sheet-grid th {
  color: #475569;
  background: #f1f5f9;
  font-size: 12px;
  font-weight: 750;
  text-align: center;
}

.sheet-column-head {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 130px;
  min-width: 130px;
}

.sheet-row-head,
.sheet-corner {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 48px;
  min-width: 48px;
}

.sheet-corner {
  top: 0;
  z-index: 3;
}

.sheet-cell {
  width: 130px;
  height: 44px;
  padding: 7px 9px;
  border: 0;
  border-radius: 0;
  color: var(--ink);
  background: transparent;
  outline: none;
}

.sheet-cell:focus {
  box-shadow: inset 0 0 0 2px var(--primary);
  background: #eff6ff;
}

.confirm-message {
  padding: 4px 0;
}

.confirm-message strong {
  display: block;
  font-size: 17px;
}

.confirm-message p {
  margin: 9px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.product-option {
  width: 100%;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.product-option:hover {
  border-color: #93c5fd;
  box-shadow: 0 12px 28px rgba(31, 99, 243, 0.11);
  transform: translateY(-1px);
}

.product-option > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.product-option > div:first-child strong {
  font-size: 17px;
}

.product-option > div:first-child span,
.product-option small {
  color: var(--muted);
  font-size: 12px;
}

.option-numbers {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 10px;
  font-size: 13px;
  font-weight: 700;
}

.option-progress {
  height: 7px;
  margin-bottom: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.option-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.timeline-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
}

.timeline-title strong,
.timeline-title span {
  display: block;
}

.timeline-title strong {
  font-size: 17px;
}

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

.timeline-table {
  width: max-content;
  min-width: 100%;
}

.timeline-table th,
.timeline-table td {
  min-width: 128px;
  height: 68px;
  padding: 9px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.timeline-table .date-row th {
  color: var(--ink);
  background: #eef4f9;
}

.timeline-table .date-row th:not(.sticky-col) {
  font-weight: 700;
  white-space: nowrap;
}

.timeline-table .process-row-label {
  min-width: 160px;
  color: var(--ink);
  background: #faf8f2;
}

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

.process-row-label span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.process-summary-table {
  min-width: 900px;
}

.process-summary-table tbody th,
.process-summary-table tbody td {
  height: auto;
  padding: 14px 12px;
  color: var(--ink);
  background: #fff;
  border-right: 0;
  border-bottom: 1px solid var(--line);
}

.process-summary-table tbody tr:hover th,
.process-summary-table tbody tr:hover td {
  background: #f8fbff;
}

.link-button {
  width: 100%;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.link-button strong {
  color: var(--green);
}

.timeline-detail {
  margin: 14px 18px 18px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.timeline-detail summary {
  padding: 13px 16px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 800;
}

.process-detail-page {
  display: grid;
  gap: 16px;
}

.process-detail-actions {
  justify-content: flex-start;
  margin: 0;
  padding: 0 18px;
}

.section-caption {
  margin: 0 18px -4px;
  color: var(--ink);
  font-size: 15px;
}

.process-detail-page .history-list {
  padding: 0 18px 18px;
}

.process-detail-table-wrap {
  margin: 0 18px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.process-detail-table {
  min-width: 1120px;
}

.process-detail-table th {
  padding: 10px 12px;
}

.process-detail-table td {
  height: auto;
  padding: 10px 12px;
  text-align: left;
}

.process-detail-table td:first-child,
.process-detail-table td:nth-child(3),
.process-detail-table td:nth-child(4),
.process-detail-table td:last-child {
  text-align: center;
}

.timeline-table td.has-quantity {
  color: var(--primary);
  background: #edf5ff;
  font-size: 18px;
  font-weight: 850;
}

.timeline-table td.quantity-excess {
  color: var(--danger);
  background: var(--red-soft);
}

.auto-time {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--primary);
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 700;
}

.time-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px dashed #a8c0df;
  border-radius: 14px;
  background: #f8fbff;
  cursor: pointer;
}

.time-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.time-toggle span,
.time-toggle small {
  display: block;
}

.time-toggle small {
  margin-top: 3px;
  color: var(--muted);
  font-weight: 400;
}

.actual-time-field[hidden] {
  display: none;
}

.danger-confirm {
  padding: 16px;
  border: 1px solid #e6bab5;
  border-radius: 12px;
  background: var(--red-soft);
}

.danger-confirm p {
  margin: 8px 0 0;
  color: var(--muted);
}

.report-scroll {
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.production-table {
  width: 100%;
  min-width: 980px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.production-table th {
  min-width: 142px;
  padding: 13px 10px;
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  background: linear-gradient(180deg, #1f3f78 0%, #142a52 100%);
  text-align: center;
  white-space: nowrap;
}

.production-table th:first-child {
  min-width: 155px;
}

.production-table th:nth-child(2) {
  min-width: 105px;
}

.production-table td {
  height: 124px;
  padding: 11px 9px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: center;
  vertical-align: middle;
  background: #fff;
}

.production-table tr:last-child td {
  border-bottom: 0;
}

.production-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
}

.production-table th.sticky-col {
  z-index: 3;
}

.production-table td.sticky-col {
  background: #faf8f2;
  box-shadow: 8px 0 18px rgba(15, 23, 42, 0.06);
}

.product-label strong,
.product-label small {
  display: block;
}

.product-label strong {
  font-size: 15px;
}

.product-label small {
  margin: 4px 0 10px;
  color: var(--muted);
}

.product-label button,
.cell-actions button {
  border: 0;
  border-radius: 9px;
  padding: 6px 8px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 11px;
  font-weight: 700;
}

.order-quantity strong,
.process-cell > strong {
  display: block;
  font-size: 18px;
}

.process-cell > small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  white-space: nowrap;
}

.latest-entry {
  margin-top: 7px;
  color: #7b5b36;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
}

.process-cell.cell-abnormal {
  background: #fff0ed;
}

.empty-cell {
  color: #aeb6b2;
  background: #fbfcfe !important;
}

.mini-progress {
  width: 100%;
  height: 6px;
  margin-top: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #e8edf4;
}

.mini-progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
}

.cell-abnormal .mini-progress i {
  background: var(--red);
}

.cell-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.report-tip {
  margin: 0;
  padding: 11px 15px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
}

.product-card {
  border-radius: 20px;
  padding: 22px;
}

.product-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.product-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.baseline {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.baseline div {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

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

.baseline strong {
  font-size: 20px;
}

.route {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.process-card {
  position: relative;
  min-height: 174px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
  box-shadow: var(--shadow-soft);
}

.process-card.excess,
.process-card.downstream-excess {
  border-color: #e2aaa4;
  background: #fff8f7;
}

.process-index {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  font-size: 11px;
  font-weight: 800;
}

.process-name {
  margin: 10px 0 4px;
  font-weight: 800;
}

.process-total {
  font-size: 24px;
  font-weight: 850;
}

.progress-track {
  height: 7px;
  margin: 11px 0 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf4;
}

.progress-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.excess .progress-track i,
.downstream-excess .progress-track i {
  background: var(--red);
}

.process-note {
  min-height: 34px;
  color: var(--muted);
  font-size: 12px;
}

.process-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
}

.outsource-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 10px 0;
}

.outsource-summary div {
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  background: #f8fbff;
}

.outsource-summary span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.outsource-summary strong {
  font-size: 15px;
}

.modal {
  width: min(760px, calc(100vw - 28px));
  max-height: calc(100vh - 36px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 20px;
  background: var(--paper);
  box-shadow: 0 30px 100px rgba(15, 23, 42, 0.28);
}

.modal.wide {
  width: min(1180px, calc(100vw - 28px));
}

.modal.wide .timeline-report {
  box-shadow: none;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(3px);
}

.modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.modal-head h3 {
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: #eef2f7;
  font-size: 20px;
}

.modal-body {
  padding: 22px;
}

.modal-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  background: var(--paper);
}

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

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

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

.field label,
.field > span {
  font-size: 13px;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #d0d9e5;
  border-radius: 12px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 3px solid rgba(31, 99, 243, 0.14);
  border-color: var(--primary);
}

.product-form {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

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

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

.route-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.route-picker {
  display: grid;
  gap: 12px;
}

.route-picker-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.route-picker-head > span {
  font-weight: 850;
}

.route-picker-head small {
  color: var(--muted);
  font-weight: 750;
}

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

.route-choice {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.route-choice:hover,
.route-choice:focus-visible {
  border-color: rgba(31, 99, 243, 0.5);
  background: #eef5ff;
  box-shadow: 0 8px 18px rgba(31, 99, 243, 0.08);
}

.route-choice-order {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--primary);
  background: #dbeafe;
  font-weight: 900;
  font-size: 13px;
}

.route-choice strong {
  font-size: 15px;
}

.route-flow {
  min-height: 54px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px dashed #b8c7dc;
  border-radius: 16px;
  background: #f8fbff;
}

.route-flow:empty::before {
  content: "点击上方工序按钮，流程会显示在这里";
  color: var(--muted);
  font-weight: 750;
}

.route-flow-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eaf3ff;
  color: #143b7a;
  font-weight: 850;
  cursor: pointer;
  outline: none;
}

.route-flow-item:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(31, 99, 243, 0.16);
  background: #dbeafe;
}

.route-flow-item::after {
  content: ">";
  color: #6d83a3;
  font-weight: 900;
}

.route-flow-item:last-child::after {
  content: "";
}

.route-flow-item button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.route-custom-field {
  margin-top: 2px;
}

.route-custom-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.route-editor {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.route-editor-row {
  display: grid;
  grid-template-columns: 34px minmax(150px, 1fr) minmax(130px, 180px) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
}

.route-editor-index {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border-radius: 50%;
  color: #fff;
  background: var(--primary);
  font-weight: 850;
}

.route-editor-row label {
  display: grid;
  gap: 6px;
}

.route-editor-row small {
  color: var(--muted);
  font-weight: 750;
}

.route-editor-row input,
.route-editor-row select {
  width: 100%;
  border: 1px solid #d0d9e5;
  border-radius: 12px;
  padding: 10px 11px;
  background: #fff;
}

.route-editor-actions {
  display: flex;
  gap: 6px;
  padding-bottom: 1px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-row {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.history-row.voided {
  opacity: 0.55;
  text-decoration: line-through;
}

.history-row strong {
  font-size: 16px;
}

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

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: 360px;
  padding: 12px 16px;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 0.2s ease;
}

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

.toast.error {
  background: var(--red);
}

@media (max-width: 1000px) {
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .order-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .outsource-order-card,
  .outsource-product-row,
  .inventory-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .outsource-order-main,
  .inventory-main,
  .outsource-product-row .product-identity,
  .outsource-product-row > span:nth-child(2),
  .outsource-order-card .open-flow,
  .outsource-product-row .open-flow,
  .inventory-row .open-flow,
  .inventory-row-actions {
    grid-column: auto / span 3;
  }

  .ledger-board,
  .inventory-summary,
  .inventory-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    padding: 15px 16px;
    gap: 14px;
  }

  .brand p {
    display: none;
  }

  .sidebar-foot {
    margin-top: 0;
  }

  .account-card {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 10px;
  }

  .account-card small {
    margin-top: 4px;
  }

  .account-actions {
    margin-top: 0;
  }

  .account-actions button {
    min-width: 74px;
  }

  .nav {
    grid-template-columns: repeat(7, minmax(72px, 1fr));
    gap: 5px;
    overflow-x: auto;
  }

  .nav button {
    display: grid;
    justify-items: center;
    gap: 5px;
    padding: 9px 6px;
    text-align: center;
    font-size: 12px;
  }

  .main {
    padding: 24px 15px 56px;
  }

  .page-head {
    display: grid;
  }

  .stats,
  .baseline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .baseline div:last-child {
    grid-column: 1 / -1;
  }

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

  .form-grid,
  .route-options,
  .route-choice-grid,
  .route-custom-row,
  .search-bar {
    grid-template-columns: 1fr;
  }

  .product-card,
  .panel {
    padding: 16px;
  }

  .production-report {
    border-radius: 14px;
  }

  .production-table {
    font-size: 12px;
  }

  .production-table td {
    height: 116px;
  }

  .product-list-head {
    display: none;
  }

  .product-options.compact {
    display: grid;
    gap: 10px;
    border: 0;
    overflow: visible;
  }

  .product-options.compact .product-option {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .product-identity,
  .product-completion,
  .open-flow {
    grid-column: 1 / -1;
  }

  .product-number::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 500;
  }

  .product-options.compact .badge {
    justify-self: start;
  }

  .open-flow {
    min-height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: #fff;
    background: var(--primary);
    text-align: center;
  }

  .sheet-toolbar {
    align-items: flex-start;
  }

  .sheet-grid-wrap {
    max-height: calc(100vh - 330px);
  }

  .outsource-process-head {
    display: grid;
  }

  .outsource-process-head .actions {
    width: 100%;
  }

  .outsource-process-head .btn {
    flex: 1;
  }

  .recycle-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .recycle-card .actions {
    width: 100%;
  }

  .recycle-card .btn {
    flex: 1;
  }
}

@media (max-width: 430px) {
  .product-options {
    grid-template-columns: 1fr;
  }

  .product-selector {
    padding: 14px;
  }

  .order-summary {
    grid-template-columns: 1fr 1fr;
  }

  .order-summary article {
    padding: 14px;
  }

  .sheet-toolbar {
    display: grid;
  }

  .sheet-toolbar .actions {
    width: 100%;
  }

  .sheet-toolbar .btn {
    flex: 1;
  }

  .outsource-order-card,
  .outsource-product-row,
  .inventory-row {
    grid-template-columns: 1fr 1fr;
  }

  .outsource-order-main,
  .inventory-main,
  .outsource-product-row .product-identity,
  .outsource-product-row > span:nth-child(2),
  .outsource-order-card .open-flow,
  .outsource-product-row .open-flow,
  .inventory-row .open-flow,
  .inventory-row-actions {
    grid-column: 1 / -1;
  }

  .outsource-totals,
  .outsource-batch-totals,
  .outsource-ledger-columns,
  .ledger-board,
  .inventory-summary,
  .inventory-totals {
    grid-template-columns: 1fr;
  }

  .outsource-batch-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .outsource-ledger-columns li {
    grid-template-columns: 1fr;
  }

  .factory-row {
    grid-template-columns: 1fr 1fr 1fr;
  }

  .factory-row > strong {
    grid-column: 1 / -1;
  }

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

  .stat {
    min-height: 105px;
  }

  .order-top,
  .product-head {
    display: grid;
  }
}

/* Modern ERP visual polish. Keep this layer at the end so it can safely refine
   the older component styles without touching business logic. */
:root {
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --sidebar: #0b1220;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --green: var(--primary);
  --green-2: var(--primary-dark);
  --green-soft: var(--primary-soft);
  --shadow: 0 20px 55px rgba(15, 23, 42, 0.07);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.055);
  --radius: 20px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

html {
  text-rendering: geometricPrecision;
  -webkit-font-smoothing: antialiased;
}

body {
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(circle at 12% -10%, rgba(37, 99, 235, 0.13), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(14, 165, 233, 0.09), transparent 28%),
    linear-gradient(180deg, #f8fbff 0%, #f4f7fb 48%, #eef3f8 100%);
}

body,
button,
input,
select,
textarea {
  letter-spacing: -0.01em;
}

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

.sidebar {
  padding: 22px 16px;
  background:
    radial-gradient(circle at 15% 0%, rgba(59, 130, 246, 0.34), transparent 30%),
    linear-gradient(180deg, #111c34 0%, #0b1220 52%, #060b14 100%);
  box-shadow: 22px 0 60px rgba(15, 23, 42, 0.18);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 68%, #1e40af 100%);
}

.brand h1 {
  font-size: 16px;
  font-weight: 850;
}

.brand p {
  color: #9fb0c6;
  font-size: 12px;
}

.nav {
  gap: 7px;
}

.nav button {
  min-height: 46px;
  border-radius: 14px;
  padding: 12px 13px;
  font-size: 15px;
  font-weight: 760;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.nav button:hover {
  transform: translateX(1px);
}

.nav button.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.88), rgba(29, 78, 216, 0.48));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 14px 32px rgba(37, 99, 235, 0.18);
}

.role-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}

.main {
  max-width: 1580px;
  padding: 32px clamp(24px, 4vw, 56px) 72px;
}

.page-head {
  margin-bottom: 24px;
  align-items: center;
}

.eyebrow {
  margin-bottom: 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
}

.page-head h2 {
  font-size: clamp(30px, 3vw, 42px);
  font-weight: 880;
  letter-spacing: -0.045em;
}

.page-head .subtitle {
  max-width: 760px;
  margin-top: 8px;
  color: #66758c;
  font-size: 16px;
  line-height: 1.65;
}

.actions {
  gap: 9px;
}

.btn {
  min-height: 42px;
  border-radius: 13px;
  padding: 9px 15px;
  font-size: 14px;
  font-weight: 800;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow:
    0 1px 0 rgba(15, 23, 42, 0.03),
    0 8px 18px rgba(15, 23, 42, 0.035);
}

.btn.primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 55%, #1d4ed8 100%);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.23);
}

.btn.danger {
  background: linear-gradient(180deg, #fff 0%, #fff5f5 100%);
}

.btn.small {
  min-height: 32px;
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
}

.stats,
.order-summary,
.inventory-summary,
.ledger-board {
  gap: 16px;
}

.stat,
.panel,
.order-card,
.product-card,
.product-selector,
.production-report,
.outsource-process-panel,
.sheet-workspace,
.inventory-style-card,
.ledger-card {
  border-color: rgba(203, 213, 225, 0.88);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

.stat {
  min-height: 118px;
  padding: 20px;
}

.stat::after {
  inset: auto 18px 0;
  height: 4px;
  opacity: 0.8;
}

.stat .label,
.order-summary span,
.order-summary small,
.inventory-summary span,
.ledger-card span {
  color: #66758c;
  font-size: 12px;
  font-weight: 800;
}

.stat strong {
  margin-top: 10px;
  font-size: clamp(28px, 2.4vw, 36px);
  font-weight: 880;
}

.panel {
  padding: 22px;
}

.panel-head {
  margin-bottom: 14px;
}

.panel h3,
.selector-head h3 {
  font-size: 20px;
  font-weight: 860;
  letter-spacing: -0.03em;
}

.order-card,
.recycle-card,
.outsource-order-card,
.outsource-product-row,
.inventory-row {
  border-radius: 18px;
  background: #fff;
}

.order-card {
  padding: 18px 20px;
}

.order-card h4 {
  font-size: 21px;
  font-weight: 880;
  letter-spacing: -0.035em;
}

.order-meta {
  color: #66758c;
  font-size: 14px;
}

.chip,
.badge {
  min-height: 26px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 820;
}

.chip {
  color: #1d4ed8;
  background: #eaf2ff;
}

.badge {
  color: #475569;
  background: #f1f5f9;
}

.badge.success {
  color: #15803d;
  background: #ecfdf3;
}

.badge.warn {
  color: #a35a0a;
  background: #fff7ed;
}

.badge.danger {
  color: #b91c1c;
  background: #fff1f2;
}

.search-bar {
  gap: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.82);
}

.product-list-head,
.ledger-head {
  color: #64748b;
  background: #f8fafc;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.product-options.compact {
  border-radius: 0 0 16px 16px;
}

.product-options.compact .product-option {
  min-height: 70px;
  padding: 13px 16px;
}

.product-options.compact .product-option:nth-child(even) {
  background: #fcfdff;
}

.product-options.compact .product-option:hover {
  background: #f3f8ff;
}

.product-identity strong,
.inventory-style-main strong {
  font-weight: 880;
  letter-spacing: -0.035em;
}

.product-number,
.inventory-summary strong,
.order-summary strong,
.ledger-card strong {
  font-variant-numeric: tabular-nums;
  font-weight: 880;
  letter-spacing: -0.035em;
}

.production-report {
  border-radius: 24px;
}

.timeline-title {
  padding: 18px 22px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.timeline-title strong {
  font-size: 20px;
  font-weight: 880;
}

.timeline-title span {
  font-size: 13px;
}

.production-table {
  font-size: 13px;
}

.production-table th {
  min-width: 138px;
  padding: 12px 10px;
  color: #334155;
  background: linear-gradient(180deg, #f8fafc 0%, #eef4fb 100%);
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #dbe4ee;
  font-size: 12px;
  font-weight: 880;
  letter-spacing: 0.01em;
}

.production-table th.sticky-col,
.production-table .date-row th.sticky-col {
  color: #0f172a;
  background: #eef4fb;
}

.production-table td {
  height: 112px;
  background: #fff;
}

.production-table tbody tr:nth-child(even) td:not(.sticky-col) {
  background: #fcfdff;
}

.production-table td.sticky-col,
.timeline-table .process-row-label {
  background: #fbfaf7;
}

.timeline-table .date-row th {
  color: #334155;
  background: #eef4fb;
}

.process-summary-table tbody th,
.process-summary-table tbody td {
  padding: 13px 14px;
}

.process-summary-table tbody tr:hover th,
.process-summary-table tbody tr:hover td,
.timeline-table tbody tr:hover td:not(.sticky-col) {
  background: #f5f9ff;
}

.timeline-table td.has-quantity {
  color: #1d4ed8;
  background: #edf5ff;
  font-size: 18px;
  font-weight: 880;
}

.timeline-table td.quantity-excess,
.process-cell.cell-abnormal {
  color: #b91c1c;
  background: #fff1f2;
}

.link-button strong {
  color: #1d4ed8;
}

.cell-actions button,
.product-label button {
  border-radius: 10px;
  color: #1d4ed8;
  background: #eaf2ff;
  font-weight: 800;
}

.baseline {
  gap: 12px;
}

.baseline div,
.auto-time,
.time-toggle {
  border-color: rgba(203, 213, 225, 0.9);
  background: #f8fbff;
}

.baseline strong {
  font-weight: 880;
}

.process-card {
  min-height: 166px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
}

.process-index,
.route-choice-order {
  background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
  color: #1d4ed8;
}

.process-name {
  font-size: 16px;
}

.process-total {
  font-size: 26px;
  letter-spacing: -0.04em;
}

.progress-track,
.mini-progress,
.option-progress,
.product-completion i {
  background: #e8eef6;
}

.progress-track i,
.mini-progress i,
.option-progress i,
.product-completion b {
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 70%, #1d4ed8 100%);
}

.modal {
  border-radius: 24px;
  box-shadow: 0 35px 120px rgba(15, 23, 42, 0.32);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.54);
  backdrop-filter: blur(6px);
}

.modal-head {
  padding: 18px 22px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.modal-head h3 {
  font-size: 22px;
  font-weight: 880;
  letter-spacing: -0.035em;
}

.icon-btn {
  width: 38px;
  height: 38px;
  color: #0f172a;
  background: #f1f5f9;
}

.modal-body {
  padding: 22px;
}

.modal-foot {
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
}

.field {
  gap: 8px;
}

.field label,
.field > span,
.route-editor-row small {
  color: #26364d;
  font-size: 13px;
  font-weight: 820;
}

.field input,
.field select,
.field textarea,
.route-editor-row input,
.route-editor-row select {
  min-height: 44px;
  border-color: #cbd5e1;
  border-radius: 13px;
  background: #fff;
  font-size: 14px;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #94a3b8;
}

.route-picker-head {
  align-items: center;
}

.route-choice {
  min-height: 58px;
  border-radius: 16px;
  background: #fff;
}

.route-choice:hover,
.route-choice:focus-visible {
  background: #f3f8ff;
}

.route-flow {
  min-height: 62px;
  border-color: #adc3df;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8fd 100%);
}

.route-flow-item {
  border-color: #bfdbfe;
  background: #eaf2ff;
}

.history-row {
  border-radius: 16px;
}

.toast {
  border-radius: 16px;
  font-weight: 800;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.2);
}

@media (max-width: 1000px) {
  .main {
    padding-inline: 22px;
  }
}

@media (max-width: 760px) {
  body {
    font-size: 14px;
  }

  .sidebar {
    border-radius: 0 0 22px 22px;
  }

  .nav {
    grid-template-columns: repeat(7, minmax(76px, 1fr));
  }

  .nav button {
    min-height: 62px;
    border-radius: 14px;
  }

  .main {
    padding: 22px 14px 58px;
  }

  .page-head h2 {
    font-size: 30px;
  }

  .page-head .subtitle {
    font-size: 14px;
  }

  .stat {
    min-height: 108px;
    padding: 17px;
  }

  .panel,
  .product-card,
  .product-selector {
    padding: 16px;
    border-radius: 18px;
  }

  .production-table th {
    min-width: 124px;
  }

  .production-table td {
    height: 104px;
  }

  .modal {
    width: min(100vw - 14px, 760px);
    max-height: calc(100vh - 18px);
    border-radius: 20px;
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-inline: 16px;
  }
}

@media (max-width: 430px) {
  .page-head h2 {
    font-size: 28px;
  }

  .stats,
  .order-summary,
  .inventory-summary,
  .ledger-board {
    gap: 10px;
  }

  .btn {
    min-height: 40px;
  }
}

/* Mobile app layout: keep the desktop ERP intact while making narrow screens
   behave like a focused phone interface. */
.nav .mobile-more-trigger,
.mobile-more-layer {
  display: none;
}

@media (max-width: 760px) {
  body.mobile-menu-open {
    overflow: hidden;
  }

  .app-shell {
    min-height: 100dvh;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    width: 100%;
    height: 68px;
    padding: 12px 16px;
    border: 0;
    border-bottom: 1px solid rgba(203, 213, 225, 0.82);
    border-radius: 0;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  }

  .brand {
    gap: 10px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
  }

  .brand h1 {
    color: var(--ink);
    font-size: 16px;
  }

  .sidebar-foot {
    display: none;
  }

  .nav {
    position: fixed;
    z-index: 35;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(66px + env(safe-area-inset-bottom));
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    overflow: visible;
    border-top: 1px solid rgba(203, 213, 225, 0.9);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 -10px 28px rgba(15, 23, 42, 0.09);
    backdrop-filter: blur(18px);
  }

  .nav > button {
    display: none;
  }

  .nav > .mobile-primary,
  .nav > .mobile-more-trigger {
    min-width: 0;
    min-height: 52px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 3px;
    padding: 4px 6px;
    border-radius: 12px;
    color: #64748b;
    background: transparent;
    font-size: 11px;
    line-height: 1.15;
    white-space: nowrap;
    box-shadow: none;
  }

  .nav > button:hover {
    transform: none;
  }

  .nav > button.active {
    color: var(--primary);
    background: var(--primary-soft);
    box-shadow: none;
  }

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

  .nav > .mobile-primary span {
    font-size: 0;
  }

  .nav > .mobile-primary span::after {
    content: attr(data-mobile-label);
    font-size: 11px;
  }

  .mobile-more-layer:not([hidden]) {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: block;
  }

  .mobile-more-backdrop {
    position: absolute;
    inset: 0;
    width: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.48);
    backdrop-filter: blur(3px);
  }

  .mobile-more-sheet {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 0 0;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 -24px 64px rgba(15, 23, 42, 0.2);
  }

  .mobile-more-head,
  .mobile-more-head > div {
    display: flex;
    align-items: center;
  }

  .mobile-more-head {
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
  }

  .mobile-more-head > div {
    gap: 8px;
  }

  .mobile-more-head small,
  .mobile-account-card span,
  .mobile-account-card small {
    color: var(--muted);
  }

  .mobile-more-links {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }

  .mobile-more-links button {
    min-height: 82px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 8px;
    padding: 12px 8px;
    border: 1px solid var(--line);
    border-radius: 16px;
    color: #334155;
    background: #f8fafc;
    font-weight: 800;
  }

  .mobile-more-links button.active {
    border-color: #bfdbfe;
    color: var(--primary);
    background: var(--primary-soft);
  }

  .mobile-account-card {
    margin-top: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fafc;
  }

  .mobile-account-card > span,
  .mobile-account-card > small {
    display: block;
  }

  .mobile-account-card > small {
    margin-top: 4px;
  }

  .mobile-account-actions {
    margin-top: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .mobile-account-actions button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    color: #334155;
    background: #fff;
    font-weight: 800;
  }

  .main {
    padding: 18px 14px calc(88px + env(safe-area-inset-bottom));
  }

  .page-head {
    gap: 12px;
    margin-bottom: 16px;
  }

  .page-head h2 {
    font-size: 26px;
  }

  .page-head .subtitle {
    margin-top: 5px;
    font-size: 13px;
    line-height: 1.55;
  }

  .page-head .actions,
  .page-head .actions .btn {
    width: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat {
    min-height: 96px;
    padding: 14px;
  }

  .stat strong {
    margin-top: 4px;
    font-size: 28px;
    line-height: 1.15;
  }

  .stat small {
    margin-top: 4px;
    font-size: 11px;
    line-height: 1.35;
  }

  .panel,
  .product-card,
  .product-selector {
    padding: 13px;
    border-radius: 16px;
  }

  .search-bar {
    grid-template-columns: minmax(0, 1fr) 108px;
    gap: 10px;
    padding: 12px;
  }

  .search-bar .field:first-child {
    grid-column: 1 / -1;
  }

  .search-button {
    width: 108px;
  }

  .order-card {
    padding: 14px;
  }

  .modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }

  .modal-head {
    z-index: 6;
    min-height: 64px;
    padding: 12px 16px;
    border-bottom-color: rgba(203, 213, 225, 0.9);
    background: #fff;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  }

  .modal-head h3 {
    font-size: 21px;
  }

  .modal-body {
    padding: 16px 14px 92px;
  }

  .modal-foot {
    z-index: 6;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    box-shadow: 0 -6px 18px rgba(15, 23, 42, 0.08);
  }

  .modal-foot .btn {
    flex: 1;
  }

  .product-form {
    padding: 13px;
  }

  .route-picker-head {
    display: grid;
    gap: 4px;
    align-items: start;
  }

  .route-picker-head small {
    font-size: 12px;
    line-height: 1.4;
  }

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

  .route-choice {
    min-height: 48px;
    grid-template-columns: 26px minmax(0, 1fr);
    gap: 7px;
    padding: 8px 9px;
    border-radius: 13px;
  }

  .route-choice-order {
    width: 26px;
    height: 26px;
    border-radius: 8px;
  }

  .route-choice strong {
    font-size: 13px;
    line-height: 1.25;
  }

  .route-flow {
    min-height: 52px;
    gap: 7px;
    padding: 10px;
  }
}

/* Mobile workshop console — compact, readable and layered like stacked steel sheets. */
.order-detail-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.stat,
.panel,
.order-card,
.product-card,
.product-selector,
.ledger-card,
.inventory-style-card {
  border-top-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
}

.order-card,
.inventory-style-card,
.inventory-row,
.clickable-row {
  transform-origin: center top;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    background 140ms ease;
}

.order-card:active,
.inventory-style-card:active,
.inventory-row:active,
.clickable-row:active {
  transform: perspective(760px) rotateX(0.8deg) translateY(1px) scale(0.995);
  box-shadow: 0 5px 12px rgba(21, 48, 78, 0.08);
}

@media (hover: hover) {
  .order-card:hover,
  .inventory-style-card:hover {
    border-color: #b8cee4;
    transform: translateY(-2px);
    box-shadow: 0 20px 42px rgba(21, 48, 78, 0.12);
  }
}

@media (max-width: 760px) {
  body {
    background:
      linear-gradient(145deg, rgba(255, 255, 255, 0.72) 0 20%, transparent 20% 100%),
      linear-gradient(180deg, #edf4fb 0%, #f6f8fb 42%, #edf2f7 100%);
  }

  .sidebar {
    height: 64px;
    padding: 10px 15px;
    border-bottom-color: rgba(181, 198, 216, 0.78);
    background: rgba(250, 252, 255, 0.94);
    box-shadow: 0 8px 22px rgba(21, 48, 78, 0.09);
  }

  .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(145deg, #3180df 0%, #1557ad 70%, #0d3e7c 100%);
    box-shadow:
      0 8px 17px rgba(21, 87, 173, 0.26),
      inset 0 1px 0 rgba(255, 255, 255, 0.38);
  }

  .brand h1 {
    font-size: 16px;
    letter-spacing: -0.01em;
  }

  .main {
    min-width: 0;
    max-width: 100%;
    padding: 17px 13px calc(86px + env(safe-area-inset-bottom));
    overflow-x: clip;
  }

  .page-head,
  .page-head > div,
  .order-summary,
  .product-selector,
  .product-options,
  .product-option,
  .panel {
    min-width: 0;
    max-width: 100%;
  }

  .eyebrow {
    margin-bottom: 5px;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: none;
  }

  .page-head h2 {
    font-size: clamp(25px, 7.2vw, 29px);
    line-height: 1.08;
    letter-spacing: -0.045em;
  }

  .page-head .subtitle {
    color: #627285;
    font-size: 13px;
    line-height: 1.5;
  }

  .page-head .actions:has(.order-detail-actions) {
    display: block;
  }

  .order-detail-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .page-head .actions .order-detail-actions .btn {
    width: auto;
    min-width: 0;
    min-height: 44px;
    padding-inline: 10px;
  }

  .order-detail-actions .order-main-action {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .order-detail-actions .order-download-action,
  .order-detail-actions .order-status-action {
    grid-row: 2;
  }

  .page-head .actions .order-detail-actions .order-delete-action {
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: end;
    width: auto;
    min-height: 36px;
    padding: 5px 8px;
    border-color: transparent;
    background: transparent;
    box-shadow: none;
    font-size: 13px;
  }

  .order-summary {
    gap: 9px;
    margin-bottom: 14px;
  }

  .order-summary article {
    min-height: 102px;
    padding: 13px;
    border-radius: 15px;
  }

  .order-summary strong {
    margin: 7px 0 4px;
    font-size: clamp(21px, 6.2vw, 27px);
    line-height: 1.1;
    letter-spacing: -0.035em;
  }

  .order-summary small {
    line-height: 1.3;
  }

  .product-selector {
    padding: 12px;
    border-radius: 17px;
  }

  .selector-head {
    align-items: center;
    margin-bottom: 12px;
  }

  .selector-head h3 {
    font-size: 20px;
  }

  .product-options.compact .product-option.sku-folder-row {
    width: 100%;
    min-width: 0;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 11px 8px;
    padding: 14px;
    border-color: #d8e3ef;
    border-radius: 14px;
    background: linear-gradient(155deg, #ffffff 0%, #f7faff 100%);
    box-shadow:
      0 10px 25px rgba(21, 48, 78, 0.07),
      inset 0 1px 0 #fff;
  }

  .product-options.compact .product-option.sku-folder-row .product-identity {
    min-width: 0;
    grid-column: 1 / -1;
    padding-bottom: 10px;
    border-bottom: 1px solid #e4ebf3;
  }

  .product-options.compact .product-option.sku-folder-row .product-identity strong,
  .product-options.compact .product-option.sku-folder-row .product-identity small {
    overflow-wrap: anywhere;
  }

  .product-options.compact .product-option.sku-folder-row .product-identity strong {
    font-size: 21px;
    letter-spacing: -0.025em;
  }

  .product-options.compact .product-option.sku-folder-row .product-number {
    min-width: 0;
    font-size: 16px;
  }

  .product-options.compact .product-option.sku-folder-row .badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .inventory-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 13px;
  }

  .inventory-summary article {
    min-height: 78px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 11px 12px;
    border-radius: 14px;
    background: rgba(248, 251, 254, 0.92);
    box-shadow:
      0 6px 15px rgba(21, 48, 78, 0.05),
      inset 0 1px 0 #fff;
  }

  .inventory-summary span {
    color: #627285;
    font-size: 11px;
    line-height: 1.25;
  }

  .inventory-summary strong {
    margin-top: 5px;
    font-size: clamp(21px, 6.2vw, 27px);
    line-height: 1.05;
    letter-spacing: -0.035em;
    font-variant-numeric: tabular-nums;
  }

  .view-backlog .inventory-summary article:last-child {
    min-height: 58px;
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
  }

  .view-backlog .inventory-summary article:last-child strong {
    margin-top: 0;
  }

  .ledger-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 12px;
  }

  .ledger-card {
    min-height: 120px;
    padding: 13px;
    border-radius: 15px;
  }

  .ledger-card strong {
    margin: 5px 0 4px;
    font-size: 26px;
    line-height: 1.05;
  }

  .ledger-card small {
    color: #607085;
    font-size: 11px;
    line-height: 1.35;
  }

  .section-title {
    margin: 15px 0 10px;
    font-size: 18px;
  }

  .inventory-style-grid,
  .inventory-list {
    gap: 9px;
  }

  .inventory-style-card,
  .inventory-row,
  .order-card {
    border-radius: 15px;
    background: linear-gradient(155deg, #fff 0%, #f8fbfe 100%);
    box-shadow:
      0 9px 23px rgba(21, 48, 78, 0.07),
      inset 0 1px 0 #fff;
  }

  .view-backlog .panel,
  .view-outsourcing .panel,
  .view-inventory .panel {
    padding: 10px;
  }

  .nav {
    border-top-color: rgba(181, 198, 216, 0.88);
    background: rgba(252, 253, 255, 0.97);
    box-shadow: 0 -9px 25px rgba(21, 48, 78, 0.1);
  }

  .nav > button.active {
    color: #1557ad;
    background: #e8f1fd;
    box-shadow: inset 0 0 0 1px rgba(27, 99, 199, 0.06);
  }

  .btn {
    min-height: 44px;
    border-radius: 12px;
  }

  .btn.primary {
    background: linear-gradient(145deg, #2a75d2 0%, #1557ad 72%, #104486 100%);
    box-shadow:
      0 10px 20px rgba(21, 87, 173, 0.2),
      inset 0 1px 0 rgba(255, 255, 255, 0.28);
  }

  .back-link {
    min-height: 38px;
    padding: 6px 4px;
    font-weight: 800;
  }
}

@media (max-width: 430px) {
  .view-backlog .inventory-summary,
  .view-outsourcing .inventory-summary,
  .view-inventory .inventory-summary,
  .view-inventory .ledger-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .toast {
    z-index: 45;
    right: 13px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 13px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Phone viewport guardrails: every app layer must fit inside the visible screen. */
html,
body,
#app {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

@media (max-width: 760px) {
  .app-shell,
  .sidebar,
  .main,
  .page-head,
  .page-head > div,
  .panel,
  .inventory-summary,
  .inventory-list,
  .inventory-row {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .sidebar {
    right: 0;
    left: 0;
    height: 58px;
    padding: 9px max(12px, env(safe-area-inset-right)) 9px
      max(12px, env(safe-area-inset-left));
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand h1 {
    min-width: 0;
    font-size: 15px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .main {
    padding: 14px max(12px, env(safe-area-inset-right))
      calc(84px + env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .page-head {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-head h2 {
    font-size: clamp(23px, 6.4vw, 27px);
  }

  .page-head .subtitle {
    max-width: 100%;
    font-size: 13px;
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .view-backlog .panel,
  .view-outsourcing .panel,
  .view-inventory .panel {
    padding: 9px;
  }

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

  .inventory-summary article {
    min-width: 0;
    overflow: hidden;
  }

  .inventory-summary strong {
    max-width: 100%;
    font-size: clamp(19px, 5.7vw, 25px);
    overflow-wrap: anywhere;
  }

  .view-backlog .inventory-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 10px;
    padding: 14px;
  }

  .view-backlog .inventory-row > span {
    min-width: 0;
    max-width: 100%;
  }

  .view-backlog .inventory-row .inventory-main,
  .view-backlog .inventory-row > span:nth-last-child(2),
  .view-backlog .inventory-row .open-flow {
    grid-column: 1 / -1;
  }

  .view-backlog .inventory-row strong {
    display: block;
    max-width: 100%;
    font-size: clamp(17px, 5vw, 21px);
    line-height: 1.15;
    overflow-wrap: anywhere;
  }

  .view-backlog .inventory-row .inventory-main strong {
    font-size: 19px;
  }

  .view-backlog .inventory-row .inventory-main small {
    line-height: 1.45;
    overflow-wrap: anywhere;
  }

  .view-backlog .inventory-row .open-flow {
    min-height: 42px;
  }

  .nav {
    right: 0;
    left: 0;
    max-width: 100vw;
  }
}

/* Standalone rework register */
.view-rework .page-head .eyebrow {
  color: #b45309;
}

.rework-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.rework-overview article {
  position: relative;
  min-width: 0;
  padding: 18px 20px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-top: 3px solid #f59e0b;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 28px rgba(120, 53, 15, 0.07);
}

.rework-overview .rework-stat-returned,
.rework-overview .rework-stat-complete {
  border-top-color: #22c55e;
}

.rework-overview span,
.rework-overview small {
  display: block;
  color: #7c6f64;
  font-size: 12px;
  font-weight: 780;
}

.rework-overview strong {
  display: block;
  margin: 7px 0 3px;
  color: #9a3412;
  font-size: clamp(26px, 3vw, 36px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.rework-overview .rework-stat-returned strong,
.rework-overview .rework-stat-complete strong {
  color: #15803d;
}

.rework-panel {
  padding: 18px;
}

.rework-panel-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.rework-panel-head .eyebrow {
  margin-bottom: 4px;
  color: #b45309;
}

.rework-count {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.rework-list {
  display: grid;
  gap: 10px;
}

.rework-row {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid #e5e7eb;
  border-left: 4px solid #f59e0b;
  border-radius: 16px;
  background: #fff;
}

.rework-row.rework-complete {
  border-left-color: #22c55e;
}

.rework-row.rework-overdue,
.rework-row.rework-error {
  border-left-color: #dc2626;
}

.rework-row > div {
  min-width: 0;
}

.rework-row span,
.rework-row small {
  display: block;
  color: #7b8797;
  font-size: 11px;
  font-weight: 720;
  line-height: 1.45;
}

.rework-row strong {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
}

.rework-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.rework-product strong {
  margin: 3px 0;
  font-size: 18px;
}

.rework-kicker {
  color: #b45309 !important;
}

.rework-state-block {
  display: grid;
  justify-items: end;
  gap: 5px;
  min-width: 110px;
}

.rework-status {
  display: inline-flex !important;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #9a3412 !important;
  background: #fff7ed;
  font-size: 12px !important;
  font-weight: 850 !important;
}

.rework-status-complete {
  color: #166534 !important;
  background: #dcfce7;
}

.rework-status-overdue,
.rework-status-error {
  color: #b91c1c !important;
  background: #fee2e2;
}

.rework-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #f8fafc;
}

.rework-flow-step {
  min-width: 0;
  padding: 14px 16px;
  border-right: 1px solid #e5e7eb;
}

.rework-flow-step:last-child {
  border-right: 0;
}

.rework-flow-step strong {
  margin: 5px 0 3px;
  color: #9a3412;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.rework-flow-returned strong {
  color: #15803d;
}

.rework-complete .rework-flow-remaining strong {
  color: #15803d;
}

.rework-overdue .rework-flow-remaining strong,
.rework-error .rework-flow-remaining strong {
  color: #dc2626;
}

.rework-meta {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.2fr);
  gap: 12px;
}

.rework-meta > div {
  min-width: 0;
  padding: 0 3px;
}

.rework-meta strong {
  margin: 3px 0;
}

.rework-return-history {
  border-top: 1px solid #eef0f3;
  padding-top: 11px;
}

.rework-return-history summary {
  width: fit-content;
  color: #38516c;
  cursor: pointer;
  font-size: 12px;
  font-weight: 820;
}

.rework-return-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.rework-return-list > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(130px, 0.75fr) minmax(180px, 1.45fr);
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f0fdf4;
}

.rework-return-list strong {
  color: #166534;
}

.rework-no-return {
  padding-top: 10px;
  border-top: 1px solid #eef0f3;
  color: #8a96a5;
  font-size: 12px;
  font-weight: 720;
}

.rework-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
  padding-top: 2px;
}

.rework-complete-note {
  display: inline-flex !important;
  align-items: center;
  margin-right: auto;
  color: #15803d !important;
  font-size: 12px !important;
  font-weight: 820 !important;
}

.rework-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 48px 20px;
  text-align: center;
}

.rework-empty span {
  max-width: 420px;
  margin-bottom: 8px;
  color: var(--muted);
}

.rework-empty-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 4px;
  border-radius: 15px;
  color: #b45309;
  background: #fff1da;
  font-size: 22px;
  font-weight: 900;
}

.rework-form-note {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #fed7aa;
  border-radius: 12px;
  color: #7c2d12;
  background: #fff7ed;
  font-size: 13px;
  line-height: 1.5;
}

.rework-return-balance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.rework-return-balance > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #f8fafc;
}

.rework-return-balance span,
.rework-return-balance strong {
  display: block;
}

.rework-return-balance span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.rework-return-balance strong {
  margin-top: 4px;
  color: #9a3412;
  font-size: 22px;
}

@media (max-width: 760px) {
  .view-rework .main,
  .view-rework .page-head,
  .view-rework .rework-overview,
  .view-rework .rework-panel,
  .view-rework .rework-row {
    min-width: 0;
    max-width: 100%;
  }

  .rework-new-button {
    width: 100%;
  }

  .rework-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 12px;
  }

  .rework-overview article {
    padding: 14px;
    border-radius: 15px;
  }

  .rework-overview strong {
    font-size: clamp(23px, 7vw, 30px);
  }

  .rework-panel {
    padding: 10px;
  }

  .rework-panel-head {
    padding: 4px 4px 0;
  }

  .rework-row {
    gap: 13px;
    padding: 15px;
  }

  .rework-row-head {
    gap: 10px;
  }

  .rework-state-block {
    min-width: 96px;
  }

  .rework-flow-step {
    padding: 12px 9px;
  }

  .rework-flow-step strong {
    font-size: clamp(20px, 6vw, 25px);
  }

  .rework-flow-step small {
    min-height: 32px;
  }

  .rework-meta,
  .rework-return-list > div {
    grid-template-columns: minmax(0, 1fr);
    gap: 7px;
  }

  .rework-return-list > div {
    padding: 11px;
  }

  .rework-actions {
    justify-content: stretch;
  }

  .rework-actions .btn {
    flex: 1;
  }

  .rework-actions .btn.primary {
    flex-basis: 100%;
  }

  .rework-complete-note {
    flex-basis: 100%;
  }

  .rework-return-balance > div {
    padding: 10px 8px;
  }

  .rework-return-balance strong {
    font-size: 19px;
  }
}
