/* =====================================================================
   WoodERP — style.css
   Thème clair/sombre via [data-theme], sidebar repliable via [data-sidebar]
   Couleur d'accent personnalisable via --accent (injectée par page)
   ===================================================================== */

:root {
  --accent: #d9782f;      /* orange bois par défaut */
  --accent-dark: #b4611f;
  --success: #1a9c6b;
  --info: #2f7fd1;
  --warning: #c9862c;
  --danger: #c94f4f;
  --radius: 12px;
  --font-ui: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-num: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 74px;
}

/* ---------- Thème clair (par défaut) ---------- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg: #f3f4f2;
  --paper: #f3f4f2;
  --card: #ffffff;
  --line: #e4e2dc;
  --ink: #211d18;
  --ink-soft: #5c574e;
  --muted: #8b8578;
  --sidebar-bg: #211d18;
  --sidebar-text: #d8d3c8;
  --sidebar-active-text: #ffffff;
}

/* ---------- Thème sombre ---------- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171a;
  --paper: #14171a;
  --card: #1c2024;
  --line: #2b3036;
  --ink: #edeef0;
  --ink-soft: #b7bcc2;
  --muted: #7b828a;
  --sidebar-bg: #0e1012;
  --sidebar-text: #b7bcc2;
  --sidebar-active-text: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; max-width: 100%; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background .15s ease, color .15s ease;
}
a { color: var(--accent-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
[data-theme="dark"] a { color: var(--accent); }
[data-theme="dark"] .btn { color: var(--ink); }
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-primary:hover { color: #fff; }
[data-theme="dark"] .shortcut { color: var(--ink); }
a.btn, a.btn:hover { text-decoration: none; }
a.btn.btn-primary, a.btn.btn-primary:hover, a.btn.btn-primary:visited { color: #fff !important; }
.badge, .chip, .sidebar a.nav-link.active { text-decoration: none; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .18s ease;
  overflow: hidden;
}
[data-sidebar="collapsed"] .sidebar { width: var(--sidebar-w-collapsed); }
[data-sidebar="collapsed"] .sidebar .brand-text,
[data-sidebar="collapsed"] .sidebar .nav-section-title,
[data-sidebar="collapsed"] .sidebar .nav-link span,
[data-sidebar="collapsed"] .sidebar .nav-link .lock,
[data-sidebar="collapsed"] .sidebar .user-box span { display: none; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; border-bottom: 1px solid rgba(255,255,255,0.08); }
.brand-logo { width: 34px; height: 34px; object-fit: contain; border-radius: 7px; background: #fff; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 18px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { color: #fff; font-weight: 800; font-size: 15.5px; letter-spacing: .01em; }
.brand-sub { font-size: 10.5px; color: #857c6a; }

.sidebar nav { flex: 1; padding: 10px 10px; overflow-y: auto; }
.nav-section-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #857c6a; margin: 16px 10px 6px; white-space: nowrap; }
.sidebar a.nav-link {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px;
  color: var(--sidebar-text); font-size: 13.5px; font-weight: 500; margin-bottom: 2px; white-space: nowrap;
}
.sidebar a.nav-link i:first-child { font-size: 17px; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar a.nav-link:hover { background: rgba(255,255,255,0.07); text-decoration: none; }
.sidebar a.nav-link.active { background: var(--accent); color: var(--sidebar-active-text); }
.sidebar a.nav-link.disabled { opacity: .45; cursor: not-allowed; }
.sidebar a.nav-link .lock { margin-left: auto; font-size: 13px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  line-height: 1; border-radius: 999px; padding: 3px 6px; min-width: 18px; text-align: center;
}
[data-sidebar="collapsed"] .sidebar .nav-badge { display: none; }

.user-box { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-box a { color: #a99; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #b7bcc2; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 64px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 5;
}
.topbar-titles h1 { font-size: 17px; margin: 0; font-weight: 700; }
.topbar-titles .sub { color: var(--muted); font-size: 12px; margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.icon-btn { background: transparent; border: 1px solid var(--line); color: var(--ink-soft); width: 36px; height: 36px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.icon-btn:hover { background: var(--paper); }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

.user-chip { display: flex; align-items: center; gap: 9px; padding-left: 10px; border-left: 1px solid var(--line); }

/* Sélecteur de langue FR/AR (voir includes/header.php et modules/auth/login.php) */
.lang-switch { display: flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; }
.lang-switch a { padding: 3px 8px; font-size: 11.5px; font-weight: 700; border-radius: 6px; color: var(--muted); }
.lang-switch a:hover { text-decoration: none; background: rgba(0,0,0,.05); }
.lang-switch a.active { background: var(--accent); color: #fff; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.user-meta .name { font-size: 13px; font-weight: 600; }
.user-meta .role { font-size: 11px; color: var(--muted); }

.content { padding: 24px; flex: 1; }

/* ---------- Cards / stats ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 620px) { .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; } }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: center; gap: 14px; }
.stat .stat-icon { width: 42px; height: 42px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat .label { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-family: var(--font-num); font-size: 22px; font-weight: 700; margin-top: 2px; }
a.stat { text-decoration: none; color: inherit; transition: background .15s ease, border-color .15s ease, transform .1s ease; -webkit-tap-highlight-color: transparent; }
a.stat:hover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--card)); }
a.stat:active { transform: scale(0.98); }

.shortcut { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.shortcut i { font-size: 22px; color: var(--accent); }
.shortcut.disabled { opacity: .5; }

table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--line); padding: 10px; font-weight: 600; }
table.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.table tr:hover td { background: var(--paper); }
table.table td.num, table.table th.num { text-align: right; font-family: var(--font-num); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 3px 9px; border-radius: 100px; font-size: 11.5px; font-weight: 600; }
.badge-success { background: #e3f5ec; color: var(--success); }
.badge-info { background: #e6f0fb; color: var(--info); }
.badge-warning { background: #fbeed9; color: var(--warning); }
.badge-danger { background: #fbe6e6; color: var(--danger); }
.badge-muted { background: #eef1f3; color: var(--ink-soft); }
[data-theme="dark"] .badge-success { background: #113328; }
[data-theme="dark"] .badge-info { background: #112b40; }
[data-theme="dark"] .badge-warning { background: #3a2a10; }
[data-theme="dark"] .badge-danger { background: #3a1414; }
[data-theme="dark"] .badge-muted { background: #262b30; }

/* ---------- Boutons / formulaires ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff !important; }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff !important; }
.sidebar a.nav-link.active { background: var(--accent); color: #fff !important; }
.sidebar a.nav-link.active i { color: #fff !important; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-warning { background: transparent; border-color: var(--warning); color: var(--warning); }
.btn-warning:hover { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=url], input[type=file], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px;
  font-family: var(--font-ui); background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
@media (max-width: 880px) {
  /* iOS Safari zoome automatiquement la page dès qu'un champ de saisie a une
     police < 16px au moment du focus, et ne dézoome pas ensuite tout seul. */
  input[type=text], input[type=email], input[type=password], input[type=number],
  input[type=date], input[type=tel], input[type=url], select, textarea { font-size: 16px; }
}
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
legend { padding: 0 6px; font-weight: 700; font-size: 13.5px; }

.flash { padding: 12px 16px; border-radius: 9px; margin-bottom: 16px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: #e3f5ec; color: var(--success); }
.flash-error { background: #fbe6e6; color: var(--danger); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .icon { font-size: 30px; margin-bottom: 8px; }

.logo-preview { width: 90px; height: 90px; object-fit: contain; border-radius: 9px; border: 1px solid var(--line); background: #fff; padding: 6px; }

/* ---------- Pointage ---------- */
.pointage-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.pointage-card { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--card); }
.pointage-card .emp-name { font-weight: 700; margin-bottom: 2px; }
.pointage-card .emp-poste { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.statut-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.statut-btn { border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 7px 6px; font-size: 12px; font-weight: 600; cursor: pointer; text-align: center; }
.statut-btn[data-statut="present"].active { background: var(--success); border-color: var(--success); color: #fff; }
.statut-btn[data-statut="absent"].active { background: var(--danger); border-color: var(--danger); color: #fff; }
.statut-btn[data-statut="demi_journee"].active { background: var(--warning); border-color: var(--warning); color: #fff; }
.statut-btn[data-statut="conge"].active { background: var(--info); border-color: var(--info); color: #fff; }

/* ---------- Pointage : grille hebdomadaire ---------- */
.week-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.week-table th, .week-table td { border: 1px solid var(--line); padding: 6px; text-align: center; min-width: 64px; }
.week-table th { background: var(--paper); font-weight: 600; font-size: 11.5px; color: var(--ink-soft); }
.week-table th.weekend, .week-table td.weekend { background: color-mix(in srgb, var(--danger) 6%, transparent); }
.week-table td.name-col, .week-table th.name-col { text-align: left; min-width: 170px; max-width: 170px; position: sticky; left: 0; background: var(--card); font-weight: 600; z-index: 1; }
.week-table td.total-col, .week-table th.total-col { font-family: var(--font-num); font-weight: 700; background: var(--paper); min-width: 56px; }

.day-cell { display: flex; gap: 3px; justify-content: center; }
.chip { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 10.5px; font-weight: 700; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.chip.chip-m.active { background: var(--warning); border-color: var(--warning); color: #fff; }
.chip.chip-am.active { background: var(--info); border-color: var(--info); color: #fff; }
.chip.chip-c.active { background: #8a6fb0; border-color: #8a6fb0; color: #fff; }
/* Journée complète = matin ET après-midi actifs simultanément (les deux chips s'allument) */

.chip-legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 3px; }
.chip-legend.chip-m { background: var(--warning); }
.chip-legend.chip-am { background: var(--info); }
.chip-legend.chip-both { background: linear-gradient(90deg, var(--warning) 50%, var(--info) 50%); }
.chip-legend.chip-c { background: #8a6fb0; }

/* ---------- Totaux de document (formulaire + vue) ---------- */
.doc-totaux { margin-left: auto; width: 300px; max-width: 100%; }
.doc-totaux div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 13.5px; border-bottom: 1px solid var(--line); }
.doc-totaux div.ttc { font-weight: 700; font-size: 16px; border-bottom: none; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 10px; }

/* ---------- Vue imprimable d'un document (devis/facture/BC) ---------- */
.doc-sheet { background: #fff; color: #16202b; max-width: 850px; margin: 0 auto; padding: 40px; border: 1px solid var(--line); border-radius: var(--radius); }

/* ---- Bloc note enrichi (Devis / Factures) ---- */
.rich-note-toolbar { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.rich-note-toolbar button {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 7px; cursor: pointer; font-size: 14px;
}
.rich-note-toolbar button:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.rich-note-toolbar .rich-note-color {
  width: 30px; height: 30px; padding: 2px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); cursor: pointer;
}
.rich-note-editor {
  min-height: 80px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font-family: var(--font-ui); font-size: 13.5px; line-height: 1.5;
}
.rich-note-editor:empty::before { content: "Écrire ici..."; color: var(--muted); }
.rich-note-editor:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.doc-notes-content { font-size: 12.5px; line-height: 1.6; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; padding: 0; }
  .doc-sheet { max-width: none; margin: 0; padding: 0; border: none; border-radius: 0; }
  .doc-head, .doc-parties, .doc-totaux, .doc-signature, .doc-footer,
  table.doc-lines thead, table.doc-lines tr, .doc-notes-content {
    break-inside: avoid; page-break-inside: avoid;
  }
  table.doc-lines thead { display: table-header-group; }
  .doc-totaux, .doc-signature { break-before: avoid-page; }
  .no-print { display: none !important; }
}
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 26px; }
.doc-head .logo img { max-height: 68px; max-width: 220px; object-fit: contain; }
.doc-head .societe-info { font-size: 11.5px; color: #5c574e; margin-top: 8px; line-height: 1.5; }
.doc-title { text-align: right; }
.doc-title h1 { margin: 0; font-size: 21px; text-transform: uppercase; letter-spacing: .04em; color: #16202b; }
.doc-title .numero { font-family: var(--font-num); color: #8b8578; }
.doc-parties { display: flex; justify-content: space-between; margin-bottom: 22px; gap: 20px; }
.doc-parties .box { flex: 1; }
.doc-parties .box h4 { font-size: 10.5px; text-transform: uppercase; color: #8b8578; margin: 0 0 6px; letter-spacing: .05em; }
table.doc-lines { width: 100%; border-collapse: collapse; margin-bottom: 18px; }
table.doc-lines th { background: #16202b; color: #fff; font-size: 10.5px; text-transform: uppercase; padding: 8px 7px; text-align: left; }
table.doc-lines td { padding: 8px 7px; border-bottom: 1px solid #e4e2dc; font-size: 12.5px; color: #16202b; }
table.doc-lines td.num, table.doc-lines th.num { text-align: right; font-family: var(--font-num); }
.doc-footer { margin-top: 26px; font-size: 11px; color: #8b8578; border-top: 1px solid #e4e2dc; padding-top: 12px; white-space: pre-line; }
.doc-signature { display: flex; justify-content: flex-end; gap: 30px; margin-top: 30px; }
.doc-signature img { max-height: 70px; max-width: 160px; }
.doc-signature .box { text-align: center; font-size: 11px; color: #8b8578; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* ---------- Responsive (mobile / tablette) ---------- */
.card { overflow-x: auto; }
.sidebar-backdrop { display: none; }

@media (max-width: 880px) {
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 250px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.35);
  }
  html.sidebar-mobile-open .sidebar { transform: translateX(0); }
  html.sidebar-mobile-open .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 55;
  }
  [data-sidebar="collapsed"] .sidebar { width: 250px; }
  [data-sidebar="collapsed"] .sidebar .brand-text,
  [data-sidebar="collapsed"] .sidebar .nav-section-title,
  [data-sidebar="collapsed"] .sidebar .nav-link span,
  [data-sidebar="collapsed"] .sidebar .nav-link .lock,
  [data-sidebar="collapsed"] .sidebar .user-box span { display: initial; }

  .content { padding: 14px; }
  .topbar { height: auto; min-height: 64px; padding: 10px 14px; gap: 8px; flex-wrap: wrap; }
  .topbar-titles { flex: 1 1 100%; order: 1; }
  .topbar-titles h1 { font-size: 15px; white-space: normal; overflow: visible; }
  .topbar-right { order: 2; flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-start; margin-left: 0; }
  .topbar-right .btn { flex: 0 0 auto; }
  .user-meta { display: none; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > * { width: 100%; }
  .field-row { flex-direction: column; }
  .field-row > .field { min-width: 0; }
  .doc-sheet { padding: 18px; }
  .week-table td.name-col, .week-table th.name-col { min-width: 120px; max-width: 120px; }
}

@media (max-width: 480px) {
  .stat { padding: 12px 14px; }
  .brand-sub, .topbar-titles .sub { display: none; }
}

/* =====================================================================
   Affinages responsive complémentaires (900px) — sans toucher au sidebar,
   déjà géré ci-dessus à 880px par le seul système realié au JS.
   ===================================================================== */
@media (max-width: 900px) {
  .card { padding: 14px; overflow-x: auto; }
  table.table { min-width: 560px; }
  table.doc-lines { min-width: 520px; }
  .doc-sheet { padding: 18px; }
  .doc-head { flex-direction: column; gap: 14px; }
  .doc-title { text-align: left; }
  .doc-parties { flex-direction: column; }
  .toolbar .filters { flex-wrap: wrap; }
}

/* ---------- Pointage : marquage visuel des absences ---------- */
.week-table td { position: relative; padding-bottom: 15px; }
.day-cell.cell-absent {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: 6px;
}
.day-cell.cell-absent::after {
  content: "Absent";
  position: absolute; bottom: 2px; left: 0; right: 0;
  font-size: 8.5px; color: var(--danger); font-weight: 700;
  text-align: center; letter-spacing: .02em; pointer-events: none;
}

/* ---------- Miniatures de justificatifs (chèques / effets) ---------- */
.doc-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }

/* =====================================================================
   Centre de notifications (cloche + panneau déroulant)
   ===================================================================== */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -5px; right: -5px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1; padding: 3px 5px; border-radius: 20px;
  min-width: 16px; text-align: center; border: 2px solid var(--card);
}
.notif-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 10px); width: 340px; max-width: 88vw;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18); z-index: 70; overflow: hidden;
}
.notif-panel.open { display: block; }
.notif-backdrop { display: none; }
.notif-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.25); z-index: 65; }

@media (max-width: 620px) {
  .notif-panel {
    position: fixed; left: 10px; right: 10px; top: 66px; width: auto; max-width: none;
  }
  .notif-panel-list { max-height: 60vh; }
}
.notif-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.notif-panel-list { max-height: 380px; overflow-y: auto; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); color: inherit; }
.notif-item:hover { background: var(--paper); }
.notif-item.lue { opacity: 0.55; }
.notif-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.notif-texte { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-titre { font-size: 13px; font-weight: 600; }
.notif-msg { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-date { font-size: 11px; color: var(--muted); }
.notif-panel-foot { display: block; text-align: center; padding: 11px; font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--line); }
.link-btn { background: none; border: none; color: var(--accent-dark); font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; }

/* Encart "Aujourd'hui" du dashboard */
.today-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 900px) { .today-grid { grid-template-columns: 1fr; } }
.today-block { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.today-block h4 { margin: 0 0 8px; font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.today-block .today-row { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-top: 1px dashed var(--line); font-size: 13px; }
.today-block .today-row:first-of-type { border-top: none; }
.today-block .today-empty { color: var(--muted); font-size: 12.5px; padding: 6px 0; }
.rappel-urgent-row { color: var(--danger); font-weight: 700; }

/* ---------- Miniatures de justificatifs (chèques / effets) ---------- */
.doc-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; }

/* ---------- Alertes d'échéances (chèques / effets) ---------- */
.row-echeance-retard { background: color-mix(in srgb, var(--danger) 10%, transparent); }
.row-echeance-retard td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.row-echeance-urgente { background: color-mix(in srgb, var(--warning) 10%, transparent); }
.row-echeance-urgente td:first-child { box-shadow: inset 3px 0 0 var(--warning); }

.alert-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-size: 13.5px; font-weight: 600; }
.alert-banner.alert-danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.alert-banner.alert-warning { background: color-mix(in srgb, var(--warning) 14%, transparent); color: #8a5a00; }
.alert-banner i { font-size: 18px; }

/* ---------- Tableaux -> cartes empilées sur mobile (opt-in via .table-cards) ---------- */
@media (max-width: 700px) {
  table.table-cards { min-width: 0 !important; border: none; }
  table.table-cards thead { display: none; }
  table.table-cards, table.table-cards tbody, table.table-cards tr, table.table-cards td { display: block; width: 100%; }
  table.table-cards tr {
    margin-bottom: 12px; border: 1px solid var(--line); border-radius: 10px;
    padding: 4px 12px; background: var(--card);
  }
  table.table-cards td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px solid var(--line); text-align: right; white-space: normal;
  }
  table.table-cards td:last-child { border-bottom: none; }
  table.table-cards td:empty { display: none; }
  table.table-cards td[data-label]::before {
    content: attr(data-label); font-weight: 600; color: var(--muted); text-align: left;
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; flex-shrink: 0;
  }
  table.table-cards td.num { font-family: var(--font-num); }
  table.table-cards td.cell-actions { justify-content: flex-end; gap: 6px; flex-wrap: wrap; }
  table.table-cards td.cell-actions::before { content: none; }
  table.table-cards tr.row-echeance-retard,
  table.table-cards tr.row-echeance-urgente { box-shadow: none; }
  table.table-cards tr.row-echeance-retard td:first-child,
  table.table-cards tr.row-echeance-urgente td:first-child { box-shadow: none; }
}

/* ---------- Modalités de paiement (devis / factures) ---------- */
.modalites-paiement { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.modalites-paiement h4 { margin: 0 0 8px; font-size: 13.5px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.modalites-paiement p { margin: 4px 0; font-size: 13.5px; }

/* ---------- Alarme de rappel (popup + son, api/rappels_alarme_*.php + assets/js/alarmes.js) ---------- */
.alarme-rappel-overlay {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.alarme-rappel-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--danger); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: alarmeRappelIn .2s ease-out;
}
@keyframes alarmeRappelIn { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.alarme-rappel-icon { font-size: 22px; color: var(--danger); line-height: 1; }
.alarme-rappel-body { flex: 1; min-width: 0; }
.alarme-rappel-body strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--danger); }
.alarme-rappel-titre { margin: 4px 0 2px; font-weight: 600; font-size: 14px; color: var(--ink); }
.alarme-rappel-desc { margin: 0; font-size: 12.5px; color: var(--muted); }
.alarme-rappel-actions { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 480px) {
  .alarme-rappel-overlay { left: 12px; right: 12px; max-width: none; }
}

/* ---------- Indication discrète sous un champ de formulaire ---------- */
.field-hint { display: block; margin-top: 4px; font-size: 12px; color: var(--muted); }
