:root {
  color-scheme: dark;
  --bg: #0a0c10;
  --panel: #141922;
  --panel-soft: #10141c;
  --panel-strong: #1b222e;
  --ink: #eef3f8;
  --muted: #9ca8b7;
  --line: #2b3443;
  --line-strong: #3b4656;
  --accent: #2f80d9;
  --accent-dark: #1e5fa8;
  --accent-soft: rgba(47, 128, 217, 0.16);
  --silver: #c4c9d0;
  --warn: #d69b35;
  --danger: #e06666;
  --focus: #58a6ff;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f7f9fc;
  --panel-strong: #edf2f8;
  --ink: #17202b;
  --muted: #5b6674;
  --line: #d8e0ea;
  --line-strong: #b7c4d2;
  --accent: #216fbf;
  --accent-dark: #18548f;
  --accent-soft: rgba(33, 111, 191, 0.13);
  --silver: #4b5563;
  --warn: #a76a08;
  --danger: #bf3434;
  --focus: #216fbf;
  --shadow: 0 16px 34px rgba(35, 50, 75, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #05070b 0%, #111722 54%, #07090d 100%);
  color: var(--ink);
  padding: 24px;
}

:root[data-theme="light"] .sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #eef4fb 55%, #dde8f5 100%);
}

.brand {
  display: grid;
  gap: 10px;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: min(100%, 228px);
  height: auto;
}

.brand small {
  color: var(--silver);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tabs button {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  padding: 11px 12px;
  text-align: left;
}

.nav-tabs button:hover,
.nav-tabs button.active {
  border-color: rgba(80, 148, 222, 0.38);
  background: rgba(47, 128, 217, 0.17);
  color: #ffffff;
}

:root[data-theme="light"] .nav-tabs button:hover,
:root[data-theme="light"] .nav-tabs button.active {
  border-color: rgba(33, 111, 191, 0.38);
  background: rgba(33, 111, 191, 0.16);
  color: #102030;
}

main {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.global-search {
  position: relative;
  display: grid;
  min-width: min(34vw, 360px);
  gap: 4px;
}

.global-search span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.session-user {
  color: var(--muted);
  font-size: 13px;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 120px);
  place-items: center;
}

.login-panel {
  width: min(100%, 390px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-panel .panel-body {
  display: grid;
  gap: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  color: var(--ink);
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  color: var(--ink);
  font-size: 18px;
}

h3 {
  color: var(--ink);
  font-size: 15px;
}

.topbar p,
.muted,
small {
  color: var(--muted);
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.icon-button:hover {
  border-color: rgba(80, 148, 222, 0.52);
  background: var(--panel-strong);
}

.message {
  margin-bottom: 16px;
  border: 1px solid rgba(80, 148, 222, 0.42);
  border-radius: 8px;
  background: rgba(47, 128, 217, 0.15);
  color: #d7eaff;
  padding: 12px 14px;
}

:root[data-theme="light"] .message {
  color: #17466f;
}

.message.error {
  border-color: rgba(224, 102, 102, 0.54);
  background: rgba(224, 102, 102, 0.13);
  color: #ffd0d0;
}

:root[data-theme="light"] .message.error {
  color: #8f2020;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
  box-shadow: var(--shadow);
  text-align: left;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 24px;
}

.metric-action:hover,
.section-card:hover {
  border-color: rgba(80, 148, 222, 0.55);
  background: var(--panel-strong);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.section-card {
  display: grid;
  min-height: 132px;
  align-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow);
}

.section-card span {
  font-weight: 700;
}

.section-card strong {
  color: var(--ink);
  font-size: 28px;
}

.workflow-stage-stack {
  display: grid;
  gap: 16px;
}

.workflow-stage {
  border-top: 1px solid rgba(148, 163, 184, 0.24);
}

.workflow-card-list {
  display: grid;
  gap: 10px;
  padding: 12px 16px 16px;
}

.workflow-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.18);
}

.workflow-card-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.workflow-counts,
.workflow-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.workflow-items small {
  color: var(--muted);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  padding: 4px 8px;
}

.workflow-checkbox {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--accent);
}

.warehouse-layout {
  display: grid;
  gap: 16px;
}

.warehouse-scan-panel {
  border-color: rgba(80, 148, 222, 0.42);
}

.scan-input {
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  padding: 12px 14px;
}

.workflow-scan-row {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.workflow-scan-row .scan-input {
  min-height: 44px;
  font-size: 16px;
}

.workflow-proof-grid {
  margin-top: 14px;
}

tr.workflow-scan-hit {
  background: rgba(34, 197, 94, 0.12);
}

.mobile-scan-shell {
  max-width: 720px;
  margin: 0 auto;
  display: grid;
  gap: 12px;
}

.mobile-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mobile-tabs button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.mobile-tabs button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.mobile-panel .panel-body {
  padding: 14px;
}

.mobile-form-stack {
  display: grid;
  gap: 12px;
}

.mobile-scan-input {
  min-height: 64px;
  font-size: 20px;
}

.mobile-number-input {
  min-height: 52px;
  font-size: 18px;
  font-weight: 700;
}

.mobile-action {
  width: 100%;
  min-height: 52px;
  justify-content: center;
}

.mobile-scan-list {
  display: grid;
  gap: 8px;
}

.mobile-chip,
.mobile-result,
.mobile-serial-row {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.mobile-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}

.mobile-result,
.mobile-serial-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.mobile-serial-row.checked {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
}

.mobile-serial-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.mobile-lookup-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.mobile-camera-button {
  min-height: 48px;
  justify-content: center;
}

.mobile-camera-panel {
  border-color: rgba(47, 128, 217, 0.5);
}

.mobile-scanner-video {
  width: 100%;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #000;
  object-fit: cover;
}

.warehouse-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.warehouse-results {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.warehouse-result-list {
  display: grid;
  gap: 10px;
}

.warehouse-result {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.label-modal {
  width: min(100%, 520px);
}

.print-label {
  display: grid;
  width: min(100%, 420px);
  gap: 8px;
  border: 2px solid #111;
  border-radius: 4px;
  background: #fff;
  color: #111;
  padding: 14px;
}

.print-label strong {
  color: #111;
  font-size: 18px;
}

.print-label small,
.label-code {
  color: #111;
  font-weight: 700;
  letter-spacing: 0;
}

.barcode {
  display: flex;
  height: 74px;
  align-items: stretch;
  gap: 0;
  overflow: hidden;
  background: #fff;
}

.barcode i {
  display: block;
  height: 100%;
}

.barcode .bar {
  background: #000;
}

.barcode .space {
  background: #fff;
}

.barcode .narrow {
  width: 2px;
}

.barcode .wide {
  width: 5px;
}

@media print {
  body {
    background: #fff;
    color: #111827;
  }

  body * {
    visibility: hidden;
  }

  .print-label,
  .print-label *,
  .printable-report,
  .printable-report * {
    visibility: visible;
  }

  .print-label {
    position: fixed;
    top: 12mm;
    left: 12mm;
    width: 90mm;
    box-shadow: none;
  }

  .printable-report {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    border: 0;
    background: #fff;
    color: #111827;
    box-shadow: none;
  }

  .printable-report .panel-actions,
  .printable-report .button {
    display: none !important;
  }

  .printable-report .table-wrap {
    overflow: visible;
  }

  .no-print {
    display: none !important;
  }
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.single-column {
  display: grid;
  min-width: 0;
  gap: 16px;
}

.product-picker {
  display: grid;
  gap: 6px;
}

.project-requirement-grid {
  grid-template-columns: minmax(260px, 1fr) minmax(120px, 180px);
  align-items: end;
}

.project-requirement-grid label:first-child {
  min-width: 0;
}

.project-requirement-grid .quantity-field input {
  max-width: 140px;
}

.project-status-groups {
  display: grid;
  gap: 18px;
  padding: 12px;
}

.project-status-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 12px 0;
}

.project-status-menu button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
  padding: 7px 10px;
}

.project-status-menu button.active {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--panel-strong);
}

.project-status-menu span {
  color: var(--muted);
  font-size: 11px;
  margin-left: 4px;
}

.project-status-group {
  display: grid;
  gap: 8px;
}

.project-status-group h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.project-status-group h3 span {
  color: var(--muted);
  font-size: 12px;
}

.compact-empty {
  padding: 12px;
}

.section-heading {
  display: grid;
  gap: 4px;
  padding: 4px 2px 0;
}

.section-heading h2 {
  margin: 0;
}

.section-heading small {
  color: var(--muted);
}

.search-results-panel {
  margin-bottom: 16px;
}

.search-result-grid,
.alert-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.search-result,
.alert-card {
  display: grid;
  gap: 6px;
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 12px;
  text-align: left;
}

.search-result span,
.alert-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.alert-card.warn {
  border-color: rgba(214, 155, 53, 0.56);
  background: rgba(214, 155, 53, 0.12);
}

.alert-card.danger {
  border-color: rgba(224, 102, 102, 0.62);
  background: rgba(224, 102, 102, 0.13);
}

.alert-card.ok strong {
  color: #65c18c;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-list {
  display: grid;
  gap: 10px;
}

.timeline h3 {
  margin: 0 0 2px;
}

.timeline-entry {
  display: grid;
  gap: 3px;
  border-left: 3px solid var(--accent);
  background: var(--panel-soft);
  padding: 10px 12px;
}

.timeline-entry time,
.timeline-entry small {
  color: var(--muted);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.admin-wide {
  grid-column: 1 / -1;
}

.admin-form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.admin-hub .panel-body {
  padding: 18px;
}

.admin-command-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.admin-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.admin-command {
  display: grid;
  min-height: 132px;
  align-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #1b222e 0%, #121822 100%);
  color: var(--ink);
  padding: 15px;
  text-align: left;
  box-shadow: var(--shadow);
}

.admin-command:hover,
.admin-command:focus-visible {
  border-color: rgba(80, 148, 222, 0.7);
  background: linear-gradient(180deg, #202a38 0%, #121b27 100%);
}

:root[data-theme="light"] .admin-command {
  background: linear-gradient(180deg, #ffffff 0%, #eef4fb 100%);
  color: var(--ink);
}

:root[data-theme="light"] .admin-command:hover,
:root[data-theme="light"] .admin-command:focus-visible {
  background: linear-gradient(180deg, #f8fbff 0%, #e4eef9 100%);
}

.admin-command-label {
  color: var(--silver);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.admin-command strong {
  color: #ffffff;
  font-size: 30px;
  line-height: 1;
  overflow-wrap: anywhere;
}

:root[data-theme="light"] .admin-command strong {
  color: var(--ink);
}

.admin-command small {
  line-height: 1.35;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.panel-body {
  padding: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #0d1118;
  color: var(--ink);
  padding: 9px 10px;
}

select option {
  background: #0d1118;
  color: var(--ink);
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea,
:root[data-theme="light"] select option {
  background: #ffffff;
  color: var(--ink);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.panel-actions {
  justify-content: flex-end;
  margin-top: 0;
}

.saved-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin-top: 12px;
}

.saved-filter-row label {
  max-width: 240px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-muted);
}

.filter-chip button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  padding: 6px 10px;
}

.filter-chip button:last-child {
  border-right: 0;
  color: var(--muted);
}

.stocktake-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.compact-list {
  display: grid;
  gap: 6px;
}

.list-card {
  display: grid;
  width: 100%;
  min-height: 48px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 8px 10px;
}

.list-card small {
  color: var(--muted);
}

.list-card.ok {
  border-color: rgba(34, 197, 94, 0.4);
}

.list-card.warn {
  border-color: rgba(245, 158, 11, 0.5);
}

.list-card.danger {
  border-color: rgba(239, 68, 68, 0.5);
}

.selected-row {
  background: rgba(59, 130, 246, 0.08);
}

.action-guidance {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.action-guidance > div {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid rgba(214, 155, 53, 0.36);
  border-radius: 8px;
  background: rgba(214, 155, 53, 0.1);
  color: var(--ink);
  padding: 10px 12px;
}

.action-guidance span {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border-radius: 999px;
  background: var(--warn);
  color: #1f1608;
  font-size: 12px;
  font-weight: 900;
}

.action-guidance strong {
  font-size: 13px;
  line-height: 1.4;
}

.table-actions {
  margin-top: 0;
}

.table-link {
  display: grid;
  gap: 2px;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
}

.table-link strong {
  color: var(--accent);
}

.table-link:hover strong {
  text-decoration: underline;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--panel-soft);
}

.clickable-row:hover strong {
  color: var(--accent);
}

.project-requirements-table {
  table-layout: fixed;
  min-width: 1040px;
}

.project-requirements-table th:first-child,
.project-requirements-table .requirement-product-cell {
  width: 26%;
}

.project-requirements-table th:last-child,
.project-requirements-table .requirement-action-cell {
  width: 330px;
}

.requirement-product-cell strong,
.requirement-product-cell small,
.project-requirements-table td small {
  display: block;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.requirement-row.requirement-flow-covered {
  background: rgba(101, 193, 140, 0.045);
}

.requirement-row.requirement-flow-ready-to-receive,
.requirement-row.requirement-flow-ready-to-allocate {
  background: rgba(214, 155, 53, 0.055);
}

.requirement-row.requirement-flow-needs-order,
.requirement-row.requirement-flow-waiting-for-stock {
  background: rgba(214, 155, 53, 0.035);
}

.requirement-action-cell {
  white-space: nowrap;
}

.requirement-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  min-width: 306px;
}

.requirement-action-slot {
  display: flex;
  min-width: 0;
}

.requirement-actions .button {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 8px 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--ink);
  padding: 9px 12px;
  text-decoration: none;
}

.button:hover {
  border-color: rgba(80, 148, 222, 0.52);
}

.button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.button.danger {
  border-color: rgba(224, 102, 102, 0.72);
  background: rgba(224, 102, 102, 0.16);
  color: #ffd0d0;
}

:root[data-theme="light"] .button.danger {
  color: #8f2020;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--ink);
  padding: 6px 10px;
  box-shadow: var(--shadow);
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 20px;
  border-radius: 999px;
  background: var(--panel-strong);
  border: 1px solid var(--line-strong);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  transition: transform 0.16s ease;
}

:root[data-theme="light"] .toggle-thumb {
  transform: translateX(18px);
}

.theme-label {
  min-width: 34px;
  color: var(--muted);
  font-size: 12px;
}

:root[data-theme="light"] .theme-label {
  color: #253244;
}

.button.danger:hover {
  background: rgba(224, 102, 102, 0.24);
}

.table-wrap {
  overflow-x: auto;
}

.product-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.nested-header {
  border-top: 1px solid var(--line);
}

.product-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}

.product-folder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.product-folder.active {
  border-color: rgba(80, 148, 222, 0.68);
  background: var(--accent-soft);
}

.folder-open {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.folder-open > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.folder-open strong,
.folder-open small {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.folder-open strong {
  line-height: 1.2;
}

.folder-icon {
  position: relative;
  display: block;
  flex: 0 0 auto;
  width: 32px;
  height: 24px;
  border-radius: 5px;
  background: var(--accent);
}

.folder-edit {
  width: 52px;
  height: 34px;
  border-radius: 8px;
  font-size: 12px;
}

.project-record-stack {
  display: grid;
  gap: 12px;
}

.project-record-stack > .panel {
  box-shadow: none;
}

.folder-icon::before {
  position: absolute;
  top: -7px;
  left: 3px;
  width: 18px;
  height: 9px;
  border-radius: 5px 5px 0 0;
  background: var(--accent-dark);
  content: "";
}

.product-card {
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.product-card-title {
  display: grid;
  gap: 2px;
  min-height: 42px;
}

.product-card-title strong {
  overflow-wrap: anywhere;
}

.product-card-meta {
  display: grid;
  gap: 5px;
  min-height: 74px;
  align-content: start;
}

.product-card-meta small {
  overflow-wrap: anywhere;
}

.product-card-actions {
  display: grid;
  gap: 8px;
  align-self: end;
  margin-top: 4px;
}

.product-card-actions .button {
  width: 100%;
  justify-content: center;
}

.product-project-picker {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}

.product-project-picker small {
  color: var(--muted);
}

.product-requirement-form {
  display: grid;
  grid-template-columns: minmax(100px, 140px) auto;
  gap: 8px;
  align-items: end;
}

.product-requirement-form.compact {
  grid-template-columns: minmax(76px, 0.7fr) 1fr;
}

.product-requirement-form label {
  min-width: 0;
}

.product-requirement-form input {
  min-width: 0;
}

.image-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.image-nav small,
.image-counter {
  min-width: 48px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.compact-image-nav {
  margin-top: -2px;
}

.product-card-open {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.product-image {
  display: grid;
  width: 100%;
  height: 190px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: var(--panel-soft);
  background-position: center;
  background-repeat: no-repeat;
  background-size: calc(100% - 28px) calc(100% - 28px);
  color: var(--muted);
  font-weight: 700;
  padding: 8px;
}

.product-image.has-image {
  background-image: none;
}

.product-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.product-detail-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.product-detail-stack {
  display: grid;
  gap: 12px;
}

.product-gallery {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0, 680px) 44px;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin: 16px;
}

.product-detail-image {
  display: grid;
  min-height: 420px;
  max-height: 72vh;
  place-items: center;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 700;
}

.gallery-nav {
  width: 42px;
  height: 42px;
  font-size: 28px;
  line-height: 1;
}

.image-counter {
  grid-column: 1 / -1;
  justify-self: center;
}

.product-detail-image img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 72vh;
  object-fit: contain;
  object-position: center;
}

.image-remove-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.image-remove-card {
  position: relative;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
}

.image-delete-button {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(224, 102, 102, 0.7);
  border-radius: 999px;
  background: rgba(20, 24, 32, 0.86);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.image-remove-card img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  object-position: center;
  border-radius: 6px;
  background: var(--panel-soft);
}

.dashboard-scroll {
  max-height: 420px;
  overflow: auto;
}

.compact-form {
  display: grid;
  gap: 10px;
  padding: 10px 0;
}

.document-upload {
  display: grid;
  gap: 12px;
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.checkbox-line input {
  width: auto;
  min-height: auto;
}

.order-lines {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.order-line {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(110px, 0.4fr) minmax(110px, 0.4fr) auto;
  gap: 10px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.order-line-remove {
  min-height: 40px;
}

.serial-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.form-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.92rem;
}

.project-history-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  align-items: start;
}

.compact-history-grid .panel {
  box-shadow: none;
}

.project-history-grid > .panel {
  min-width: 0;
}

.project-history-hero .detail-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.project-progress-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.workflow-path {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.workflow-path span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  padding: 5px 8px;
}

.workflow-path b {
  color: var(--silver);
  font-weight: 900;
}

.project-progress-step {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.project-progress-step span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.16);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.project-progress-step strong {
  color: var(--ink);
}

.project-progress-step small {
  color: var(--muted);
}

.project-progress-step.done {
  border-color: rgba(36, 163, 90, 0.5);
  background: rgba(36, 163, 90, 0.12);
}

.project-progress-step.done span {
  background: var(--good);
  color: #fff;
}

.project-progress-step.current {
  border-color: rgba(214, 155, 53, 0.55);
  background: rgba(214, 155, 53, 0.12);
}

.project-progress-step.current span {
  background: var(--warn);
  color: #1f1608;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--silver);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #e6edf4;
}

:root[data-theme="light"] td {
  color: var(--ink);
}

td strong,
td small {
  display: block;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

:root[data-theme="light"] tr:hover td,
tr.active-row td {
  background: rgba(33, 111, 191, 0.08);
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid rgba(80, 148, 222, 0.32);
  border-radius: 999px;
  padding: 4px 9px;
  background: var(--accent-soft);
  color: #cfe7ff;
  font-size: 12px;
  font-weight: 800;
}

:root[data-theme="light"] .status {
  border-color: rgba(33, 111, 191, 0.35);
  background: rgba(33, 111, 191, 0.12);
  color: #17466f;
}

.status.warn {
  border-color: rgba(214, 155, 53, 0.42);
  background: rgba(214, 155, 53, 0.14);
  color: #ffd890;
}

.status.good {
  border-color: rgba(36, 163, 90, 0.46);
  background: rgba(36, 163, 90, 0.16);
  color: #bff3d3;
}

:root[data-theme="light"] .status.warn {
  border-color: rgba(167, 106, 8, 0.36);
  background: rgba(167, 106, 8, 0.14);
  color: #704500;
}

:root[data-theme="light"] .status.good {
  border-color: rgba(20, 128, 71, 0.34);
  background: rgba(20, 128, 71, 0.12);
  color: #0f6738;
}

.diagnostic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.diagnostic-summary {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  margin-bottom: 16px;
  padding: 14px;
}

.diagnostic-summary.warn {
  border-color: rgba(214, 155, 53, 0.44);
}

.diagnostic-summary.ok {
  border-color: rgba(36, 163, 90, 0.35);
}

.diagnostic-summary > div:first-child small,
.diagnostic-summary-grid small {
  display: block;
  color: var(--muted);
}

.diagnostic-summary > div:first-child strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
}

.diagnostic-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.diagnostic-summary-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.diagnostic-summary-grid > div.warn {
  border-color: rgba(214, 155, 53, 0.42);
  background: rgba(214, 155, 53, 0.11);
}

.diagnostic-summary-grid > div.ok {
  border-color: rgba(36, 163, 90, 0.28);
}

.diagnostic-summary-grid span {
  display: block;
  color: var(--ink);
  font-size: 20px;
  font-weight: 900;
}

.diagnostic-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.diagnostic-card > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.diagnostic-card h3 {
  margin: 0;
  font-size: 15px;
}

.diagnostic-card.warn {
  border-color: rgba(214, 155, 53, 0.44);
}

.diagnostic-card.ok {
  border-color: rgba(36, 163, 90, 0.35);
}

.diagnostic-list {
  display: grid;
  gap: 8px;
}

.diagnostic-list > div {
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 8px;
}

.diagnostic-list strong,
.diagnostic-list small {
  display: block;
}

.empty-state {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.empty-state strong,
.empty-state span {
  display: block;
}

.backup-state {
  display: grid;
  justify-items: center;
  gap: 12px;
}

.danger-zone {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  border: 1px solid rgba(224, 102, 102, 0.48);
  border-radius: 8px;
  background: rgba(224, 102, 102, 0.11);
  color: #ffe4e4;
  padding: 14px;
}

:root[data-theme="light"] .danger-zone {
  color: #8f2020;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 12px;
}

.detail-grid strong {
  display: block;
  margin-top: 4px;
  color: #ffffff;
  overflow-wrap: anywhere;
}

:root[data-theme="light"] .detail-grid strong {
  color: var(--ink);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.68);
  padding: 20px;
}

.modal {
  width: min(920px, 100%);
  max-height: min(88vh, 920px);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #111721;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.58);
}

:root[data-theme="light"] .modal {
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-close {
  flex: 0 0 auto;
  box-shadow: none;
}

.modal-body {
  max-height: calc(88vh - 76px);
  overflow: auto;
  padding: 16px;
}

.modal-body > .panel-body {
  padding: 0;
}

@media (max-width: 1180px) {
  .admin-command-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    padding: 16px;
  }

  .brand {
    align-items: center;
    grid-template-columns: minmax(0, 220px) 1fr;
    margin-bottom: 16px;
  }

  .nav-tabs {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    overflow-x: auto;
  }

  .nav-tabs button {
    text-align: center;
    white-space: nowrap;
  }

  .metric-grid,
  .search-result-grid,
  .alert-grid,
  .layout-grid,
  .admin-grid,
  .admin-command-grid,
  .project-history-grid,
  .project-progress-strip,
  .warehouse-result,
  .product-detail-layout,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .admin-wide {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  main {
    padding: 12px 12px 86px;
  }

  .sidebar {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    gap: 8px;
  }

  .top-actions {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: auto;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .top-actions > *,
  .top-actions .button,
  .top-actions .icon-button,
  .theme-toggle {
    width: auto;
    flex: 0 0 auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-tabs button {
    min-height: 42px;
    padding: 10px 8px;
    white-space: normal;
  }

  .panel-header,
  .modal-header {
    align-items: stretch;
    flex-direction: column;
  }

  .panel-actions,
  .button-row {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .button,
  .icon-button,
  .section-card,
  .metric,
  .admin-command,
  .search-result,
  .alert-card {
    min-width: 0;
    width: 100%;
  }

  .workflow-card {
    grid-template-columns: 1fr;
  }

  .stocktake-columns {
    grid-template-columns: 1fr;
  }

  .image-nav .icon-button,
  .gallery-nav {
    width: 42px;
  }

  .product-gallery {
    grid-template-columns: 38px minmax(0, 1fr) 38px;
    margin: 12px;
  }

  .product-detail-image {
    min-height: 280px;
  }

  .table-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: min(180px, 100%);
  }

  .requirement-actions {
    grid-template-columns: 1fr;
    min-width: 0;
    width: min(180px, 100%);
  }

  .project-requirements-table th:last-child,
  .project-requirements-table .requirement-action-cell {
    width: 190px;
  }

  table {
    min-width: 720px;
  }

  .global-search {
    width: 210px;
    min-width: 210px;
  }

  .session-user {
    display: none;
  }

  .brand {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .product-project-picker,
  .product-requirement-form,
  .product-requirement-form.compact {
    grid-template-columns: 1fr;
  }

  .project-requirement-grid {
    grid-template-columns: 1fr;
  }

  .project-requirement-grid .quantity-field input {
    max-width: 180px;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .search-result-grid,
  .alert-grid {
    grid-template-columns: 1fr;
  }

  .order-line {
    grid-template-columns: 1fr;
  }

  .serial-field-grid {
    grid-template-columns: 1fr;
  }

  .modal-backdrop {
    align-items: stretch;
    padding: 8px;
  }

  .modal {
    max-height: calc(100vh - 16px);
  }

  .modal-body {
    max-height: calc(100vh - 96px);
  }
}
