:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20251f;
  background: #f4f2e9;
}

* { box-sizing: border-box; }
body { margin: 0; }

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem clamp(1rem, 4vw, 3rem);
  background: #24321f;
  color: #fff;
}

.site-header strong,
.site-header span { display: block; }
.site-header span { color: #d3ddcb; font-size: .9rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; }
.header-actions a { color: #fff; font-weight: 700; text-decoration: none; }

main {
  width: min(1100px, calc(100% - 2rem));
  margin: 2rem auto 4rem;
}

.hero { margin: 2rem 0; }
.hero h1, .card h1, .card h2 { margin-top: .2rem; }
.eyebrow {
  margin: 0;
  color: #607058;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.muted { color: #687065; }
.card {
  margin: 1rem 0;
  padding: clamp(1rem, 3vw, 2rem);
  border: 1px solid #d9d6c8;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 12px 35px rgba(32, 37, 31, .07);
}
.compact-card { padding: 1rem 1.25rem; }
.form-card { width: min(680px, 100%); }
.alert-card { border-color: #d7a87a; background: #fff8ef; }

.login-card { width: min(440px, 100%); margin: 8vh auto; }
.document-header { display: flex; justify-content: space-between; gap: 1rem; }
.delivery-date-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}
.delivery-date-card {
  padding: 1.35rem;
  border: 2px solid #cfd8c7;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(32, 37, 31, .07);
}
.delivery-date-card h2 { margin: .2rem 0 .8rem; font-size: 1.65rem; }
.delivery-date-card .button-link { width: 100%; margin-top: .35rem; text-align: center; }
.delivery-date-card.is-closed { border-color: #d9d6c8; background: #f7f6f1; }
.date-status { font-weight: 800; }
.status-open { color: #31551f; }
.status-closed { color: #687065; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .75rem; border-bottom: 1px solid #ebe8df; text-align: left; }
th { color: #607058; font-size: .8rem; text-transform: uppercase; }

input {
  width: 5rem;
  padding: .55rem;
  border: 1px solid #c7c9c2;
  border-radius: 8px;
}
input[type="file"] { width: 100%; padding: .8rem; background: #f8f7f2; }
input[type="checkbox"] { width: auto; }
select { padding: .55rem; border: 1px solid #c7c9c2; border-radius: 8px; }
.helptext { color: #687065; font-size: .88rem; }
.errorlist { color: #9c2f23; font-weight: 700; }

button {
  padding: .7rem 1rem;
  border: 0;
  border-radius: 9px;
  background: #5f7f33;
  color: white;
  font-weight: 700;
  cursor: pointer;
}

button.secondary { background: transparent; border: 1px solid #8da084; }
button.secondary-dark { background: #53604e; }
.danger-button { background: #a23b32; }
.icon-button {
  display: inline-grid;
  width: 2.2rem;
  height: 2.2rem;
  padding: 0;
  place-items: center;
  border-radius: 8px;
}
.text-link { color: #4b6b2d; font-weight: 700; text-decoration: none; }
.button-link {
  display: inline-block;
  padding: .7rem 1rem;
  border-radius: 9px;
  background: #5f7f33;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}
.secondary-link { background: #53604e; }
.actions { display: flex; justify-content: flex-end; gap: .75rem; margin-top: 1rem; }
.actions-left { justify-content: flex-start; flex-wrap: wrap; }
.actions form { display: inline-flex; }
.row-actions { display: flex; align-items: center; gap: .65rem; }
.row-actions form { margin: 0; }
.search-form {
  display: grid;
  gap: .45rem;
  margin-bottom: 1rem;
}
.search-form > div {
  display: flex;
  align-items: center;
  gap: .65rem;
}
.search-form input { min-width: min(420px, 100%); }
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: .65rem;
  padding: .75rem 0;
}
.pagination a { color: #4b6b2d; font-weight: 700; text-decoration: none; }
.pagination-pages { display: flex; gap: .35rem; }
.pagination-pages a {
  display: grid;
  min-width: 2.15rem;
  min-height: 2.15rem;
  padding: .35rem;
  place-items: center;
  border: 1px solid #cfd8c7;
  border-radius: 8px;
}
.pagination a.is-current { background: #5f7f33; color: #fff; }
.pagination a.is-disabled {
  color: #a4a79f;
  pointer-events: none;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .75rem;
}
.table-toolbar a {
  padding: .45rem .7rem;
  border: 1px solid #cfd8c7;
  border-radius: 8px;
  color: #4b6b2d;
  font-weight: 700;
  text-decoration: none;
}
.table-toolbar a.is-active { background: #5f7f33; color: #fff; }
.category-row th {
  padding: .7rem .75rem;
  border-top: 2px solid #cfd8c7;
  background: #eef1e9;
  color: #40542e;
  font-size: .82rem;
  letter-spacing: .03em;
  text-align: left;
  text-transform: uppercase;
}
.quantity-hint {
  display: block;
  margin-top: .25rem;
  color: #607058;
  font-size: .7rem;
  line-height: 1.15;
}
.mobile-article-number,
.mobile-field-label { display: none; }
.article-name-cell strong { font-weight: inherit; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}
.return-counter {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid #cfd8c7;
  border-radius: 16px;
  background: #e5eadf;
}
.return-counter > div {
  padding: .8rem 1rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, .72);
}
.return-counter span {
  display: block;
  color: #607058;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
}
.return-counter strong {
  display: block;
  margin-top: .3rem;
  font-size: 1.45rem;
}
.return-counter p {
  grid-column: 1 / -1;
  margin: 0;
  color: #53604e;
}
.return-counter .is-over {
  background: #f8ddc4;
  color: #743a14;
}
.return-counter .is-over span { color: #743a14; }
.delivered-cell strong { display: block; text-align: center; }
.overdelivery-field {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  margin-top: .3rem;
  color: #4b6b2d;
  font-size: .72rem;
  font-weight: 700;
  white-space: nowrap;
}
.overdelivery-field input {
  width: 3.4rem;
  padding: .4rem .25rem;
  text-align: center;
}
.replacement-toggle {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .3rem;
  margin-top: .35rem;
  color: #4b6b2d;
  font-size: .68rem;
  font-weight: 700;
  line-height: 1.15;
}
.replacement-toggle input { width: auto; }
.replacement-detail-row td {
  padding: .6rem .8rem;
  background: #eef2e9;
}
.replacement-fields {
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(16rem, 2fr) 7rem;
  align-items: center;
  gap: .65rem;
}
.replacement-fields label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: .4rem;
  font-size: .8rem;
  font-weight: 700;
}
.additional-returns {
  display: grid;
  gap: .8rem;
  margin-top: 1.25rem;
  padding: 1rem;
  border: 1px solid #dfe3da;
  border-radius: 12px;
  background: #f6f7f3;
}
.additional-returns h2 { margin: 0 0 .25rem; font-size: 1.2rem; }
.additional-returns p { margin: 0; }
.additional-return-row {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) 7rem auto auto;
  align-items: end;
  gap: .65rem;
  padding: .7rem 0;
  border-top: 1px solid #dfe3da;
}
.additional-return-row label { display: grid; gap: .25rem; font-weight: 700; }
.additional-return-accepted { align-self: center; white-space: nowrap; }
.danger-quiet {
  background: #fff;
  color: #8a3926;
  border-color: #b86752;
}
.stat-card {
  padding: 1.2rem;
  border-radius: 14px;
  background: #e5eadf;
}
.stat-card span { display: block; color: #607058; font-size: .85rem; }
.stat-card strong { display: block; margin-top: .25rem; font-size: 1.8rem; }
.status {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  background: #e5eadf;
  font-size: .8rem;
  font-weight: 700;
}
.status-error, .status-review { background: #f8ddc4; color: #743a14; }
.status-ready, .status-parsed { background: #dcebd2; color: #31551f; }
.status-submitted { background: #dcebd2; color: #31551f; }
.status-draft { background: #fff0c2; color: #705400; }
.status-none { background: #e8e9e5; color: #4f554d; }
.messages {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  padding: .8rem 1rem;
  border-radius: 10px;
  background: #24321f;
  color: #fff;
  box-shadow: 0 12px 35px rgba(32, 37, 31, .2);
}

form p { display: grid; gap: .35rem; }
form input { width: 100%; }

@media (max-width: 700px) {
  .site-header { padding: .65rem .75rem; }
  .site-header span { display: none; }
  .header-actions { gap: .5rem; }
  .header-actions a { font-size: .85rem; }
  .header-actions button { padding: .5rem .7rem; }
  main { width: min(100% - .5rem, 1100px); margin: .75rem auto 3rem; }
  .hero { margin: .75rem .25rem 1rem; }
  .hero h1 { font-size: 1.65rem; }
  .hero p { margin: .45rem 0; font-size: .9rem; }
  .card { border-radius: 11px; padding: .6rem; }
  .delivery-date-grid { grid-template-columns: 1fr; gap: .65rem; }
  .delivery-date-card { padding: 1rem; border-radius: 12px; }
  .delivery-date-card h2 { font-size: 1.45rem; }
  th, td { padding: .5rem .35rem; }
  .return-counter {
    position: sticky;
    top: .25rem;
    z-index: 5;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .35rem;
    margin: .5rem 0;
    padding: .45rem;
    border-radius: 11px;
    box-shadow: 0 8px 20px rgba(32, 37, 31, .12);
  }
  .return-counter > div { padding: .45rem; border-radius: 8px; }
  .return-counter span { font-size: .58rem; line-height: 1.15; }
  .return-counter strong { margin-top: .2rem; font-size: .95rem; }
  .return-counter p {
    grid-column: 1 / -1;
    font-size: .76rem;
    line-height: 1.25;
  }
  .table-toolbar {
    gap: .35rem;
    margin: .1rem 0 .65rem;
    font-size: .85rem;
  }
  .table-toolbar a { padding: .45rem .6rem; }
  .return-table,
  .return-table tbody { display: block; }
  .return-table thead { display: none; }
  .return-table .category-row {
    display: block;
    margin: .9rem 0 .35rem;
  }
  .return-table .category-row th {
    display: block;
    padding: .55rem .65rem;
    border: 0;
    border-radius: 8px;
  }
  .return-table .return-line-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "article article accepted"
      "delivered shortage return";
    gap: .45rem;
    margin-top: .65rem;
    padding: .75rem .55rem;
    border: 1px solid #dfe3da;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(32, 37, 31, .05);
  }
  .return-table .return-line-row:first-child { margin-top: 0; }
  .return-table .return-line-row > td {
    display: block;
    min-width: 0;
    padding: 0;
    border: 0;
  }
  .return-table .return-line-row > .article-number-column,
  .return-table .return-line-row > .price-column { display: none; }
  .return-table .article-name-cell {
    grid-area: article;
    align-self: center;
    padding-right: .25rem;
  }
  .article-name-cell strong {
    display: block;
    overflow-wrap: anywhere;
    font-size: 1rem;
    font-weight: 750;
    line-height: 1.2;
  }
  .mobile-article-number,
  .mobile-field-label {
    display: block;
    color: #607058;
    font-size: .62rem;
    font-weight: 800;
    letter-spacing: .035em;
    line-height: 1.15;
    text-transform: uppercase;
  }
  .mobile-article-number { margin-bottom: .15rem; }
  .return-table .delivered-cell { grid-area: delivered; }
  .return-table .shortage-cell { grid-area: shortage; }
  .return-table .return-input-cell { grid-area: return; }
  .return-table .accepted-cell {
    grid-area: accepted;
    align-self: center;
    color: #31551f;
    font-size: 1rem;
    font-weight: 800;
    text-align: right;
  }
  .return-table .accepted-cell .mobile-field-label { margin-bottom: .2rem; }
  .return-table .delivered-cell,
  .return-table .shortage-cell,
  .return-table .return-input-cell {
    padding: .5rem .35rem;
    border-radius: 9px;
    background: #f6f7f3;
    text-align: center;
  }
  .return-table .delivered-cell > strong {
    margin: .35rem 0 .1rem;
    font-size: 1.05rem;
  }
  .return-table input {
    width: 3.6rem;
    min-height: 2.75rem;
    min-width: 0;
    padding: .4rem .3rem;
    font-size: 1rem;
    text-align: center;
  }
  .return-table .shortage-cell > input,
  .return-table .return-input-cell > input { margin-top: .35rem; }
  .return-table .overdelivery-field {
    display: flex;
    flex-direction: column;
    gap: .2rem;
    margin-top: .2rem;
    font-size: .62rem;
    text-align: center;
  }
  .return-table .overdelivery-field input { width: 3.6rem; }
  .replacement-toggle {
    grid-template-columns: auto 1fr;
    justify-items: center;
    width: max-content;
    max-width: 100%;
    margin: .4rem auto 0;
    font-size: .58rem;
    text-align: left;
  }
  .replacement-toggle input { width: 1.35rem; min-height: 1.35rem; }
  .replacement-detail-row { display: block; }
  .replacement-detail-row[hidden] { display: none; }
  .replacement-detail-row td {
    display: block;
    margin: -.05rem .35rem .7rem;
    padding: .65rem;
    border: 1px solid #dfe3da;
    border-top: 0;
    border-radius: 0 0 10px 10px;
  }
  .replacement-fields {
    grid-template-columns: 1fr 5.5rem;
    gap: .45rem;
  }
  .replacement-fields strong { grid-column: 1 / -1; }
  .replacement-fields > input { width: 100%; text-align: left; }
  .replacement-fields label {
    grid-template-columns: 1fr;
    gap: .2rem;
    text-align: center;
  }
  .replacement-fields label input { width: 100%; text-align: center; }
  .additional-returns { padding: .75rem; }
  .additional-return-row {
    grid-template-columns: 1fr 5.5rem;
    gap: .5rem;
  }
  .additional-return-row > label:first-child { grid-column: 1 / -1; }
  .additional-return-accepted { font-size: .8rem; white-space: normal; }
  .additional-return-row .danger-quiet { padding: .65rem .45rem; }
  [data-return-form] .table-scroll { overflow-x: visible; }
  [data-return-form] .actions {
    position: static;
    margin: .6rem 0 0;
    padding: .45rem;
    border-radius: 10px;
    background: #f6f7f3;
    box-shadow: none;
  }
  [data-return-form] .actions button { flex: 1; padding: .7rem .4rem; }
  .search-form > div { flex-wrap: wrap; }
  .search-form input { min-width: 100%; }
  .management-table { min-width: 720px; }
  .pagination { gap: .25rem; font-size: .72rem; }
  .pagination-pages { gap: .2rem; }
  .pagination-pages a { min-width: 1.8rem; min-height: 1.8rem; }
}

.staff-action { padding: 1.25rem 0; border-top: 1px solid var(--border, #ddd); }
.staff-action.alert-card { padding: 1.25rem; margin: 1rem 0; }
.notification-status { font-size: .9rem; }
.history-metadata { margin: .75rem 0 1.5rem; }
.history-products td { vertical-align: top; }
.history-products th:first-child { min-width: 15rem; }
