:root {
  --bg: #fff6f3;
  --surface: #ffffff;
  --surface-muted: #fff0ec;
  --surface-strong: #ffe2da;
  --text: #261410;
  --text-muted: #735e58;
  --border: #ead1ca;
  --primary: #e42d12;
  --primary-hover: #ba220d;
  --primary-soft: #ffe7e1;
  --primary-glow: rgba(228, 45, 18, 0.22);
  --shipment: #e8790b;
  --shipment-hover: #c45f06;
  --shipment-soft: #fff0dc;
  --shipment-border: #f3bc78;
  --warning: #ad6b00;
  --warning-soft: #fff2d6;
  --danger: #b42318;
  --danger-soft: #fee4df;
  --info: #1d5f99;
  --info-soft: #e3f0fb;
  --received: #396d2f;
  --received-soft: #e7f3df;
  --shadow: 0 18px 40px rgba(77, 22, 12, 0.14);
  --radius: 8px;
  --focus: 0 0 0 3px rgba(228, 45, 18, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

body.auth-locked {
  overflow: hidden;
}

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

button,
select {
  cursor: pointer;
}

textarea {
  resize: vertical;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: 12px;
  z-index: 100;
  transform: translateY(-140%);
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  padding: 10px 14px;
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

body.auth-locked .skip-link,
body.auth-locked .app-header,
body.auth-locked .app-main {
  display: none;
}

.auth-gate {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.76), rgba(255, 231, 225, 0.5)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.48), rgba(255, 246, 243, 0.78)),
    url("assets/warehouse_header.png");
  background-position: center;
  background-size: cover;
}

body:not(.auth-locked) .auth-gate {
  display: none;
}

.auth-panel {
  width: min(430px, 100%);
  border: 1px solid rgba(234, 209, 202, 0.92);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  padding: 28px;
  backdrop-filter: blur(6px);
}

.auth-logo {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--primary);
  box-shadow: 0 18px 36px rgba(228, 45, 18, 0.24);
  margin-bottom: 18px;
}

.auth-logo::after {
  content: "";
  position: absolute;
  inset: -45%;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.42) 50%, transparent 65%);
  transform: translateX(-80%) rotate(8deg);
  animation: logo-shimmer 4.2s ease-in-out infinite;
}

.auth-logo img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-field {
  display: grid;
  gap: 6px;
  margin-top: 22px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.auth-field input {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  color: var(--text);
  padding: 10px 12px;
}

.auth-error {
  margin-top: 10px;
}

.auth-button {
  width: 100%;
  margin-top: 4px;
}

.app-header {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.76) 0%, rgba(255, 246, 243, 0.68) 48%, rgba(255, 231, 225, 0.46) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), rgba(255, 246, 243, 0.66)),
    url("assets/warehouse_header.png");
  background-position: center 58%;
  background-size: cover;
}

.header-main {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 18px;
}

.brand-lockup {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.header-actions {
  position: relative;
  z-index: 2;
}

.brand-logo-card {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  overflow: hidden;
  border: 1px solid rgba(228, 45, 18, 0.22);
  border-radius: var(--radius);
  background: var(--primary);
  box-shadow: 0 14px 30px rgba(228, 45, 18, 0.22);
}

.brand-logo-card::after {
  content: "";
  position: absolute;
  inset: -45%;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.42) 50%, transparent 65%);
  transform: translateX(-80%) rotate(8deg);
  animation: logo-shimmer 4.2s ease-in-out infinite;
}

.brand-logo-card img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes logo-shimmer {
  0%,
  38% {
    transform: translateX(-90%) rotate(8deg);
  }

  62%,
  100% {
    transform: translateX(90%) rotate(8deg);
  }
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.7rem, 2vw, 2.35rem);
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

h3 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.3;
}

.header-actions,
.week-controls,
.filters,
.modal-actions,
.modal-actions-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-weight: 700;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
.icon-button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.button-primary {
  background: var(--primary);
  color: white;
}

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

.button-shipment {
  background: var(--shipment);
  color: white;
}

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

.button-logout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-color: #d2b9b2;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
}

.button-logout:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.button-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.button-secondary,
.button-icon-text {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover,
.button-icon-text:hover {
  border-color: #d9aaa0;
  background: #fff8f6;
}

.button-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.button-icon-text span {
  font-size: 1.4rem;
  line-height: 0.7;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 12px;
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 0 0 20px;
}

.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 249, 247, 0.82);
  backdrop-filter: blur(2px);
  padding: 14px 16px;
}

.metric-label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  font-size: 1.7rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-shipment {
  border-color: var(--shipment-border);
  background: rgba(255, 240, 220, 0.82);
}

.metric-euro {
  border-color: #d8b44f;
  background: rgba(255, 248, 225, 0.86);
}

.app-main {
  width: min(1540px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

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

.field-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field-inline input,
.field-inline select,
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px 11px;
}

.search-field input {
  min-width: 260px;
}

.operator-field input {
  min-width: 220px;
}

.board {
  display: grid;
  grid-template-columns: repeat(7, minmax(150px, 1fr));
  gap: 12px;
  align-items: start;
}

.day-column {
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  transition:
    border-color 160ms ease,
    background 160ms ease;
}

.day-column.drag-over {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.day-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  padding: 12px;
}

.day-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.day-count {
  min-width: 28px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-muted);
  padding: 3px 8px;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.day-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.day-add-button {
  min-height: 30px;
  padding: 4px 8px;
}

.day-list {
  display: grid;
  gap: 10px;
  min-height: 280px;
  padding: 10px;
}

.delivery-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
  box-shadow: 0 4px 12px rgba(77, 22, 12, 0.07);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease,
    transform 160ms ease;
}

.delivery-card:hover {
  border-color: #d9aaa0;
  box-shadow: 0 10px 20px rgba(77, 22, 12, 0.11);
  transform: translateY(-1px);
}

.delivery-card:focus-within {
  box-shadow: var(--focus);
}

.delivery-card.dragging {
  opacity: 0.48;
}

.delivery-card.priority-high {
  border-left-color: var(--danger);
}

.delivery-card.shipment-card {
  border-left-color: var(--shipment);
  background:
    linear-gradient(180deg, rgba(255, 240, 220, 0.52), rgba(255, 255, 255, 0.92)),
    var(--surface);
}

.delivery-card.shipment-card:hover {
  border-color: var(--shipment-border);
  box-shadow: 0 10px 20px rgba(143, 72, 7, 0.15);
}

.card-topline,
.card-footer,
.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-topline,
.card-footer {
  justify-content: space-between;
}

.card-footer,
.card-actions {
  flex-wrap: wrap;
}

.card-footer {
  margin-top: 10px;
}

.card-actions {
  justify-content: flex-end;
  margin-left: auto;
}

.card-title {
  margin: 8px 0 4px;
  overflow-wrap: anywhere;
}

.card-reference,
.card-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.tym-alert {
  display: inline;
  border-radius: 4px;
  background: #ffe66b;
  color: #4a3400;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 1px 3px;
  font-weight: 850;
  animation: tym-flash 1.15s ease-in-out infinite;
}

@keyframes tym-flash {
  0%,
  100% {
    background: #ffe66b;
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.62);
  }

  50% {
    background: #fff6bf;
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0);
  }
}

.card-note {
  margin-top: 8px;
}

.card-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.priority-alert {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--danger);
  color: white;
  box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.42);
  font-size: 0.95rem;
  font-weight: 900;
  line-height: 1;
  animation: priority-pulse 1.8s ease-in-out infinite;
}

@keyframes priority-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.42);
  }

  50% {
    box-shadow: 0 0 0 7px rgba(180, 35, 24, 0);
  }
}

.type-badge {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.type-delivery {
  background: var(--primary-soft);
  color: var(--primary);
}

.type-shipment {
  background: var(--shipment-soft);
  color: var(--shipment-hover);
}

.card-audit {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.card-audit p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.card-audit strong {
  color: var(--text);
  font-weight: 800;
}

.card-time {
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.card-pallets {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.card-euro {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.card-packing {
  margin: 8px 0 0;
  color: var(--shipment-hover);
  font-size: 0.82rem;
  font-weight: 850;
}

.card-actual-arrival {
  margin: 8px 0 0;
  color: var(--primary-hover);
  font-size: 0.82rem;
  font-weight: 850;
}

.euro-chip {
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}

.euro-in {
  background: var(--received-soft);
  color: var(--received);
}

.euro-out {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 0.72rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-planned {
  background: var(--surface-strong);
  color: #48534a;
}

.status-transit {
  background: var(--info-soft);
  color: var(--info);
}

.status-in_progress {
  background: #fff0b8;
  color: #8a5700;
}

.status-received {
  background: var(--received-soft);
  color: var(--received);
}

.status-issue {
  background: var(--danger-soft);
  color: var(--danger);
}

.text-button {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--primary);
  padding: 6px 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

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

.empty-state {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed #e3bcb4;
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.88rem;
  font-weight: 700;
}

.modal {
  width: min(760px, calc(100% - 24px));
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(24, 32, 27, 0.46);
}

.modal-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
}

.icon-button:hover {
  background: var(--surface-muted);
}

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

.form-field {
  display: grid;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.full-width {
  grid-column: 1 / -1;
}

.audit-summary {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 12px;
}

.audit-summary p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.audit-summary strong {
  color: var(--text);
}

.form-error {
  min-height: 22px;
  margin: 12px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.modal-actions {
  justify-content: space-between;
  margin-top: 18px;
}

#deleteDeliveryButton {
  color: var(--danger);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  max-width: min(420px, calc(100% - 36px));
  transform: translateY(16px);
  border-radius: var(--radius);
  background: var(--text);
  color: white;
  padding: 12px 14px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1200px) {
  .board {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .header-main,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .header-actions,
  .filters,
  .week-controls {
    width: 100%;
  }

  .header-actions .button,
  .week-controls .button,
  .field-inline,
  .filters .field-inline {
    flex: 1 1 100%;
  }

  .field-inline {
    display: grid;
    align-items: stretch;
    gap: 6px;
  }

  .search-field input {
    min-width: 0;
  }

  .operator-field input {
    min-width: 0;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .day-column {
    min-height: auto;
  }

  .day-list {
    min-height: 160px;
  }
}

@media (max-width: 560px) {
  .header-main,
  .metrics,
  .app-main {
    width: min(100% - 20px, 1540px);
  }

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

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

  .modal-panel {
    padding: 16px;
  }

  .modal-actions,
  .modal-actions-right {
    align-items: stretch;
    flex-direction: column;
  }

  .modal-actions .button,
  .modal-actions-right .button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .brand-logo-card::after,
  .auth-logo::after,
  .priority-alert,
  .tym-alert {
    animation: none;
  }
}
