:root {
  --ink: #102033;
  --muted: #5f7184;
  --line: #d8e2ec;
  --paper: #ffffff;
  --background: #eef3f8;
  --accent: #087c74;
  --accent-dark: #055f59;
  --accent-soft: #e8f7f5;
  --nav: #172b3d;
  --danger: #c4312c;
  --danger-soft: #fff1f0;
  --shadow: 0 16px 40px rgba(20, 40, 60, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(8, 124, 116, .08), transparent 30%),
    var(--background);
}
a { color: var(--accent); text-decoration: none; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 236px;
  display: flex;
  flex-direction: column;
  padding: 16px 22px;
  background: var(--nav);
  color: white;
  overflow: hidden;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white;
  font-weight: 800;
  margin-bottom: 18px;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: var(--accent);
}
.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}
.nav-main {
  display: grid;
  gap: 3px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 12px;
}
.nav-account {
  display: grid;
  gap: 3px;
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-backup-status {
  flex-shrink: 0;
  margin: 8px 12px 7px;
  color: #65d99b;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.3;
}
.sidebar-backup-status.stale {
  color: #ff8a80;
}
.sidebar-nav a {
  color: #d8e2ea;
  padding: 7px 12px;
  border-radius: 8px;
}
.sidebar-nav a:hover { background: rgba(255,255,255,.08); color: white; }
.logout-form {
  margin: 0;
}
.logout-form button {
  width: 100%;
  min-height: 32px;
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d8e2ea;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.logout-form button:hover {
  background: rgba(255,255,255,.08);
  color: white;
}
.nav-section {
  margin: 8px 12px 2px;
  color: #8ea1b2;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.business-switcher {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}
.business-switcher label {
  color: #aebdca;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.business-switcher select {
  min-height: 38px;
  border-color: rgba(255,255,255,.18);
  background: #2a3c4c;
  color: white;
}
.shell {
  margin-left: 236px;
  padding: 28px 32px 38px;
}
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 22px;
}
.page-header h1 { margin: 0; font-size: 32px; line-height: 1.1; }
.eyebrow {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease, transform .15s ease;
}
.button:hover {
  border-color: #b8c8d8;
  background: #f8fbfd;
}
.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell {
  width: min(100%, 440px);
}
.login-panel {
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.login-logo {
  width: 58px;
  height: 58px;
  object-fit: contain;
}
.login-brand h1 {
  margin: 0;
  font-size: 28px;
}
.alert {
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}
.alert.danger {
  border: 1px solid #ffd0cc;
  background: var(--danger-soft);
  color: var(--danger);
}
.alert.success {
  border: 1px solid #bfe6d7;
  background: #effaf5;
  color: #0f6b47;
}
.narrow-panel {
  max-width: 620px;
}
.button.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}
.button.danger {
  border-color: #f3b4ad;
  color: var(--danger);
}
.button.small { min-height: 34px; }
.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -8px 0 20px;
}
.subnav a {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,.76);
  color: var(--muted);
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(20,40,60,.04);
}
.subnav a.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}
.panel, .empty {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metrics div {
  padding: 20px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(20,40,60,.05);
}
.metrics span { display: block; font-size: 30px; font-weight: 800; }
.metrics p { margin: 4px 0 0; color: var(--muted); }
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 24px;
}
.detail-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}
.detail-list div {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.detail-list dd {
  margin: 4px 0 0;
  font-weight: 700;
  text-align: left;
  overflow-wrap: anywhere;
}
.detail-note {
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.5;
}
.stock-actions {
  display: grid;
  gap: 14px;
}
.stock-actions form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfd;
}
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.module-card {
  display: grid;
  gap: 8px;
  min-height: 150px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fbfcfd;
}
.module-card:hover { border-color: var(--accent); }
.module-card h3 {
  margin: 0;
  font-size: 18px;
}
.module-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}
.module-card .status {
  width: fit-content;
}
.module-placeholder {
  max-width: 760px;
}
.module-placeholder h2 {
  margin-top: 0;
}
.module-placeholder p {
  color: var(--muted);
  line-height: 1.55;
}
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.metric-card {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  box-shadow: var(--shadow);
}
.metric-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}
.metric-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}
.finished-goods-metrics {
  grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0; font-size: 20px; }
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.action-table-wrap {
  overflow: visible;
}
.inventory-table-wrap {
  overflow-x: visible;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: white;
}
th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  background: #f7fafc;
  color: #4d6276;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}
tbody tr {
  transition: background .15s ease;
}
tbody tr:hover {
  background: #f8fbfd;
}
tbody tr:last-child td {
  border-bottom: 0;
}
.number { text-align: right; }
.compact-number {
  width: 82px;
  min-height: 36px;
  margin-left: auto;
  padding: 7px 8px;
}
.actions {
  width: 1%;
  min-width: 260px;
  text-align: right;
  white-space: nowrap;
}
.compact-actions {
  min-width: 96px;
}
.action-group {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: nowrap;
}
.inventory-actions {
  gap: 7px;
}
.actions form { margin: 0; }
.actions .compact-password {
  width: 120px;
  min-height: 30px;
  padding: 4px 8px;
  border-radius: 8px;
}
.actions a,
.actions .link-button {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 6px;
  border-radius: 8px;
  font-weight: 700;
}
.actions a:hover,
.actions .link-button:hover {
  background: var(--accent-soft);
}
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
.link-button.danger { color: var(--danger); }
.muted { color: var(--muted); }
.muted-action { color: var(--muted); }
[data-inventory-combobox] {
  min-width: 0;
}
.table-note {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.35;
}
.bom-disclosure {
  max-width: 620px;
}
.bom-disclosure summary {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfd;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}
.bom-disclosure summary:hover {
  border-color: var(--accent);
}
.bom-disclosure.has-blockers summary {
  border-color: #f3b4ad;
  background: #fffafa;
}
.bom-disclosure summary small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.shortage-pill {
  padding: 3px 7px;
  border-radius: 999px;
  background: #fee4e2;
  color: #b42318 !important;
}
.bom-contents {
  display: grid;
  gap: 14px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfd;
}
.bom-group {
  display: grid;
  gap: 7px;
}
.bom-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}
.bom-chip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}
.bom-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bom-chip strong {
  color: var(--accent-dark);
}
.bom-chip.shortage {
  border-color: #f3b4ad;
  background: #fffafa;
}
.bom-chip.shortage span,
.bom-chip.shortage strong,
.shortage-group h3 {
  color: #b42318;
}
.profile-list {
  margin-bottom: 20px;
}
.danger-zone {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-color: #f3b4ad;
  background: #fffafa;
}
.danger-zone h2 {
  margin: 0 0 8px;
}
.danger-zone p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}
.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 240px auto;
  gap: 12px;
  align-items: center;
}
.planner-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px auto;
  gap: 12px;
  align-items: end;
}
.finished-goods-filter {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) repeat(3, minmax(150px, 190px)) auto;
  gap: 12px;
  align-items: center;
}
.finished-goods-table-wrap .actions {
  min-width: 100px;
}
.finished-good-rma {
  box-shadow: inset 4px 0 0 #c4312c;
}
.table-head-link {
  color: inherit;
  display: inline-flex;
  width: 100%;
}
.number .table-head-link {
  justify-content: flex-end;
}
.table-head-link:hover,
.table-head-link.active {
  color: var(--accent-dark);
}
.activity-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.activity-row {
  display: grid;
  grid-template-columns: 86px 130px minmax(0, 1fr) 130px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.activity-row:last-child {
  border-bottom: 0;
}
.activity-row span:not(.status),
.activity-row small {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}
.planner-result {
  display: grid;
  gap: 18px;
  margin-top: 20px;
}
.planner-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.planner-summary div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbfd;
}
.planner-summary span {
  display: block;
  font-size: 24px;
  font-weight: 800;
}
.planner-summary p {
  margin: 4px 0 0;
  color: var(--muted);
}
.compact-empty {
  margin-bottom: 0;
  box-shadow: none;
}
.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfd;
  color: var(--ink);
}
.inline-check input {
  width: 18px;
  min-height: 18px;
}
.inventory-summary {
  margin-top: 14px;
  color: var(--muted);
}
.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.inline-form input {
  width: 70px;
  min-height: 32px;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f8fbfd;
}
.inventory-table {
  table-layout: fixed;
  font-size: 12px;
  line-height: 1.25;
}
.inventory-table th,
.inventory-table td {
  padding: 8px 6px;
  overflow-wrap: anywhere;
}
.inventory-table th {
  font-size: 10px;
}
.table-sort {
  display: inline-flex;
  align-items: center;
  justify-content: inherit;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  text-align: inherit;
  text-transform: inherit;
  white-space: nowrap;
}
.number .table-sort {
  justify-content: flex-end;
}
.table-sort:hover,
.table-sort[aria-sort="ascending"],
.table-sort[aria-sort="descending"] {
  color: var(--accent-dark);
}
.inventory-table .table-note {
  font-size: 11px;
}
.inventory-table .actions {
  min-width: 0;
  width: auto;
  white-space: normal;
}
.inventory-table .action-group {
  display: flex;
  justify-content: flex-start;
  gap: 4px;
  flex-wrap: wrap;
}
.inventory-table .actions a,
.inventory-table .actions .link-button {
  min-height: 24px;
  padding: 0 4px;
  border-radius: 6px;
  font-size: 11px;
}
.inventory-table .icon-action {
  width: 26px;
  height: 26px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fbfd;
  color: var(--accent);
  font-size: 16px;
  font-weight: 800;
  line-height: 1;
}
.inventory-table .icon-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.inventory-table .icon-action.danger {
  color: var(--danger);
}
.inventory-table .icon-action.danger:hover {
  border-color: #f3b4ad;
  background: var(--danger-soft);
}
.inventory-table .inline-form {
  gap: 3px;
}
.inventory-table .inline-form input {
  width: 42px;
  min-height: 26px;
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 11px;
}
.inventory-unused {
  color: #6b7f95;
}
.inventory-table tr.inventory-unused {
  background: #f7fafc;
}
.inventory-card.inventory-unused {
  background: #f7fafc;
}
.unused-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  border: 1px solid #d3dee8;
  border-radius: 999px;
  background: #eef4f8;
  color: #5b6f85;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}
.action-menu {
  position: relative;
  display: inline-block;
  text-align: left;
}
.action-menu summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  list-style: none;
}
.action-menu summary::-webkit-details-marker {
  display: none;
}
.action-menu summary::after {
  content: "▾";
  margin-left: 6px;
  font-size: 10px;
}
.action-menu[open] summary,
.action-menu summary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.action-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  display: grid;
  gap: 6px;
  min-width: 170px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  box-shadow: var(--shadow);
}
.action-menu.opens-up .action-menu-panel {
  top: auto;
  bottom: calc(100% + 6px);
}
.action-menu-panel a,
.action-menu-panel .link-button,
.action-menu-panel .muted-action {
  width: 100%;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  font-size: 12px;
  text-align: left;
}
.action-menu-panel a,
.action-menu-panel .muted-action {
  display: flex;
  align-items: center;
}
.action-menu-panel .link-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.action-menu-panel form {
  margin: 0;
}
.menu-stock-form {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
}
.action-menu-panel form:not(.menu-stock-form) {
  display: grid;
}
.menu-stock-form input {
  width: 52px;
  min-height: 28px;
  padding: 3px 5px;
  border-radius: 7px;
  font-size: 12px;
}
.inventory-col-dpart { width: 8%; }
.inventory-col-mpart { width: 15%; }
.inventory-col-description { width: 20%; }
.inventory-col-category { width: 11%; }
.inventory-col-unit { width: 4%; }
.inventory-col-stock { width: 5%; }
.inventory-col-min { width: 5%; }
.inventory-col-price { width: 7%; }
.inventory-col-total { width: 8%; }
.inventory-col-location { width: 5%; }
.inventory-col-actions { width: 8%; }
.inventory-card-list {
  display: none;
}
.inventory-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 12px;
}
.inventory-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.inventory-card h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.25;
}
.inventory-card-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 12px;
}
.inventory-card-details div {
  min-width: 0;
}
.inventory-card-details dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}
.inventory-card-details dd {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
  overflow-wrap: anywhere;
}
.stock-low {
  color: #b42318;
  font-weight: 800;
}
.status {
  display: inline-flex;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e7f5f3;
  color: #0b5f59;
  font-size: 12px;
  font-weight: 800;
}
.status.overdue {
  background: #fff1f0;
  color: #c4312c;
}
.danger-status {
  background: #fff1f0;
  color: #c4312c;
}
.warning-status {
  background: #fff7e6;
  color: #9a5b00;
}
.info-status {
  background: #eaf6ff;
  color: #145b8f;
}
.ship-status {
  background: #eef4ff;
  color: #314b9d;
}
.status-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 260px;
}
.status-stack .table-note {
  flex-basis: 100%;
}
.overdue-text {
  color: #c4312c;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.source-document-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
}
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
input, textarea, select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: white;
  font: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
input:hover, textarea:hover, select:hover {
  border-color: #b8c8d8;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 124, 116, .14);
}
textarea { min-height: 92px; resize: vertical; }
.wide { grid-column: 1 / -1; }
.form-actions, .sticky-actions, .header-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.sticky-actions {
  position: sticky;
  bottom: 0;
  padding: 14px 0 4px;
  background: linear-gradient(transparent, var(--background) 28%);
}
.item-row {
  display: grid;
  grid-template-columns: minmax(98px, .7fr) minmax(170px, 1.55fr) minmax(82px, .65fr) minmax(96px, .7fr) minmax(82px, .65fr) minmax(96px, .7fr) minmax(98px, .75fr) 82px;
  gap: 10px;
  margin-bottom: 10px;
  align-items: center;
  min-width: 0;
}
.bom-list {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
}
.bom-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 130px 86px;
  gap: 10px;
  align-items: center;
}
.item-row select[name="item_type"] { grid-column: 1; }
.item-row input[name="item_description"] { grid-column: 2; }
.item-row input[name="item_quantity"] { grid-column: 3; }
.item-row input[name="item_unit_price"] { grid-column: 4; }
.item-row input[name="item_hours"] { grid-column: 5; }
.item-row input[name="item_hourly_rate"] { grid-column: 6; }
.item-row .line-total { grid-column: 7; }
.item-row .remove-button { grid-column: 8; }
.sales-order-items .item-row {
  grid-template-columns: 54px minmax(88px, .58fr) minmax(122px, .82fr) minmax(160px, 1.35fr) minmax(72px, .5fr) minmax(88px, .62fr) minmax(72px, .5fr) minmax(88px, .62fr) minmax(92px, .68fr) 82px;
}
.sales-order-items .item-row .line-item-number { grid-column: 1; }
.sales-order-items .item-row select[name="item_type"] { grid-column: 2; }
.sales-order-items .item-row input[name="item_part_number"] { grid-column: 3; }
.sales-order-items .item-row input[name="item_description"] { grid-column: 4; }
.sales-order-items .item-row input[name="item_quantity"] { grid-column: 5; }
.sales-order-items .item-row input[name="item_unit_price"] { grid-column: 6; }
.sales-order-items .item-row input[name="item_hours"] { grid-column: 7; }
.sales-order-items .item-row input[name="item_hourly_rate"] { grid-column: 8; }
.sales-order-items .item-row .line-total { grid-column: 9; }
.sales-order-items .item-row .remove-button { grid-column: 10; }
.field-hidden {
  visibility: hidden;
  pointer-events: none;
}
.line-total {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fafc;
  font-weight: 800;
}
.line-item-number {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
  color: var(--muted);
  font-weight: 800;
}
.item-heading {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.remove-button {
  width: 82px;
  max-width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  font-weight: 800;
  color: #9f1239;
}
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
}
.toggle input { width: 18px; min-height: 18px; }
.toggle label { display: inline; color: var(--ink); }
.live-summary {
  display: grid;
  gap: 8px;
  max-width: 420px;
  margin-left: auto;
}
.live-summary div {
  display: flex;
  justify-content: space-between;
  gap: 24px;
}
.live-summary span {
  color: var(--muted);
}
.live-summary .grand {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 2px solid var(--nav);
  font-size: 20px;
}
.invoice-preview {
  max-width: 940px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 42px;
  box-shadow: 0 16px 38px rgba(31,42,55,.08);
}
.invoice-top, .invoice-parties {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-bottom: 34px;
}
.invoice-top h2, .invoice-title h2 { margin: 0 0 8px; }
.invoice-title { text-align: right; }
.invoice-preview p { color: var(--muted); line-height: 1.55; }
.invoice-logo {
  display: block;
  max-width: 180px;
  max-height: 90px;
  object-fit: contain;
  margin-bottom: 14px;
}
.logo-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}
.logo-preview img {
  max-width: 150px;
  max-height: 72px;
  object-fit: contain;
}
dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px 22px;
  margin: 0;
}
dt { color: var(--muted); }
dd { margin: 0; font-weight: 800; text-align: right; }
.invoice-items th {
  background: var(--nav);
  color: white;
}
.invoice-items th:nth-child(n+2), .invoice-items td:nth-child(n+2) { text-align: right; }
.document-items-basic th:nth-child(-n+2), .document-items-basic td:nth-child(-n+2),
.document-items-part th:nth-child(-n+3), .document-items-part td:nth-child(-n+3) {
  text-align: left;
}
.document-items-basic th:nth-child(n+3), .document-items-basic td:nth-child(n+3),
.document-items-part th:nth-child(n+4), .document-items-part td:nth-child(n+4) {
  text-align: right;
}
.totals {
  width: min(340px, 100%);
  margin: 18px 0 28px auto;
}
.totals div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
}
.totals .grand {
  border-top: 2px solid var(--nav);
  font-size: 20px;
}
.invoice-notes {
  display: grid;
  gap: 14px;
}
.invoice-notes h3 { margin: 0 0 6px; font-size: 15px; }
.invoice-notes p { margin: 0; white-space: pre-wrap; }
.signature span {
  display: block;
  width: 220px;
  border-top: 1px solid var(--ink);
  margin-top: 26px;
}

.flash-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.flash {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
.flash-success {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border: 1px solid #b3e0db;
}
.flash-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f5c6c5;
}

@media (max-width: 820px) {
  .sidebar {
    position: static;
    width: auto;
  }
  .shell {
    margin-left: 0;
    padding: 18px;
  }
  .page-header, .invoice-top, .invoice-parties {
    align-items: flex-start;
    flex-direction: column;
  }
  .metrics, .metric-grid, .form-grid, .module-grid, .filter-bar, .finished-goods-filter, .planner-form, .planner-summary, .bom-row, .detail-grid, .detail-list, .source-document-form, .activity-row {
    grid-template-columns: 1fr;
  }
  .item-row {
    grid-template-columns: 1fr;
  }
  .item-row select[name="item_type"],
  .item-row input[name="item_part_number"],
  .item-row input[name="item_description"],
  .item-row input[name="item_quantity"],
  .item-row input[name="item_unit_price"],
  .item-row input[name="item_hours"],
  .item-row input[name="item_hourly_rate"],
  .item-row .line-item-number,
  .item-row .line-total,
  .item-row .remove-button {
    grid-column: 1;
  }
  .inventory-table-wrap {
    display: none;
  }
  .inventory-card-list {
    display: grid;
    gap: 10px;
  }
  .inventory-card .action-menu-panel {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    margin-top: 0;
    min-width: 190px;
  }
  .invoice-preview {
    padding: 22px;
  }
  .invoice-title {
    text-align: left;
  }
}
