.orders-hero,
.order-detail-hero {
  align-items: end;
  margin-bottom: 26px;
}

.orders-hero h1,
.order-detail-hero h1 {
  margin: 0 0 8px;
  font: 600 clamp(30px, 4vw, 46px) Onest;
  letter-spacing: -.04em;
}

.order-summary,
.order-detail-summary {
  margin-bottom: 14px;
  grid-template-columns: 1.35fr repeat(4, 1fr);
}

/* Keep monetary values and the currency sign on one line. Order cards use a
   slightly more compact size because their five-column layout is the tightest. */
.summary-card > strong,
.total-chip,
.row-title > span,
.order-money > strong {
  white-space: nowrap;
}

.order-money > small {
  line-height: 1.35;
  white-space: normal;
}

.order-summary .summary-card > strong,
.order-detail-summary .summary-card > strong {
  font-size: clamp(18px, 2vw, 25px);
  font-variant-numeric: tabular-nums;
}

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

.dashboard-debt-grid {
  margin-top: 14px;
}

.debt-card {
  min-width: 0;
  padding: 19px 21px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--card);
}

.debt-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-weight: 700;
}

.debt-card > strong {
  display: block;
  margin-top: 15px;
  font: 600 clamp(24px, 3vw, 34px) Onest;
  letter-spacing: -.04em;
  white-space: nowrap;
}

.receivable-debt > strong {
  color: var(--green);
}

.payable-debt > strong {
  color: #926031;
}

.debt-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.debt-card > a {
  display: inline-block;
  margin-top: 12px;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}

.order-list-panel,
.counterparty-panel,
.nomenclature-panel,
.order-items-panel,
.order-info-panel,
.order-costs-panel {
  overflow: hidden;
}

.order-table,
.counterparty-table,
.nomenclature-table,
.detail-table,
.cost-table {
  overflow-x: auto;
}

.order-row {
  display: grid;
  grid-template-columns: minmax(300px, 1.5fr) 125px 135px 135px 145px 130px 34px;
  gap: 16px;
  align-items: center;
  min-width: 1170px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.order-row:last-child {
  border-bottom: 0;
}

.order-head,
.counterparty-head,
.detail-head,
.cost-head {
  background: #f8f8f5;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.order-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.order-number {
  flex: 0 0 auto;
  min-width: 54px;
  padding: 8px 9px;
  border-radius: 9px;
  background: var(--ink);
  color: white;
  font: 700 11px Onest;
  text-align: center;
}

.order-identity > div,
.order-money {
  min-width: 0;
}

.order-identity strong,
.order-identity p {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.order-identity p,
.order-money small,
.counterparty-row p,
.detail-row p,
.cost-row p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.order-status {
  justify-self: start;
  padding: 6px 9px;
  border-radius: 20px;
  background: #edf0eb;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.status-in_progress,
.status-invoiced,
.status-part_paid {
  background: var(--warm);
  color: #926031;
}

.status-paid,
.status-closed {
  background: var(--mint);
  color: var(--green);
}

.status-cancelled {
  background: #f5e1de;
  color: var(--red);
}

.order-money {
  display: flex;
  flex-direction: column;
}

.order-money.profit strong {
  color: var(--green);
}

.order-money.tax strong {
  color: #926031;
}

.row-arrow {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green);
  font-weight: 700;
  text-decoration: none;
}

.order-empty > div {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.counterparty-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.3fr) 140px minmax(210px, 1fr) 170px 100px;
  gap: 18px;
  align-items: center;
  min-width: 920px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.nomenclature-row {
  display: grid;
  grid-template-columns: minmax(260px, 1.5fr) 150px 90px 130px 110px 90px;
  gap: 18px;
  align-items: center;
  min-width: 900px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--line);
}

.nomenclature-row:last-child {
  border-bottom: 0;
}

.nomenclature-head {
  background: #f8f8f5;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nomenclature-row p,
.cost-row > div:first-child small {
  display: block;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.nomenclature-row > strong {
  white-space: nowrap;
}

.nomenclature-row.inactive {
  opacity: .58;
}

.counterparty-row:last-child {
  border-bottom: 0;
}

.counterparty-name {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.counterparty-name > span {
  flex: 0 0 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--mint);
  color: var(--green);
  font: 700 14px Onest;
}

.counterparty-name > div {
  min-width: 0;
}

.counterparty-name strong,
.counterparty-name p {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.role-chips span {
  padding: 5px 7px;
  border-radius: 12px;
  background: #edf0eb;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.order-detail-shell > .back {
  display: inline-block;
  margin-bottom: 16px;
}

.order-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .55fr);
  gap: 14px;
}

.order-finance-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
  padding: 17px 20px;
  border: 1px solid #efd7b5;
  border-radius: 14px;
  background: #fff8ed;
}

.order-finance-alert p {
  margin: 4px 0 0;
  color: #856848;
  font-size: 11px;
}

.order-finance-alert a {
  white-space: nowrap;
}

.order-finance-alert.company-alert {
  border-color: #cbdcd2;
  background: #edf5f0;
}

.order-finance-alert.company-alert p {
  color: #50645a;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 110px 125px 130px 85px;
  gap: 16px;
  align-items: center;
  min-width: 810px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row .item-total {
  text-align: right;
}

.item-actions {
  display: grid;
  gap: 5px;
  justify-items: end;
}

.item-actions a,
.item-actions button {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  text-align: right;
  text-decoration: none;
}

.item-actions button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--red);
  cursor: pointer;
  font-family: Manrope, sans-serif;
}

.items-total {
  display: flex;
  justify-content: flex-end;
  gap: 30px;
  padding: 15px 20px;
  background: #f8f8f5;
}

.items-total span {
  color: var(--muted);
  font-size: 11px;
}

.finance-edit-link {
  display: block;
  width: auto;
  margin: 0 20px 12px;
  text-align: center;
}

.order-facts {
  margin: 0;
  padding: 10px 20px 18px;
}

.order-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.order-facts dt {
  color: var(--muted);
  font-size: 11px;
}

.order-facts dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.order-info-panel > form {
  padding: 0 20px 20px;
}

.order-info-panel > form.payment-actions {
  display: grid;
  gap: 8px;
}

.bik-status.success {
  color: var(--green);
  font-weight: 700;
}

.bik-status.error {
  color: var(--red);
  font-weight: 700;
}

.order-note {
  margin: 0 20px 20px;
  padding: 14px;
  border-radius: 11px;
  background: #f7f8f4;
}

.order-note p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.order-costs-panel {
  margin-top: 14px;
}

.cost-row {
  display: grid;
  grid-template-columns: minmax(280px, 1.4fr) 115px 115px 135px 95px 115px 105px;
  gap: 15px;
  align-items: center;
  min-width: 1090px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}

.cost-row:last-child {
  border-bottom: 0;
}

.cost-vat {
  display: flex;
  flex-direction: column;
}

.cost-vat small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.cost-actions {
  display: grid;
  gap: 6px;
  justify-items: stretch;
}

.cost-actions > a {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
}

.cost-actions form,
.cost-actions .small-button {
  width: 100%;
}

.receipt-warning {
  background: #fff9ef;
}

.document-toggle {
  border: 0;
  border-radius: 8px;
  padding: 7px 8px;
  background: #f0f0ec;
  color: var(--muted);
  font: 700 9px Manrope;
  cursor: pointer;
}

.document-toggle.received {
  background: var(--mint);
  color: var(--green);
}

.receipt-warning .document-toggle {
  background: var(--warm);
  color: #926031;
}

.paid-label {
  color: var(--green);
  font-size: 10px;
  font-weight: 700;
}

.stack-form input[type="checkbox"] {
  width: auto;
  margin-right: auto;
  accent-color: var(--green);
}

.input-with-plus {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
}

.field-plus {
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  font: 600 23px Onest;
  line-height: 1;
  text-decoration: none;
}

.field-plus:hover,
.field-plus:focus-visible {
  background: var(--green);
}

.created-card {
  text-align: center;
}

.created-card .primary {
  margin-top: 22px;
}

.created-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--mint);
  color: var(--green);
  font-size: 23px;
  font-weight: 700;
}

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

.company-card {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
}

.company-card.inactive {
  opacity: .72;
}

.company-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.company-card-head > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  font: 700 12px Onest;
}

.company-card-head i {
  font-style: normal;
}

.company-card h2 {
  margin: 18px 0 5px;
  font: 600 21px Onest;
}

.company-tax {
  margin: 0;
  color: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.company-card dl {
  margin: 18px 0;
}

.company-card dl > div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.company-card dt {
  color: var(--muted);
}

.company-card dd {
  margin: 0;
  overflow: hidden;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-card > .secondary {
  display: block;
  text-align: center;
}

.company-empty {
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: white;
}

.company-empty > a {
  margin-top: 12px;
}

@media (max-width: 900px) {
  .order-summary,
  .order-detail-summary {
    grid-template-columns: 1fr 1fr;
  }

  .order-detail-grid {
    grid-template-columns: 1fr;
  }

  .order-summary .summary-card > strong,
  .order-detail-summary .summary-card > strong {
    font-size: clamp(24px, 4vw, 31px);
  }

  .orders-hero,
  .order-detail-hero {
    align-items: flex-start;
  }

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

@media (max-width: 600px) {
  .order-summary,
  .order-detail-summary {
    grid-template-columns: 1fr;
  }

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

  .debt-grid {
    grid-template-columns: 1fr;
  }
  .order-finance-alert {
    align-items: stretch;
    flex-direction: column;
  }

  .order-finance-alert a {
    text-align: center;
  }

  .order-empty > div {
    flex-direction: column;
    width: 100%;
  }

  .order-empty > div a {
    width: 100%;
  }
}
