:root {
  --bg: #f8f6f3;
  --panel: #fffdf9;
  --text: #2a241f;
  --muted: #756a60;
  --line: #e5ddd3;
  --accent: #3b342d;
  --accent-soft: #ebe1d5;
  --ok: #2f7d53;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "DM Sans", sans-serif;
  background: radial-gradient(circle at top left, #fffaf3, #f5f2ed 65%);
  color: var(--text);
}

.layout {
  min-height: 100dvh;
  width: 100%;
  margin: 0;
  padding: 1.25rem;
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1rem;
  box-shadow: 0 4px 14px rgba(36, 30, 25, 0.06);
}

.panel-header h1,
.panel-header h2,
.panel-header h3 {
  margin: 0;
}

.panel-header p {
  margin: 0.2rem 0 0;
  color: var(--muted);
}

.order-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 0.6rem 0.7rem;
  font: inherit;
  color: var(--text);
  resize: vertical;
}

input:focus {
  outline: 2px solid #dac8b5;
  border-color: #cab6a0;
}

textarea:focus {
  outline: 2px solid #dac8b5;
  border-color: #cab6a0;
}

.primary-btn,
.icon-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.primary-btn {
  padding: 0.7rem;
  border-radius: 10px;
  font-weight: 600;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.secondary-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 0.7rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  font: inherit;
}

.primary-btn:hover {
  filter: brightness(1.08);
}

.product-field-wrap {
  position: relative;
}

.product-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1rem;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.autocomplete {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0.25rem;
  position: absolute;
  width: 100%;
  z-index: 10;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  max-height: 220px;
  overflow: auto;
}

.autocomplete li {
  padding: 0.5rem;
  border-radius: 8px;
  cursor: pointer;
}

.autocomplete li:hover {
  background: #f6f0e8;
}

.orders-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: end;
}

.filters-wrap {
  display: flex;
  gap: 0.7rem;
  align-items: end;
}

.filter-date span,
.filter-status span {
  font-size: 0.8rem;
}

#orderDate,
#filterDate,
#filterStatus {
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  border: 1px solid #d4c5b5;
  background: linear-gradient(180deg, #fffdf9 0%, #f7efe5 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

#filterStatus {
  height: 48px;
  line-height: 1.2;
}

#orderDate::-webkit-calendar-picker-indicator,
#filterDate::-webkit-calendar-picker-indicator {
  cursor: pointer;
  background: #efe2d4;
  border-radius: 8px;
  padding: 0.2rem;
}

.filter-date,
.filter-status {
  display: grid;
  gap: 0.3rem;
}

.table-wrap {
  margin-top: 0.8rem;
  overflow: auto;
  max-height: calc(100dvh - 140px);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

th {
  position: sticky;
  top: 0;
  background: #fbf8f4;
  z-index: 1;
}

tr.status-pending td {
  background: #fffdf9;
}

tr.status-done td {
  color: #6f675f;
  background: #f7f2ea;
}

tr.status-served td {
  color: #6d7268;
  background: #eef4ed;
}

tr.status-done td:nth-child(4),
tr.status-served td:nth-child(4) {
  text-decoration: line-through;
}

tr.order-row {
  cursor: pointer;
}

tr.order-row.active {
  outline: 2px solid #d1b594;
  outline-offset: -2px;
  background: #fff7ec;
}

.status-separator td {
  background: #f2ebe2;
  font-weight: 700;
  color: #4f4338;
}

.status-check {
  width: 22px;
  height: 22px;
  cursor: pointer;
  accent-color: #5f5246;
}

td:first-child,
td:last-child {
  text-align: center;
}

.empty-state {
  color: var(--muted);
  margin: 1rem 0;
}

.product-modal {
  width: min(820px, 92vw);
  max-height: 86dvh;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
}

.product-modal::backdrop {
  background: rgba(30, 22, 16, 0.42);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.7rem;
}

.modal-header .icon-btn {
  width: 34px;
  height: 34px;
}

.modal-list {
  display: grid;
  gap: 0.8rem;
  max-height: 70dvh;
  overflow: auto;
  padding-right: 0.25rem;
}

.modal-category {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.65rem;
}

.modal-category h4 {
  margin: 0 0 0.5rem;
}

.modal-category ul {
  margin: 0;
  padding-left: 1rem;
  columns: 2;
}

.modal-category li {
  margin-bottom: 0.35rem;
  cursor: pointer;
}

.modal-category li:hover {
  color: var(--ok);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    padding: 0.8rem;
  }

  .panel {
    border-radius: 14px;
    padding: 0.85rem;
  }

  .panel-form {
    position: relative;
  }

  .order-form {
    gap: 0.7rem;
    margin-top: 0.75rem;
  }

  .orders-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .filters-wrap {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  input,
  textarea,
  #orderDate,
  #filterDate,
  #filterStatus {
    min-height: 52px;
    font-size: 1rem;
  }

  textarea {
    min-height: 88px;
  }

  .icon-btn {
    width: 52px;
    height: 52px;
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    grid-template-columns: 1fr 1fr;
    background: linear-gradient(180deg, rgba(255, 253, 249, 0.82), #fffdf9 40%);
    padding-top: 0.55rem;
    z-index: 2;
  }

  .primary-btn,
  .secondary-btn {
    min-height: 50px;
  }

  .table-wrap {
    max-height: none;
  }

  .modal-category ul {
    columns: 1;
  }
}

@media (max-width: 620px) {
  .filters-wrap {
    grid-template-columns: 1fr;
  }

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

  .table-wrap {
    overflow: visible;
  }

  table thead {
    display: none;
  }

  table tbody {
    display: grid;
    gap: 0.55rem;
  }

  tr.status-separator {
    display: block;
    margin-top: 0.35rem;
  }

  tr.status-separator td {
    display: block;
    border-radius: 10px;
    border-bottom: 0;
    padding: 0.5rem 0.6rem;
  }

  tr.order-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem 0.6rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 0.35rem 0.4rem;
  }

  tr.order-row td {
    border-bottom: 0;
    white-space: normal;
    padding: 0.35rem 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
  }

  tr.order-row td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
  }

  tr.order-row td:nth-child(4),
  tr.order-row td:nth-child(7) {
    grid-column: 1 / -1;
  }
}
