.achat-koudijs-page {
  width: 100%;
}

#clientResults button {
  display: block;
  width: 100%;
  padding: 0.55rem 0.75rem;
  text-align: left;
}

#clientResults button:hover {
  background: #f0fdf4;
}

#achatsBody tr:hover {
  cursor: pointer;
  background: #f7fee7;
}

#achatsBody tr.selected {
  background: #dcfce7;
}

#produitsBody td[contenteditable="true"] {
  background: #fff;
  outline: none;
}

#produitsBody td[contenteditable="true"]:focus {
  box-shadow: inset 0 0 0 2px #16a34a;
}

.achat-koudijs-columns {
  display: grid;
  gap: 1rem;
  width: 100%;
  align-items: start;
}

.achat-left,
.achat-right {
  min-width: 0;
}

@media (min-width: 1024px) {
  .achat-koudijs-columns {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
}

.achat-right {
  width: 100%;
}

.achat-proformas-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.achat-table-card {
  width: min(100%, 430px);
  flex: 0 0 auto;
}

.achat-base-table {
  width: 430px;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
}

.achat-table-card > .overflow-x-auto {
  width: 100%;
}

.achat-base-table th,
.achat-base-table td,
.achat-proformas-table th,
.achat-proformas-table td {
  height: 36px;
  padding: 0.5rem 0.6rem !important;
  vertical-align: middle;
  white-space: nowrap;
}

.achat-base-table td:nth-child(2),
.achat-proformas-table td:nth-child(3) {
  overflow: hidden;
  text-overflow: ellipsis;
}

.achat-base-table th,
.achat-base-table td {
  padding-left: 0.45rem !important;
  padding-right: 0.45rem !important;
}

.achat-base-table .col-num {
  width: 38px;
}

.achat-base-table .col-designation {
  width: 160px;
}

.achat-base-table .col-prix {
  width: 82px;
}

.achat-base-table .col-qte {
  width: 70px;
}

.achat-base-table .col-total {
  width: 80px;
}

.achat-proformas-table .col-num {
  width: 44px;
}

.achat-proformas-table .col-date {
  width: 78px;
}

.achat-proformas-table .col-client {
  width: auto;
}

.achat-proformas-table .col-facture {
  width: 96px;
}

.achat-proformas-table .col-tonnage {
  width: 86px;
}

.achat-proformas-table .col-sac {
  width: 82px;
}

.achat-proformas-table .col-camion {
  width: 132px;
}

@media (max-width: 767px) {
  .achat-base-table {
    min-width: 430px;
  }

  .achat-proformas-table {
    min-width: 760px;
  }
}

.proforma-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.56);
}

.proforma-modal.hidden {
  display: none;
}

.proforma-dialog {
  width: min(100%, 860px);
  max-height: 92vh;
  overflow: auto;
  border-radius: 8px;
  background: #f8fafc;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.35);
}

.proforma-actions {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  background: rgba(248, 250, 252, 0.96);
}

.proforma-sheet {
  margin: 0 auto;
  padding: 2rem;
  background: #fff;
  color: #111827;
}

@media (min-width: 1024px) {
  .proforma-dialog {
    width: 58.333333%;
    min-width: 720px;
  }
}

@media (max-width: 767px) {
  .proforma-sheet {
    padding: 1rem;
  }
}

.proforma-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 2px solid #166534;
  padding-bottom: 1rem;
}

.proforma-kicker {
  margin: 0 0 0.2rem;
  color: #166534;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
}

.proforma-header h2 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 800;
}

.proforma-meta {
  display: grid;
  gap: 0.45rem;
  min-width: 220px;
  text-align: right;
}

.proforma-meta span,
.proforma-client span {
  display: block;
  color: #64748b;
  font-size: 0.78rem;
}

.proforma-meta strong,
.proforma-client strong {
  color: #111827;
}

.proforma-client {
  margin: 1.25rem 0;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 0.85rem 1rem;
  background: #f9fafb;
}

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

.proforma-table th,
.proforma-table td {
  border: 1px solid #d1d5db;
  padding: 0.65rem 0.75rem;
}

.proforma-table thead th {
  background: #166534;
  color: #fff;
}

.proforma-table tfoot td {
  background: #f3f4f6;
  font-weight: 700;
}

.proforma-table .num {
  text-align: right;
}

@media print {
  aside,
  header,
  #printBtn,
  #message,
  #saveBtn,
  #updateBtn,
  #deleteBtn,
  #clientResults,
  .proforma-actions {
    display: none !important;
  }

  body {
    background: white !important;
  }

  body.proforma-print #page > div > *:not(.proforma-modal) {
    display: none !important;
  }

  body.proforma-print .proforma-modal:not(.hidden) {
    position: static;
    display: block;
    padding: 0;
    background: white;
  }

  body.proforma-print .proforma-dialog {
    max-height: none;
    overflow: visible;
    box-shadow: none;
    border-radius: 0;
  }

  body.proforma-print .proforma-sheet {
    padding: 0;
  }
}
