:root {
  --teal-900: #0B3D3D;
  --teal-700: #14665F;
  --sage-50: #EEF4EF;
  --bg: #F4F7F5;
  --ink: #16241F;
  --amber: #D98E2B;
  --coral: #C4483B;
  --ok: #14665F;
  --white: #FFFFFF;
  --border: rgba(11, 61, 61, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
h1, h2, h3, .font-display { font-family: 'Space Grotesk', sans-serif; }
.mono { font-family: 'IBM Plex Mono', monospace; }
a { text-decoration: none; color: inherit; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main-content { flex: 1; min-width: 0; padding: 24px; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--teal-900);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
}
.sidebar-brand { display: flex; align-items: flex-start; gap: 10px; padding: 0 8px; margin-bottom: 20px; }
.lang-switch { display: flex; gap: 4px; padding: 0 8px; margin-bottom: 16px; }
.lang-btn {
  flex: 1; text-align: center; padding: 5px 0; border-radius: 6px; font-size: 11px; font-weight: 700;
  letter-spacing: 0.03em; color: rgba(255,255,255,0.55); background: rgba(255,255,255,0.06);
  transition: background 0.15s, color 0.15s;
}
.lang-btn:hover { background: rgba(255,255,255,0.14); color: #fff; }
.lang-btn.active { background: #fff; color: var(--teal-900); }
.brand-icon {
  width: 32px; height: 32px; border-radius: 8px; background: var(--teal-700); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
}
.brand-logo { width: 40px; height: 40px; object-fit: contain; flex-shrink: 0; }
.brand-name { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 12px; line-height: 1.3; }
.brand-version { font-size: 10px; color: rgba(255,255,255,0.5); font-family: 'IBM Plex Mono', monospace; }
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.72); font-size: 13.5px; transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.10); color: #fff; }
.nav-link.active { background: #fff; color: var(--teal-900); font-weight: 600; }
.nav-badge {
  margin-left: auto; background: var(--coral); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center;
}
.nav-link.active .nav-badge { background: var(--amber); }
.sidebar-date {
  margin-top: auto; padding: 10px 12px; background: rgba(255,255,255,0.06); border-radius: 8px;
  font-size: 11px; color: rgba(255,255,255,0.55); font-family: 'IBM Plex Mono', monospace;
}
.nav-icon { width: 15px; height: 15px; display: inline-block; opacity: 0.9; }
.nav-icon::before { content: '•'; }
.icon-dashboard::before { content: '▦'; }
.icon-pill::before { content: '●'; }
.icon-cart::before { content: '▤'; }
.icon-users::before { content: '◐'; }
.icon-file::before { content: '▥'; }
.icon-chart::before { content: '▲'; }
.icon-admin::before { content: '⚙'; }
.icon-sales::before { content: '$'; }
.icon-tag::before { content: '🏷'; }
.icon-stetho::before { content: '🩺'; }
.icon-flask::before { content: '🧪'; }
.icon-radio::before { content: '🩻'; }
.icon-hospital::before { content: '🏥'; }

/* ---------- Catégories ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Laboratoire / Examens spécialisés (styles partagés) ---------- */
.labo-cat-block, .spec-cat-block { margin-bottom: 16px; }
.labo-cat-heading, .spec-cat-heading {
  display: flex; align-items: center; justify-content: space-between; font-weight: 600;
  font-size: 13px; color: var(--teal-900); margin-bottom: 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.labo-exam-line, .spec-exam-line {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px;
}
.labo-exam-line:hover, .spec-exam-line:hover { background: var(--sage-50); }
.labo-exam-line input[type="checkbox"], .spec-exam-line input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; }
.labo-exam-name, .spec-exam-name { flex: 1; }

/* ---------- Bloc opératoire (désignation + prix éditable) ---------- */
.bloc-desig-line {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-radius: 6px; font-size: 12.5px;
}
.bloc-desig-line:hover { background: var(--sage-50); }
.bloc-desig-check { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; min-width: 0; }
.bloc-desig-check input[type="checkbox"] { width: auto; margin: 0; flex-shrink: 0; }
.bloc-desig-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bloc-desig-prix {
  width: 92px; flex-shrink: 0; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border);
  font-family: 'IBM Plex Mono', monospace; font-size: 12px; text-align: right;
}
.bloc-desig-prix:disabled { background: var(--sage-50); color: rgba(22,36,31,0.4); }
.cat-card {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid;
  border-radius: 10px; padding: 12px 14px; display: flex; align-items: center; gap: 10px;
}
.cat-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.cat-info { flex: 1; min-width: 0; }
.cat-name { font-weight: 600; font-size: 13.5px; }
.cat-count { font-size: 11.5px; color: rgba(22,36,31,0.5); margin-top: 2px; }
.cat-actions { display: flex; gap: 2px; flex-shrink: 0; }

/* ---------- Sidebar user block ---------- */
.sidebar-user {
  display: flex; align-items: center; gap: 8px; margin-top: 16px; padding: 10px;
  background: rgba(255,255,255,0.06); border-radius: 10px;
}
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--teal-700); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  font-family: 'Space Grotesk', sans-serif; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: 10.5px; color: rgba(255,255,255,0.5); }
.logout-link { color: rgba(255,255,255,0.6); font-size: 15px; padding: 4px; border-radius: 6px; }
.logout-link:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.export-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; font-weight: 700; margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px;
  padding: 9px 14px; font-size: 13.5px; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: background 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--teal-900); color: #fff; }
.btn-primary:hover { background: var(--teal-700); }
.btn-outline { background: #fff; color: var(--ink); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--sage-50); }
.btn-danger { background: var(--coral); color: #fff; }
.btn-danger:hover { background: #a83c31; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { background: none; border: none; cursor: pointer; padding: 5px; border-radius: 6px; color: var(--ink); font-size: 13px; line-height: 1; }
.btn-icon:hover { background: var(--sage-50); }
.btn-icon.icon-danger:hover { background: rgba(196,72,59,0.10); color: var(--coral); }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 1px 2px rgba(11,61,61,0.03); }
.stat-card .stat-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.06em; color: rgba(22,36,31,0.5); font-weight: 600; }
.stat-card .stat-value { font-family: 'Space Grotesk', sans-serif; font-size: 24px; font-weight: 700; margin: 6px 0 2px; }
.stat-card .stat-sub { font-size: 11px; color: rgba(22,36,31,0.45); }
.stat-card.tone-coral .stat-value { color: var(--coral); }
.stat-card.tone-amber .stat-value { color: var(--amber); }

.panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; box-shadow: 0 1px 2px rgba(11,61,61,0.03); margin-bottom: 16px; }
.panel h3 { font-size: 13.5px; font-weight: 600; margin: 0 0 12px; }
.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Rapports : bloc hero + cartes par rubrique ---------- */
.rap-hero {
  background: linear-gradient(135deg, var(--teal-900) 0%, var(--teal-700) 100%);
  border-radius: 14px; padding: 24px 28px; margin-bottom: 16px; color: #fff;
  box-shadow: 0 4px 16px rgba(11,61,61,0.18);
}
.rap-hero-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.75); font-weight: 600; }
.rap-hero-value { font-family: 'Space Grotesk', sans-serif; font-size: 34px; font-weight: 700; margin: 8px 0 4px; }
.rap-hero-sub { font-size: 12px; color: rgba(255,255,255,0.7); }

.rap-cards-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; margin-bottom: 20px; }
.rap-card {
  background: #fff; border: 1px solid var(--border); border-left: 4px solid; border-radius: 12px;
  padding: 16px; box-shadow: 0 1px 2px rgba(11,61,61,0.03); position: relative; overflow: hidden;
}
.rap-card-icon { font-size: 20px; display: block; margin-bottom: 8px; }
.rap-card-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(22,36,31,0.5); font-weight: 600; }
.rap-card-value { font-family: 'Space Grotesk', sans-serif; font-size: 21px; font-weight: 700; margin: 4px 0 2px; color: var(--ink); }
.rap-card-sub { font-size: 11px; color: rgba(22,36,31,0.45); }
.rap-card-pharma { border-left-color: #14665F; }
.rap-card-labo { border-left-color: #D98E2B; }
.rap-card-conso { border-left-color: #8B3A62; }
.rap-card-special { border-left-color: #C4483B; }
.rap-card-bloc { border-left-color: #5C4A8B; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: 10.5px; font-family: 'IBM Plex Mono', monospace; border: 1px solid transparent;
}
.badge-ok { background: rgba(20,102,95,0.10); color: var(--teal-900); border-color: rgba(20,102,95,0.25); }
.badge-warn { background: rgba(217,142,43,0.10); color: var(--amber); border-color: rgba(217,142,43,0.3); }
.badge-danger { background: rgba(196,72,59,0.10); color: var(--coral); border-color: rgba(196,72,59,0.3); }
.badge-default { background: var(--sage-50); color: var(--teal-700); border-color: rgba(20,102,95,0.2); }
.badge-purple { background: rgba(92,74,139,0.10); color: #5C4A8B; border-color: rgba(92,74,139,0.3); }

/* ---------- Medicine label (fiche médicament) ---------- */
.med-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.med-list.compact { grid-template-columns: 1fr; }
.med-label {
  background: #fff; border: 1px solid var(--border); border-left: 3px dashed;
  border-radius: 8px; padding: 12px 12px 12px 16px; display: flex; align-items: center; gap: 12px;
}
.med-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.med-info { flex: 1; min-width: 0; }
.med-name-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.med-name { font-weight: 600; font-size: 13.5px; }
.med-batch { font-size: 10px; color: rgba(22,36,31,0.4); }
.med-meta { font-size: 11px; color: rgba(22,36,31,0.5); margin-top: 2px; }
.med-badges { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.med-actions { display: flex; gap: 2px; flex-shrink: 0; align-self: flex-start; }

/* ---------- Search ---------- */
.search-box { position: relative; max-width: 320px; margin-bottom: 16px; }
.search-box input {
  width: 100%; padding: 9px 12px 9px 32px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13.5px; font-family: inherit;
}
.search-box::before { content: '⌕'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: rgba(22,36,31,0.4); }

/* ---------- Scanner de codes-barres (POS) ---------- */
.scan-box {
  display: flex; align-items: center; gap: 8px; max-width: 400px; margin-bottom: 12px;
  background: #fff; border: 2px dashed var(--teal-700); border-radius: 8px; padding: 8px 12px;
}
.scan-icon { font-size: 15px; flex-shrink: 0; }
.scan-box input {
  border: none; outline: none; font-size: 13.5px; font-family: 'IBM Plex Mono', monospace;
  flex: 1; background: transparent; color: var(--ink);
}
.scan-box:focus-within { border-style: solid; background: var(--sage-50); }

/* ---------- Barre de filtres ---------- */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type="date"] {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; font-family: inherit;
}

/* ---------- Tables ---------- */
table.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 12px; overflow: hidden; }
table.data-table thead { background: var(--sage-50); }
table.data-table th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: rgba(22,36,31,0.5); padding: 10px 14px; font-weight: 600; }
table.data-table td { padding: 10px 14px; border-top: 1px solid var(--border); font-size: 13px; }
.table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }

/* ---------- POS (ventes) ---------- */
.pos-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; align-items: start; }
.pos-items { display: flex; flex-direction: column; gap: 16px; max-height: 65vh; overflow-y: auto; padding-right: 4px; }
.pos-cat-section { display: flex; flex-direction: column; gap: 8px; }
.pos-cat-heading {
  display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--teal-900);
  position: sticky; top: 0; background: var(--bg); padding: 4px 2px; z-index: 1;
}
.pos-cat-count { color: rgba(22,36,31,0.4); font-weight: 500; text-transform: none; letter-spacing: 0; margin-left: 2px; }
.pos-cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pos-item {
  text-align: left; background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  cursor: pointer; font-family: inherit;
}
.pos-item:hover { border-color: var(--teal-700); }
.pos-item:disabled { opacity: 0.4; cursor: not-allowed; }
.pos-item-name { font-size: 13px; font-weight: 600; }
.pos-item-row { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.pos-item-price { font-family: 'IBM Plex Mono', monospace; color: var(--teal-700); font-weight: 600; font-size: 13px; }

/* Chips de filtrage par categorie */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: #fff; font-size: 12px; font-weight: 500; color: var(--ink);
  cursor: pointer; font-family: inherit; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cat-chip:hover:not(.active) { background: var(--sage-50); }
.cat-chip.active { background: var(--teal-900); color: #fff; border-color: var(--teal-900); }
.cat-chip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.cart-panel { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: sticky; top: 16px; }
.cart-panel select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px; margin-bottom: 10px; font-family: inherit; }
.cart-patient-field { margin-bottom: 10px; }
.cart-patient-field input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13px; font-family: inherit;
}
.cart-patient-hint { display: block; font-size: 10.5px; margin-top: 3px; color: rgba(22,36,31,0.45); min-height: 14px; }
.cart-patient-hint.known { color: var(--teal-700); font-weight: 500; }

#manualItemForm input {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13px; font-family: inherit; margin-bottom: 8px;
}
#manualItemForm .field-row input { margin-bottom: 0; }
#manualItemForm .field-row { align-items: center; }
.cart-line { display: flex; align-items: center; gap: 8px; font-size: 13px; border-bottom: 1px solid var(--border); padding-bottom: 8px; margin-bottom: 8px; }
.cart-line-info { flex: 1; min-width: 0; }
.cart-line-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-line-price { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: rgba(22,36,31,0.5); }
.qty-btn { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer; }
.qty-input {
  width: 34px; height: 22px; text-align: center; font-size: 12px; padding: 0 2px;
  border: 1px solid var(--border); border-radius: 6px; font-family: 'IBM Plex Mono', monospace;
}
.qty-input::-webkit-inner-spin-button, .qty-input::-webkit-outer-spin-button { margin: 0; }
.cart-total { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: 10px; border-top: 1px solid var(--border); margin-top: 4px; }
.cart-subtotal-row { display: flex; justify-content: space-between; width: 100%; font-size: 11.5px; margin-bottom: 4px; }

.cart-remise-field { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.cart-remise-field label { font-size: 12.5px; color: rgba(22,36,31,0.6); }
.remise-input-wrap { display: flex; align-items: center; gap: 4px; }
.remise-input-wrap input {
  width: 56px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border);
  font-size: 13px; font-family: 'IBM Plex Mono', monospace; text-align: right;
}
.remise-input-wrap span { font-size: 12.5px; color: rgba(22,36,31,0.5); }
.cart-total-value { font-family: 'IBM Plex Mono', monospace; font-size: 19px; font-weight: 700; color: var(--teal-900); }
.cart-empty { text-align: center; color: rgba(22,36,31,0.4); font-size: 12px; padding: 20px 0; }
.pay-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }

/* ---------- Prescriptions ---------- */
.rx-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; border-left: 4px dashed var(--amber); }
.rx-card.delivree { border-left-color: var(--teal-700); }
.rx-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.rx-id { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: rgba(22,36,31,0.4); }
.rx-patient { font-weight: 600; font-size: 13.5px; }
.rx-doctor { color: rgba(22,36,31,0.45); font-weight: 400; }
.rx-date { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: rgba(22,36,31,0.5); margin-bottom: 8px; }
.rx-line { font-size: 13px; margin-bottom: 3px; }
.rx-line .rx-posologie { color: rgba(22,36,31,0.45); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: none;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; padding: 20px; width: 380px; max-width: 90vw; }
.modal-box h3 { margin: 0 0 12px; font-size: 15px; }
.field-row { display: flex; gap: 8px; }
.modal-box input, .modal-box select {
  width: 100%; padding: 9px 11px; border-radius: 8px; border: 1px solid var(--border); font-size: 13px;
  margin-bottom: 10px; font-family: inherit;
}
.modal-close { float: right; background: none; border: none; font-size: 16px; cursor: pointer; color: rgba(22,36,31,0.5); }

/* ---------- Champ mot de passe avec bouton "afficher" ---------- */
.password-field { position: relative; }
.password-field input { padding-right: 38px !important; margin-bottom: 0 !important; }
.password-field { margin-bottom: 10px; }
.password-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 15px; line-height: 1;
  padding: 6px; border-radius: 6px; color: rgba(22,36,31,0.45);
}
.password-toggle:hover { background: var(--sage-50); color: var(--ink); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 20px; right: 20px; background: var(--ink); color: #fff; font-size: 13px;
  padding: 11px 16px; border-radius: 8px; box-shadow: 0 4px 14px rgba(0,0,0,0.2); z-index: 200;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Charts ---------- */
.chart-box { width: 100%; height: 220px; }

/* ---------- Alerts list ---------- */
.alert-list { max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Misc ---------- */
.text-muted { color: rgba(22,36,31,0.45); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.empty-state { text-align: center; padding: 30px; color: rgba(22,36,31,0.4); font-size: 13px; }

/* ---------- Reçu ---------- */
.modal-box.receipt-box { width: auto; max-width: 92vw; display: flex; flex-direction: column; align-items: center; }

/* Onglets de sélection du format d'impression */
.format-tabs { display: flex; gap: 6px; margin-bottom: 14px; width: 100%; }
.format-tab {
  flex: 1; padding: 8px 6px; border-radius: 8px; border: 1px solid var(--border); background: #fff;
  font-size: 11px; font-weight: 500; cursor: pointer; font-family: 'Inter', sans-serif; color: var(--ink);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.format-tab.active { background: var(--teal-900); color: #fff; border-color: var(--teal-900); }
.format-tab:hover:not(.active) { background: var(--sage-50); }

.receipt {
  font-family: 'IBM Plex Mono', monospace; color: var(--ink);
  border: 1px dashed rgba(11,61,61,0.3); border-radius: 4px; background: #fff;
  box-sizing: border-box; overflow: hidden;
}
/* Format Epson 80mm : largeur imprimable standard ~72mm */
.receipt.format-80 { width: 76mm; font-size: 14px; padding: 4.5mm 4mm; line-height: 1.45; }
.receipt.format-80 .pharmacy-name { font-size: 16.5px; line-height: 1.3; }
.receipt.format-80 .pharmacy-sub { font-size: 12px; font-weight: 700; }

/* Format petite imprimante 58mm : largeur imprimable ~46-48mm.
   Police agrandie et mise en gras pour se rapprocher d'un rendu
   d'imprimante a impact (type reçu de reference), bien lisible malgre
   la largeur etroite. */
.receipt.format-58 { width: 48mm; font-size: 12.5px; padding: 3.5mm 3mm; line-height: 1.4; }
.receipt.format-58 .pharmacy-name { font-size: 13.5px; line-height: 1.3; }
.receipt.format-58 .pharmacy-sub { font-size: 10.5px; font-weight: 700; }
.receipt.format-58 .receipt-total-row { font-size: 15px; }

.receipt-header { text-align: center; margin-bottom: 8px; }
.receipt-logo { display: block; margin: 0 auto 6px; }
.receipt.format-80 .receipt-logo { width: 52px; height: 52px; object-fit: contain; }
.receipt.format-58 .receipt-logo { width: 36px; height: 36px; object-fit: contain; }
.receipt-header .pharmacy-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; color: var(--teal-900); }
.receipt-header .pharmacy-sub { color: rgba(22,36,31,0.5); }
.receipt-divider { border: none; border-top: 1px dashed rgba(11,61,61,0.35); margin: 8px 0; }
.receipt-meta { margin-bottom: 3px; display: flex; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.receipt-line { display: flex; justify-content: space-between; gap: 6px; margin-bottom: 5px; font-weight: 600; }
/* min-width: 0 est le correctif du bug flexbox : sans ca, un nom d'article
   long et sans espace ("Appendicectomie", "Echocardiographie"...) empeche
   le conteneur flex de retrecir et pousse tout le recu au-dela de la
   largeur fixee (76mm/48mm), meme si "width" est bien defini plus haut.
   Applique a tous les formats desormais (pas seulement le 58mm). */
.receipt-line .rl-name { flex: 1; min-width: 0; word-break: break-word; overflow-wrap: break-word; }
.receipt-meta span { min-width: 0; overflow-wrap: break-word; }
.receipt-total-row { display: flex; justify-content: space-between; font-weight: 700; margin-top: 8px; font-size: 1.2em; }
.receipt-footer { text-align: center; margin-top: 10px; color: rgba(22,36,31,0.6); font-size: 0.95em; }
.receipt-actions { display: flex; gap: 8px; margin-top: 14px; width: 100%; }
.receipt-actions .btn { flex: 1; justify-content: center; }

/* ---------- Fiche patient imprimable ---------- */
.modal-box.fiche-box { width: 480px; max-width: 92vw; }
.fiche { font-family: 'Inter', sans-serif; color: var(--ink); font-size: 13px; }
.fiche-header { display: flex; align-items: center; justify-content: space-between; }
.fiche-pharmacy { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; color: var(--teal-900); }
.fiche-identity h2 { font-family: 'Space Grotesk', sans-serif; font-size: 18px; margin: 0 0 8px; }
.fiche-meta-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 3px 0; border-bottom: 1px dotted rgba(11,61,61,0.15); }
.fiche h3 { font-size: 13.5px; margin: 14px 0 8px; font-family: 'Space Grotesk', sans-serif; color: var(--teal-900); }
.fiche-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fiche-table th { text-align: left; padding: 6px 8px; background: var(--sage-50); font-size: 10.5px; text-transform: uppercase; color: rgba(22,36,31,0.5); }
.fiche-table td { padding: 6px 8px; border-top: 1px solid var(--border); }
.fiche-rx { border: 1px dashed rgba(11,61,61,0.25); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.fiche-rx-line { font-size: 12px; color: rgba(22,36,31,0.7); margin-top: 2px; }

/* ---------- En-tête visible uniquement à l'impression (rapports) ---------- */
.print-only-header { display: none; }
@media print {
  .print-only-header { display: block; margin-bottom: 14px; }
}

@media print {
  body * { visibility: hidden; }
  .print-target, .print-target * { visibility: visible; }
  /* display:block (au lieu de flex herite de .modal-overlay) + align-items
     desactive : sans ca, le contenu restait centre verticalement dans la
     page au lieu de partir du tout en haut, ce qui le poussait vers le
     milieu/bas de la feuille et le faisait deborder/couper a l'impression. */
  .print-target {
    position: absolute; top: 0; left: 0; right: auto; bottom: auto;
    width: 100%; height: auto; min-height: 0; max-height: none;
    background: #fff; display: block !important;
    align-items: flex-start !important; justify-content: flex-start !important;
    margin: 0; padding: 0;
  }
  .print-target .modal-box { box-shadow: none; margin: 0 auto; padding: 0; }
  .print-target .modal-box.fiche-box { padding: 10mm; width: 100%; max-width: 100%; }
  #receiptContent { border: none; }
  .no-print { display: none !important; }
}

/* ---------- Auth pages (login / setup) ---------- */
.auth-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--teal-900) radial-gradient(circle at 25% 15%, rgba(20,102,95,0.55), transparent 55%);
  font-family: 'Inter', sans-serif; padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 16px; padding: 32px 30px; width: 380px; max-width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.auth-brand .brand-icon {
  width: 34px; height: 34px; border-radius: 9px; background: var(--teal-900); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.auth-brand-centered { flex-direction: column; text-align: center; gap: 8px; }
.auth-logo { width: 84px; height: 84px; object-fit: contain; }
.auth-brand-centered .auth-brand-text { font-size: 15px; text-align: center; }
.auth-brand-text { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 14px; line-height: 1.3; color: var(--teal-900); }
.auth-title { font-family: 'Space Grotesk', sans-serif; font-size: 21px; margin: 0 0 4px; color: var(--ink); }
.auth-sub { font-size: 13px; color: rgba(22,36,31,0.55); margin: 0 0 20px; }
.auth-form input {
  width: 100%; padding: 11px 13px; border-radius: 9px; border: 1px solid var(--border);
  font-size: 13.5px; margin-bottom: 10px; font-family: inherit;
}
.auth-error {
  background: rgba(196,72,59,0.08); color: var(--coral); border: 1px solid rgba(196,72,59,0.25);
  padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-bottom: 14px;
}
.auth-footnote { font-size: 11.5px; color: rgba(22,36,31,0.45); text-align: center; margin: 16px 0 0; }

@media (max-width: 900px) {
  .stat-grid, .rap-cards-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2b, .pos-grid { grid-template-columns: 1fr; }
  .med-list, .cat-grid { grid-template-columns: 1fr; }
}
