.orders-main {
  max-width: 1600px;
  margin: 24px auto;
  padding: 0 20px;
}

.orders-page {
  color: #1d2923;
}

.orders-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 18px;
}

.orders-heading h1 {
  margin: 0 0 3px;
  font-size: 25px;
  line-height: 1.2;
}

.orders-heading p {
  margin: 0;
  color: #718078;
  font-size: 12px;
}

.order-tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  border-bottom: 1px solid #ccd8d1;
  overflow-x: auto;
}

.order-tab {
  appearance: none;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #596860;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 13px 9px;
  white-space: nowrap;
}

.order-tab:hover:not(:disabled) {
  color: #176640;
  background: #edf4f0;
}

.order-tab.is-active {
  border-bottom-color: #176640;
  color: #145b39;
}

.order-tab:disabled {
  color: #a0aaa5;
  cursor: not-allowed;
}

.order-tab [data-count] {
  display: inline-flex;
  min-width: 19px;
  justify-content: center;
  margin-left: 4px;
  border-radius: 9px;
  background: #e2eae5;
  color: #4b5a52;
  font-size: 11px;
  line-height: 18px;
}

.tab-check {
  color: #158348;
}

.active-summary {
  display: flex;
  align-items: stretch;
  gap: 1px;
  margin-top: 12px;
  overflow-x: auto;
  border: 1px solid #d7e0db;
  border-radius: 7px;
  background: #dfe7e2;
}

.summary-title,
.summary-item {
  min-width: 84px;
  background: #fff;
  padding: 8px 11px;
}

.summary-title {
  display: flex;
  min-width: 132px;
  align-items: center;
  color: #43534a;
  font-size: 12px;
  font-weight: 650;
}

.summary-item span,
.summary-item strong {
  display: block;
  text-align: center;
}

.summary-item span {
  color: #748179;
  font-size: 10px;
}

.summary-item strong {
  margin-top: 2px;
  color: #176640;
  font-size: 16px;
}

.order-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px 170px 145px 170px;
  gap: 8px;
  margin: 12px 0;
}

.order-filters label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #65736c;
  font-size: 11px;
  white-space: nowrap;
}

.order-filters input,
.order-filters select {
  width: 100%;
  min-width: 0;
  height: 34px;
  border: 1px solid #cbd7d0;
  border-radius: 6px;
  background: #fff;
  color: #26332d;
  padding: 0 9px;
  font: inherit;
  font-size: 12px;
}

.order-filters input:focus,
.order-filters select:focus {
  outline: 2px solid #a8cfb9;
  outline-offset: 1px;
}

.orders-table-wrap {
  overflow: auto;
  border: 1px solid #d7e0db;
  border-radius: 8px;
  background: #fff;
}

.orders-table {
  width: 100%;
  min-width: 1220px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.orders-table th,
.orders-table td {
  padding: 8px 7px;
  border-right: 1px solid #edf1ef;
  border-bottom: 1px solid #e4ebe7;
  text-align: left;
  vertical-align: middle;
  line-height: 1.25;
}

.orders-table th:last-child,
.orders-table td:last-child {
  border-right: 0;
}

.orders-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f0;
  color: #506058;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .01em;
  white-space: nowrap;
}

.orders-table tbody tr:hover {
  background: #f7faf8;
}

.orders-table tbody tr[data-order-id] {
  cursor: pointer;
}

.orders-table tbody tr[data-order-id]:focus-visible {
  outline: 2px solid #2b8657;
  outline-offset: -2px;
}

.sent-column { width: 72px; text-align: center !important; }
.date-column { width: 92px; }
.warehouse-column { width: 104px; }
.client-column { width: 150px; }
.address-column { width: 25%; }
.district-column { width: 92px; }
.qty-column { width: 45px; text-align: center !important; }
.other-column { width: 72px; text-align: center !important; }
.ai-column { width: 55px; text-align: center !important; }
.sent-cell, .number-cell { text-align: center !important; }
.address-cell { white-space: normal; }
.warehouse-cell { color: #365847; font-weight: 650; white-space: nowrap; }

.cheese-cell.has-cheese {
  background: #fff1b8;
  color: #6f5200;
  font-weight: 700;
}

.client-cell strong,
.client-cell span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-cell strong {
  font-weight: 650;
}

.client-cell span {
  margin-top: 2px;
  color: #78847e;
  font-size: 11px;
}

.sent-toggle {
  width: 24px;
  height: 24px;
  border: 1px solid #aebdb5;
  border-radius: 5px;
  background: #fff;
  color: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  line-height: 20px;
}

.sent-toggle:hover {
  border-color: #557766;
}

.sent-toggle.is-sent {
  border-color: #16844a;
  background: #16844a;
}

.sent-toggle.is-overdue {
  border-color: #c54141;
  background: #d84b4b;
}

.ai-score {
  display: inline-block;
  min-width: 38px;
  border-radius: 10px;
  background: #e7eee9;
  color: #35453d;
  padding: 3px 6px;
  text-align: center;
  font-weight: 650;
}

.ai-score.is-low {
  background: #ffe4e1;
  color: #af2525;
}

.empty-row td {
  padding: 28px;
  color: #7b8881;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

body.drawer-open {
  overflow: hidden;
}

.order-drawer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
}

.drawer-backdrop,
.source-viewer-backdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(12, 27, 19, .38);
  cursor: default;
}

.drawer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(620px, 94vw);
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid #cdd8d2;
  background: #f5f7f6;
  box-shadow: -12px 0 34px rgba(18, 46, 31, .16);
}

.drawer-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #dce4df;
  background: #fff;
  padding: 16px 18px;
}

.drawer-header h2 {
  margin: 3px 0 0;
  font-size: 20px;
}

.drawer-status {
  color: #6a776f;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.drawer-status.is-sent {
  color: #16844a;
}

.drawer-close,
.source-viewer-close {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border: 1px solid #d2ddd7;
  border-radius: 7px;
  background: #fff;
  color: #435149;
  cursor: pointer;
  font-size: 24px;
  line-height: 28px;
}

.drawer-close:hover,
.source-viewer-close:hover {
  background: #edf3ef;
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 18px 28px;
}

.drawer-loading,
.drawer-error {
  margin: 32px 0;
  color: #718078;
  text-align: center;
}

.drawer-error {
  color: #af2525;
}

.drawer-section {
  margin-bottom: 12px;
  border: 1px solid #dbe4df;
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.composition-section {
  border-top: 3px solid #24754b;
}

.drawer-section-title {
  margin: 0 0 12px;
  font-size: 15px;
}

.drawer-subtitle {
  margin: 13px 0 6px;
  color: #5f6d65;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.drawer-items {
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer-items li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid #edf1ef;
}

.drawer-items li:last-child {
  border-bottom: 0;
}

.drawer-item-name {
  min-width: 0;
}

.drawer-item-value {
  flex: 0 0 auto;
  color: #174f34;
  white-space: nowrap;
}

.drawer-details {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 14px;
  margin: 0;
  font-size: 12px;
}

.drawer-details dt {
  color: #748179;
}

.drawer-details dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.source-text {
  margin: 0;
  border-left: 3px solid #73a68a;
  border-radius: 4px;
  background: #f3f7f4;
  padding: 11px 12px;
  color: #26332d;
  font: inherit;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.source-preview-button {
  display: block;
  width: min(100%, 320px);
  border: 1px solid #d2ddd7;
  border-radius: 7px;
  background: #f7faf8;
  padding: 6px;
  color: #4c5d54;
  cursor: zoom-in;
  font: inherit;
  font-size: 11px;
}

.source-preview {
  display: block;
  width: 100%;
  max-height: 350px;
  margin-bottom: 6px;
  object-fit: contain;
  border-radius: 4px;
  background: #e9eeeb;
}

.source-viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}

.source-viewer-content {
  position: relative;
  z-index: 1;
  display: grid;
  width: min(900px, 94vw);
  height: min(92vh, 1100px);
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #17211c;
  box-shadow: 0 18px 60px rgba(0, 0, 0, .32);
}

.source-viewer-content img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.source-viewer-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

@media (max-width: 900px) {
  .orders-main { padding: 0 12px; }
  .order-filters { grid-template-columns: 1fr 1fr; }
  .search-field { grid-column: 1 / -1; }
  .drawer-details { grid-template-columns: 110px minmax(0, 1fr); }
}
