:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #121723;
  --muted: #687385;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --accent: #f97316;
  --danger: #b42318;
  --warning: #92400e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 64px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 8px;
}

nav a {
  min-width: 104px;
  padding: 10px 14px;
  border-radius: 6px;
  color: var(--muted);
  text-align: center;
  text-decoration: none;
}

nav a.active,
nav a:hover {
  background: #e7f5f2;
  color: var(--brand-dark);
}

main {
  width: min(1440px, calc(100vw - 32px));
  margin: 26px auto 56px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

p {
  margin: 8px 0 0;
  color: var(--muted);
}

.page-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.page-head {
  margin-bottom: 22px;
}

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

.auth-shell {
  display: grid;
  min-height: calc(100vh - 180px);
  place-items: center;
}

.auth-panel {
  width: min(420px, 100%);
}

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

.toolbar,
.inline-fields {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  margin: 16px 0;
}

.toolbar label {
  min-width: 140px;
}

.inline-fields.wide label {
  min-width: 190px;
}

label {
  display: grid;
  gap: 6px;
  color: #374151;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  max-width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 500;
  padding: 8px 10px;
}

input[type="number"] {
  width: 96px;
}

input[type="date"] {
  width: 150px;
}

.row-check {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

.bulk-actions {
  display: flex;
  justify-content: flex-end;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.bulk-tracking {
  min-width: 220px;
}

.bulk-selection {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  flex-wrap: wrap;
}

.bulk-selection[hidden] {
  display: none;
}

.link-button {
  min-height: auto;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  padding: 0;
  text-decoration: underline;
}

.link-button:hover {
  background: transparent;
  color: var(--brand);
}

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

.danger-button:hover {
  border-color: #7f1d1d;
  background: #7f1d1d;
}

.secondary-button {
  border-color: #92400e;
  background: #f59e0b;
}

.secondary-button:hover {
  border-color: #78350f;
  background: #d97706;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  padding: 8px 14px;
  text-decoration: none;
  white-space: nowrap;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.ghost {
  border-color: #b8c2cf;
  background: #fff;
  color: #1f2937;
}

.ghost:hover {
  border-color: var(--brand);
  background: #e7f5f2;
  color: var(--brand-dark);
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-weight: 650;
}

.notice.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: var(--warning);
}

.notice.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--danger);
}

.notice.success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 1420px;
  border-collapse: collapse;
  background: #fff;
}

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid #e7ebf0;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f3f6f8;
  color: #3b4656;
  font-size: 12px;
  text-transform: uppercase;
}

td strong {
  display: block;
}

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

.sync-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.sync-status.completed {
  color: var(--brand-dark);
}

.sync-status.running {
  color: #1d4ed8;
}

.sync-status.failed {
  color: var(--danger);
  white-space: normal;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.label-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  min-height: 32px;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.label-pill.pickup {
  background: #111827;
}

.label-pill.delivery {
  background: var(--accent);
}

.state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 112px;
  min-height: 28px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
}

.state-pill.pending {
  background: #e0f2fe;
  color: #075985;
}

.state-pill.fulfilled {
  background: #dcfce7;
  color: #166534;
}

.state-pill.backorder {
  background: #fef3c7;
  color: #92400e;
}

.stock-negative {
  color: var(--danger);
  font-weight: 850;
}

.thumb-strip {
  display: flex;
  gap: 6px;
  min-width: 126px;
  min-height: 42px;
}

.image-zoom-trigger {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid #d6dce4;
  border-radius: 6px;
  background: #fff;
  color: inherit;
}

.image-media {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  min-width: 0;
}

.image-shopify-link {
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.image-shopify-link:hover {
  text-decoration: underline;
}

.image-zoom-trigger:hover {
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(47, 107, 100, 0.14);
}

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

.order-thumb {
  width: 42px;
  height: 42px;
}

.inventory-article {
  display: grid;
  grid-template-columns: 58px minmax(150px, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 250px;
}

.inventory-thumb {
  width: 58px;
  height: 58px;
}

.image-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border: 1px dashed #c9d1dc;
  border-radius: 6px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.shopify-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 5px;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
  white-space: nowrap;
}

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

.image-lightbox {
  width: min(920px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  padding: 42px 18px 18px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(17, 24, 39, 0.34);
}

.image-lightbox::backdrop {
  background: rgba(17, 24, 39, 0.78);
}

.image-lightbox figure {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 12px;
  height: min(780px, calc(100vh - 92px));
  margin: 0;
}

.image-lightbox img {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
}

.image-lightbox figcaption {
  overflow: hidden;
  color: #374151;
  font-weight: 700;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-lightbox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  border-color: #cbd5e1;
  background: #fff;
  color: #111827;
  font-size: 25px;
  font-weight: 400;
  line-height: 1;
}

.image-lightbox-close:hover {
  background: #f3f4f6;
  color: #111827;
}

.fulfill-form {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto;
  gap: 8px;
  min-width: 300px;
}

.action-form {
  display: flex;
  min-width: 190px;
}

.order-actions {
  display: grid;
  gap: 8px;
  min-width: 300px;
}

.order-actions .action-form {
  min-width: 0;
}

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

.inventory-inline-form,
.inventory-adjust-form {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 420px;
}

.inventory-inline-form select {
  min-width: 220px;
}

.inventory-inline-form input[type='number'] {
  width: 76px;
}

.inventory-adjust-form input[type='number'] {
  width: 72px;
}

.inventory-adjust-form input[type='text'] {
  min-width: 160px;
}

.inventory-adjust-form select {
  min-width: 130px;
}

.field-error {
  display: block;
  color: #a53927;
  font-size: 0.85rem;
  margin-top: 6px;
}

.component-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-width: 180px;
}

.component-row form {
  margin: 0;
}

.maatwerk-actions .action-form button {
  min-height: 48px;
  line-height: 1.2;
  white-space: normal;
}

.fulfill-form input {
  min-width: 140px;
}

code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #eef2f7;
}

@media (max-width: 720px) {
  .topbar,
  .page-head,
  .section-title,
  .actions-row,
  .bulk-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding: 14px 16px;
  }

  nav {
    width: 100%;
  }

  nav a {
    flex: 1;
  }

  main {
    width: min(100vw - 20px, 1440px);
    margin-top: 18px;
  }

  .panel {
    padding: 14px;
  }

  .toolbar,
  .inline-fields,
  .inline-fields label,
  .toolbar label,
  .toolbar button,
  .inline-fields button {
    width: 100%;
  }

  .inventory-inline-form,
  .inventory-adjust-form {
    align-items: stretch;
    flex-direction: column;
    min-width: 260px;
  }

  .inventory-inline-form select,
  .inventory-inline-form input,
  .inventory-adjust-form select,
  .inventory-adjust-form input {
    min-width: 0;
    width: 100%;
  }

  input,
  select,
  button,
  .button {
    width: 100%;
  }

  .fulfill-form {
    grid-template-columns: 1fr;
    min-width: 220px;
  }

  .bulk-tracking {
    width: 100%;
  }

  .bulk-selection {
    align-items: flex-start;
    justify-content: flex-start;
  }
}
