/* ==========================================================================
   PharmaGest — Tiers payant (refonte 14/10/2026)
   Classes tp-* ; s'appuie sur les jetons --pg-* de design-system.css.
   L'impression n'est pas concernée.
   ========================================================================== */
@media screen {

.tp { max-width: 1320px; margin: 0 auto; font-family: var(--pg-font); color: var(--pg-text); }
.tp *, .tp *::before, .tp *::after { box-sizing: border-box; }
.tp .num, .tp-num { font-family: var(--pg-font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; white-space: nowrap; }
.tp-muted { color: var(--pg-text-3); }
.tp-small { font-size: 12px; }

/* --- Barre du haut : recherche globale + actions ------------------------ */
.tp-top { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.tp-search { position: relative; flex: 1 1 420px; min-width: 240px; }
.tp-search > i, .tp-search > svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--pg-text-3); pointer-events: none;
}
.tp-search input {
  width: 100%; height: 46px; padding: 0 40px 0 44px;
  border: 1px solid var(--pg-border-strong); border-radius: 12px;
  background: var(--pg-surface); font-size: 14.5px; color: var(--pg-text);
  box-shadow: var(--pg-shadow-1);
}
.tp-search input:focus { outline: none; border-color: var(--pg-brand); box-shadow: 0 0 0 3px rgba(14,90,74,.14); }
.tp-search-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 30px; height: 30px; border-radius: 8px; border: none; background: none;
  color: var(--pg-text-3); cursor: pointer; display: none; align-items: center; justify-content: center;
}
.tp-search-clear:hover { background: var(--pg-surface-3); color: var(--pg-text); }
.tp-search.has-value .tp-search-clear { display: inline-flex; }
.tp-search-clear svg, .tp-search-clear i { width: 16px; height: 16px; }
.tp-top-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.tp-pop {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 50;
  background: var(--pg-surface); border: 1px solid var(--pg-border);
  border-radius: 14px; box-shadow: var(--pg-shadow-2);
  max-height: min(70vh, 520px); overflow-y: auto; padding: 6px; display: none;
}
.tp-pop.open { display: block; }
.tp-pop-group { padding: 10px 10px 4px; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--pg-text-3); }
.tp-pop-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 9px 10px; border: none; background: none; border-radius: 10px;
  text-align: left; cursor: pointer; font: inherit; color: var(--pg-text);
}
.tp-pop-item:hover, .tp-pop-item.is-active { background: var(--pg-surface-3); }
.tp-pop-ico {
  width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--pg-brand-soft); color: var(--pg-brand);
}
.tp-pop-ico svg, .tp-pop-ico i { width: 16px; height: 16px; }
.tp-pop-main { flex: 1; min-width: 0; }
.tp-pop-title { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-pop-sub { font-size: 12px; color: var(--pg-text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-pop-side { font-size: 12.5px; font-weight: 600; color: var(--pg-text-2); white-space: nowrap; }
.tp-pop-empty { padding: 18px; text-align: center; font-size: 13px; color: var(--pg-text-3); }
.tp-mark { background: #FBF1DF; color: inherit; border-radius: 3px; padding: 0 1px; }

/* --- Indicateurs -------------------------------------------------------- */
.tp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.tp-kpi {
  background: var(--pg-surface); border: 1px solid var(--pg-border);
  border-radius: var(--pg-r-md); box-shadow: var(--pg-shadow-1);
  padding: 14px 18px 16px; min-width: 0; text-align: left; font: inherit; color: inherit;
}
button.tp-kpi { cursor: pointer; transition: border-color var(--pg-fast) ease, box-shadow var(--pg-fast) ease; }
button.tp-kpi:hover { border-color: var(--pg-border-strong); box-shadow: 0 4px 14px -6px rgba(28,27,25,.14); }
.tp-kpi-label { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 500; color: var(--pg-text-2); margin-bottom: 8px; }
.tp-kpi-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pg-brand); flex-shrink: 0; }
.tp-kpi-dot.is-warning { background: var(--pg-warning); }
.tp-kpi-dot.is-danger { background: var(--pg-danger); }
.tp-kpi-dot.is-info { background: var(--pg-info); }
.tp-kpi-value { font-family: var(--pg-font-num); font-size: 22px; font-weight: 600; letter-spacing: -0.03em; white-space: nowrap; }
.tp-kpi-value small { font-family: var(--pg-font); font-size: 12px; font-weight: 500; color: var(--pg-text-3); margin-left: 4px; letter-spacing: 0; }
.tp-kpi-note { font-size: 12px; color: var(--pg-text-3); margin-top: 4px; }

/* --- Onglets ------------------------------------------------------------ */
.tp-tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--pg-border);
  margin-bottom: 16px; overflow-x: auto; scrollbar-width: none;
}
.tp-tabs::-webkit-scrollbar { display: none; }
.tp-tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 14px; border: none; background: none; cursor: pointer;
  font: inherit; font-size: 13.5px; font-weight: 500; color: var(--pg-text-2); white-space: nowrap;
}
.tp-tab svg, .tp-tab i { width: 16px; height: 16px; color: var(--pg-text-3); }
.tp-tab:hover { color: var(--pg-text); }
.tp-tab.active { color: var(--pg-brand); font-weight: 650; }
.tp-tab.active svg, .tp-tab.active i { color: var(--pg-brand); }
.tp-tab.active::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--pg-brand); }
.tp-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--pg-surface-3); color: var(--pg-text-2);
  font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.tp-tab.active .tp-count { background: var(--pg-brand-soft); color: var(--pg-brand); }
.tp-count.is-warning { background: var(--pg-warning-soft); color: var(--pg-warning); }

/* --- Filtres ------------------------------------------------------------ */
.tp-filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tp-filters .pg-seg { flex-wrap: wrap; }
.tp-select, .tp-date, .tp-filter-input {
  height: 34px; padding: 0 10px; border: 1px solid var(--pg-border-strong); border-radius: 9px;
  background: var(--pg-surface); font: inherit; font-size: 13px; color: var(--pg-text);
}
.tp-filter-input { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
.tp-select:focus, .tp-date:focus, .tp-filter-input:focus { outline: none; border-color: var(--pg-brand); box-shadow: 0 0 0 3px rgba(14,90,74,.14); }
.tp-dates { display: none; align-items: center; gap: 6px; font-size: 12.5px; color: var(--pg-text-2); }
.tp-dates.show { display: inline-flex; }
.tp-filters-end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tp-active-filter {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 6px 0 12px;
  border-radius: 999px; background: var(--pg-brand-soft); color: var(--pg-brand); font-size: 12.5px; font-weight: 600;
}
.tp-active-filter button { width: 22px; height: 22px; border: none; border-radius: 50%; background: none; color: inherit; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tp-active-filter button:hover { background: rgba(14,90,74,.14); }
.tp-active-filter svg, .tp-active-filter i { width: 14px; height: 14px; }

/* --- Panneaux et tableaux ---------------------------------------------- */
.tp-panel { background: var(--pg-surface); border: 1px solid var(--pg-border); border-radius: var(--pg-r-md); box-shadow: var(--pg-shadow-1); overflow: hidden; }
.tp-panel + .tp-panel { margin-top: 16px; }
.tp-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--pg-border); flex-wrap: wrap; }
.tp-panel-title { margin: 0; font-size: 14px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.tp-panel-title svg, .tp-panel-title i { width: 16px; height: 16px; color: var(--pg-text-3); }
.tp-panel-meta { font-size: 12.5px; color: var(--pg-text-3); }
.tp-scroll { overflow-x: auto; }
.tp-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.tp-table th {
  background: var(--pg-surface-2); text-align: left; white-space: nowrap;
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--pg-text-3);
  padding: 9px 14px; border-bottom: 1px solid var(--pg-border);
}
.tp-table td { padding: 10px 14px; border-bottom: 1px solid #EFEDE8; vertical-align: middle; font-family: var(--pg-font); }
.tp-table th { font-family: var(--pg-font); }
.tp-table td.tp-nowrap { white-space: nowrap; }
.tp-table tbody tr:last-child td { border-bottom: none; }
.tp-table tbody tr:hover { background: #F8F7F3; }
.tp-table tr.is-clickable { cursor: pointer; }
.tp-table .r { text-align: right; }
.tp-table .c { text-align: center; }
.tp-table tfoot td { background: var(--pg-surface-2); font-weight: 600; border-top: 1px solid var(--pg-border); border-bottom: none; }
.tp-cell-main { font-weight: 600; color: var(--pg-text); }
.tp-cell-sub { font-size: 12px; color: var(--pg-text-3); margin-top: 1px; }
.tp-row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.tp-ibtn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid transparent; background: none;
  color: var(--pg-text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.tp-ibtn:hover { background: var(--pg-surface-3); color: var(--pg-text); }
.tp-ibtn.is-danger:hover { background: var(--pg-danger-soft); color: var(--pg-danger); }
.tp-ibtn:disabled { opacity: .4; cursor: not-allowed; }
.tp-ibtn svg, .tp-ibtn i { width: 16px; height: 16px; }
.tp-more { display: flex; justify-content: center; padding: 12px; border-top: 1px solid var(--pg-border); }

/* --- Statuts ------------------------------------------------------------ */
.tp-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--pg-surface-3); color: var(--pg-text-2);
}
.tp-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tp-pill.is-success { background: var(--pg-success-soft); color: var(--pg-success); }
.tp-pill.is-warning { background: var(--pg-warning-soft); color: var(--pg-warning); }
.tp-pill.is-danger { background: var(--pg-danger-soft); color: var(--pg-danger); }
.tp-pill.is-info { background: var(--pg-info-soft); color: var(--pg-info); }
.tp-pill.is-brand { background: var(--pg-brand-soft); color: var(--pg-brand); }
.tp-type {
  display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; background: var(--pg-surface-3); color: var(--pg-text-2);
}
.tp-progress { height: 6px; border-radius: 999px; background: var(--pg-surface-3); overflow: hidden; min-width: 60px; }
.tp-progress > span { display: block; height: 100%; border-radius: 999px; background: var(--pg-success); }

/* --- À traiter ---------------------------------------------------------- */
.tp-todo { list-style: none; margin: 0; padding: 6px; }
.tp-todo li {
  display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 12px;
}
.tp-todo li + li { border-top: 1px solid #EFEDE8; border-radius: 0; }
.tp-todo-ico { width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; }
.tp-todo-ico svg, .tp-todo-ico i { width: 18px; height: 18px; }
.tp-todo-ico.is-danger { background: var(--pg-danger-soft); color: var(--pg-danger); }
.tp-todo-ico.is-warning { background: var(--pg-warning-soft); color: var(--pg-warning); }
.tp-todo-ico.is-info { background: var(--pg-info-soft); color: var(--pg-info); }
.tp-todo-main { flex: 1; min-width: 0; }
.tp-todo-title { font-size: 13.5px; font-weight: 600; }
.tp-todo-sub { font-size: 12.5px; color: var(--pg-text-3); margin-top: 2px; }
.tp-todo-amount { font-family: var(--pg-font-num); font-weight: 600; font-size: 14px; white-space: nowrap; }
.tp-todo details { margin-top: 6px; }
.tp-todo summary { cursor: pointer; font-size: 12px; color: var(--pg-brand); font-weight: 600; list-style: none; }
.tp-todo summary::-webkit-details-marker { display: none; }

/* --- Cartes organisme --------------------------------------------------- */
.tp-orgs { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.tp-org {
  background: var(--pg-surface); border: 1px solid var(--pg-border); border-radius: var(--pg-r-md);
  box-shadow: var(--pg-shadow-1); padding: 16px; display: flex; flex-direction: column; gap: 12px;
  cursor: pointer; transition: border-color var(--pg-fast) ease, box-shadow var(--pg-fast) ease; text-align: left; font: inherit; color: inherit;
}
.tp-org:hover { border-color: var(--pg-border-strong); box-shadow: 0 6px 18px -8px rgba(28,27,25,.18); }
.tp-org-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tp-org-name { font-size: 14.5px; font-weight: 650; line-height: 1.25; }
.tp-org-meta { font-size: 12px; color: var(--pg-text-3); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tp-org-figs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tp-org-fig { background: var(--pg-surface-2); border-radius: 10px; padding: 8px 10px; }
.tp-org-fig-label { font-size: 11.5px; color: var(--pg-text-3); }
.tp-org-fig-value { font-family: var(--pg-font-num); font-weight: 600; font-size: 15px; margin-top: 2px; white-space: nowrap; }
.tp-org-fig-value.is-warning { color: var(--pg-warning); }
.tp-org-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--pg-text-3); }

/* --- États -------------------------------------------------------------- */
.tp-empty { padding: 40px 20px; text-align: center; color: var(--pg-text-3); font-size: 13px; }
.tp-empty-ico { width: 44px; height: 44px; border-radius: 12px; background: var(--pg-surface-3); color: var(--pg-text-3); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.tp-empty-ico svg, .tp-empty-ico i { width: 22px; height: 22px; }
.tp-empty-title { font-size: 14px; font-weight: 600; color: var(--pg-text); margin-bottom: 4px; }
.tp-loading { padding: 40px 20px; text-align: center; color: var(--pg-text-3); }
.tp-note {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px;
  background: var(--pg-info-soft); color: #23496B; font-size: 12.5px; line-height: 1.45;
}
.tp-note.is-warning { background: var(--pg-warning-soft); color: #7A4A00; }
.tp-note.is-danger { background: var(--pg-danger-soft); color: #8A1C13; }
.tp-note svg, .tp-note i { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; }

/* --- Volet latéral (dossier organisme / bordereau) --------------------- */
.tp-drawer-overlay {
  position: fixed; inset: 0; z-index: 1500; background: rgba(28,27,25,.32);
  display: flex; justify-content: flex-end; animation: pg-fade-in var(--pg-med) ease;
}
.tp-drawer {
  width: min(720px, 100vw); height: 100%; background: var(--pg-bg);
  display: flex; flex-direction: column; box-shadow: var(--pg-shadow-2);
  animation: tp-slide-in 220ms var(--pg-ease);
}
@keyframes tp-slide-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.tp-drawer-head { background: var(--pg-surface); border-bottom: 1px solid var(--pg-border); padding: 18px 22px 0; }
.tp-drawer-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tp-drawer-title { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.tp-drawer-sub { font-size: 12.5px; color: var(--pg-text-3); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tp-drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; padding: 14px 0; }
.tp-drawer .tp-tabs { margin-bottom: 0; border-bottom: none; }
.tp-drawer-body { flex: 1; overflow-y: auto; padding: 18px 22px 28px; }
.tp-drawer-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.tp-dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; font-size: 13px; margin: 0; }
.tp-dl dt { color: var(--pg-text-3); }
.tp-dl dd { margin: 0; font-weight: 500; }

/* --- Fenêtres de saisie ------------------------------------------------- */
.modal-overlay.tp-modal-overlay { z-index: 2000; padding: 12px; }
.tp-modal { max-width: 560px; width: calc(100vw - 24px); max-height: 92vh; display: flex; flex-direction: column; }
.tp-modal.is-wide { max-width: 820px; }
.tp-modal .modal-body { overflow-y: auto; flex: 1; }
.tp-modal .modal-footer { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tp-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.tp-form-grid .full { grid-column: 1 / -1; }
.tp-form-grid .form-group { margin: 0; }
.tp-form-grid label { display: block; margin-bottom: 6px; }
.tp-form-grid input, .tp-form-grid select, .tp-form-grid textarea { width: 100%; }
.tp-help { font-size: 12px; color: var(--pg-text-3); margin-top: 4px; }
.tp-sum { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--pg-brand-soft); margin-top: 12px; }
.tp-sum-label { font-size: 13px; font-weight: 600; color: var(--pg-brand); }
.tp-sum-value { font-family: var(--pg-font-num); font-size: 20px; font-weight: 650; color: var(--pg-brand); }

/* --- Responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
  .tp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .tp-top { gap: 8px; }
  .tp-top-actions { width: 100%; }
  .tp-top-actions .btn { flex: 1; justify-content: center; }
  .tp-kpi { padding: 12px 14px; }
  .tp-kpi-value { font-size: 18px; }
  .tp-filter-input { max-width: none; }
  .tp-filters-end { margin-left: 0; width: 100%; }
  .tp-drawer-figs { grid-template-columns: 1fr 1fr; }
  .tp-dl { grid-template-columns: 1fr; gap: 2px; }
  .tp-dl dd { margin-bottom: 8px; }
  .tp-form-grid { grid-template-columns: 1fr; }
  /* Tableaux en cartes */
  .tp-table.is-cards thead { display: none; }
  .tp-table.is-cards, .tp-table.is-cards tbody, .tp-table.is-cards tr, .tp-table.is-cards td { display: block; width: 100%; }
  .tp-table.is-cards tr { padding: 10px 14px; border-bottom: 1px solid var(--pg-border); display: flex; flex-direction: column; }
  .tp-table.is-cards td { border: none; padding: 2px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .tp-table.is-cards td::before { content: attr(data-label); font-family: var(--pg-font); font-size: 12px; color: var(--pg-text-3); text-align: left; flex-shrink: 0; }
  .tp .tp-table.is-cards td { padding: 3px 0 !important; font-size: 13px; }
  .tp .tp-table.is-cards tfoot td { padding: 8px 4px !important; }
  .tp-table.is-cards td.tp-hide-sm { display: none; }
  .tp-table.is-cards td.tp-td-main { display: block; text-align: left; padding-bottom: 4px; order: -1; }
  .tp-table.is-cards td.tp-td-main::before { display: none; }
  .tp-table.is-cards td.tp-td-actions::before { display: none; }
  .tp-table.is-cards td.tp-td-actions { justify-content: flex-end; padding-top: 6px; }
  .tp-table.is-cards tfoot { display: block; }
  .tp-table.is-cards tfoot tr { display: flex; flex-direction: row; flex-wrap: wrap; }
  .tp-table.is-cards tfoot td { width: auto; flex: 1; }
}
@media (max-width: 480px) {
  .tp-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tp-kpi-value { font-size: 16px; }
  .tp-drawer-head, .tp-drawer-body { padding-left: 14px; padding-right: 14px; }
}

} /* fin @media screen */
