:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-strong: #eef2f5;
  --text: #1e252b;
  --muted: #64717c;
  --line: #dce3e8;
  --accent: #256f75;
  --accent-dark: #174f54;
  --warn: #b56b11;
  --ok: #24704a;
  --danger: #a8423f;
  --shadow: 0 18px 45px rgba(32, 45, 54, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #172126;
  color: #fff;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: #f0c526;
  color: #172126;
  font-weight: 800;
}

.brand small,
.eyebrow,
.section-head p,
.empty-state,
label span {
  color: var(--muted);
}

.brand small {
  display: block;
  color: #adbac3;
  margin-top: 2px;
}

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

.nav-item {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  background: transparent;
  color: #dfe7ec;
}

.nav-item.active,
.nav-item:hover {
  background: #26353c;
  color: #fff;
}

.sidebar-summary {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.main {
  min-width: 0;
  padding: 26px;
}

.topbar,
.section-head,
.toolbar,
.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.topbar {
  margin-bottom: 22px;
}

.topbar h1,
.section-head h2,
.modal h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

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

.primary,
.secondary,
.danger,
.small-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 0 14px;
  font-weight: 700;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary,
.small-button {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.danger {
  background: #fff;
  border-color: #e9c6c4;
  color: var(--danger);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 24px;
  line-height: 1;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.toolbar {
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 7px;
  min-width: 170px;
}

label span {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

textarea {
  resize: vertical;
}

.search {
  flex: 1;
}

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

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

.model-card,
.model-list-row,
.order-card,
.production-card,
.order-details,
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.model-card {
  overflow: hidden;
}

.model-list-row {
  display: grid;
  grid-template-columns: 88px minmax(220px, 360px) 96px 92px minmax(500px, 1fr);
  gap: 12px;
  align-items: center;
  padding: 8px;
}

.model-photo {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #d9e1e5, #f6f1dd);
  color: #55616b;
  font-weight: 800;
  cursor: zoom-in;
}

.model-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.model-thumb,
.mini-thumb {
  display: grid;
  place-items: center;
  overflow: hidden;
  background: linear-gradient(135deg, #d9e1e5, #f6f1dd);
  color: #55616b;
  font-weight: 800;
  cursor: zoom-in;
}

.model-thumb {
  height: 88px;
  border-radius: 8px;
  position: relative;
}

.mini-thumb {
  width: 52px;
  height: 52px;
  border-radius: 8px;
  flex: 0 0 auto;
}

.mini-thumb.large {
  width: 74px;
  height: 74px;
}

.model-thumb img,
.mini-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.stl-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  border: 0;
  border-radius: 999px;
  padding: 5px 8px;
  background: rgba(23, 33, 38, 0.82);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
}

.model-thumb .stl-badge {
  top: 6px;
  right: 6px;
  padding: 4px 6px;
  font-size: 11px;
}

.model-photo {
  position: relative;
}

.model-card-body {
  padding: 14px;
}

.model-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.model-card .primary {
  width: 100%;
  margin: 12px 0 8px;
}

.catalog-order {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.catalog-order.compact {
  margin: 0;
  padding: 0;
  border-top: 0;
}

.catalog-order select,
.catalog-order input[data-order-quantity] {
  padding-left: 8px;
  padding-right: 8px;
}

.catalog-order.compact .catalog-colors,
.catalog-order.compact .list-actions {
  grid-column: auto;
}

.catalog-order .primary {
  margin: 0;
}

.catalog-order-line {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(120px, 180px) 122px 68px 34px max-content;
  gap: 6px;
  align-items: end;
  min-width: 0;
}

.catalog-order-line label {
  min-width: 0;
}

.catalog-order-line input[data-order-quantity] {
  width: 68px;
  min-width: 68px;
}

.catalog-order-line select,
.catalog-order-line input[data-order-quantity] {
  min-height: 32px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.catalog-order-line .small-button {
  width: 34px;
  height: 32px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.catalog-order-submit {
  width: auto;
  min-height: 30px;
  height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.model-card .catalog-order-line {
  grid-template-columns: minmax(0, 1fr) 122px 68px 34px;
}

.model-card .catalog-order-submit {
  grid-column: 1 / -1;
  width: 100%;
}

.color-select-wrap {
  position: relative;
  display: block;
}

.color-select-wrap .swatch {
  position: absolute;
  left: 8px;
  top: 50%;
  z-index: 1;
  width: 13px;
  height: 13px;
  transform: translateY(-50%);
  pointer-events: none;
}

.color-select-wrap select {
  padding-left: 28px;
}

.catalog-drafts {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 0;
}

.draft-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 7px;
  background: #fbfcfc;
  color: #34414a;
  font-size: 12px;
  font-weight: 700;
}

.draft-pill button {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: var(--panel-strong);
  color: var(--muted);
  line-height: 1;
}

.catalog-colors {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.catalog-colors > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.color-choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.color-choice {
  min-width: max-content;
  width: max-content;
  max-width: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fff;
  color: #34414a;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  flex: 0 0 max-content;
}

.color-choice span:last-child {
  overflow: visible;
  white-space: nowrap;
}

.color-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.color-choice:has(input:checked) {
  border-color: var(--accent);
  background: #e7f1f1;
  color: var(--accent-dark);
}

.view-toggle {
  display: flex;
  gap: 8px;
  align-items: end;
}

.view-toggle .active {
  border-color: var(--accent);
  background: #e7f1f1;
  color: var(--accent-dark);
}

.model-list-main {
  min-width: 0;
}

.model-list-main h3 {
  margin: 0 0 4px;
}

.model-list-price {
  justify-self: end;
  white-space: nowrap;
}

.reference-cell {
  display: grid;
  gap: 4px;
  justify-items: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.reference-cell .mini-thumb {
  width: 58px;
  height: 58px;
}

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

.table-product,
.production-head {
  display: flex;
  gap: 12px;
  align-items: center;
}

.production-head {
  margin-bottom: 14px;
  justify-content: space-between;
}

.production-head h3,
.production-head p {
  margin: 0;
}

.production-head p {
  color: var(--muted);
}

.meta-row,
.price-row,
.order-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 14px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  color: #34414a;
  font-size: 12px;
  font-weight: 700;
}

.swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  flex: 0 0 auto;
}

.section-head {
  margin-bottom: 16px;
}

.section-head p {
  margin: 5px 0 0;
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 780px;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

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

tr.row-ready td {
  background: #e9f7ee;
}

tr.row-ready:hover td {
  background: #ddf1e5;
}

tr.row-shipped td {
  background: #eef2f5;
}

.shipping-actions {
  margin-top: 6px;
}

.shipment-history {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.shipment-history h2 {
  margin: 0;
}

.shipment-archive {
  display: grid;
  gap: 10px;
}

.shipment-date {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.shipment-archive[open] .shipment-date {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.status {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: var(--panel-strong);
}

.status.new {
  color: var(--accent-dark);
}

.status.printing {
  color: var(--warn);
}

.status.ready,
.status.picked {
  color: var(--ok);
}

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

.order-card {
  padding: 14px;
  text-align: left;
}

.order-card.selected {
  outline: 3px solid rgba(37, 111, 117, 0.2);
}

.order-card h3,
.production-card h3 {
  margin: 0 0 8px;
}

.order-details {
  padding: 18px;
  min-height: 380px;
}

.order-items {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.order-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.production-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.production-card {
  padding: 16px;
}

.progress {
  height: 10px;
  background: var(--panel-strong);
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.stepper {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.stepper button {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 20px;
}

.stepper input {
  text-align: center;
}

.inline-stepper {
  display: grid;
  grid-template-columns: 32px 54px 32px;
  gap: 6px;
  align-items: center;
}

.inline-stepper button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.inline-stepper input {
  height: 34px;
  padding: 6px;
  text-align: center;
}

.empty-state {
  padding: 22px;
  text-align: center;
}

.modal {
  width: min(820px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(23, 33, 38, 0.54);
}

.modal form {
  padding: 22px;
}

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

.wide {
  grid-column: 1 / -1;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.viewer-modal {
  width: min(640px, calc(100vw - 32px));
  height: min(480px, calc(100vh - 32px));
  max-width: min(640px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 32px));
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.viewer-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  display: grid;
  place-items: center;
  color: var(--text);
  box-shadow: 0 18px 70px rgba(32, 45, 54, 0.22);
}

.viewer-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.viewer-modal::backdrop {
  background: transparent;
}

.image-stage {
  width: 100vw;
  height: 100vh;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 24px;
}

.image-stage img {
  display: block;
  max-width: min(1024px, calc(100vw - 48px));
  max-height: min(768px, calc(100vh - 48px));
  height: auto;
  width: auto;
  object-fit: contain;
  box-shadow: 0 18px 70px rgba(32, 45, 54, 0.22);
  cursor: default;
}

.image-modal {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.image-modal::backdrop {
  background: transparent;
}

#modelStlFileStatus,
#modelImageFileStatus,
#modelReferenceImageFileStatus {
  color: var(--muted);
  line-height: 1.35;
}

.file-source-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.file-source-card > strong {
  font-size: 13px;
}

.file-drop-zone {
  border: 1px dashed transparent;
  border-radius: 8px;
  padding: 8px;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.file-drop-zone.drag-over {
  border-color: var(--accent);
  background: #e7f1f1;
}

@media (max-width: 920px) {
  .app-shell,
  .orders-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 16px;
  }

  .nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .nav-item {
    text-align: center;
    padding: 10px 8px;
  }

  .sidebar-summary {
    display: none;
  }

  .topbar,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .model-list-row {
    grid-template-columns: 88px minmax(0, 1fr) auto 74px;
  }

  .model-list-row .catalog-order {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .model-list-price {
    grid-column: 3;
  }

  .catalog-order.compact .catalog-colors,
  .catalog-order.compact .list-actions {
    grid-column: 1 / -1;
  }

  .catalog-order-line {
    grid-template-columns: minmax(120px, 180px) 122px 68px 34px max-content;
  }
}

@media (max-width: 620px) {
  .main {
    padding: 16px;
  }

  .topbar-actions,
  .form-grid,
  .nav {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar-actions {
    width: 100%;
  }

  .viewer-stage {
    min-height: 420px;
  }

  .catalog-order-line {
    grid-template-columns: minmax(0, 1fr) 68px 34px;
  }

  .catalog-order-line label:first-child {
    grid-column: 1 / -1;
  }

  .catalog-order-line label:nth-child(2) {
    grid-column: 1 / 2;
  }

  .catalog-order-submit {
    grid-column: 1 / -1;
    width: 100%;
  }

  .catalog-order-line select {
    min-width: 0;
  }
}
