@font-face {
  font-family: "Questrial";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/questrial.a386fd6d0041.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --bg: #f5f5f5;
  --panel: #ffffff;
  --ink: #2c2c2c;
  --muted: #64748b;
  --line: #ddeef1;
  --accent: #00687a;
  --accent-dark: #013943;
  --accent-hover: #155e6e;
  --soft: #e8f4f6;
  --field-bg: #fbfbfb;
  --danger: #a43a2f;
  --danger-dark: #7d2c24;
  --warning: #f16521;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(1, 57, 67, 0.04);
  position: sticky;
  top: 0;
  z-index: 2;
}

.brand {
  align-items: center;
  color: var(--accent);
  display: inline-flex;
  flex: 0 0 auto;
  font-family: "Questrial", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 18px;
  font-weight: 400;
  gap: 12px;
  line-height: 1;
  text-decoration: none;
}

.brand-logo {
  display: block;
  height: 38px;
  width: auto;
}

.brand-text {
  color: var(--accent-dark);
  white-space: nowrap;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

nav a,
nav button,
.button {
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 4px;
}

nav a:hover,
nav button:hover,
.button:hover {
  background: var(--soft);
}

.logout-form {
  margin: 0;
}

.menu-toggle,
.menu-close {
  display: none;
}

.nav-backdrop {
  display: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.inline-action-form {
  margin: 0;
}

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

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

.button.danger {
  background: var(--danger);
  color: #ffffff;
}

.button.danger:hover {
  background: var(--danger-dark);
}

.page {
  width: min(1400px, calc(100% - 32px));
  margin: 28px auto 48px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

h1 {
  margin: 0;
  font-family: "Questrial", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-family: "Questrial", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 400;
}

.subheading {
  color: var(--muted);
  margin: 6px 0 0;
}

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

.detail-group {
  margin-bottom: 20px;
}

.detail-group .section-heading {
  margin-top: 0;
}

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

.description-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.description-panel h3 {
  color: var(--accent-dark);
  font-size: 14px;
  margin: 0 0 10px;
  text-transform: uppercase;
}

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

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-dark);
  padding: 10px 12px;
}

.form-field-richtext {
  grid-column: 1 / -1;
}

.linked-product-panel {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  grid-column: 1 / -1;
  margin: 0 0 18px;
  padding: 14px;
}

.linked-product-panel .form-field {
  flex: 1 1 320px;
  margin: 0;
  min-width: 0;
}

.linked-product-url-field {
  flex: 1.4 1 360px;
}

.linked-product-url {
  display: block;
  line-height: 1.4;
  overflow-wrap: anywhere;
  padding: 8px 0;
}

.linked-product-actions {
  align-self: flex-end;
  flex: 0 0 auto;
  margin: 0;
}

.filter-bar {
  align-items: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  grid-template-columns: 220px 1fr 1fr auto auto;
  margin-bottom: 18px;
  padding: 14px;
}

.filter-bar fieldset {
  border: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  min-width: 0;
  padding: 0;
}

.filter-bar legend {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
  width: 100%;
}

.filter-bar label {
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  min-height: 32px;
  padding: 6px 9px;
}

.filter-bar label[hidden] {
  display: none;
}

.product-filter-bar {
  grid-template-columns: 1fr;
}

.product-category-filter {
  display: grid;
  gap: 8px;
}

.product-category-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

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

.product-tools-grid {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.product-tools-grid .product-filter-bar {
  margin-bottom: 0;
}

.bulk-sync-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.bulk-sync-heading {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.bulk-sync-heading h2 {
  color: var(--accent-dark);
  font-size: 18px;
  margin: 0 0 4px;
}

.bulk-sync-heading p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.bulk-sync-panel .bulk-sync-toolbar {
  margin: 14px 0 0;
  padding: 0;
}

  .inventory-filter-bar {
  grid-template-areas:
    "search sort ended without reset"
    "type owner plastic-type plastic-type plastic-type"
    "category category category category category"
    "color color color color color";
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.4fr) auto auto auto;
}

.inventory-filter-bar .filter-search {
  grid-area: search;
}

.inventory-filter-bar .filter-sort {
  grid-area: sort;
}

.inventory-filter-bar .filter-checkbox {
  align-self: end;
}

.inventory-filter-bar .filter-hide-ended {
  grid-area: ended;
}

.inventory-filter-bar .filter-without-document {
  grid-area: without;
}

.inventory-filter-bar .filter-type {
  grid-area: type;
}

.inventory-filter-bar .filter-owner {
  grid-area: owner;
}

.inventory-filter-bar .filter-category {
  grid-area: category;
}

.inventory-filter-bar .filter-plastic-type {
  grid-area: plastic-type;
}

.inventory-filter-bar .filter-color {
  grid-area: color;
}

.inventory-filter-bar .filter-reset {
  align-self: end;
  grid-area: reset;
}

.filter-control {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.filter-control > label {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: default;
  font-size: 13px;
  font-weight: 700;
  min-height: 0;
  padding: 0;
}

.filter-bar input {
  margin: 0;
}

.stepper-controls {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.stepper-controls .button {
  min-height: 34px;
  padding: 6px 10px;
}

.qr-card {
  align-items: center;
  display: flex;
  gap: 22px;
}

.qr-card img {
  background: #fff;
  border: 1px solid var(--line);
  padding: 8px;
}

.inventory-label-tools {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
}

.inventory-label-tools .checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
}

.inventory-label-tools .form-note { margin: 0; }
.label-select-column { text-align: center; width: 72px; }

.inventory-label-preview {
  align-items: flex-start;
  display: grid;
  gap: 14px;
  justify-items: start;
}

.inventory-label-preview > img {
  background: #fff;
  border: 1px solid var(--line);
  height: auto;
  max-width: 100%;
  width: 296px;
}

.inventory-label-preview .form-note { margin: 0; }

.color-group-select {
  min-height: 180px;
  padding: 8px;
}

.filter-toggle {
  display: none;
  margin-bottom: 12px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat strong {
  font-size: 26px;
}

.stat small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 6px;
}

.stat-emphasis strong {
  font-size: 34px;
  line-height: 1.1;
}

.stat-status strong {
  font-size: 22px;
  line-height: 1.3;
}

.stat-compact {
  padding: 16px 18px;
}

.stat-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.stat-list-row {
  align-items: baseline;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

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

.stat-list dd {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.stat-breakdown {
  grid-column: span 2;
}

.order-detail-stats {
  margin-bottom: 20px;
}

.order-guide {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 14px 18px;
}

.order-guide summary {
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 800;
}

.order-guide-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 14px;
}

.order-guide h2 {
  font-size: 16px;
  margin-bottom: 6px;
}

.order-guide p {
  color: var(--muted);
  margin: 0;
}

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

.detail-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.detail-panel h2 {
  margin-bottom: 14px;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.detail-list div {
  align-items: baseline;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding-top: 10px;
}

.detail-list div:first-child {
  border-top: 0;
  padding-top: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
}

.detail-list dd {
  font-weight: 700;
  margin: 0;
  text-align: right;
}

.detail-subvalue {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 400;
  margin-top: 2px;
}

.order-lines-table {
  min-width: 900px;
}

.dashboard-stats {
  margin-bottom: 20px;
}

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

.dashboard-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.dashboard-panel .section-heading {
  margin: 0 0 14px;
}

.website-stats-panel {
  margin-bottom: 20px;
}

.website-stats-summary-heading {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  list-style: none;
}

.website-stats-summary-heading::-webkit-details-marker {
  display: none;
}

.website-stats-summary-heading::after {
  color: var(--accent-dark);
  content: "Visa";
  font-size: 13px;
  font-weight: 700;
}

.website-stats-panel[open] .website-stats-summary-heading::after {
  content: "Dölj";
}

.website-stats-content {
  margin-top: 16px;
}

.website-stats-layout {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(320px, 1fr) minmax(360px, 1.2fr);
}

.website-stats-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.website-stats-summary .stat {
  background: var(--field-bg);
}

.website-stats-chart {
  align-items: end;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(30, minmax(4px, 1fr));
  min-height: 220px;
  padding: 16px;
}

.website-stats-bar {
  align-items: end;
  display: flex;
  height: 100%;
  min-width: 0;
}

.website-stats-bar span {
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  display: block;
  min-height: 2px;
  width: 100%;
}

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

.compact-list-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 48px;
  padding-top: 10px;
}

.compact-list-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.compact-list-row div {
  min-width: 0;
}

.compact-list-row strong,
.compact-list-row span {
  display: block;
}

.compact-list-row strong {
  font-size: 14px;
}

.compact-list-row span {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap {
  -webkit-overflow-scrolling: touch;
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.inventory-page {
  display: grid;
  gap: 22px;
}

.inventory-page > .page-heading,
.inventory-page > .filter-toggle,
.inventory-page > .filter-bar {
  margin-bottom: 0;
}

.inventory-average-grid {
  display: grid;
  gap: 18px;
}

.inventory-average-panel {
  min-width: 0;
}

.inventory-average-panel .section-heading {
  margin-top: 0;
}

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

.table-sort-button {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
  font: inherit;
  padding: 0;
  text-align: inherit;
  width: 100%;
}

.table-sort-button::after {
  content: "↕";
  flex: 0 0 auto;
  opacity: 0.45;
}

.table-sort-button[data-direction="asc"]::after { content: "↑"; opacity: 1; }
.table-sort-button[data-direction="desc"]::after { content: "↓"; opacity: 1; }

.compact-table {
  min-width: 560px;
}

.inventory-summary-table {
  min-width: 0;
  width: 100%;
}

@media (min-width: 1180px) {
  .inventory-average-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: var(--soft);
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}

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

tr.is-low td {
  background: #fff8e7;
}

tr.is-negative td {
  background: #fff0ed;
}

.order-group-row td {
  background: #f5faf7;
  border-top: 1px solid var(--line);
}

.order-toggle {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--accent-dark);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 800;
  height: 28px;
  justify-content: center;
  margin-right: 8px;
  padding: 0;
  vertical-align: middle;
  width: 28px;
}

.order-toggle:hover {
  background: var(--soft);
}

.order-total-row td {
  background: var(--field-bg);
  border-top: 1px solid var(--line);
}

.order-total-row strong {
  color: var(--accent-dark);
}

.order-total-subtext {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.3;
  margin-top: 2px;
}

.is-negative-text {
  color: var(--danger) !important;
}

.order-detail-row td {
  background: #fff;
}

.order-detail-row td:first-child {
  border-right: 1px solid var(--line);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product-table td.num {
  padding-right: 25px;
  text-align: right;
}

.row-action {
  text-align: right;
}

.order-summary-cell {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  white-space: normal;
}

.order-summary-actions {
  flex: 0 0 auto;
  white-space: nowrap;
}

.row-action form {
  display: inline;
  margin: 0 0 0 10px;
}

.row-action a {
  color: var(--accent-dark);
  font-weight: 700;
  margin-left: 10px;
  text-decoration: none;
}

.row-action a:hover {
  text-decoration: underline;
}

.row-action .inline-action-form {
  display: inline;
  margin: 0 0 0 10px;
}

.is-inactive-row {
  color: var(--muted);
  opacity: 0.72;
}

.is-inactive-row .table-link {
  color: var(--muted);
}

.inactive-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-block;
  font-size: 11px;
  margin-right: 6px;
  padding: 2px 7px;
  vertical-align: middle;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-decoration: none;
}

.link-button:hover {
  text-decoration: underline;
}

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

.table-link {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.table-link:hover {
  text-decoration: underline;
}

.status-pill {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  white-space: nowrap;
}

.status-pill.is-synced {
  background: var(--soft);
  color: var(--accent-dark);
}

.status-pill.job-status-pending {
  background: #fff7db;
  border-color: #ecd48a;
  color: #7a5a00;
}

.status-pill.job-status-running {
  background: #e8f4ff;
  border-color: #a7cbed;
  color: #195a8a;
}

.status-pill.job-status-success {
  background: #e5f7ed;
  border-color: #9ed7b7;
  color: #1c6b3e;
}

.status-pill.job-status-failed {
  background: #fde8e8;
  border-color: #efabab;
  color: #9b1c1c;
}

.tooltip-trigger {
  border-bottom: 1px dotted var(--muted);
  cursor: help;
  display: inline-block;
  position: relative;
}

.tooltip-trigger:focus {
  outline: 2px solid var(--soft);
  outline-offset: 2px;
}

.floating-tooltip {
  background: var(--ink);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(1, 57, 67, 0.18);
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  padding: 8px 10px;
  pointer-events: none;
  position: fixed;
  text-align: left;
  white-space: pre;
  z-index: 1000;
}

.detail-stats {
  margin-bottom: 8px;
}

.inventory-overview-table {
  table-layout: fixed;
}

.inventory-overview-table .overview-name {
  width: 42%;
}

.inventory-overview-table .overview-balance {
  width: 14%;
}

.inventory-overview-table .overview-price {
  width: 20%;
}

.inventory-overview-table .overview-count {
  width: 10%;
}

.inventory-overview-table .overview-action {
  width: 14%;
}

.inventory-count-table {
  table-layout: fixed;
}

.inventory-count-table .inventory-count-label {
  width: 7%;
}

.inventory-count-table .inventory-count-id {
  width: 14%;
}

.inventory-count-table .inventory-count-supplier {
  width: 18%;
}

.inventory-count-table .inventory-count-balance {
  width: 13%;
}

.inventory-count-table .inventory-count-ended {
  width: 8%;
}

.inventory-count-table .inventory-count-gross,
.inventory-count-table .inventory-count-spool {
  width: 20%;
}

.inventory-count-table input.input {
  height: 40px;
  min-height: 40px;
}

.inventory-floating-save {
  bottom: max(18px, env(safe-area-inset-bottom));
  box-shadow: 0 8px 24px rgba(1, 57, 67, 0.28);
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  z-index: 15;
}

.inventory-floating-save[hidden] {
  display: none;
}

.inventory-count-errors {
  margin-bottom: 18px;
}

.inventory-count-errors p {
  margin: 6px 0 0;
}

.inventory-count-table tr.inventory-count-row-error {
  box-shadow: inset 4px 0 0 var(--danger);
}

.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.form-section {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  padding: 24px 0;
}

.form-section:first-of-type {
  border-top: 0;
  padding-top: 12px;
}

.form-section-heading h3 {
  color: var(--accent-dark);
  font-size: 17px;
  margin: 0 0 6px;
}

.form-section-heading p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
}

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

.utility-panel {
  margin-top: 12px;
}

.bulk-edit-panel {
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 14px;
}

.bulk-edit-grid {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(180px, 220px) minmax(220px, 260px) auto;
}

.bulk-edit-actions {
  align-self: start;
  margin-top: 0;
  padding-top: 24px;
}

.bulk-edit-panel .form-note {
  margin: 8px 0 0;
}

.bulk-edit-panel .form-field small {
  min-height: 0;
}

.bulk-sync-toolbar {
  align-items: center;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 14px;
  padding: 12px 14px;
}

.bulk-sync-toolbar strong {
  margin-right: auto;
}

.bulk-sync-toolbar .checkbox-label {
  margin: 0;
}

.bulk-sync-panel .bulk-sync-toolbar {
  background: transparent;
  border: 0;
  margin-bottom: 0;
  padding: 0;
}

.bulk-sync-panel .bulk-sync-toolbar[hidden] {
  display: none;
}

.bulk-sync-panel .button {
  background: var(--field-bg);
  border: 1px solid var(--line);
  min-height: 38px;
}

.bulk-sync-panel .button:hover {
  background: var(--soft);
}

.bulk-sync-panel .button.primary,
.bulk-sync-panel .button.primary:hover {
  background: var(--accent);
  color: #ffffff;
}

.product-table .bulk-sync-column {
  width: 42px;
}

.auth-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 64px auto 0;
  max-width: 460px;
  padding: 24px;
}

.auth-panel h1 {
  margin-bottom: 18px;
}

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

.auth-panel input[type="text"],
.auth-panel input[type="password"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  font: inherit;
}

.turnstile-field {
  margin-top: 16px;
}

.form-note {
  color: var(--muted);
  margin: 0 0 18px;
}

.image-result {
  display: grid;
  grid-template-columns: minmax(280px, 520px) minmax(220px, 1fr);
  gap: 20px;
  align-items: start;
}

.image-preview {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.image-preview img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 6px;
}

.image-meta {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 18px;
}

.image-meta div + div {
  border-top: 1px solid var(--line);
  margin-top: 12px;
  padding-top: 12px;
}

.image-meta dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.image-meta dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
}

.image-library {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

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

.image-card-preview {
  display: block;
  aspect-ratio: 1;
  background: var(--bg);
}

.image-card-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-card-body {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.image-card-body span {
  color: var(--muted);
  font-size: 13px;
}

.image-card-body a {
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent-dark);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 0;
  text-align: left;
}

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

.product-image-library {
  margin-bottom: 8px;
}

.inline-image-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.inline-image-item {
  position: relative;
}

.inline-image-list a {
  display: block;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.inline-image-list img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-delete-button {
  align-items: center;
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-flex;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 1px 4px rgba(1, 57, 67, 0.25);
  color: #ffffff;
  cursor: pointer;
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 800;
  line-height: 18px;
  padding: 0;
}

.image-delete-button:hover {
  background: var(--danger-dark);
}

.image-upload-button {
  align-items: center;
  position: absolute;
  right: -6px;
  bottom: -6px;
  display: inline-flex;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 1px 4px rgba(1, 57, 67, 0.25);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 18px;
  padding: 0;
}

.image-upload-button:hover {
  background: var(--accent-hover);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
  gap: 16px;
}

.adjustment-grid {
  grid-template-columns: minmax(220px, 420px);
}

.form-field {
  display: grid;
  gap: 6px;
}

.product-form-category-field {
  grid-column: 1 / -1;
}

.product-form-category-field select {
  min-height: 220px;
}

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

.form-field label {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  background: var(--field-bg);
  color: var(--ink);
  font: inherit;
  box-shadow: 0 1px 2px rgba(1, 57, 67, 0.05);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: none;
  outline: 2px solid var(--soft);
}

.input.is-calculated,
.search-select-native.is-calculated + .search-select-input {
  background-color: var(--soft);
}

.search-select-native.is-calculated + .search-select-input {
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 17px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 17px / 6px 6px no-repeat,
    var(--soft);
}

select.input {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 17px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 17px / 6px 6px no-repeat,
    var(--field-bg);
  padding-right: 34px;
}

.search-select {
  position: relative;
}

.search-select-native {
  display: none;
}

.search-select-input {
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 17px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 17px / 6px 6px no-repeat,
    var(--field-bg);
  cursor: pointer;
  padding-right: 34px;
}

.search-select-input:focus {
  border-color: var(--accent);
  outline: 2px solid var(--soft);
}

.search-select-list {
  position: fixed;
  z-index: 1100;
  max-height: 260px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(1, 57, 67, 0.14);
  padding: 4px;
}

.search-select-option {
  border-radius: 4px;
  cursor: pointer;
  padding: 8px 10px;
}

.search-select-option:hover,
.search-select-option.is-active {
  background: var(--soft);
}

.search-select-empty {
  color: var(--muted);
  padding: 8px 10px;
}

textarea.input {
  resize: vertical;
}

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

.richtext-toolbar {
  align-items: center;
  background: var(--field-bg);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
}

.richtext-heading {
  max-width: 160px;
  min-height: 36px;
}

.richtext-button {
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-flex;
  gap: 6px;
  min-height: 36px;
  padding: 6px 10px;
}

.richtext-button.is-active {
  background: var(--soft);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
  color: var(--accent-dark);
}

.richtext-editor {
  background: var(--panel);
  min-height: 140px;
  outline: none;
  padding: 12px 14px;
}

.richtext-editor:focus {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 35%, transparent);
}

.richtext-editor h4,
.richtext-editor h5,
.richtext-editor p,
.richtext-editor ul,
.richtext-content h1,
.richtext-content h2,
.richtext-content h3,
.richtext-content h4,
.richtext-content h5,
.richtext-content h6,
.richtext-content p,
.richtext-content ul,
.richtext-content ol {
  margin: 0 0 12px;
}

.richtext-editor ul,
.richtext-content ul,
.richtext-content ol {
  padding-left: 22px;
}

.richtext-editor p:last-child,
.richtext-editor ul:last-child,
.richtext-editor h4:last-child,
.richtext-editor h5:last-child,
.richtext-content > :last-child {
  margin-bottom: 0;
}

.richtext-content {
  color: var(--ink);
  line-height: 1.65;
}

.richtext-content h1,
.richtext-content h2,
.richtext-content h3 {
  color: var(--accent-dark);
  font-family: "Questrial", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 20px;
  font-weight: 400;
  line-height: 1.25;
}

.richtext-content h4,
.richtext-content h5,
.richtext-content h6 {
  color: var(--accent-dark);
  font-size: 15px;
  line-height: 1.35;
}

.richtext-content a {
  color: var(--accent);
}

.richtext-content img,
.richtext-content iframe,
.richtext-content video {
  display: block;
  height: auto;
  max-width: 100%;
}

.richtext-content table {
  border-collapse: collapse;
  max-width: 100%;
}

.richtext-content th,
.richtext-content td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
}

.checkbox {
  width: 18px;
  height: 18px;
}

.radio {
  margin: 0;
}

.form-field div:has(.radio) {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.form-field div:has(.radio) label {
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  gap: 8px;
  min-height: 36px;
  padding: 7px 9px;
}

.checkbox-list {
  display: grid;
  gap: 8px 12px;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  margin: 0;
}

.checkbox-list div {
  min-width: 0;
}

.checkbox-list label {
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  min-height: 36px;
  padding: 7px 9px;
}

.checkbox-list input {
  margin: 0;
}

.form-field-checkbox {
  align-content: start;
}

.form-field small {
  color: var(--muted);
  min-height: 18px;
}

.inventory-document-items {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 0;
  max-height: 720px;
  overflow-y: auto;
  padding: 0;
}

.inventory-document-items li {
  min-width: 0;
}

.inventory-document-items label {
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  font-size: 12px;
  gap: 6px;
  line-height: 1.25;
  min-height: 30px;
  padding: 5px 7px;
}

.inventory-document-items label[hidden] {
  display: none;
}

.inventory-document-items label > span {
  min-width: 0;
}

.inventory-document-item-details {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 400;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inventory-document-items input[type="checkbox"] {
  flex: 0 0 auto;
  height: 16px;
  margin: 0;
  width: 16px;
}

.inventory-document-filters {
  display: grid;
  gap: 4px 8px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 8px;
}

.inventory-document-filters label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

@media (max-width: 600px) {
  .inventory-document-filters {
    grid-template-columns: 1fr;
  }
}

.field-error,
.form-errors {
  color: var(--danger);
  font-size: 13px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.split-actions .button.danger {
  margin-left: auto;
}

.formset-wrap {
  border-radius: 6px;
  overflow: visible;
}

.add-row-button {
  margin-top: 10px;
}

.formset-table {
  min-width: 100%;
  table-layout: fixed;
}

.formset-table td {
  vertical-align: top;
  white-space: normal;
}

.formset-table .input {
  min-width: 0;
}

.formset-table select.input {
  min-width: 0;
}

.actual-material-table {
  min-width: 920px;
}

.actual-material-cell {
  display: grid;
  gap: 8px;
}

.actual-material-info {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  gap: 4px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  line-height: 1.35;
  min-height: 82px;
  padding: 9px 10px;
}

.actual-material-readonly {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  display: grid;
  gap: 3px;
  min-height: 40px;
  padding: 8px 10px;
}

.actual-material-readonly span {
  color: var(--muted);
  font-size: 13px;
}

.actual-material-info span:first-child {
  color: var(--text);
  font-weight: 700;
}

.actual-material-info [data-info-part],
.actual-material-info [data-info-material],
.actual-material-info [data-info-amount],
.actual-material-info [data-info-time],
.actual-material-info [data-info-stock] {
  grid-column: 1;
}

.actual-material-info [data-info-product-material-cost],
.actual-material-info [data-info-product-machine-cost],
.actual-material-info [data-info-product-total-cost] {
  grid-column: 2;
}

.actual-material-info [data-info-product-total-cost],
.actual-material-cost-info [data-actual-total-cost] {
  color: var(--text);
  font-weight: 700;
}

.actual-material-fields {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(80px, 0.35fr) minmax(64px, 0.3fr) minmax(120px, 0.55fr) minmax(160px, 1fr);
}

.actual-material-fields label {
  color: var(--accent-dark);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
  text-transform: uppercase;
}

.actual-material-cost-info {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 10px 16px;
  padding: 8px 10px;
}

.variant-formset-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

table.variant-formset-table {
  min-width: 980px;
  table-layout: fixed;
}

table.variant-formset-table th:nth-child(1),
table.variant-formset-table td:nth-child(1) {
  width: 18%;
}

table.variant-formset-table th:nth-child(2),
table.variant-formset-table td:nth-child(2) {
  width: 25%;
}

table.variant-formset-table th:nth-child(3),
table.variant-formset-table td:nth-child(3) {
  width: 8%;
}

table.variant-formset-table th:nth-child(5),
table.variant-formset-table td:nth-child(5) {
  width: 15%;
}

table.variant-formset-table th:nth-child(6),
table.variant-formset-table td:nth-child(6) {
  width: 8%;
}

table.variant-formset-table th:nth-child(4),
table.variant-formset-table td:nth-child(4) {
  width: 12%;
}

table.variant-formset-table th:nth-child(7),
table.variant-formset-table td:nth-child(7) {
  width: 10%;
}

table.variant-formset-table th:nth-child(8),
table.variant-formset-table td:nth-child(8) {
  width: 4%;
}

table.variant-formset-table th {
  line-height: 1.2;
  white-space: normal;
  vertical-align: middle;
}

.sku-input {
  align-items: stretch;
  display: flex;
  flex-wrap: nowrap;
  min-width: 0;
  width: 100%;
}

.sku-prefix {
  align-items: center;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-right: 0;
  border-radius: 6px 0 0 6px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-weight: 700;
  min-height: 40px;
  padding: 0 10px;
  white-space: nowrap;
}

.sku-input .input {
  border-radius: 0 6px 6px 0;
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.delete-cell {
  text-align: center;
}

.formset-table th:nth-child(1),
.formset-table td:nth-child(1) {
  width: 15%;
}

.formset-table th:nth-child(2),
.formset-table td:nth-child(2) {
  width: 28%;
}

.formset-table th:nth-child(3),
.formset-table td:nth-child(3) {
  width: 10%;
}

.formset-table th:nth-child(4),
.formset-table td:nth-child(4) {
  width: 10%;
}

.formset-table th:nth-child(5),
.formset-table td:nth-child(5) {
  width: 14%;
}

.formset-table th:nth-child(6),
.formset-table td:nth-child(6) {
  width: 18%;
}

.formset-table th:nth-child(7),
.formset-table td:nth-child(7) {
  width: 5%;
}

.bom-formset-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

table.bom-formset-table {
  min-width: 1280px;
}

table.bom-formset-table th:nth-child(1),
table.bom-formset-table td:nth-child(1) {
  width: 12%;
}

table.bom-formset-table th:nth-child(2),
table.bom-formset-table td:nth-child(2) {
  width: 14%;
}

table.bom-formset-table th:nth-child(3),
table.bom-formset-table td:nth-child(3) {
  width: 12%;
}

table.bom-formset-table th:nth-child(4),
table.bom-formset-table td:nth-child(4) {
  width: 20%;
}

table.bom-formset-table th:nth-child(5),
table.bom-formset-table td:nth-child(5) {
  width: 9%;
}

table.bom-formset-table th:nth-child(6),
table.bom-formset-table td:nth-child(6) {
  width: 8%;
}

table.bom-formset-table th:nth-child(7),
table.bom-formset-table td:nth-child(7) {
  width: 10%;
}

table.bom-formset-table th:nth-child(8),
table.bom-formset-table td:nth-child(8) {
  width: 11%;
}

table.bom-formset-table th:nth-child(9),
table.bom-formset-table td:nth-child(9) {
  width: 4%;
}

/* Product edit BOM: keep the type selector separate from the calculated unit. */
table.bom-formset-table th:nth-child(1), table.bom-formset-table td:nth-child(1) { width: 11%; }
table.bom-formset-table th:nth-child(2), table.bom-formset-table td:nth-child(2) { width: 10%; }
table.bom-formset-table th:nth-child(3), table.bom-formset-table td:nth-child(3) { width: 13%; }
table.bom-formset-table th:nth-child(4), table.bom-formset-table td:nth-child(4) { width: 11%; }
table.bom-formset-table th:nth-child(5), table.bom-formset-table td:nth-child(5) { width: 18%; }
table.bom-formset-table th:nth-child(6), table.bom-formset-table td:nth-child(6) { width: 8%; }
table.bom-formset-table th:nth-child(7), table.bom-formset-table td:nth-child(7) { width: 8%; }
table.bom-formset-table th:nth-child(8), table.bom-formset-table td:nth-child(8) { width: 9%; }
table.bom-formset-table th:nth-child(9), table.bom-formset-table td:nth-child(9) { width: 8%; }
table.bom-formset-table th:nth-child(10), table.bom-formset-table td:nth-child(10) { width: 4%; }

/* Keep conditional BOM columns aligned with the header when their contents are hidden. */
table.bom-formset-table td[data-filament-bom-field][hidden],
table.bom-formset-table td[data-material-bom-field][hidden] {
  display: table-cell !important;
  visibility: hidden;
}

.development-formset-wrap {
  overflow-x: auto;
  overflow-y: hidden;
}

table.development-line-formset-table {
  min-width: 850px;
}

table.development-line-formset-table th:nth-child(1),
table.development-line-formset-table td:nth-child(1) {
  width: 38%;
}

table.development-line-formset-table th:nth-child(2),
table.development-line-formset-table td:nth-child(2) {
  width: 12%;
}

table.development-line-formset-table th:nth-child(3),
table.development-line-formset-table td:nth-child(3) {
  width: 10%;
}

table.development-line-formset-table th:nth-child(4),
table.development-line-formset-table td:nth-child(4) {
  width: 12%;
}

table.development-line-formset-table th:nth-child(5),
table.development-line-formset-table td:nth-child(5) {
  width: 23%;
}

table.development-line-formset-table th:nth-child(6),
table.development-line-formset-table td:nth-child(6) {
  width: 5%;
}

@media (min-width: 761px) {
  table.bom-formset-table {
    display: block;
    min-width: 0;
    width: 100%;
  }

  table.bom-formset-table thead {
    display: none;
  }

  table.bom-formset-table tbody {
    display: grid;
    gap: 12px;
  }

  table.bom-formset-table tbody tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 0 12px;
    grid-template-columns: minmax(140px, 1.15fr) minmax(130px, 1fr) minmax(150px, 1.2fr) minmax(140px, 1.1fr) minmax(180px, 1.5fr);
    grid-template-areas:
      "description type category variant article"
      "amount unit time comment delete";
    align-items: start;
    padding: 10px 12px;
  }

  table.bom-formset-table td {
    align-content: start;
    border: 0;
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 6px 0;
    width: auto !important;
  }

  table.bom-formset-table td::before {
    color: var(--muted);
    content: "";
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    min-height: 27px;
    text-transform: uppercase;
  }

  table.bom-formset-table td > .input,
  table.bom-formset-table td > select,
  table.bom-formset-table td > textarea {
    min-width: 0;
    width: 100%;
  }

  table.bom-formset-table td:nth-child(1) { grid-area: description; }
  table.bom-formset-table td:nth-child(2) { grid-area: type; }
  table.bom-formset-table td:nth-child(3) { grid-area: category; }
  table.bom-formset-table td:nth-child(4) { grid-area: variant; }
  table.bom-formset-table td:nth-child(5) { grid-area: article; }
  table.bom-formset-table td:nth-child(6) { grid-area: amount; }
  table.bom-formset-table td:nth-child(7) { grid-area: unit; }
  table.bom-formset-table td:nth-child(8) { grid-area: time; }
  table.bom-formset-table td:nth-child(9) { grid-area: comment; }
  table.bom-formset-table td:nth-child(10) { grid-area: delete; }

  table.bom-formset-table td:nth-child(1)::before { content: "Beskrivning"; }
  table.bom-formset-table td:nth-child(2)::before { content: "Typ"; }
  table.bom-formset-table td:nth-child(3)::before { content: "Plast/kategori"; }
  table.bom-formset-table td:nth-child(4)::before { content: "Färg/variant"; }
  table.bom-formset-table td:nth-child(5)::before { content: "Materialartikel"; }
  table.bom-formset-table td:nth-child(6)::before { content: "Mängd"; }
  table.bom-formset-table td:nth-child(7)::before { content: "Enhet"; }
  table.bom-formset-table td:nth-child(8)::before { content: "Tid"; }
  table.bom-formset-table td:nth-child(9)::before { content: "Kommentar"; }
  table.bom-formset-table td:nth-child(10)::before { content: "Radera"; }

  table.bom-formset-table td[data-filament-bom-field][hidden],
  table.bom-formset-table td[data-material-bom-field][hidden] {
    display: grid !important;
  }
}

table.actual-material-table th:nth-child(1),
table.actual-material-table td:nth-child(1) {
  width: 42%;
}

table.actual-material-table th:nth-child(2),
table.actual-material-table td:nth-child(2) {
  width: 51%;
}

table.actual-material-table th:nth-child(3),
table.actual-material-table td:nth-child(3) {
  width: 7%;
}

@media (max-width: 1180px) {
  .topbar {
    min-height: 58px;
    padding: 0 18px;
  }

  .brand {
    max-width: calc(100% - 56px);
    min-width: 0;
  }

  .brand-logo {
    height: 34px;
    max-width: min(210px, 58vw);
    object-fit: contain;
  }

  .menu-toggle {
    display: inline-grid;
    gap: 4px;
    align-content: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    cursor: pointer;
    padding: 0;
  }

  .menu-toggle span:not(.sr-only) {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--accent-dark);
  }

  .site-nav {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 4px;
    width: min(320px, 82vw);
    height: 100vh;
    padding: 18px;
    background: var(--panel);
    border-left: 1px solid var(--line);
    box-shadow: -16px 0 40px rgba(1, 57, 67, 0.16);
    transform: translateX(100%);
    transition: transform 180ms ease;
  }

  body.menu-open .site-nav {
    transform: translateX(0);
  }

  body.menu-open {
    overflow: hidden;
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 19;
    display: block;
    background: rgba(1, 57, 67, 0.28);
  }

  .nav-backdrop[hidden] {
    display: none;
  }

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

  .menu-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--accent-dark);
    cursor: pointer;
    font: inherit;
    font-weight: 800;
  }

  .site-nav a,
  .site-nav button {
    width: 100%;
    min-height: 42px;
    text-align: left;
  }

  .site-nav .logout-form {
    width: 100%;
  }

  table {
    min-width: 980px;
  }

  .hide-tablet {
    display: none;
  }

  .inventory-table {
    min-width: 760px;
  }

  .sales-table {
    min-width: 820px;
  }

  .variant-table {
    min-width: 760px;
  }

  .product-table {
    min-width: 820px;
  }

}

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

  .bulk-sync-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .inventory-overview-table {
    min-width: 0;
  }

  .inventory-overview-table colgroup,
  .inventory-overview-table thead {
    display: none;
  }

  .inventory-overview-table tbody {
    display: block;
  }

  .inventory-overview-table tbody tr {
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 0 10px;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    margin-bottom: 10px;
    overflow: hidden;
  }

  .inventory-overview-table .filament-overview-row {
    grid-template-areas:
      "name name name action"
      "count balance price price";
  }

  .inventory-overview-table .material-overview-row {
    grid-template-areas:
      "name name name action"
      "balance price price price";
  }

  .inventory-overview-table td {
    border: 0;
    min-width: 0;
    padding: 10px 12px;
  }

  .inventory-overview-table .overview-name-cell {
    align-self: center;
    grid-area: name;
  }

  .inventory-overview-table .overview-count-cell {
    grid-area: count;
  }

  .inventory-overview-table .overview-balance-cell {
    grid-area: balance;
  }

  .inventory-overview-table .overview-price-cell {
    grid-area: price;
  }

  .inventory-overview-table .overview-action-cell {
    align-self: center;
    grid-area: action;
  }

  .inventory-overview-table .overview-count-cell,
  .inventory-overview-table .overview-balance-cell,
  .inventory-overview-table .overview-price-cell {
    background: var(--soft);
    text-align: left;
  }

  .inventory-overview-table td[data-label]::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 11px;
    margin-bottom: 3px;
  }

  .inventory-overview-table .overview-empty-cell {
    display: none;
  }

  .inventory-overview-table .overview-action-cell .button {
    white-space: nowrap;
  }

  .linked-product-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    align-items: center;
    flex-direction: row;
    padding: 14px 18px;
  }

  .brand {
    line-height: 1.2;
  }

  .brand-text {
    display: none;
  }

  nav,
  .actions,
  .form-actions {
    width: 100%;
  }

  nav a,
  nav button,
  .button {
    min-height: 40px;
  }

  .actions .button,
  .actions form,
  .form-actions .button {
    flex: 1 1 0;
    min-width: 0;
    text-align: center;
  }

  .page-heading .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .page-heading .actions form,
  .page-heading .actions .button {
    width: 100%;
  }

  .page-heading .actions .button {
    white-space: normal;
  }

  .inline-action-form button {
    width: 100%;
  }

  .page {
    width: min(100% - 20px, 1400px);
    margin-top: 18px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

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

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

  .stat {
    min-width: 0;
    padding: 14px;
  }

  .stat-list-row,
  .stat-list dt,
  .stat-list dd {
    min-width: 0;
  }

  .stat-list dt,
  .stat-list dd {
    overflow-wrap: anywhere;
  }

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

  .stat-emphasis strong {
    font-size: 26px;
  }

  .stat-status strong {
    font-size: 18px;
  }

  .stat-breakdown {
    grid-column: auto;
  }

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

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

  .website-stats-chart {
    min-height: 180px;
    padding: 12px;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .inventory-filter-bar {
    grid-template-areas:
      "search"
      "sort"
      "ended"
      "without"
      "type"
      "owner"
      "plastic-type"
      "category"
      "color"
      "reset";
  }

  .filter-bar label {
    min-height: 38px;
  }

  .filter-toggle {
    display: inline-flex;
  }

  .inventory-filter-bar {
    display: none;
  }

  .inventory-filter-bar.is-open {
    display: grid;
  }

  .hide-mobile {
    display: none;
  }

  th,
  td {
    padding: 9px 10px;
  }

  .inventory-summary-table th,
  .inventory-summary-table td {
    white-space: normal;
    word-break: break-word;
  }

  .inventory-summary-table {
    min-width: 0;
  }

  .inventory-summary-table thead {
    display: none;
  }

  .inventory-summary-table tbody,
  .inventory-summary-table tr {
    display: block;
  }

  .inventory-summary-table tr {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
  }

  .inventory-summary-table tr:last-child {
    border-bottom: 0;
  }

  .inventory-summary-table td {
    border: 0;
    min-width: 0;
    padding: 4px 0;
  }

  .inventory-summary-table .summary-name {
    color: var(--accent-dark);
    font-weight: 700;
    padding-bottom: 8px;
  }

  .inventory-summary-table td[data-label] {
    display: inline-block;
    margin-right: 14px;
    text-align: left;
    vertical-align: top;
  }

  .inventory-summary-table td[data-label]::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 400;
    margin-bottom: 2px;
  }

  .inventory-table {
    min-width: 640px;
  }

  .sales-table {
    min-width: 700px;
  }

  .variant-table {
    min-width: 640px;
  }

  .product-table {
    min-width: 680px;
  }

  .form-panel {
    padding: 14px;
  }

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

  .form-section {
    gap: 12px;
    grid-template-columns: 1fr;
    padding: 20px 0;
  }

  .bulk-edit-grid {
    grid-template-columns: 1fr;
  }

  .bulk-edit-actions {
    margin-top: 4px;
  }

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

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

  .image-result {
    grid-template-columns: 1fr;
  }

  .split-actions .button.danger {
    margin-left: 0;
  }

  .formset-wrap {
    background: transparent;
    border: 0;
    overflow: visible;
  }

  .formset-table {
    border-collapse: separate;
    border-spacing: 0 12px;
    min-width: 0;
  }

  table.variant-formset-table {
    min-width: 0;
  }

  table.bom-formset-table {
    min-width: 0;
  }

  table.development-line-formset-table {
    min-width: 0;
  }

  .formset-table,
  .formset-table thead,
  .formset-table tbody,
  .formset-table tr,
  .formset-table td {
    display: block;
    width: 100%;
  }

  .formset-table thead {
    display: none;
  }

  .formset-table tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
  }

  .formset-table td {
    border-bottom: 0;
    padding: 8px 0;
  }

  .formset-table td:nth-child(n) {
    width: 100%;
  }

  .bom-formset-table td[data-filament-bom-field][hidden],
  .bom-formset-table td[data-material-bom-field][hidden] {
    display: block !important;
  }

  .formset-table td::before {
    color: var(--accent-dark);
    display: block;
    font-size: 12px;
    font-weight: 800;
    margin-bottom: 5px;
    text-transform: uppercase;
  }

  .bom-formset-table td:nth-child(1)::before {
    content: "Beskrivning";
  }

  .bom-formset-table td:nth-child(2)::before {
    content: "Typ";
  }

  .bom-formset-table td:nth-child(3)::before {
    content: "Plast/kategori";
  }

  .bom-formset-table td:nth-child(4)::before {
    content: "Färg/variant";
  }

  .bom-formset-table td:nth-child(5)::before {
    content: "Materialartikel";
  }

  .bom-formset-table td:nth-child(6)::before {
    content: "Mängd";
  }

  .bom-formset-table td:nth-child(7)::before {
    content: "Enhet";
  }

  .bom-formset-table td:nth-child(8)::before {
    content: "Tid";
  }

  .bom-formset-table td:nth-child(9)::before {
    content: "Kommentar";
  }

  .bom-formset-table td:nth-child(10)::before,
  .variant-formset-table td:nth-child(8)::before,
  .development-line-formset-table td:nth-child(6)::before {
    content: "Radera";
  }

  .variant-formset-table td:nth-child(1)::before {
    content: "Färg";
  }

  .variant-formset-table td:nth-child(2)::before {
    content: "SKU";
  }

  .variant-formset-table td:nth-child(3)::before {
    content: "Aktiv";
  }

  .variant-formset-table td:nth-child(4)::before {
    content: "Antal i lager";
  }

  .variant-formset-table td:nth-child(5)::before {
    content: "Eget pris inkl moms";
  }

  .variant-formset-table td:nth-child(6)::before {
    content: "Sortering";
  }

  .variant-formset-table td:nth-child(7)::before {
    content: "3MF-fil";
  }

  .variant-formset-table td:nth-child(8)::before {
    content: "Radera";
  }

  .variant-formset-table tr {
    display: block;
  }

  .variant-formset-table td {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 8px 0;
  }

  table.variant-formset-table td:nth-child(n) {
    width: 100%;
  }

  .variant-formset-table td:nth-child(3),
  .variant-formset-table td:nth-child(8) {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .variant-formset-table td:nth-child(3)::before,
  .variant-formset-table td:nth-child(8)::before {
    margin-bottom: 0;
  }

  .variant-formset-table .input,
  .variant-formset-table select.input,
  table.variant-formset-table input.input,
  table.variant-formset-table select.input {
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  .variant-formset-table .sku-input {
    width: 100%;
  }

  .variant-formset-table input[type="checkbox"] {
    flex: 0 0 auto;
  }

  .development-line-formset-table td:nth-child(1)::before {
    content: "Lagerpost";
  }

  .development-line-formset-table td:nth-child(2)::before {
    content: "Mängd";
  }

  .development-line-formset-table td:nth-child(3)::before {
    content: "Enhet";
  }

  .development-line-formset-table td:nth-child(4)::before {
    content: "Tid";
  }

  .development-line-formset-table td:nth-child(5)::before {
    content: "Kommentar";
  }

  .actual-material-table td:nth-child(1)::before {
    content: "Produktens materialrad";
  }

  .actual-material-table td:nth-child(2)::before {
    content: "Faktisk rulle/material";
  }

  .actual-material-table td:nth-child(3)::before {
    content: "Radera";
  }

  .actual-material-fields {
    grid-template-columns: 1fr;
  }

  .actual-material-table tr {
    padding: 14px;
  }

  .actual-material-table td {
    padding: 10px 0;
  }

  .actual-material-table .actual-material-cell,
  .actual-material-table .actual-material-fields {
    width: 100%;
  }

  .actual-material-table select.input,
  .actual-material-table input.input {
    min-width: 0;
    width: 100%;
  }

  .actual-material-info {
    grid-template-columns: 1fr;
  }

  .actual-material-info [data-info-product-material-cost],
  .actual-material-info [data-info-product-machine-cost],
  .actual-material-info [data-info-product-total-cost] {
    grid-column: 1;
  }

  .delete-cell {
    text-align: left;
  }

}

@media (max-width: 900px) {
  .table-wrap:has(.inventory-count-table) {
    overflow: visible;
  }

  table.inventory-count-table {
    min-width: 0;
    table-layout: auto;
  }

  .inventory-count-table colgroup,
  .inventory-count-table thead {
    display: none;
  }

  .inventory-count-table tbody {
    display: block;
  }

  .inventory-count-table tr[data-inventory-count-row] {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 0 10px;
    grid-template-areas:
      "label stock stock ended"
      "label supplier supplier ended"
      "balance balance balance balance"
      "gross gross spool spool";
    grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) auto;
    margin-bottom: 12px;
    overflow: hidden;
    width: 100%;
  }

  .inventory-count-table tr[data-inventory-count-row] td {
    border: 0;
    min-width: 0;
    padding: 10px 12px;
    text-align: left;
    width: auto;
  }

  .inventory-count-table .inventory-count-label-cell {
    align-items: center;
    display: flex;
    grid-area: label;
    justify-content: center;
    padding-right: 0;
  }

  .inventory-count-table .inventory-count-id-cell {
    align-self: end;
    font-weight: 800;
    grid-area: stock;
    padding-bottom: 2px;
  }

  .inventory-count-table .inventory-count-supplier-cell {
    color: var(--muted);
    font-size: 13px;
    grid-area: supplier;
    padding-top: 2px;
  }

  .inventory-count-table .inventory-count-balance-cell {
    background: var(--soft);
    grid-area: balance;
  }

  .inventory-count-table .inventory-count-ended-cell {
    align-self: center;
    grid-area: ended;
  }

  .inventory-count-table .inventory-count-gross-cell {
    grid-area: gross;
  }

  .inventory-count-table .inventory-count-spool-cell {
    grid-area: spool;
  }

  .inventory-count-table td[data-label]::before {
    color: var(--muted);
    content: attr(data-label);
    display: block;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 5px;
  }

  .inventory-count-table .input {
    min-width: 0;
    width: 100%;
  }
}
