/* ============================================================
   PILOTAGE DG — Stylesheet
   Design: Corporate / Premium / Minimaliste
   ============================================================ */

/* ── Polices charte ARP (auto-hébergées, sous-ensemble latin) ───
   Inter (corps) + Source Serif 4 (titres). Fichiers variables dans
   /public/fonts/ — pas de CDN externe : compatible CSP fontSrc 'self'
   et aucune dépendance réseau tierce. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/fonts/inter-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('/fonts/source-serif-4-latin.woff2') format('woff2');
}

/* ── Variables (ARP — Agence sénégalaise de Réglementation pharmaceutique) */
:root {
  /* Brand colours — ARP charte officielle */
  --brand-900: #1f4a35;        /* vert très foncé (sidebar) */
  --brand-800: #2a6244;        /* vert foncé (hover) */
  --brand-700: #337A57;        /* vert ARP foncé (primary actions) */
  --brand-600: #46AA77;        /* vert ARP moyen (highlights) */
  --brand-50:  #ecf7f0;        /* vert très clair (backgrounds) */
  --gold:      #E9C155;        /* doré ARP */
  --gold-lt:   #FBF5AD;        /* doré clair ARP */

  /* Semantic */
  --color-confirmed:  #2a6244;
  --color-pending:    #d68910;
  --color-cancelled:  #a93226;
  --color-urgent:     #922b21;
  --color-important:  #1a5276;
  --color-normal:     #2a6244;

  /* Neutrals */
  --bg:       #f0f2f5;
  --surface:  #ffffff;
  --border:   #dde1e7;
  --text:     #1a1a2e;
  --muted:    #6b7280;

  /* Sizing */
  --sidebar-w:   240px;
  --header-h:    64px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow:      0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg:   0 8px 32px rgba(0,0,0,.14);

  /* Typography — charte ARP : Inter (corps) + Source Serif 4 (titres) */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, 'Times New Roman', serif;
}

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ensure HTML hidden attribute always hides, even against display:flex rules */
[hidden] { display: none !important; }

html { font-size: 16px; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--brand-700); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary   { background: var(--brand-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }

.btn-gold      { background: var(--gold); color: var(--brand-900); font-weight: 600; }
.btn-gold:hover:not(:disabled) { background: var(--gold-lt); }

.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--brand-700); background: #f5f7fb; }

.btn-ghost     { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text); }
.btn-ghost:focus-visible { outline-color: var(--brand-700); }

.btn-danger    { background: #c0392b; color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a93226; }

.btn-success   { background: var(--color-confirmed); color: #fff; }
.btn-success:hover:not(:disabled) { background: #145a32; }

.btn-sm { padding: 5px 12px; font-size: .8125rem; }
.btn-icon { padding: 8px; border-radius: 6px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Form elements ──────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-label { font-size: .8125rem; font-weight: 500; color: var(--text); }
.form-label .required { color: #c0392b; margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .9375rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-700);
  box-shadow: 0 0 0 3px rgba(27,58,107,.12);
}
.form-input::placeholder { color: #9ca3af; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }

.input-password-wrap { position: relative; }
.input-password-wrap .form-input { padding-right: 44px; }
.btn-toggle-pwd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); padding: 4px; border-radius: 4px;
}
.btn-toggle-pwd:hover { color: var(--text); }
.btn-toggle-pwd:focus-visible { outline: 2px solid var(--gold); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 16px;
}
.alert-error   { background: #fdeded; border: 1px solid #fca5a5; color: #991b1b; }
.alert-success { background: #ecfdf5; border: 1px solid #6ee7b7; color: #065f46; }
.alert-info    { background: #eff6ff; border: 1px solid #93c5fd; color: #1e3a8a; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-confirmed  { background: #d1fae5; color: #065f46; }
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }
.badge-urgent     { background: #fee2e2; color: #991b1b; }
.badge-important  { background: #dbeafe; color: #1e3a8a; }
.badge-normal     { background: #d1fae5; color: #065f46; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-body { background: linear-gradient(135deg, var(--brand-900) 0%, var(--brand-700) 100%); }

.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  gap: 24px;
}

.login-brand {
  display: flex;
  justify-content: center;
  width: 100%;
}
.login-logo-img {
  height: 130px;
  width: auto;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.30));
}

.login-tagline {
  text-align: center;
  color: #fff;
  max-width: 520px;
  padding: 0 16px;
}
.login-org {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .02em;
  color: #fff;
  margin-bottom: 4px;
  line-height: 1.3;
}
.login-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
  color: var(--gold-lt);
}
.login-subtitle {
  font-size: .8rem;
  color: rgba(255,255,255,.6);
  margin-top: 8px;
  font-weight: 400;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--text);
}

.login-help {
  margin: 16px 0 0;
  text-align: center;
  font-size: .875rem;
}

.login-help-link {
  color: var(--primary, #337A57);
  text-decoration: none;
  font-weight: 500;
}

.login-help-link:hover,
.login-help-link:focus {
  text-decoration: underline;
}

.pwd-strength {
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin-top: 6px;
  transition: background .2s;
  position: relative;
  overflow: hidden;
}
.pwd-strength.weak::after,
.pwd-strength.medium::after,
.pwd-strength.strong::after {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  border-radius: 2px;
  transition: width .2s, background .2s;
}
.pwd-strength.weak::after   { width: 33%; background: #e74c3c; }
.pwd-strength.medium::after { width: 66%; background: #f39c12; }
.pwd-strength.strong::after { width: 100%; background: #27ae60; }

.pwd-rules {
  list-style: none;
  margin: 12px 0 18px;
  padding: 12px 14px;
  background: var(--bg);
  border-radius: var(--radius);
  font-size: .8rem;
}
.pwd-rules li {
  position: relative;
  padding-left: 22px;
  margin: 4px 0;
  color: var(--muted);
  transition: color .15s;
}
.pwd-rules li::before {
  content: '○';
  position: absolute; left: 0;
  color: var(--muted);
}
.pwd-rules li.valid {
  color: #1a7f4b;
}
.pwd-rules li.valid::before {
  content: '✓';
  color: #1a7f4b;
  font-weight: 700;
}

.login-credentials {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.login-hint { font-size: .8rem; color: var(--muted); margin-bottom: 10px; }

.credential-grid { display: flex; flex-direction: column; gap: 6px; }
.credential-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .8125rem; }
.credential-role { color: var(--muted); min-width: 140px; }
.credential-item code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: .8rem; color: var(--brand-700); }

.login-footer {
  color: rgba(255,255,255,.4);
  font-size: .75rem;
  text-align: center;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--brand-900);
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  flex-shrink: 0;
  background: rgba(255,255,255,.08);
  padding: 4px;
  border-radius: 8px;
}
.sidebar-app-name { font-size: .9rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-app-sub  { font-size: .7rem; color: rgba(255,255,255,.5); }

.sidebar-user {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-700);
  border: 2px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; }
.sidebar-user-name { font-size: .8125rem; font-weight: 600; color: #fff; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }
.sidebar-user-role { font-size: .7125rem; color: var(--gold); margin-top: 1px; }
.sidebar-user-wrap { display: flex; align-items: center; gap: 10px; }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.35);
  padding: 10px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: .875rem;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  transition: background .15s, color .15s;
  margin-bottom: 2px;
  width: 100%;
  text-align: left;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--gold); color: var(--brand-900); font-weight: 600; }
.nav-item.active svg { color: var(--brand-900); }
.nav-item:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Top header ──────────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  position: sticky;
  top: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 30;
  gap: 16px;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.header-page-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.header-breadcrumb { font-size: .8rem; color: var(--muted); }

.header-right { display: flex; align-items: center; gap: 8px; }

.hamburger {
  display: none;
  padding: 8px;
  border-radius: 6px;
  color: var(--text);
}
.hamburger:hover { background: var(--bg); }
.hamburger:focus-visible { outline: 2px solid var(--brand-700); }

/* ── Content area ────────────────────────────────────────────── */
.app-content { flex: 1; padding: 24px; overflow-x: hidden; }

/* ── Views ────────────────────────────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* Blocs chiffrés migrés vers .kpi-card / .kpi-primary-grid (cockpit). */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
}
@media (max-width: 960px) { .dashboard-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-family: var(--font-serif); font-size: .9375rem; font-weight: 600; color: var(--text); }
.card-body  { padding: 16px 20px; }

/* ── Appointment list items ──────────────────────────────────── */
.appt-list { display: flex; flex-direction: column; gap: 8px; }

.appt-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: var(--surface);
}
.appt-item:hover { border-color: var(--brand-700); box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.appt-item:focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; }

.appt-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.dot-urgent    { background: var(--color-urgent); }
.dot-important { background: var(--color-important); }
.dot-normal    { background: var(--color-confirmed); }

.appt-item-body { flex: 1; min-width: 0; }
.appt-item-title { font-size: .875rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt-item-meta  { font-size: .775rem; color: var(--muted); margin-top: 2px; display: flex; gap: 8px; flex-wrap: wrap; }
.appt-item-time  { display: flex; align-items: center; gap: 3px; }

.appt-item-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }

/* ── Calendar toolbar ─────────────────────────────────────────── */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.calendar-nav { display: flex; align-items: center; gap: 8px; }
.calendar-period { font-size: 1rem; font-weight: 600; min-width: 200px; text-align: center; }

.view-tabs { display: flex; width: 100%; border: 1.5px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.view-tab {
  flex: 1;
  padding: 7px 16px;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--muted);
  border: none;
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.view-tab:hover   { background: var(--bg); color: var(--text); }
.view-tab.active  { background: var(--brand-700); color: #fff; }
.view-tab:focus-visible { outline: 2px solid var(--brand-700); outline-offset: -2px; }

/* ── Month calendar ───────────────────────────────────────────── */
.month-grid {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.month-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--brand-900);
}
.month-weekday {
  padding: 10px 4px;
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.month-cells {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-top: 1px solid var(--border);
}

.month-cell {
  min-height: 110px;
  min-width: 0;             /* allow grid columns to shrink below content */
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  vertical-align: top;
  transition: background .1s;
  overflow: hidden;
}
.month-cell:nth-child(7n) { border-right: none; }
.month-cell:hover { background: #f8f9fc; }

.month-cell-num {
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  margin-bottom: 4px;
}
.month-cell.today .month-cell-num {
  background: var(--brand-700);
  color: #fff;
  font-weight: 700;
}
.month-cell.other-month .month-cell-num { color: #c0c8d8; }
.month-cell.other-month { background: #fafbfc; }

.cal-event {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity .15s;
}
.cal-event:hover { opacity: .85; }
.cal-event:focus-visible { outline: 2px solid var(--text); }

.cal-event.status-confirmed { background: #d1fae5; color: #065f46; }
.cal-event.status-pending   { background: #fef3c7; color: #92400e; }
.cal-event.status-cancelled { background: #fee2e2; color: #991b1b; text-decoration: line-through; }

.cal-event.priority-urgent   .event-dot { background: #e74c3c; }
.cal-event.priority-important .event-dot { background: #3498db; }
.cal-event.priority-normal    .event-dot { background: #27ae60; }

.event-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.cal-more  { font-size: .7rem; color: var(--brand-700); padding: 2px 5px; cursor: pointer; font-weight: 600; }
.cal-more:hover { text-decoration: underline; }

/* ── Week / Day grid ──────────────────────────────────────────── */
.time-grid-wrap {
  display: flex;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.time-col {
  width: 56px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: #fafbfc;
}
.time-slot-label {
  height: 60px;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4px 8px 0 0;
  font-size: .7rem;
  color: var(--muted);
  font-weight: 500;
}
.time-slot-label.first { height: 36px; } /* header row */

.day-col-wrap { flex: 1; display: flex; flex-direction: column; overflow-x: auto; }
.day-headers  { display: grid; border-bottom: 1px solid var(--border); }
.day-header-cell {
  padding: 8px 4px;
  text-align: center;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  border-right: 1px solid var(--border);
  min-width: 100px;
}
.day-header-cell.today-col { background: var(--brand-900); color: #fff; }
.day-header-cell:last-child { border-right: none; }

.day-body { display: grid; position: relative; }
.day-col {
  border-right: 1px solid var(--border);
  position: relative;
  min-width: 100px;
}
.day-col:last-child { border-right: none; }

.time-row {
  height: 60px;
  border-bottom: 1px solid #edf0f5;
  position: relative;
}
.time-row.half-hour { border-bottom: 1px dashed #edf0f5; height: 30px; }

.tg-event {
  position: absolute;
  left: 2px; right: 2px;
  border-radius: 5px;
  padding: 3px 6px;
  font-size: .7rem;
  font-weight: 500;
  cursor: pointer;
  overflow: hidden;
  z-index: 2;
  transition: opacity .15s, box-shadow .15s;
  line-height: 1.3;
}
.tg-event:hover { opacity: .88; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
.tg-event:focus-visible { outline: 2px solid var(--text); }
.tg-event.status-confirmed { background: #d1fae5; color: #065f46; border-left: 3px solid #059669; }
.tg-event.status-pending   { background: #fef3c7; color: #92400e; border-left: 3px solid #d97706; }
.tg-event.status-cancelled { background: #fee2e2; color: #991b1b; border-left: 3px solid #dc2626; text-decoration: line-through; }
.tg-event-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tg-event-time  { font-size: .65rem; opacity: .8; }

/* ── Appointment Detail / Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13,27,42,.55);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  backdrop-filter: blur(2px);
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title { font-family: var(--font-serif); font-size: 1rem; font-weight: 600; }

.modal-close {
  padding: 6px; border-radius: 6px; color: var(--muted);
  transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-close:focus-visible { outline: 2px solid var(--brand-700); }

.modal-body   { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* ── Appointment detail view ─────────────────────────────────── */
.detail-section { margin-bottom: 18px; }
.detail-label   { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.detail-value   { font-size: .9375rem; color: var(--text); }
.detail-badges  { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-meta    { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.detail-creator { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--muted); }
.detail-creator svg { flex-shrink: 0; }

/* ── History panel ────────────────────────────────────────────── */
/* La page Historique reprend la grammaire « ligne d'activité » du cockpit
   (.pl-row) ; seule la pastille d'icône par type d'action lui est propre. */
.history-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.history-icon.created   { background: #d1fae5; color: #065f46; }
.history-icon.modified  { background: #dbeafe; color: #1e3a8a; }
.history-icon.confirmed { background: #d1fae5; color: #065f46; }
.history-icon.cancelled { background: #fee2e2; color: #991b1b; }
/* Les lignes .pl-row portent leur propre rythme — liste à fleur de carte. */
#historyContainer { padding: 0; }

/* ── Toast notifications ─────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--brand-900);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .875rem;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: slideLeft .2s ease;
}
@keyframes slideLeft { from { transform: translateX(20px); opacity: 0 } to { transform: translateX(0); opacity: 1 } }
.toast.toast-success { background: var(--color-confirmed); }
.toast.toast-error   { background: var(--color-urgent); }
.toast.toast-info    { background: var(--brand-700); }
.toast-msg { flex: 1; }

/* ── Empty state — composant unique ───────────────────────────── */
/* Une seule grammaire : conteneur .empty-state + icône SVG + <p> +
   CTA optionnel. Variante .empty-state--compact pour les colonnes
   Kanban et les blocs d'action du cockpit. */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--muted);
  text-align: center;
  gap: 8px;
}
.empty-state svg { opacity: .35; width: 44px; height: 44px; }
.empty-state p { font-size: .9rem; margin: 0; }
.empty-state .btn { margin-top: 4px; }
.empty-state--compact { padding: 20px 14px; gap: 6px; }
.empty-state--compact svg { width: 28px; height: 28px; }
.empty-state--compact p { font-size: .8rem; }
.kanban-col .empty-state { flex: 1; }

/* ── Spinner ────────────────────────────────────────────────── */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg) } }

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: inherit;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-700);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
/* Bloc de chargement inline (spinner sans superposition absolue). */
.loading-block { position: static; min-height: 160px; }
.loading-block--lg { min-height: 360px; }

/* ── Sidebar overlay for mobile ──────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 39;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }

  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .sidebar-overlay.open { opacity: 1; pointer-events: auto; }

  .app-main { margin-left: 0; }
  .hamburger { display: flex; }

  .app-header { padding: 0 12px; gap: 8px; }
  .app-content { padding: 12px; }

  .header-page-title { font-size: .9rem; }

  /* Month — compact cells */
  .month-cell { min-height: 70px; padding: 4px; }
  .month-cell-num { width: 22px; height: 22px; font-size: .75rem; margin-bottom: 2px; }
  .cal-event { font-size: .62rem; padding: 1px 4px; }
  .cal-event .event-dot { display: none; }      /* save space on tiny cells */
  .cal-more { font-size: .62rem; padding: 1px 4px; }

  .month-weekday { font-size: .6rem; padding: 6px 2px; letter-spacing: 0; }

  .modal { max-width: 100%; max-height: 96vh; border-radius: 10px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }

  .form-row { grid-template-columns: 1fr; }

  /* Calendar toolbar wraps */
  .calendar-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .calendar-nav     { justify-content: space-between; }
  .calendar-period  { font-size: .9rem; min-width: 0; flex: 1; text-align: center; }
  .view-tabs        { width: 100%; }
  .view-tab         { flex: 1; padding: 7px 4px; font-size: .75rem; }

  /* Time grid — give a sensible min-width and let it scroll horizontally on phone */
  .day-col-wrap { overflow-x: auto; }
  .day-headers, .day-body { min-width: 600px; }
  .time-col { width: 44px; }
  .time-slot-label { font-size: .65rem; padding-right: 4px; }

  /* Toasts on mobile — top-anchored, full width */
  .toast-container { right: 12px; left: 12px; bottom: 12px; max-width: none; }

  /* Detail meta single column */
  .detail-meta { grid-template-columns: 1fr; }

  .login-page { padding: 24px 16px; gap: 18px; }
  .login-card { padding: 24px 20px; }
}

@media (max-width: 480px) {
  .month-cell { min-height: 56px; padding: 3px; }
  .month-cell-num { width: 20px; height: 20px; font-size: .7rem; }
  .cal-event { font-size: .58rem; }
  .login-logo-img { height: 100px; }
  .login-org { font-size: .9rem; }
  .login-title { font-size: 1.15rem; }
}

/* ── Utility ──────────────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.mt-16 { margin-top: 16px; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-meta { font-size: .75rem; color: var(--muted); }
.cell-inline { display: flex; align-items: center; gap: 8px; }

/* ── Today indicator on time grid ───────────────────────────── */
.time-now-line {
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: #e74c3c;
  z-index: 3;
  pointer-events: none;
}
.time-now-dot {
  position: absolute;
  left: -4px;
  top: -4px;
  width: 10px; height: 10px;
  background: #e74c3c;
  border-radius: 50%;
}

/* ═══════════════════════════════════════════════════════════════════
   Suivi des tâches & dossiers — additions (zéro nouvelle couleur,
   tout est mappé sur les tokens existants)
   ═══════════════════════════════════════════════════════════════════ */

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.muted { color: var(--muted); }

/* Header actions wrapper — multiple action buttons per view */
.header-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Form helper text */
.form-help { font-size: .75rem; color: var(--muted); margin: 4px 0 0; }

/* ── Data table (users, tasks list, performance) ─────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .875rem;
}
.data-table th, .data-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  background: var(--bg);
  font-weight: 600;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-table tbody tr:hover { background: var(--brand-50); }
.data-table .th-actions, .data-table .td-actions {
  text-align: right;
  white-space: nowrap;
}
.data-table .td-actions .btn { margin-left: 4px; }

@media (max-width: 768px) {
  .data-table { font-size: .8rem; }
  .data-table th, .data-table td { padding: 8px 10px; }
}

/* ── Kanban (tasks) ─────────────────────────────────────────────── */
.kanban-grid {
  display: grid;
  gap: 16px;
  /* Flux souple : 4 colonnes en grand écran, paliers fins jusqu'à 1 sur mobile. */
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.kanban-col {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
}
/* Colonne Kanban vide — composant .empty-state--compact unifié (voir Empty state). */
.kanban-col-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.kanban-col-count {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  font-size: .75rem;
  color: var(--text);
}

.task-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.task-card:hover { border-color: var(--brand-700); box-shadow: 0 2px 6px rgba(0,0,0,.05); }
.task-card:focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; }

.task-card-title { font-weight: 600; color: var(--text); font-size: .9rem; }
.task-card-dossier { font-size: .75rem; color: var(--muted); }
.task-card-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .75rem; }
.task-card-assignee { color: var(--muted); }

/* ── Status badges (pattern .badge existant) ───────────────────── */
.badge-status-assignee   { background: #eef0f3; color: var(--muted); }
.badge-status-en_cours   { background: #d6efe1; color: var(--brand-900); }
.badge-status-soumise    { background: var(--gold-lt); color: #6b4f0a; }
.badge-status-validee    { background: #d1fae5; color: #065f46; }
.badge-status-a_corriger { background: #fee2e2; color: #991b1b; }
.badge-overdue           { background: #fee2e2; color: #991b1b; }
.badge-warning           { background: #fef3c7; color: #92400e; }

/* ── Deadline pills ────────────────────────────────────────────── */
.deadline-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 500;
}
.deadline-pill.normal     { color: var(--muted); }
.deadline-pill.due-soon   { background: #fef3c7; color: #92400e; }
.deadline-pill.due-today  { background: var(--gold-lt); color: #6b4f0a; }
.deadline-pill.overdue    { background: #fee2e2; color: #991b1b; }

/* ── Modal large (task detail with timeline) ───────────────────── */
.modal.modal-large { max-width: 720px; }

/* ── Rating stars ──────────────────────────────────────────────── */
.rating-stars {
  display: inline-flex;
  flex-direction: row-reverse;
  border: none;
  padding: 0;
  gap: 4px;
}
.rating-stars input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.rating-stars label {
  font-size: 2rem;
  cursor: pointer;
  color: var(--border);
  transition: color 150ms ease-out;
  line-height: 1;
}
.rating-stars label:hover,
.rating-stars label:hover ~ label,
.rating-stars input:checked ~ label {
  color: var(--gold);
}
.rating-stars input:focus-visible + label {
  outline: 2px solid var(--brand-700);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── Drop-zone (file uploads) ──────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  color: var(--muted);
  transition: all 150ms ease-out;
}
.dropzone:focus-visible {
  outline: 2px solid var(--brand-700);
  outline-offset: 2px;
}
.dropzone--active {
  border-color: var(--brand-700);
  background: var(--brand-50);
  color: var(--brand-700);
}
.dropzone-text { margin: 0 0 12px; font-size: .875rem; }

.file-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.file-chip {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .8rem;
  color: var(--text);
}
.file-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 4px;
  border-radius: 4px;
}
.file-chip-remove:hover, .file-chip-remove:focus-visible {
  color: var(--color-cancelled);
  outline: 0;
  background: var(--bg);
}

/* ── Performance dashboard ─────────────────────────────────────── */
.perf-toolbar {
  margin-bottom: 16px;
  display: flex;
  justify-content: flex-end;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
}
.perf-period {
  display: inline-flex;
  gap: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  background: var(--surface);
}
.perf-period legend { display: none; }
.perf-period label {
  padding: 6px 14px;
  cursor: pointer;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--muted);
  border-right: 1px solid var(--border);
  transition: all 150ms ease-out;
}
.perf-period label:last-of-type { border-right: 0; }
.perf-period input { position: absolute; opacity: 0; pointer-events: none; }
.perf-period input:checked + span,
.perf-period label:has(input:checked) { background: var(--brand-700); color: #fff; }
.perf-period label:hover { background: var(--brand-50); color: var(--brand-700); }
.perf-period label:focus-within { outline: 2px solid var(--brand-700); outline-offset: 2px; }

.perf-bar {
  background: var(--bg);
  height: 8px;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
}
.perf-bar-fill {
  height: 100%;
  background: var(--brand-700);
  transition: width 250ms ease-out;
}
.perf-bar-fill.warn   { background: var(--color-pending, #d68910); }
.perf-bar-fill.danger { background: var(--color-cancelled, #a93226); }

/* ── Dossier card grid ─────────────────────────────────────────── */
.dossiers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.dossier-card {
  position: relative;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color 150ms ease-out, box-shadow 150ms ease-out;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 140px;
}
.dossier-card-edit {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  font-size: .85rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 120ms ease-out, color 120ms ease-out;
}
.dossier-card-edit:hover { border-color: var(--brand-700); color: var(--brand-700); }
.dossier-card-edit:focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; }
.dossier-card:hover { border-color: var(--brand-700); box-shadow: 0 2px 6px rgba(0,0,0,.05); }
/* Titre = vrai bouton (action principale accessible au clavier). Reset
   d'apparence pour rester visuellement identique à l'ancien <div>. */
.dossier-card-title {
  display: block; width: 100%;
  background: none; border: 0; padding: 0; margin: 0;
  font-family: inherit; font-weight: 600; font-size: 1rem; color: var(--text);
  text-align: left; cursor: pointer;
}
.dossier-card-title:hover { color: var(--brand-700); text-decoration: underline; }
.dossier-card-title:focus-visible { outline: 2px solid var(--brand-700); outline-offset: 2px; border-radius: 3px; }
.dossier-card-desc  { font-size: .8125rem; color: var(--muted); flex: 1; line-height: 1.5; }
.dossier-card-counts {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: .75rem;
}

/* ── Submission timeline (task detail) ─────────────────────────── */
.task-timeline { list-style: none; padding: 0; margin: 16px 0 0; }
.task-timeline-item {
  border-left: 2px solid var(--border);
  padding: 0 0 16px 16px;
  margin-left: 8px;
  position: relative;
}
.task-timeline-item::before {
  content: '';
  position: absolute;
  left: -7px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-700);
}
.task-timeline-item.verdict-validee::before  { background: var(--color-confirmed); }
.task-timeline-item.verdict-a_corriger::before { background: var(--color-cancelled); }
.task-timeline-meta { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.task-timeline-comment {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: .875rem;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
}
.task-timeline-files { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* ── Reduced motion (couvre toute l'app) ───────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ── Pilotage DG : projets & PTBA ────────────────────────────── */
.badge-strategic { background: #ede9fe; color: #5b21b6; }
.badge-ptba      { background: var(--gold-lt); color: #6b4f0a; font-weight: 600; }

.badge-pstatus-draft     { background: #eef0f3; color: var(--muted); }
.badge-pstatus-active    { background: #d6efe1; color: var(--brand-900); }
.badge-pstatus-blocked   { background: #fee2e2; color: #991b1b; }
.badge-pstatus-at_risk   { background: #fef3c7; color: #92400e; }
.badge-pstatus-completed { background: #d1fae5; color: #065f46; }
.badge-pstatus-archived  { background: #eef0f3; color: var(--muted); }

.progress-track {
  background: #e9ecef;
  border-radius: 999px;
  height: 8px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-fill {
  background: var(--brand-600);
  height: 100%;
  border-radius: 999px;
  transition: width .25s ease;
}

.project-card { border-left: 3px solid var(--brand-600); }
.project-card.status-at_risk  { border-left-color: #f59e0b; }
.project-card.status-blocked  { border-left-color: #dc2626; }
.project-card.status-completed,
.project-card.status-archived { border-left-color: #9ca3af; }

.ptba-fieldset {
  border: 1px solid var(--border, #e2e6ea);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 8px;
}
.ptba-fieldset legend {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--brand-700);
  padding: 0 6px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  cursor: pointer;
}
.form-check input { width: 16px; height: 16px; }

.mini-list { list-style: none; padding: 0; margin: 4px 0 0; }
.mini-list li {
  padding: 5px 0;
  border-bottom: 1px solid #f0f2f4;
  font-size: .8125rem;
}
.mini-list li:last-child { border-bottom: none; }

/* ══════════ Tableau de bord Pilotage DG ══════════════════════════════ */
.pilotage-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
}
.pilotage-toolbar .filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted);
}
.form-select-sm { padding: 6px 10px; font-size: .8125rem; min-width: 150px; }
.pilotage-toolbar .btn { margin-left: auto; }

.pl-group-title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--brand-700);
  margin: 18px 0 8px;
}
.pl-group-title:first-child { margin-top: 0; }
.pl-stats { margin-bottom: 4px; }
.pl-kpis { margin-bottom: 26px; }

.pl-sections {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.pl-section-wide { grid-column: 1 / -1; }

.pl-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 22px; padding: 0 7px;
  background: var(--brand-50); color: var(--brand-700);
  font-size: .75rem; font-weight: 700; border-radius: 11px;
}
.pl-list { list-style: none; margin: 0; padding: 0; }
.pl-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0f2f4;
  cursor: pointer;
}
.pl-row:last-child { border-bottom: none; }
.pl-row:hover { background: var(--brand-50); }
.pl-row:focus-visible { outline: 2px solid var(--brand-700); outline-offset: -2px; }
.pl-row-static, .pl-row-empty { cursor: default; }
.pl-row-static:hover, .pl-row-empty:hover { background: transparent; }
.pl-row-main {
  display: flex; align-items: center; gap: 8px;
  justify-content: space-between;
}
.pl-row-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.pl-row-meta { font-size: .75rem; color: var(--muted); }
.pl-row-empty { padding: 16px; text-align: center; }

/* Ligne d'activité avec pastille d'icône en tête (page Historique). */
.pl-row--with-icon { flex-direction: row; align-items: flex-start; gap: 10px; }
.pl-row--with-icon .pl-row__body {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px;
}

@media (max-width: 860px) {
  .pl-sections { grid-template-columns: 1fr; }
  .pilotage-toolbar .btn { margin-left: 0; }
  .form-select-sm { min-width: 130px; }
}

/* Badge "origine / décision DG" (Lot 6) */
.badge-source { background: #e0e7ff; color: #3730a3; }
.pilotage-hint { font-size: .8rem; margin: -8px 0 18px; }

/* ── Recherche transverse (vue dédiée) ───────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #d8dde2);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 18px;
}
.search-bar:focus-within { border-color: var(--brand-600); box-shadow: 0 0 0 3px var(--brand-50); }
.search-bar__icon { color: var(--muted); flex-shrink: 0; }
.search-bar__input {
  flex: 1; border: none; outline: none; background: transparent;
  font: inherit; font-size: .95rem; color: var(--text);
}
.search-group { margin-bottom: 18px; }
.search-group__title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--brand-600); margin: 0 0 8px 2px;
}
.search-group__count {
  display: inline-block; min-width: 18px; padding: 0 6px; margin-left: 4px;
  font-size: .72rem; font-weight: 700; line-height: 18px; text-align: center;
  color: var(--brand-700); background: var(--brand-50); border-radius: 9px;
}
/* La ligne de résultat est un <button> : on neutralise son style natif et on
   réutilise la grammaire .pl-row (titre + méta). */
.search-row {
  width: 100%; text-align: left; background: none; border: none;
  border-bottom: 1px solid #f0f2f4; font: inherit;
}
.search-row:last-child { border-bottom: none; }

/* ============================================================
   Tableau de bord exécutif — Pilotage DG (refonte UX)
   Zones : 1 header · 2 filtres · 3 résumé · 4 blocs d'action · 5 détails
   ============================================================ */
.executive-dashboard { width: 100%; }

/* ── Zone 1 — Header exécutif ──────────────────────────────────── */
.dashboard-hero {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
}
.dashboard-hero-eyebrow,
.page-header__eyebrow {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--brand-600);
}
.dashboard-hero-title,
.page-header__title {
  font-family: var(--font-serif);
  font-size: 1.5rem; font-weight: 700; color: var(--text);
  line-height: 1.2; margin-top: 2px;
}
.dashboard-hero-sub,
.page-header__sub { font-size: .9rem; color: var(--muted); margin-top: 4px; }

/* En-tête de page réutilisable (référence visuelle = dashboard-hero) */
.page-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
  margin-bottom: 20px;
}
.view > .view-tabs,
.view > .calendar-toolbar,
.view > .perf-toolbar { margin-bottom: 16px; }
@media (max-width: 640px) {
  .page-header__title { font-size: 1.25rem; }
}
.dashboard-hero-aside {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.dashboard-hero-date { font-size: .8rem; color: var(--muted); text-transform: capitalize; }
.dashboard-hero-note {
  display: flex; align-items: center; gap: 8px;
  margin-top: 14px; padding: 9px 14px;
  background: var(--brand-50); border-radius: var(--radius);
  font-size: .82rem; color: var(--brand-800);
}
.dashboard-hero-note svg { flex-shrink: 0; color: var(--brand-600); }

/* ── Zone 2 — Filtres compacts ─────────────────────────────────── */
.dashboard-filters {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  margin-top: 18px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filter-field { display: flex; flex-direction: column; gap: 3px; }
.filter-field label {
  font-size: .68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.dashboard-filters .form-select-sm {
  padding: 5px 9px; font-size: .8125rem; min-width: 140px; height: 32px;
}
.dashboard-filters #plAssignee { min-width: 200px; }
.dashboard-filters__reset { margin-left: auto; }
.dashboard-filters__hint { font-size: .76rem; color: var(--muted); margin: 8px 2px 0; }

/* Barre de filtre légère (vues Tâches, Dossiers) */
.list-filters {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 16px;
}

/* Widget multi-assignés (formulaire tâche) */
.multi-assignee { display: flex; flex-direction: column; gap: 8px; }
.multi-assignee__add { display: flex; gap: 8px; align-items: center; }
.multi-assignee__add .form-select { flex: 1; min-width: 0; }
.multi-assignee__add .btn { flex-shrink: 0; }
.multi-assignee__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.multi-assignee__empty { font-size: .8rem; color: var(--muted); }
.assignee-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 5px 4px 11px;
  background: var(--brand-50); color: var(--brand-800);
  border: 1px solid var(--border); border-radius: 14px;
  font-size: .8rem; font-weight: 500;
}
.assignee-chip__remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: transparent; color: var(--brand-700);
  font-size: 1rem; line-height: 1; cursor: pointer;
}
.assignee-chip__remove:hover,
.assignee-chip__remove:focus-visible {
  background: var(--brand-700); color: #fff; outline: none;
}
/* Badge assigné — affichage liste / détail */
.badge-assignee { background: var(--brand-50); color: var(--brand-800); }

/* ── Zone 3 — Résumé exécutif (6 KPIs critiques) ───────────────── */
.kpi-primary-grid {
  display: grid; gap: 16px; margin-top: 22px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.kpi-card {
  --tone: var(--brand-700);
  --tone-bg: #eef1f5;
  display: flex; flex-direction: column;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: box-shadow .18s ease, transform .18s ease;
}
.kpi-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.kpi-card--critical { --tone: var(--color-urgent);  --tone-bg: #fdecea; }
.kpi-card--warning  { --tone: var(--color-pending); --tone-bg: #fdf3e3; }
.kpi-card--success  { --tone: var(--brand-700);     --tone-bg: var(--brand-50); }
.kpi-card--neutral  { --tone: var(--brand-700);      --tone-bg: #eef1f5; }
.kpi-card__top { display: flex; }
.kpi-card__icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--tone-bg); color: var(--tone);
}
.kpi-card__icon svg { width: 20px; height: 20px; }
.kpi-card__value {
  font-size: 2.1rem; font-weight: 700; line-height: 1.1;
  color: var(--tone); margin-top: 14px;
  font-variant-numeric: tabular-nums;
}
/* Tone warning : valeur foncée (#b8730a ~4.5:1) — marge AA pleine même en texte normal. */
.kpi-card--warning .kpi-card__value { color: #b8730a; }
.kpi-card__label { font-size: .92rem; font-weight: 600; color: var(--text); margin-top: 2px; }
.kpi-card__desc { font-size: .76rem; color: var(--muted); margin-top: 4px; line-height: 1.4; }

/* ── Zone 4 — Blocs d'action prioritaires ──────────────────────── */
.dashboard-panels {
  display: grid; gap: 16px; margin-top: 24px;
  grid-template-columns: repeat(3, 1fr);
}
.dashboard-panel {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.dashboard-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.dashboard-panel--critical .dashboard-panel-header { background: #fdecea; }
.dashboard-panel--warning  .dashboard-panel-header { background: #fdf3e3; }
.dashboard-panel--success  .dashboard-panel-header { background: var(--brand-50); }
.dashboard-panel__title {
  font-size: .82rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text);
}
.dashboard-panel__count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 7px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); font-size: .72rem; font-weight: 700; border-radius: 10px;
}
.dashboard-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.dashboard-list__empty { padding: 6px; }
.dashboard-list__more {
  padding: 8px 16px; font-size: .73rem; color: var(--muted); text-align: center;
}

/* Empty state des blocs d'action — composant .empty-state--compact unifié. */

/* ── Zone 5 — Détails par domaine (accordéons) ─────────────────── */
.dashboard-details { margin-top: 28px; }
.dashboard-details__title {
  font-size: .8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--brand-700); margin-bottom: 10px;
}
.dashboard-accordion {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.dashboard-accordion__summary {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; cursor: pointer;
  font-size: .85rem; font-weight: 600; color: var(--text);
  list-style: none;
}
.dashboard-accordion__summary::-webkit-details-marker { display: none; }
.dashboard-accordion__summary:hover { color: var(--brand-700); }
.dashboard-accordion__summary:focus-visible {
  outline: 2px solid var(--brand-700); outline-offset: -2px;
}
.dashboard-accordion__chevron {
  width: 16px; height: 16px; color: var(--muted);
  transition: transform .18s ease;
}
.dashboard-accordion[open] .dashboard-accordion__chevron { transform: rotate(180deg); }
.kpi-mini-grid {
  display: grid; gap: 10px; padding: 14px 16px;
  border-top: 1px solid var(--border);
  grid-template-columns: repeat(3, 1fr);
}
.kpi-mini {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface);
}
.kpi-mini__dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.kpi-mini__dot--total     { background: var(--brand-700); }
.kpi-mini__dot--pending   { background: var(--color-pending); }
.kpi-mini__dot--urgent    { background: var(--color-urgent); }
.kpi-mini__dot--confirmed { background: var(--color-confirmed); }
.kpi-mini__value {
  font-size: 1.05rem; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-mini__label { font-size: .75rem; color: var(--muted); }
.dashboard-list--flush { border-top: 1px solid var(--border); }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dashboard-panels { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kpi-mini-grid { grid-template-columns: repeat(2, 1fr); }
  .dashboard-hero-title { font-size: 1.25rem; }
  .dashboard-hero-aside { width: 100%; }
  .dashboard-filters__reset { margin-left: 0; }
  .dashboard-filters .form-select-sm,
  .dashboard-filters #plAssignee { min-width: 0; width: 100%; }
  .filter-field { flex: 1 1 140px; }
}

/* ── Section Tendances (dashboard DG) ─────────────────────────────────── */
.trend-section { margin: 20px 0 8px; }
.trend-section__head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.trend-section__icon { color: var(--brand-700); width: 22px; height: 22px; display: inline-flex; }
.trend-section__icon svg { width: 22px; height: 22px; }
.trend-section__title { font-size: 17px; font-weight: 700; color: var(--brand-900); margin: 0; }
.trend-seg-group { display: inline-flex; margin-left: auto; border: 1px solid var(--border); border-radius: 7px; overflow: hidden; }
.trend-seg { padding: 5px 12px; font-size: 12px; background: var(--surface); color: var(--muted); border: 0; cursor: pointer; transition: background .15s, color .15s; }
.trend-seg:hover { background: var(--brand-50); color: var(--brand-800); }
.trend-seg:focus-visible { outline: 2px solid var(--brand-600); outline-offset: -2px; }
.trend-seg.on { background: var(--brand-700); color: #fff; font-weight: 600; }
.trend-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 768px) { .trend-grid { grid-template-columns: 1fr 1fr; } }
.trend-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 16px 18px; }
.trend-card__title { font-size: 14px; font-weight: 600; color: var(--text); margin: 0; }
.trend-card__desc { font-size: 12px; color: var(--muted); margin: 2px 0 12px; }
.trend-empty { background: var(--brand-50); border-left: 3px solid var(--brand-600); border-radius: 0 6px 6px 0; padding: 14px 16px; font-size: 13px; color: var(--muted); }
.trend-empty--inline { border: 0; background: transparent; padding: 24px 0; text-align: center; }

/* SVG charts */
.chart { width: 100%; height: auto; display: block; }
.chart-grid { stroke: #eef1f4; stroke-width: 1; }
.chart-axis { font-size: 11px; fill: var(--muted); }
.chart-line { fill: none; stroke: var(--brand-700); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: url(#chartFill); }
.chart-fill-top { stop-color: var(--brand-600); stop-opacity: .32; }
.chart-fill-bot { stop-color: var(--brand-600); stop-opacity: .02; }
.chart-dot { fill: var(--brand-700); stroke: #fff; stroke-width: 2; }
.chart-series { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart-series--dashed { stroke-dasharray: 5 4; }
.chart-series--brand { stroke: var(--brand-700); }
.chart-series--brand-light { stroke: var(--brand-600); }
.chart-series--gold { stroke: var(--gold); }
.chart-series--danger { stroke: var(--color-cancelled); stroke-opacity: .8; }

/* Legend */
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-key { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-key--brand { background: var(--brand-700); }
.chart-key--brand-light { background: var(--brand-600); }
.chart-key--gold { background: var(--gold); }
.chart-key--danger { background: var(--color-cancelled); }

/* Horizontal bars */
.chart-bars { display: flex; flex-direction: column; gap: 7px; }
.chart-bar-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.chart-bar-label { width: 64px; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.chart-bar-track { flex: 1; height: 18px; background: #f1f3f5; border-radius: 5px; overflow: hidden; }
.chart-bar-fill { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--brand-600), var(--brand-700)); }
.chart-bar-val { width: 28px; font-weight: 600; color: var(--brand-800); }
.chart-bar-more { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* ── Encart « Directions à surveiller » (lien de pied) ─────────────────── */
.dirwatch-link { list-style: none; padding: 8px 2px 0; text-align: right; }
.dirwatch-link a { font-size: 12.5px; font-weight: 600; color: var(--brand-700); text-decoration: none; }
.dirwatch-link a:hover { color: var(--brand-800); text-decoration: underline; }

/* ── Notifications (cloche) ──────────────────────────────────────── */
.notif-wrap { position: relative; display: inline-flex; }
.notif-bell { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px;
  padding: 0 5px; border-radius: 9px; background: #a93226; color: #fff;
  font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0; width: 340px; max-width: 90vw;
  background: #fff; border: 1px solid var(--border, #e5e7eb); border-radius: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); z-index: 60; overflow: hidden;
}
.notif-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border, #eee); font-weight: 600;
}
.notif-readall {
  background: none; border: none; color: var(--brand, #337A57);
  font-size: .8rem; cursor: pointer; padding: 0;
}
.notif-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid #f1f1f4; cursor: pointer; }
.notif-item:hover { background: #f8f9fc; }
.notif-item.is-unread { background: #f0f7f3; }
.notif-item.is-unread .notif-item__title { font-weight: 700; }
.notif-item__title { font-size: .85rem; color: #1a1a2e; }
.notif-item__body { font-size: .82rem; color: #444; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item__meta { font-size: .72rem; color: #888; margin-top: 3px; }
.notif-empty { padding: 18px 14px; text-align: center; color: #888; font-size: .85rem; }
.dirwatch-link a:focus-visible { outline: 2px solid var(--brand-600); outline-offset: 2px; border-radius: 3px; }
