/* BIMTRAZA — Achats + réceptions + stock mouvement */
#bimtraza-achats.bt-ach {
  position: fixed;
  z-index: 21600;
  top: var(--bimtraza-menubar-h, 38px);
  left: var(--bimtraza-shell-width, 148px);
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  background:
    radial-gradient(1100px 380px at 0% -8%, rgba(14, 116, 144, 0.12), transparent 50%),
    linear-gradient(180deg, #f1f5f9 0%, #e2e8f0 100%);
  color: #0f172a;
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}
#bimtraza-achats.bt-ach[hidden] {
  display: none !important;
}

.bt-ach-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 8px 14px;
  background: linear-gradient(180deg, #fff 0%, #f8fafc 100%);
  border-bottom: 1px solid #cbd5e1;
}
.bt-ach-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 200px;
}
.bt-ach-mark {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #0e7490 0%, #155e75 100%);
  color: #ecfeff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.02em;
}
.bt-ach-brand h1 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.15;
}
.bt-ach-brand p {
  margin: 2px 0 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;
}
.bt-ach-project {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  color: #334155;
}
.bt-ach-project strong {
  color: #0f172a;
}
.bt-ach-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.bt-ach-btn {
  border: 1px solid #94a3b8;
  background: #f8fafc;
  color: #0f172a;
  border-radius: 7px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.bt-ach-btn:hover {
  background: #e2e8f0;
}
.bt-ach-btn--primary {
  background: #0e7490;
  border-color: #0e7490;
  color: #fff;
}
.bt-ach-btn--primary:hover {
  background: #155e75;
}
.bt-ach-btn--danger {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}
.bt-ach-btn--ghost {
  background: transparent;
}

.bt-ach-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  overflow-x: auto;
  border-bottom: 1px solid #cbd5e1;
  background: rgba(255, 255, 255, 0.55);
}
.bt-ach-tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: #475569;
  padding: 9px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  white-space: nowrap;
}
.bt-ach-tab.is-active {
  background: #fff;
  color: #0e7490;
  border-color: #cbd5e1;
  box-shadow: 0 -1px 0 #fff;
}

.bt-ach-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 14px;
  overflow: hidden;
}
.bt-ach-panel {
  display: none;
  flex: 1 1 auto;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
}
.bt-ach-panel.is-active {
  display: flex;
}

.bt-ach-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 1200px) {
  .bt-ach-kpi-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.bt-ach-kpi {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 72px;
}
.bt-ach-kpi span {
  display: block;
  font-size: 11px;
  color: #64748b;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.bt-ach-kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
  font-weight: 780;
  color: #0f172a;
  line-height: 1.1;
}
.bt-ach-kpi.is-warn strong {
  color: #b45309;
}
.bt-ach-kpi.is-ok strong {
  color: #15803d;
}
.bt-ach-kpi.is-bad strong {
  color: #b91c1c;
}

.bt-ach-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.bt-ach-toolbar input[type="search"],
.bt-ach-toolbar select,
.bt-ach-form input,
.bt-ach-form select,
.bt-ach-form textarea,
.bt-ach-editor input,
.bt-ach-editor select,
.bt-ach-editor textarea {
  border: 1px solid #94a3b8;
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12px;
  background: #fff;
  color: #0f172a;
  box-sizing: border-box;
}
.bt-ach-toolbar input[type="search"] {
  min-width: 200px;
  flex: 1 1 180px;
}
.bt-ach-toolbar select {
  min-width: 140px;
}

.bt-ach-split {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 10px;
}
@media (max-width: 980px) {
  .bt-ach-split {
    grid-template-columns: 1fr;
  }
}
.bt-ach-card {
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.bt-ach-card-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 750;
}
.bt-ach-card-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0;
}
.bt-ach-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.bt-ach-table th,
.bt-ach-table td {
  border-bottom: 1px solid #e2e8f0;
  padding: 7px 8px;
  text-align: left;
  vertical-align: top;
}
.bt-ach-table th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  z-index: 1;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #475569;
}
.bt-ach-table tbody tr {
  cursor: pointer;
}
.bt-ach-table tbody tr:hover {
  background: #f0f9ff;
}
.bt-ach-table tbody tr.is-selected {
  background: #ecfeff;
  outline: 1px solid #67e8f9;
  outline-offset: -1px;
}
.bt-ach-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bt-ach-muted {
  color: #64748b;
  font-size: 12px;
  padding: 16px;
}
.bt-ach-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border: 1px solid transparent;
}
.bt-ach-badge--draft {
  background: #f1f5f9;
  color: #475569;
  border-color: #cbd5e1;
}
.bt-ach-badge--open {
  background: #e0f2fe;
  color: #075985;
  border-color: #7dd3fc;
}
.bt-ach-badge--wait {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fdba74;
}
.bt-ach-badge--ok {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}
.bt-ach-badge--bad {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}
.bt-ach-badge--partial {
  background: #fef9c3;
  color: #854d0e;
  border-color: #fde047;
}

.bt-ach-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}
.bt-ach-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.bt-ach-form-grid label,
.bt-ach-editor label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.bt-ach-form-grid label.full,
.bt-ach-editor label.full {
  grid-column: 1 / -1;
}
.bt-ach-lines {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.bt-ach-lines table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.bt-ach-lines th,
.bt-ach-lines td {
  border-bottom: 1px solid #e2e8f0;
  padding: 5px 6px;
}
.bt-ach-lines input,
.bt-ach-lines select {
  width: 100%;
  min-width: 0;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 4px 6px;
  font-size: 11px;
}
.bt-ach-editor-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  padding-top: 4px;
}
.bt-ach-toast {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 3;
  background: #0f172a;
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12px;
  max-width: min(360px, 80vw);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
  display: none;
}
.bt-ach-toast.is-on {
  display: block;
}
.bt-ach-toast.is-err {
  background: #991b1b;
}
