/* CSU Caisse — feuille de style (aucune dépendance externe : fonctionne hors ligne) */
:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f7;
  --ink: #1b2321;
  --muted: #5d6965;
  --line: #dde3df;
  --line-strong: #c6cfca;
  --brand: #1d5b4f;
  --brand-2: #164a40;
  --brand-soft: #e3efe9;
  --accent: #b5651d;
  --good: #1d7347; --good-bg: #e5f3ea;
  --warn: #8a5a00; --warn-bg: #fff3d6;
  --bad: #b1261b; --bad-bg: #fde9e7;
  --info: #1c5687; --info-bg: #e7f0f8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 35, 30, .06), 0 2px 8px rgba(20, 35, 30, .04);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; font-weight: 650; }
h2 { font-size: 1.1rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--bad); }
.pos { color: var(--good); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* --- Mise en page --------------------------------------------------------- */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--brand-2); color: #dfeae5; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 4px; overflow-y: auto;
}
.brand { padding: 4px 10px 16px; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: 10px; }
.brand strong { display: block; color: #fff; font-size: 1.05rem; letter-spacing: .01em; }
.brand span { font-size: .78rem; color: #a9c2b9; }
.nav-title { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #8fb0a5; margin: 12px 10px 4px; }
.sidebar a.nav {
  display: flex; align-items: center; gap: 10px; color: #e3eee9; padding: 8px 10px; border-radius: 8px;
  font-size: .93rem;
}
.sidebar a.nav:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar a.nav.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }

main { padding: 22px 28px 60px; max-width: 1400px; width: 100%; }

/* --- Menu du compte (en haut à droite) ------------------------------------- */
.topbar { display: flex; justify-content: flex-end; margin: -8px 0 10px; }
.user-menu { position: relative; }
.user-menu summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 5px 10px 5px 5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); box-shadow: var(--shadow);
}
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { border-color: var(--line-strong); }
.user-menu summary:focus-visible { outline: 2px solid #8cc1b2; outline-offset: 2px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand); color: #fff; font-weight: 650; font-size: .9rem;
}
.user-label { display: grid; line-height: 1.2; text-align: left; }
.user-label b { font-weight: 600; font-size: .9rem; }
.user-label small { color: var(--muted); font-size: .75rem; }
.chevron { color: var(--muted); transition: transform .15s; }
.user-menu[open] .chevron { transform: rotate(180deg); }
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 200px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(20, 35, 30, .16);
}
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; border: 0; background: none;
  color: var(--ink); font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--surface-2); }
.user-dropdown form { margin: 0; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.user-dropdown button { color: var(--bad); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.crumb { font-size: .85rem; color: var(--muted); margin-bottom: 4px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.stack > * + * { margin-top: 16px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.sticky { position: sticky; top: 16px; }

.kpi { padding: 14px 16px; }
.kpi .label { font-size: .8rem; color: var(--muted); }
.kpi .value { font-size: 1.55rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .sub { font-size: .82rem; color: var(--muted); margin-top: 2px; }

/* --- Tableaux ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); border-bottom: 1px solid var(--line-strong); position: sticky; top: 0; }
table.data thead th.num { text-align: right; }  /* titres des colonnes de nombres alignés sur les valeurs */
table.data tbody tr:hover { background: #fafbf9; }
table.data tfoot td, table.data tr.total td { font-weight: 650; background: var(--brand-soft); border-top: 1px solid var(--line-strong); }
table.data tr.group td { background: var(--surface-2); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding-top: 10px; }
table.compact th, table.compact td { padding: 5px 7px; font-size: .84rem; }
table.data td.strong { font-weight: 650; }

/* --- Formulaires ---------------------------------------------------------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff;
  min-height: 38px;
}
.password-field { position: relative; }
.password-field input { padding-right: 84px; }
.password-toggle { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); border: 0; background: none;
  color: var(--brand); font-size: .85rem; font-weight: 600; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.password-toggle:hover { background: var(--brand-soft); }
input:focus, select:focus, textarea:focus { outline: 2px solid #8cc1b2; outline-offset: 0; border-color: var(--brand); }
input[type=number] { text-align: right; font-variant-numeric: tabular-nums; }
input.qty { width: 92px; }
input.amount { width: 130px; }
label { font-size: .85rem; color: var(--muted); display: block; margin-bottom: 3px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 12px; align-items: end; }
.form-grid .wide { grid-column: span 2; }
.form > div, .form p { margin-bottom: 12px; }
/* badge « facultatif » : bien visible (ambre) */
.optional { display: inline-block; vertical-align: middle; margin-left: 6px; padding: 2px 9px; border-radius: 99px;
  background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d9a2; font-size: .74rem; font-weight: 650;
  letter-spacing: .02em; text-transform: uppercase; }
.stock-today { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 10px; }
.stock-today h4 { margin: 0 0 4px; font-size: .92rem; font-weight: 650; }
.count-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 6px; margin-bottom: 8px; }
.count-part { display: flex; align-items: flex-end; gap: 6px; }
.count-part[hidden] { display: none; }
.count-part label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--ink); }
.count-part label small { color: var(--muted); font-size: .75rem; }
.count-part input { width: 88px; }
.count-op { font-size: 1.1rem; font-weight: 600; color: var(--muted); padding-bottom: 8px; }
.count-total input { width: 110px; font-weight: 650; background: var(--brand-soft); border-color: var(--brand); }
.fieldset-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(380px, 100%), 1fr)); gap: 0 16px; align-items: start; }
.fieldset-column { min-width: 0; }
.fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 4px; margin: 0 0 14px; min-width: 0; }
.fieldset legend { font-weight: 650; padding: 0 6px; }
.fieldset-help { font-size: .85rem; color: var(--muted); margin: 0 0 10px; }
.fieldset .form-grid { align-items: end; grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr)); }
.fieldset .form-grid > div { margin-bottom: 8px; }
.unit-summary { background: var(--brand-soft); color: var(--brand-2); border-radius: 8px; padding: 8px 12px; font-size: .9rem; }
.unit-summary ul { margin: 4px 0 0; padding-left: 18px; }
.unit-summary li { margin: 2px 0; }
.unit-summary li b { font-weight: 600; }
.form .helptext, .helptext { font-size: .8rem; color: var(--muted); display: block; margin-top: 3px; }
.errorlist { color: var(--bad); margin: 4px 0; padding-left: 18px; font-size: .85rem; }
input[type=checkbox] { width: 18px; height: 18px; vertical-align: middle; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; min-height: 38px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: #fff; color: var(--ink); cursor: pointer;
  font-weight: 550; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { filter: brightness(.95); background: var(--accent); }
.btn-danger { color: var(--bad); border-color: #efc2bd; }
.btn-danger:hover { background: var(--bad-bg); }
.btn-danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger-solid:hover { filter: brightness(.92); background: var(--bad); }
.btn-sm { padding: 4px 9px; min-height: 30px; font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--bad); padding: 2px 4px; cursor: pointer; font-size: .85rem; }
.btn-group { display: inline-flex; gap: 0; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn + .btn { border-left: 0; }
.btn.is-current { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-2); }

/* --- Badges, alertes ------------------------------------------------------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 600; white-space: nowrap; }
.badge-OUVERTE { background: var(--warn-bg); color: var(--warn); }
.badge-CLOTUREE { background: var(--info-bg); color: var(--info); }
.badge-VALIDEE { background: var(--good-bg); color: var(--good); }
.badge-BROUILLON { background: #eef0ee; color: var(--muted); }
.badge-COMMANDEE { background: var(--info-bg); color: var(--info); }
.badge-RECUE { background: var(--good-bg); color: var(--good); }
.badge-ANNULEE { background: var(--bad-bg); color: var(--bad); }
.badge-low { background: var(--bad-bg); color: var(--bad); }
.badge-ok { background: var(--good-bg); color: var(--good); }
.badge-fund { background: #eef2f0; color: var(--muted); font-weight: 500; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 10px; border: 1px solid transparent; font-size: .93rem; }
.alert.flash { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; transition: opacity .4s; }
.alert.flash-hide { opacity: 0; }
.flash-close { border: 0; background: none; color: inherit; font-size: 1.2rem; line-height: 1; padding: 0 2px; cursor: pointer; opacity: .7; }
.flash-close:hover { opacity: 1; }
.alert-success { background: var(--good-bg); color: var(--good); border-color: #bfe0cb; }
.alert-info { background: var(--info-bg); color: var(--info); border-color: #c4d9ec; }
.alert-warning, .alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #f0d9a2; }
.alert-error, .alert-bad { background: var(--bad-bg); color: var(--bad); border-color: #f2c4bf; }
.alert a { color: inherit; text-decoration: underline; }
ul.alerts { list-style: none; margin: 0; padding: 0; }

/* --- Résumé de journée ----------------------------------------------------- */
.summary dl { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 0; font-size: .92rem; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.summary dd.sum, .summary dt.sum { font-weight: 650; color: var(--ink); border-top: 1px solid var(--line); padding-top: 4px; }
.summary .fund { padding: 10px 0; border-bottom: 1px dashed var(--line-strong); }
.summary .fund:last-of-type { border-bottom: 0; }
.summary .fund h3 { margin-bottom: 6px; }
.summary .net { display: flex; justify-content: space-between; align-items: baseline; background: var(--brand); color: #fff; border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.summary .net strong { font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.summary .sub dt { padding-left: 10px; font-size: .86rem; }
.summary .sub dd { font-size: .86rem; }

.day-nav { display: inline-flex; align-items: center; gap: 6px; }
.status-line { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: .88rem; color: var(--muted); }

/* --- Graphiques simples ----------------------------------------------------- */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; align-items: end; height: 170px; padding-top: 8px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: stretch; height: 100%; position: relative; }
.bar .gross { background: #cfe0d9; border-radius: 4px 4px 0 0; position: relative; }
.bar .netbar { background: var(--brand); border-radius: 4px 4px 0 0; position: absolute; bottom: 0; left: 22%; right: 22%; }
.bar.current .gross { background: #f1dcc7; }
.bar.current .netbar { background: var(--accent); }
.bar-labels { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; font-size: .72rem; color: var(--muted); text-align: center; margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.hbar { height: 8px; background: #e4ebe7; border-radius: 4px; overflow: hidden; min-width: 80px; }
.hbar span { display: block; height: 100%; background: var(--brand); }

/* --- Paramètres ------------------------------------------------------------- */
.settings a.card { display: block; color: inherit; }
.settings a.card:hover { border-color: var(--brand); text-decoration: none; }
.settings a.card h2 { color: var(--brand); }
.form #id_roles label { color: var(--ink); font-size: .9rem; margin-bottom: 6px; }

/* --- Reçu patient ------------------------------------------------------------ */
.suggestions { margin-top: 10px; display: grid; gap: 4px; }
.suggestions[hidden] { display: none; }
.suggestion { text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: .9rem; }
.suggestion:hover { border-color: var(--brand); background: var(--brand-soft); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
/* Reçu : ticket d'imprimante thermique POS 80 mm (zone imprimable ≈ 72 mm). À l'écran, le reçu a sa taille
   réelle (aperçu). Marge de page nulle : le navigateur n'a plus de place pour l'adresse, la date et le n° de page.
   La hauteur de page est ajustée au contenu par le script de la page du reçu (rouleau sans fin). */
.card.receipt { width: 80mm; max-width: 100%; padding: 4mm 4mm 6mm; font-size: 12px; line-height: 1.35; }
.receipt-head { text-align: center; border-bottom: 1px dashed var(--line-strong); padding-bottom: 6px; margin-bottom: 6px; }
.receipt-head strong { font-size: 13px; }
.receipt-meta { display: grid; gap: 1px; margin-bottom: 6px; }
.receipt-meta span { display: inline-block; min-width: 22mm; color: var(--muted); }
.receipt table.data th, .receipt table.data td { padding: 2px 0 2px 4px; font-size: 11px; }
.receipt table.data th:first-child, .receipt table.data td:first-child { padding-left: 0; }
.receipt table.data tfoot td { font-size: 13px; border-top: 1px dashed var(--ink); }
@page receipt { size: 80mm 200mm; margin: 0; }
@media print {
  body.print-receipt { page: receipt; }
  body.print-receipt main { padding: 0; }
  .card.receipt { width: 80mm; border: 0; padding: 3mm 4mm 6mm; }
  .card.receipt, .card.receipt * { color: #000 !important; background: #fff !important; }
  .receipt-head, .receipt table.data th, .receipt table.data td { border-color: #000 !important; }
}

/* --- Connexion -------------------------------------------------------------- */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(circle at 15% 10%, #dcebe4 0, transparent 45%),
              radial-gradient(circle at 90% 90%, #f3e6d6 0, transparent 40%), var(--bg);
}
.login-shell {
  width: min(940px, 100%); display: grid; grid-template-columns: 1fr 1fr; background: var(--surface);
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(20, 35, 30, .14), 0 2px 6px rgba(20, 35, 30, .06);
}
.login-brand {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: center; gap: 22px;
  padding: 44px 40px; color: #fff; background: linear-gradient(155deg, var(--brand) 0%, var(--brand-2) 100%);
}
/* halos décoratifs, rappel du soleil du logo */
.login-brand::before, .login-brand::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.login-brand::before { width: 340px; height: 340px; right: -140px; top: -120px; background: rgba(255, 255, 255, .06); }
.login-brand::after { width: 220px; height: 220px; left: -90px; bottom: -90px; background: rgba(240, 190, 60, .12); }
.login-logo {
  position: relative; z-index: 1; width: 148px; height: 148px; padding: 10px; background: #fff; border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.login-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.login-brand > div, .login-brand p { position: relative; z-index: 1; }
.login-kicker { margin: 0 0 6px; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; color: rgba(255, 255, 255, .72); }
.login-brand h2 { margin: 0; font-size: 1.5rem; line-height: 1.25; color: #fff; }
.login-tagline { margin: 0; color: rgba(255, 255, 255, .82); border-left: 3px solid #f0be3c; padding-left: 12px; }
.login-form { padding: 48px 44px; display: flex; flex-direction: column; justify-content: center; }
.login-form h1 { font-size: 1.6rem; margin-bottom: 4px; }
.login-form .form { margin-top: 14px; }
.login-form input[type=text], .login-form input[type=password] { padding-top: 11px; padding-bottom: 11px; }
.login-submit { width: 100%; min-height: 46px; font-size: 1rem; margin-top: 4px; }
.login-help { margin: 18px 0 0; text-align: center; }
.login-page { grid-template-rows: 1fr auto; }
.login-credit { margin-top: 18px; text-align: center; font-size: .8rem; color: var(--muted); }
.login-credit a { color: var(--brand); }
@media (max-width: 760px) {
  .login-shell { grid-template-columns: minmax(0, 1fr); }
  .login-brand { padding: 28px 22px; gap: 14px; align-items: center; text-align: center; }
  .login-logo { width: 104px; height: 104px; border-radius: 18px; }
  .login-brand h2 { font-size: 1.2rem; }
  .login-tagline { border-left: 0; padding-left: 0; }
  .login-form { padding: 28px 22px 32px; }
}

/* --- Responsive ------------------------------------------------------------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 8px 10px; gap: 2px; }
  .brand { display: none; }
  .nav-title { display: none; }
  .sidebar a.nav { white-space: nowrap; padding: 7px 10px; font-size: .88rem; }
  .user-label { display: none; }
  main { padding: 16px 16px 50px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .wide { grid-column: auto; }
  .hide-sm { display: none; }
  table.data th, table.data td { padding: 6px 5px; }
  input.qty { width: 70px; } input.amount { width: 100px; }
  .bars { gap: 4px; } .bar-labels { gap: 4px; font-size: .62rem; }
}

/* --- Impression (rapports) -------------------------------------------------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .layout { display: block; min-height: 0; }
  .sidebar, .no-print, .actions, .messages, .toast-zone { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 10px; }
  table.data th, table.data td { padding: 3px 5px; }
  table.data thead th { position: static; }
  .print-only { display: block !important; }
  a { color: inherit; }
}
.print-only { display: none; }

/* --- Choix d'un produit par recherche ---------------------------------------- */
.picker { position: relative; min-width: 220px; }
.picker .picker-input { padding-right: 34px; cursor: pointer; }
.picker .picker-input:focus { cursor: text; }
.picker-toggle {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%); width: 28px; height: 28px; display: grid;
  place-items: center; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer;
}
.picker-toggle:hover { background: var(--surface-2); color: var(--ink); }
.picker .picker-input[aria-expanded=true] ~ .picker-toggle svg { transform: rotate(180deg); }
.picker-list {
  position: fixed; z-index: 60; max-height: 320px; overflow-y: auto;
  margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; box-shadow: 0 12px 28px rgba(20, 35, 30, .16);
}
.picker-list li { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.picker-list li.active, .picker-list li:hover { background: var(--brand-soft); }
.picker-meta { font-size: .78rem; color: var(--muted); }
.picker-list li.picker-out .picker-meta { color: var(--bad); }
.picker-list .picker-empty { color: var(--muted); cursor: default; }
.picker-list .picker-empty:hover { background: none; }

/* --- Onglets (Recettes par acte) -------------------------------------------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin: 4px 0 0; scrollbar-width: thin; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; margin-bottom: -1px;
  border: 1px solid transparent; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0;
  background: none; color: var(--muted); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap;
}
.tab:hover { color: var(--ink); background: var(--surface-2); }
.tab[aria-selected=true] { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.tab:focus-visible { outline: 2px solid #8cc1b2; outline-offset: -2px; }
.tab-amount { font-size: .78rem; font-weight: 600; color: var(--brand-2); background: var(--brand-soft); border-radius: 99px; padding: 1px 7px; font-variant-numeric: tabular-nums; }
.tab-panel .print-only-row { display: none; }
@media print {
  .tab-panel[hidden] { display: table-row-group !important; }
  .tab-panel .print-only-row { display: table-row; }
}

/* --- Pagination ------------------------------------------------------------------ */
.pager { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* --- Choix de la période (rapports) ---------------------------------------------- */
.period-picker { display: inline-flex; align-items: center; gap: 6px; }
.period-picker label { font-size: .9rem; color: var(--muted); }
.period-picker select { width: auto; min-height: 32px; padding: 4px 30px 4px 10px; font-weight: 600; }

/* --- Rapport mensuel : détail par jour ---------------------------------------- */
.day-list { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.day-row { border-bottom: 1px solid var(--line); }
.day-row:last-child { border-bottom: 0; }
.day-row summary { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 9px 12px;
  cursor: pointer; list-style: none; }
.day-row summary::-webkit-details-marker { display: none; }
.day-row summary { grid-template-columns: 14px 1fr auto auto; }
.day-row summary::before { content: "▸"; display: inline-block; color: var(--muted); font-size: 1rem; line-height: 1; }
.day-row[open] summary::before { transform: rotate(90deg); }
.day-row summary:hover { background: var(--surface-2); }
.day-row[open] summary { background: var(--brand-soft); }
.day-row .day-meta { color: var(--muted); font-size: .85rem; }
.day-row .day-total { min-width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.day-row > table, .day-row > a { margin: 4px 12px 10px 28px; display: block; width: auto; }
.day-row > table { display: table; width: calc(100% - 40px); }
.day-missing .day-line { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 16px; align-items: center;
  padding: 9px 12px; color: var(--muted); background: repeating-linear-gradient(135deg, transparent 0 8px, var(--surface-2) 8px 16px); }
.day-missing .day-meta { color: var(--warn); }
.day-missing .day-total { min-width: 90px; text-align: right; }
.day-month-total { display: flex; justify-content: space-between; padding: 10px 12px; margin-top: 8px;
  background: var(--brand-soft); border-radius: 8px; font-weight: 650; }
.day-tools { display: flex; gap: 6px; }

/* --- Boîte de dialogue ---------------------------------------------------------- */
.dialog { width: min(440px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: 0 24px 60px rgba(20, 35, 30, .25); color: var(--ink); background: var(--surface); }
.dialog::backdrop { background: rgba(20, 35, 30, .35); }
.dialog h2 { margin-bottom: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* Confirmation en toast */
.toast-zone { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 50;
  width: min(440px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); border: 1px solid var(--line-strong); border-left: 4px solid var(--brand);
  border-radius: var(--radius); box-shadow: 0 8px 28px rgba(20, 35, 30, .18); padding: 14px 16px;
  animation: toast-in .16s ease-out;
}
.toast p { margin: 0 0 12px; }
.toast-actions { display: flex; justify-content: flex-end; gap: 8px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
