: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; }
.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; }
.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; }
.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;
  }
  .return-table { table-layout: fixed; font-size: .84rem; }
  .return-table .article-number-column,
  .return-table .price-column { display: none; }
  .return-table th:nth-child(2) { width: 31%; }
  .return-table th:nth-child(3) { width: 12%; }
  .return-table th:nth-child(4) { width: 19%; }
  .return-table th:nth-child(6) { width: 19%; }
  .return-table th:nth-child(7) { width: 19%; }
  .return-table th { font-size: .62rem; }
  .return-table input {
    width: 100%;
    min-width: 0;
    padding: .5rem .35rem;
    font-size: 1rem;
    text-align: center;
  }
  [data-return-form] .table-scroll { overflow-x: visible; }
  [data-return-form] .actions {
    position: sticky;
    bottom: .35rem;
    z-index: 6;
    margin: .6rem 0 0;
    padding: .45rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, .95);
    box-shadow: 0 8px 24px rgba(32, 37, 31, .18);
  }
  [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; }
}
