:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #687586;
  --soft: #8a96a5;
  --line: #d7dde5;
  --line-soft: #edf0f4;
  --surface: #f5f7fa;
  --panel: #ffffff;
  --nav: #fbfcfd;
  --accent: #0f766e;
  --accent-soft: #e6f4f2;
  --warning: #a85510;
  --danger: #b42318;
}

* { box-sizing: border-box; }

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--surface);
}

body.app-booting .app-shell,
body.auth-required .app-shell {
  visibility: hidden;
  pointer-events: none;
  user-select: none;
}

html.has-session-token body.app-booting .app-shell {
  visibility: visible;
}

body.auth-required {
  overflow: hidden;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(180deg, #eef4f7 0%, #e2eaef 100%);
}

body:not(.auth-required) .login-gate,
body.app-booting #adminSettingsDialog {
  display: none;
}

html.has-session-token body.app-booting .login-gate {
  display: none;
}

.login-gate-card {
  width: min(480px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.16);
}

.login-gate input::placeholder {
  color: #9aa6b2;
}

button, input, select, textarea { font: inherit; }
h1, h2, h3, p { margin: 0; }
p, .muted { color: var(--muted); }

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

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

.app-shell.sidebar-collapsed .sidebar {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  padding: 18px 14px;
  background: var(--nav);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 8px 18px;
}

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

.brand strong,
.brand span {
  display: block;
  line-height: 1.15;
}

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

.nav {
  display: grid;
  gap: 4px;
  flex: 1;
  align-content: start;
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  padding: 8px;
  border-top: 1px solid var(--line);
}

.nav-row-secondary {
  color: #0b5d56;
  background: var(--accent-soft);
}

.sidebar-user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
}

.sidebar-user-badge.signed-in {
  border-color: #86c9b8;
  background: #e9f8f3;
  color: #08715f;
  font-weight: 700;
}

.sidebar-user-badge.signed-in::before {
  content: '';
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
  background: #15936f;
  box-shadow: 0 0 0 3px rgba(21, 147, 111, .14);
}

.sidebar-logout-button {
  width: 100%;
  justify-content: center;
}

.nav-row,
.nav-children button {
  width: 100%;
  min-height: 36px;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.nav-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-weight: 700;
}

.nav-row:hover,
.nav-row.active,
.nav-group.active > .nav-group-toggle,
.nav-children button:hover,
.nav-children button.active {
  background: var(--accent-soft);
  color: #0b5d56;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--muted);
}

.nav-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-row:hover .nav-icon,
.nav-row.active .nav-icon,
.nav-group.active > .nav-group-toggle .nav-icon {
  color: #0b5d56;
}
.chevron {
  color: var(--muted);
  font-size: 14px;
  text-align: right;
}

.nav-children {
  display: none;
  gap: 1px;
  margin: 0 0 8px 42px;
  padding: 2px 0 2px 13px;
  border-left: 3px solid #e5e8ed;
}

.nav-group.open .nav-children {
  display: grid;
}

.nav-group.open .chevron {
  transform: rotate(180deg);
}

.nav-children button {
  position: relative;
  min-height: 34px;
  padding: 6px 8px 6px 12px;
  border-radius: 0;
  color: #4d5968;
}

.nav-children button:hover,
.nav-children button.active {
  background: transparent;
}

.nav-children button.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 999px;
  background: var(--accent);
}

.workspace {
  min-width: 0;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 86px;
  padding: 16px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1 { font-size: 25px; line-height: 1.2; }
h2 { font-size: 21px; line-height: 1.25; }
h3 { font-size: 15px; line-height: 1.25; }

main {
  padding: 22px 26px 34px;
  max-width: 1520px;
  width: 100%;
  overflow-x: hidden;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 11px;
  font-weight: 700;
  cursor: pointer;
}

button:hover { border-color: #9aa6b4; }
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}
button.primary, .actions button:last-child {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 11px;
  color: var(--ink);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.button-link:hover { border-color: #9aa6b4; }
.file-input { max-width: 210px; font-size: 13px; }

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

.aligned-actions {
  align-items: flex-end;
}

.aligned-actions button,
.aligned-actions .button-link,
.aligned-actions .file-input {
  margin-bottom: 1px;
}

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

.dashboard-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.dashboard-toolbar h2,
.dashboard-toolbar p {
  margin: 0;
}

.dashboard-toolbar p {
  margin-top: 5px;
}

.dashboard-storage-notice {
  margin-bottom: 18px;
}

.dashboard-groups,
.dashboard-group {
  display: grid;
  gap: 12px;
}

.dashboard-groups {
  gap: 24px;
}

.dashboard-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

.dashboard-card {
  min-width: 0;
  min-height: 82px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid #8aa0ad;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

button.dashboard-card:hover {
  border-color: #9fb8b4;
  box-shadow: 0 5px 16px rgba(25, 61, 57, .08);
  transform: translateY(-1px);
}

.dashboard-card-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf2f4;
  color: #4b6875;
  font-size: 15px;
  font-weight: 800;
}

.dashboard-card-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.dashboard-card-copy strong {
  font-size: 20px;
  line-height: 1;
}

.dashboard-card-copy span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.dashboard-card-arrow {
  color: var(--muted);
  font-size: 24px;
}

.dashboard-card.critical { border-left-color: #d64545; }
.dashboard-card.critical .dashboard-card-icon { background: #ffeded; color: #b42318; }
.dashboard-card.warning { border-left-color: #e58b21; }
.dashboard-card.warning .dashboard-card-icon { background: #fff3df; color: #a65b00; }
.dashboard-card.info { border-left-color: #2878a8; }
.dashboard-card.info .dashboard-card-icon { background: #e9f4fa; color: #17658f; }
.dashboard-card.healthy { border-left-color: #23936f; }
.dashboard-card.healthy .dashboard-card-icon { background: #e9f8f3; color: #08715f; }

.dashboard-all-clear {
  display: grid;
  gap: 4px;
  padding: 24px;
  border: 1px solid #9bd6c8;
  border-radius: 8px;
  background: #f0faf7;
}

.dashboard-all-clear span {
  color: var(--muted);
}

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 14px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.notice strong { font-size: 14px; }
.notice span { color: var(--muted); font-size: 13px; }
.notice.ok { border-color: #9bd6c8; background: #f0faf7; }
.notice.warn { border-color: #f7c98b; background: #fff8ed; }
.hidden-notice {
  display: none;
  margin-bottom: 0;
}

.hidden-notice.show {
  display: flex;
}

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

.metric strong {
  display: block;
  font-size: 24px;
  margin-top: 4px;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
  margin-bottom: 18px;
}

.workflow-strip div {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  column-gap: 10px;
  row-gap: 3px;
  background: #fff;
  padding: 14px;
}

.workflow-strip p {
  grid-column: 2;
  font-size: 13px;
}

.step-number {
  grid-row: span 2;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
}

.view { display: none; }
.view.active { display: block; }

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

.section-head-actions {
  justify-content: flex-end;
}

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 36px;
}

.bom-toolbar {
  align-items: center;
  flex-wrap: nowrap;
  gap: 14px;
}

.list-toolbar {
  align-items: center;
}

.bom-toolbar-actions,
.bom-toolbar-filters {
  flex-wrap: nowrap;
}

.bom-toolbar-actions {
  flex: 1 1 auto;
  min-width: 0;
}

.bom-toolbar-filters {
  flex: 0 0 auto;
  margin-left: auto;
}

.toolbar-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: auto;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.toolbar-input {
  width: min(380px, 26vw);
  min-width: 220px;
}

.list-toolbar .toolbar-input {
  width: min(300px, 22vw);
}

.toolbar-field select {
  min-width: 110px;
}

#newBomBtn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

#newItemBtnSecondary,
#newAssemblyBtnSecondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

.compact-panel-head p {
  margin: 0;
}

.check-col {
  width: 44px;
  text-align: center;
}

.check-col input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}

.grid.two { grid-template-columns: minmax(0, 1.15fr) minmax(360px, .85fr); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.collapsible-panel summary {
  list-style: none;
  cursor: pointer;
}

.collapsible-panel summary::-webkit-details-marker {
  display: none;
}

.summary-head::after {
  content: '+';
  font-size: 20px;
  color: var(--muted);
}

.collapsible-panel[open] .summary-head::after {
  content: '-';
}

.inset-panel {
  border-style: dashed;
  background: #fcfdfd;
}

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

.panel-head p {
  margin-top: 3px;
  font-size: 13px;
}

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  white-space: nowrap;
  vertical-align: top;
}
th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.category-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 14px 0;
}

.category-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.category-select-all input {
  width: auto;
  margin: 0;
}

.category-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.category-groups {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.category-group {
  overflow: hidden;
}

.category-group-summary {
  cursor: pointer;
  list-style: none;
}

.category-group-summary::-webkit-details-marker {
  display: none;
}

.category-group-summary::after {
  content: '+';
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.category-group[open] .category-group-summary::after {
  content: '-';
}

.category-group-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.category-group-meta strong {
  font-size: 15px;
}

.category-group-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.table-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 800;
}

.table-link:hover {
  color: #0b5d56;
  text-decoration: underline;
}

.table-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.detail-row td {
  padding: 0;
  background: #fbfcfd;
}

.table-detail {
  padding: 14px;
}

.stack {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.compact-stack {
  padding: 0 0 14px;
}

.record {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e4e8ee;
  border-radius: 7px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #eef4ff;
  color: #1849a9;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok { background: #ecfdf3; color: #027a48; }
.badge.wait { background: #fff6ed; color: var(--warning); }
.badge.muted-badge { background: #f2f4f7; color: var(--muted); }

.record-title {
  display: grid;
  gap: 2px;
  min-width: 0;
  border: 0;
  padding: 0;
  text-align: left;
  background: transparent;
}

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

.build-details {
  display: grid;
  gap: 12px;
  padding-top: 4px;
}

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

.detail-grid div {
  display: grid;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
}

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

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

.requirement-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.line-editor {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(110px, .55fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
}

.line-list {
  display: grid;
  gap: 8px;
}

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

.export-columns-grid .line-row {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  min-height: 42px;
}

.import-preview {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid #9bd6c8;
  border-radius: 6px;
  background: #f0faf7;
  font-size: 13px;
}

.import-preview.muted {
  border-color: var(--line-soft);
  background: #fff;
}

.import-preview.error {
  border-color: #f4b4b4;
  background: #fff2f2;
}

.import-preview.error strong,
.import-preview.error span {
  color: var(--danger);
}

.import-preview.success {
  border-color: #9bd6c8;
  background: #f0faf7;
}

.import-preview.success strong,
.import-preview.success span {
  color: #027a48;
}

.import-preview span { color: var(--muted); }

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

.line-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.po-line-row {
  grid-template-columns: minmax(0, 1.2fr) auto auto auto auto;
}

.mapping-row {
  grid-template-columns: minmax(180px, .8fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
}

.store-check-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.store-check-row input[type="checkbox"] {
  width: auto;
  justify-self: end;
}

.po-doc {
  font-family: "Segoe UI", Arial, sans-serif;
  color: #111827;
  margin: 28px;
}

.po-doc-header,
.po-doc-meta,
.po-doc-addresses,
.po-doc-totals {
  display: grid;
  gap: 16px;
}

.po-doc-header {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
}

.po-doc-brand {
  display: grid;
  gap: 8px;
}

.po-doc-brand img {
  max-width: 140px;
  max-height: 72px;
  object-fit: contain;
}

.po-doc-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 20px 0;
}

.po-doc-addresses {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 20px 0;
}

.po-doc-card {
  border: 1px solid #d7dde5;
  border-radius: 6px;
  padding: 12px;
}

.po-doc-card strong,
.po-doc-meta strong {
  display: block;
  margin-bottom: 6px;
}

.po-doc-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 20px;
}

.po-doc-table th,
.po-doc-table td {
  border-bottom: 1px solid #d7dde5;
  padding: 10px;
  text-align: left;
}

.po-doc-table th {
  background: #f5f7fa;
}

.po-doc-totals {
  grid-template-columns: minmax(0, 1fr) 280px;
  margin-top: 20px;
}

.po-doc-summary {
  border: 1px solid #d7dde5;
  border-radius: 6px;
  padding: 12px;
}

.po-doc-summary-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0;
}

.po-doc-notes,
.po-doc-reference {
  white-space: pre-wrap;
}

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

textarea { resize: vertical; }

dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  width: min(920px, calc(100vw - 32px));
  padding: 0;
}

dialog::backdrop { background: rgba(16, 24, 40, .42); }
.modal h2 { padding-bottom: 4px; }

#dashboardSettingsDialog {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
}

.dashboard-settings-modal {
  display: grid;
  min-height: 0;
  background: var(--panel);
}

.dashboard-settings-list {
  max-height: min(620px, calc(100vh - 190px));
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
}

.dashboard-setting-row {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #fff;
}

.dashboard-setting-row .checkbox-row {
  min-width: 0;
  flex: 1;
}

.dashboard-setting-row .checkbox-row span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.dashboard-setting-row small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.dashboard-setting-row .actions {
  flex-wrap: nowrap;
}

.dashboard-setting-row .actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.dashboard-settings-actions {
  justify-content: space-between;
  padding: 14px;
  border-top: 1px solid var(--line);
}

#adminSettingsDialog {
  width: min(1440px, calc(100vw - 24px));
  height: min(960px, calc(100vh - 24px));
  max-width: none;
}

.admin-settings-modal {
  height: 100%;
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  background: var(--panel);
}

.admin-settings-sidebar {
  padding: 18px 16px;
  border-right: 1px solid var(--line);
  background: var(--nav);
  display: grid;
  align-content: start;
  gap: 14px;
}

.admin-settings-nav {
  display: grid;
  gap: 8px;
}

.admin-settings-tab {
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  font-weight: 700;
}

.admin-settings-tab.active {
  background: var(--accent-soft);
  border-color: #b9ddd8;
  color: #0b5d56;
}

.admin-settings-body {
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-width: 0;
}

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

.admin-settings-panel {
  display: none;
  min-height: 0;
  overflow: auto;
}

.admin-settings-panel.active {
  display: block;
}

#adminShopifySyncStatus {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin-bottom: 0;
}

#adminShopifySyncStatus .grid.two {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

#adminShopifySyncStatus .detail-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.admin-collapsible summary {
  list-style: none;
}

.admin-collapsible summary::-webkit-details-marker {
  display: none;
}

.admin-collapsible,
.admin-collapse-summary > div,
#adminShopifySyncStatus .detail-grid > div,
#adminShopifySyncStatus form {
  min-width: 0;
}

.admin-collapse-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 15px;
  cursor: pointer;
  user-select: none;
}

.admin-collapse-summary h3,
.admin-collapse-summary p {
  margin: 0;
}

.admin-collapse-summary p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-collapse-summary::after {
  content: '+';
  color: var(--accent);
  font-size: 20px;
  line-height: 1;
  flex: 0 0 auto;
}

.admin-collapsible[open] > .admin-collapse-summary {
  border-bottom: 1px solid var(--line);
}

.admin-collapsible[open] > .admin-collapse-summary::after {
  content: '-';
}

.admin-collapse-content {
  padding: 14px 15px;
}

#adminShopifySyncStatus .detail-grid strong,
#adminShopifySyncStatus .movement span,
#adminShopifySyncStatus .movement strong,
#adminShopifySyncStatus .notice span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#adminShopifySyncStatus .movement {
  align-items: flex-start;
}

.admin-collapse-content.notice,
.admin-collapse-content > .notice:last-child,
.admin-collapse-content > .grid:last-child {
  margin-bottom: 0;
}

.admin-user-grid {
  gap: 10px;
  margin-bottom: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

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

.admin-permission-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.selected-line {
  border-color: #b9ddd8;
  background: var(--accent-soft);
}

.build-form {
  gap: 16px;
}

.build-form-top,
.build-form-schedule {
  margin-bottom: 0;
}

.build-preview {
  display: grid;
  gap: 14px;
}

.build-preview-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.build-preview-head div {
  display: grid;
  gap: 4px;
}

.build-preview-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.build-preview-summary div {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255,255,255,.65);
}

.build-preview-section {
  display: grid;
  gap: 8px;
}

.build-preview-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.build-preview-table th,
.build-preview-table td {
  white-space: nowrap;
}

.build-preview-sub {
  margin-top: 2px;
  white-space: normal;
}

.bom-editor-dialog {
  width: min(1280px, calc(100vw - 24px));
  height: min(920px, calc(100vh - 24px));
}

.bom-editor-modal {
  height: 100%;
  gap: 16px;
  grid-template-rows: auto auto auto 1fr auto;
}

.bom-editor-head {
  margin: -14px -14px 0;
}

.bom-editor-top {
  margin-bottom: 0;
  align-items: start;
}

.bom-line-editor {
  margin-bottom: 0;
}

.bom-editor-lines {
  min-height: 0;
  overflow: auto;
  align-content: start;
  padding: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fff;
}

.movement-list {
  padding: 14px 16px;
  display: grid;
  gap: 8px;
}

.movement {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line-soft);
  padding-bottom: 8px;
}

.positive { color: #027a48; }
.negative { color: var(--danger); }

.placeholder {
  min-height: 260px;
  padding: 28px;
  background: #fff;
  border: 1px dashed #c4ccd6;
  border-radius: 7px;
}

.placeholder p { margin-top: 6px; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding-bottom: 12px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 8px; }
  .nav-group,
  .nav > .nav-row {
    min-width: 0;
  }
  .nav-children {
    margin-left: 0;
    padding-left: 12px;
  }
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }
  #refresh,
  #pullShopify {
    width: 100%;
  }
  main { padding: 16px; }
  .metrics, .workflow-strip, .grid.two, .grid.three, .po-doc-header, .po-doc-meta, .po-doc-addresses, .po-doc-totals { grid-template-columns: 1fr; }
  .section-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .bom-toolbar,
  .bom-toolbar-actions,
  .bom-toolbar-filters,
  .actions.aligned-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .bom-toolbar-filters {
    margin-left: 0;
  }
  .toolbar-input,
  .list-toolbar .toolbar-input {
    width: 100%;
    min-width: 0;
    flex: 1 1 240px;
  }
  .toolbar-field {
    flex: 1 1 180px;
    min-width: 0;
  }
  .toolbar-field select {
    min-width: 0;
  }
  .compact-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }
  .build-preview-head,
  .movement,
  .po-doc-summary-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .category-group .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .category-group table th:last-child,
  .category-group table td:last-child {
    position: sticky;
    right: 0;
    z-index: 1;
    background: #fff;
  }
  .category-group table td:last-child {
    min-width: 88px;
  }
}

@media (max-width: 620px) {
  .dashboard-toolbar,
  .dashboard-setting-row { align-items: stretch; flex-direction: column; }
  .dashboard-toolbar .actions,
  .dashboard-settings-actions { width: 100%; flex-wrap: wrap; }
  .dashboard-card-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-setting-row .actions button { flex: 1; }
  .admin-settings-modal { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .admin-settings-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .admin-settings-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-settings-body { padding: 14px; }
  .admin-settings-head { align-items: stretch; flex-direction: column; }
  .admin-settings-head .actions { width: 100%; }
  #adminShopifySyncStatus .grid.two,
  #adminShopifySyncStatus .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .nav { grid-template-columns: 1fr; }
  .section-head { align-items: flex-start; flex-direction: column; }
  .bom-toolbar,
  .bom-toolbar-actions,
  .bom-toolbar-filters {
    flex-wrap: wrap;
    width: 100%;
  }
  .bom-toolbar-filters {
    margin-left: 0;
  }
  .toolbar-input {
    width: 100%;
    min-width: 0;
  }
  .line-editor, .line-row, .po-line-row, .bom-line-editor { grid-template-columns: 1fr; align-items: stretch; }
  .detail-grid, .requirement-row, .build-preview-summary, .bom-editor-top { grid-template-columns: 1fr; }
  .bom-editor-dialog { width: calc(100vw - 16px); height: calc(100vh - 16px); }
}

