/* =========================================================
   MODULE PRESTATIONS & FACTURATION EXTERNES
   ========================================================= */

/* ---------------------------------------------------------
   Layout global
--------------------------------------------------------- */
.external-page {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 34px 28px;
  box-sizing: border-box;
}

.external-header {
  max-width: 820px;
  margin: 0 auto 24px;
}

.external-header h1,
.external-title-row h1 {
  margin: 0 0 6px;
  font-size: 32px;
  color: #111827;
}

.external-header p,
.external-title-row p {
  margin: 0;
  font-size: 15px;
  color: rgba(15, 23, 42, 0.58);
}

.external-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  width: 100%;
  margin-bottom: 2px;
  box-sizing: border-box;
}

.external-title-row .external-secondary-btn {
  flex-shrink: 0;
}

.external-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
  max-width: 1120px;
  margin: 0 auto;
  gap: 22px;
  align-items: stretch;
}

.external-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}

/* ---------------------------------------------------------
   Cartes / formulaires
--------------------------------------------------------- */
.external-card {
  display: flex;
  flex-direction: column;
  min-height: 320px;
  padding: 24px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-card h2 {
  margin: 0 0 20px;
  font-size: 19px;
  color: #111827;
}

.external-card label {
  display: block;
  margin-bottom: 15px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.72);
}

.external-card input,
.external-card select {
  display: block;
  width: 100%;
  height: 46px;
  margin-top: 7px;
  padding: 0 14px;
  box-sizing: border-box;
  border: 1px solid rgba(15, 23, 42, 0.13);
  border-radius: 14px;
  background: #fff;
  font-size: 14px;
}

.external-card > button {
  width: 100%;
  height: 46px;
  margin-top: auto;
  border: 0;
  border-radius: 15px;
  background: #111827;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.external-card button:hover,
.external-secondary-btn:hover,
.external-invoice-card:hover {
  transform: translateY(-1px);
}

.external-card--wide {
  grid-column: auto;
  max-height: 360px;
  overflow-y: auto;
}

.external-card--clients {
  max-height: 320px;
  overflow: hidden;
}

.external-card--clients #clients-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}

/* ---------------------------------------------------------
   Boutons
--------------------------------------------------------- */
.external-primary-btn,
.external-secondary-btn,
.external-danger-btn,
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  text-decoration: none;
}

.external-primary-btn,
.external-secondary-btn,
.btn-primary {
  background: #111827;
  color: #fff;
}

.external-secondary-btn {
  padding: 12px 18px;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.18);
}

.btn-secondary {
  background: #e5e7eb;
  color: #111827;
}

.external-danger-btn,
.btn-danger {
  background: #dc2626;
  color: #fff;
}

.external-danger-btn {
  padding: 12px 18px;
}

/* ---------------------------------------------------------
   Liste clients
--------------------------------------------------------- */
.client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.client-row__info {
  display: grid;
  gap: 3px;
}

.external-card button.client-row__btn {
  width: auto;
  height: 36px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  box-shadow: none;
  cursor: pointer;
}

/* ---------------------------------------------------------
   Modales génériques
--------------------------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal[hidden] {
  display: none;
}

.modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(4px);
}

.modal__content {
  position: relative;
  z-index: 2;
  width: min(440px, calc(100vw - 40px));
  padding: 26px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 24px;
  box-shadow: 0 30px 90px rgba(15, 23, 42, 0.28);
}

.modal__content h2 {
  margin: 0 0 22px;
  font-size: 24px;
  color: #111827;
}

.modal__content label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.72);
}

.modal__content input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  box-sizing: border-box;
  border: 1px solid rgba(15, 23, 42, 0.13);
  border-radius: 14px;
  background: #fff;
  font-size: 14px;
}

.modal__actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  background: transparent;
}

.modal__actions button {
  flex: 1;
  height: 46px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
}

/* ---------------------------------------------------------
   Historique rapide sur page prestations
--------------------------------------------------------- */
.external-history {
  grid-column: 1 / -1;
  width: 100%;
  max-height: 420px;
  margin-top: 8px;
  padding: 24px;
  box-sizing: border-box;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-history__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 18px;
}

.external-history__header h2,
.external-history h2 {
  margin: 0;
  font-size: 22px;
  color: #111827;
}

.external-history__header .external-secondary-btn {
  padding: 10px 16px;
  font-size: 14px;
  white-space: nowrap;
}

#external-sessions-list {
  display: flex;
  flex-direction: column;
  max-height: 120px;
  overflow-y: auto;
  padding-right: 8px;
}

.external-history::-webkit-scrollbar,
#external-sessions-list::-webkit-scrollbar,
#external-history-clients-stats::-webkit-scrollbar {
  width: 8px;
}

.external-history::-webkit-scrollbar-thumb,
#external-sessions-list::-webkit-scrollbar-thumb,
#external-history-clients-stats::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.18);
  border-radius: 999px;
}

.external-session-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

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

.external-session-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  color: #111827;
  font-size: 14px;
}

.external-session-actions {
  display: flex;
  gap: 10px;
}

.external-session-actions button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
}

.external-session-edit {
  background: #111827;
  color: #fff;
}

.external-session-delete {
  background: #dc2626;
  color: #fff;
}

.external-session-edit:disabled,
.external-session-delete:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(1);
}

.external-session-lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 10px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(29, 78, 216, 0.12);
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------------------------------------------------------
   Liste factures
--------------------------------------------------------- */
.external-invoices-list,
#externalInvoicesList {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.external-invoice-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  min-height: auto;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.external-invoice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
}

.external-invoice-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 16px;
}

.external-invoice-top h3 {
  margin: 0;
  font-size: 22px;
}

.external-invoice-top p {
  margin: 6px 0 0;
  color: #6b7280;
}

.external-invoice-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.external-invoice-meta p {
  margin: 0;
}

.external-invoice-compact-main {
  display: grid;
  grid-template-columns: 190px 180px 340px 140px;
  align-items: center;
  gap: 18px;
  width: 100%;
}

.external-invoice-compact-main strong {
  color: #111827;
}

.external-invoice-compact-main span:nth-child(3) {
  justify-self: start;
}

.external-invoice-compact-main strong:last-child {
  width: 120px;
  justify-self: end;
  padding-right: 10px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.external-invoice-card-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.external-invoice-open {
  font-size: 12px;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.32);
  white-space: nowrap;
  transition: color 0.15s ease;
}

.external-invoice-card:hover .external-invoice-open {
  color: rgba(15, 23, 42, 0.55);
}

/* ---------------------------------------------------------
   Statuts facture
--------------------------------------------------------- */
.external-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.external-status-draft {
  background: #fef3c7;
  color: #92400e;
}

.external-status-issued {
  background: #dbeafe;
  color: #1d4ed8;
}

.external-status-paid {
  background: #dcfce7;
  color: #166534;
}

.external-status-cancelled {
  background: #fee2e2;
  color: #991b1b;
}

.external-status-correcting {
  background: #ede9fe;
  color: #6d28d9;
}

/* ---------------------------------------------------------
   Détail facture
--------------------------------------------------------- */
.external-invoice-summary-card,
#externalInvoiceDetail .external-invoice-summary-card {
  min-height: 0;
  padding: 20px 24px;
}

.external-invoice-summary-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 22px;
}

.external-invoice-summary-top h2 {
  margin: 0 0 6px;
}

.external-invoice-summary-top p {
  margin: 0;
  color: rgba(15, 23, 42, 0.58);
}

.external-invoice-summary-grid,
#externalInvoiceDetail .external-invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 18px;
  max-width: 900px;
  margin-bottom: 14px;
}

.external-invoice-summary-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.58);
}

.external-invoice-summary-grid strong {
  font-size: 16px;
  color: #111827;
}

.external-invoice-actions,
#externalInvoiceDetail .external-invoice-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.external-invoice-actions .external-primary-btn,
.external-invoice-actions .external-secondary-btn,
.external-invoice-actions .external-danger-btn {
  width: auto;
  min-width: 180px;
  height: 46px;
  padding: 0 18px;
}

#externalInvoiceDetail > .external-card {
  min-height: 0;
}

#externalInvoiceDetail .external-invoice-actions a,
#externalInvoiceDetail .external-invoice-actions button {
  width: 190px;
  min-width: 190px;
  height: 46px;
  margin: 0;
  padding: 0 14px;
  box-sizing: border-box;
  line-height: 1;
  text-align: center;
}

.external-invoice-session-row {
  display: grid;
  grid-template-columns: 1fr 130px 90px 110px 110px;
  align-items: center;
  gap: 18px;
  padding: 12px 18px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
}

.external-invoice-session-row span {
  color: rgba(15, 23, 42, 0.62);
  font-size: 14px;
}

.external-invoice-session-row strong:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------
   Page historique prestations externes
--------------------------------------------------------- */
.external-history-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 1280px;
}

.external-history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: end;
  padding: 24px;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 24px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-history-filters label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(15, 23, 42, 0.72);
}

.external-history-filters select {
  height: 46px;
  min-width: 180px;
  padding: 0 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  background: #fff;
  font-size: 14px;
}

#history-reset-filters {
  height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.external-history-stats {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 14px;
  align-items: stretch;
}

.external-history-stats-left {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-history-stat {
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.88);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-history-stats-left .external-history-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  background: transparent;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: 0;
  box-shadow: none;
}

.external-history-stats-left .external-history-stat:last-child {
  border-bottom: 0;
}

.external-history-stat span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.58);
}

.external-history-stats-left .external-history-stat span {
  margin: 0;
}

.external-history-stat strong {
  font-size: 24px;
  color: #111827;
}

.external-history-stats-left .external-history-stat strong {
  font-size: 22px;
}

.external-history-stats-right,
.external-history-clients-card,
.external-history-table-card {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.06);
}

.external-history-stats-right {
  max-height: 190px;
  padding: 18px 22px;
  overflow: hidden;
}

.external-history-clients-card,
.external-history-table-card {
  padding: 20px 24px;
}

#external-history-clients-stats {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 118px;
  overflow-y: auto;
  padding-right: 6px;
}

.external-history-client-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 18px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
}

.external-history-client-row:last-child {
  border-bottom: 0;
}

.external-history-client-row > div {
  display: block;
}

.external-history-client-row span {
  margin-left: 10px;
  font-size: 13px;
  color: rgba(15, 23, 42, 0.58);
}

.external-history-client-row strong {
  font-size: 16px;
  color: #111827;
}

.external-history-client-row > strong {
  white-space: nowrap;
}

.external-history-table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.external-history-table-header h2 {
  margin: 0;
  font-size: 21px;
}

.external-history-table-header p {
  margin: 0;
  color: rgba(15, 23, 42, 0.58);
}

.external-history-table {
  width: 100%;
  border-collapse: collapse;
}

.external-history-table th {
  padding-bottom: 10px;
  text-align: left;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  color: rgba(15, 23, 42, 0.5);
  font-size: 12px;
  text-transform: uppercase;
}

.external-history-table td {
  padding: 12px 0;
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  color: #111827;
  font-size: 13px;
}

.external-history-table tbody tr {
  cursor: pointer;
  transition: background 0.18s ease;
}

.external-history-table tbody tr:hover {
  background: rgba(15, 23, 42, 0.035);
}

.external-history-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.external-history-badge--success {
  background: rgba(22, 163, 74, 0.12);
  color: #15803d;
}

.external-history-badge--info {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.external-history-badge--warning {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
}

.external-history-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.external-history-pagination button {
  height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.external-history-pagination button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
}

#history-page-label {
  font-weight: 700;
  color: #111827;
}

/* ---------------------------------------------------------
   Aperçu facture imprimable
--------------------------------------------------------- */
.invoice-preview-page {
  padding: 32px;
}

.invoice-preview-toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.invoice-preview {
  width: 794px;
  min-height: 1123px;
  margin: 0 auto;
  padding: 56px;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.invoice-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
}

.invoice-preview h1 {
  margin: 0 0 12px;
  font-size: 34px;
}

.invoice-preview h2 {
  margin-top: 28px;
}

.invoice-preview hr {
  margin: 28px 0;
  border: none;
  border-top: 2px solid #111827;
}

.invoice-preview-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  text-align: right;
}

.invoice-preview-brand img {
  width: 180px;
  height: auto;
  margin-bottom: 12px;
  object-fit: contain;
}

.invoice-preview-brand p {
  margin: 4px 0;
  line-height: 1;
}

.invoice-preview-line {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 40px;
  padding: 24px 0;
}

.invoice-preview-line p {
  margin: 0 0 12px;
}

.invoice-preview-line-amount {
  min-width: 160px;
  text-align: right;
  font-size: 28px;
  font-weight: 800;
  white-space: nowrap;
}

.invoice-preview-note {
  margin-top: 18px;
  color: #374151;
  font-style: italic;
  line-height: 1.6;
}

.invoice-preview-totals {
  display: flex;
  justify-content: space-between;
  gap: 40px;
  margin-top: 28px;
}

.invoice-preview-totals-left {
  flex: 1;
  color: #4b5563;
  font-size: 13px;
  line-height: 1.5;
}

.invoice-preview-totals-right {
  width: 280px;
}

.invoice-preview-total-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid #e5e7eb;
}

.invoice-preview-total-final {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 2px solid #111827;
  border-bottom: none;
  font-size: 20px;
}

.invoice-preview-total-final strong {
  font-size: 22px;
}

.invoice-preview-footer {
  margin-top: 56px;
  padding-top: 18px;
  border-top: 1px solid #e5e7eb;
  color: #6b7280;
  font-size: 12px;
  line-height: 1.6;
}

.invoice-preview-footer p {
  margin: 6px 0;
}

/* ---------------------------------------------------------
   Modale email facture
--------------------------------------------------------- */
.invoice-email-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.55);
}

.invoice-email-modal[hidden] {
  display: none;
}

.invoice-email-modal__box {
  width: min(640px, 100%);
  padding: 28px;
  background: #fff;
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.28);
}

.invoice-email-modal__box h2 {
  margin: 0 0 20px;
}

.invoice-email-modal__box label {
  display: block;
  margin-bottom: 16px;
  font-weight: 700;
}

.invoice-email-modal__box input,
.invoice-email-modal__box textarea {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 14px;
  font: inherit;
}

.invoice-email-modal__box textarea {
  resize: vertical;
  line-height: 1.5;
}

.invoice-email-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.invoice-email-modal__actions .external-primary-btn {
  padding: 14px 22px;
  background: #111827;
  color: #fff;
  border: none;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.22);
  font-weight: 800;
  cursor: pointer;
  appearance: none;
}

/* ---------------------------------------------------------
   Responsive
--------------------------------------------------------- */
@media (max-width: 1100px) {
  .external-grid,
  .external-history-stats {
    grid-template-columns: 1fr;
  }

  .external-invoice-compact-main,
  .external-invoice-session-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .external-invoice-compact-main strong:last-child {
    width: auto;
    justify-self: start;
    padding-right: 0;
    text-align: left;
  }

  #externalInvoiceDetail .external-invoice-actions {
    flex-wrap: wrap;
  }
}

@media (max-width: 900px) {
  .external-page {
    padding: 22px;
  }

  .external-header,
  .external-grid {
    max-width: 100%;
  }

  .external-form-grid,
  .external-invoice-summary-grid {
    grid-template-columns: 1fr;
  }

  .external-title-row,
  .external-history__header,
  .external-invoice-summary-top,
  .external-history-table-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .external-invoice-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .external-history-table-card {
    overflow-x: auto;
  }

  .invoice-preview-page {
    padding: 16px;
  }

  .invoice-preview {
    width: 100%;
    min-height: auto;
    padding: 28px;
  }

  .invoice-preview-header,
  .invoice-preview-line,
  .invoice-preview-totals {
    flex-direction: column;
  }

  .invoice-preview-brand {
    align-items: flex-start;
    text-align: left;
  }
}

/* ---------------------------------------------------------
   Impression facture
--------------------------------------------------------- */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }

  .app-sidebar,
  .invoice-preview-toolbar,
  .admin-mobile-nav,
  .mobile-admin-nav,
  .bottom-nav,
  .admin-bottom-nav,
  .mobile-topbar,
  .mobile-header,
  .mobile-navbar,
  .mobile-nav-wrapper,
  .mobile-topbar-wrapper,
  .mobile-bottom-nav {
    display: none !important;
  }

  html,
  body {
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .app-shell,
  .app-main,
  .invoice-preview-page {
    display: block !important;
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
    background: #fff !important;
  }

  .invoice-preview {
    width: 210mm !important;
    min-height: 297mm !important;
    margin: 0 !important;
    padding: 18mm !important;
    box-sizing: border-box !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
  }

  .invoice-preview-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    gap: 24mm !important;
  }

  .invoice-preview-brand {
    align-items: flex-end !important;
    text-align: right !important;
  }

  .invoice-preview-line,
  .invoice-preview-totals {
    flex-direction: row !important;
  }
}

/* ---------------------------------------------------------
   Correctifs finaux après refactor
--------------------------------------------------------- */
.external-title-row {
  margin-bottom: 28px;
}

.external-header {
  margin-bottom: 28px;
}

.external-title-row + .external-card,
.external-title-row + .external-history-filters,
.external-title-row + .external-history-stats,
.external-title-row + .external-invoices-list {
  margin-top: 0;
}

#createExternalInvoiceForm button[type="submit"] {
  width: auto;
  min-width: 180px;
  height: 46px;
  margin-top: 10px;
  padding: 0 18px;
  border-radius: 14px;
  font-size: 14px;
}
#client-modal .modal__actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

#client-modal .modal__actions button {
  opacity: 1 !important;
  visibility: visible !important;
  color: #111827 !important;
  background: #f3f4f6 !important;
  border: 1px solid #d1d5db !important;
  border-radius: 12px !important;
  padding: 12px 18px !important;
  font-weight: 700 !important;
}

#client-modal .modal__actions .btn-primary {
  background: #111827 !important;
  color: #ffffff !important;
  border-color: #111827 !important;
}
@media (max-width: 900px) {
  body.page-external .external-title-row h1,
  body.page-external .external-title-row p,
  body.page-external .external-title-row a {
    margin-left: 16px;
  }
}

@media (max-width: 900px) {
  body.page-external-invoice-preview .invoice-preview-toolbar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 14px !important;
    padding: 0 32px !important;
    box-sizing: border-box !important;
  }

  body.page-external-invoice-preview .invoice-preview-toolbar > a,
  body.page-external-invoice-preview .invoice-preview-toolbar > button {
    flex: 0 0 calc(50% - 7px) !important;
    max-width: calc(50% - 7px) !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    white-space: normal !important;
    text-align: center !important;
    justify-content: center !important;
    border-radius: 18px !important;
  }
}
@media (min-width: 901px) and (max-width: 1200px) {
  .invoice-preview,
  .invoice-page,
  .invoice-document,
  .external-invoice-preview {
    max-width: 100% !important;
    width: 100% !important;
    overflow-x: auto !important;
  }
}
