/* ==========================================================================
   Design System 2026 — Renonciations.app
   Chargé APRÈS style.css / style-super.css : redéfinit les jetons et ajoute
   les composants communs (notifications, recherche rapide, aides de saisie).
   Contrastes vérifiés WCAG 2.2 AA (voir rapport d'audit, section 7).
   ========================================================================== */
:root {
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-2: #EEF2F0;
  --ink: #14211C;
  --muted: #4F5E58;
  --line: #C9D3CE;
  --line-input: #76867F;      /* 3,8:1 sur blanc (WCAG 1.4.11) */
  --accent: #0B5D46;          /* 7,9:1 sur blanc */
  --accent-hover: #08483A;
  --accent-ink: #FFFFFF;
  --accent-soft: #DDEFE7;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warn: #8A5300;
  --warn-soft: #FDF1DC;
  --info: #1D4ED8;
  --focus: #B45309;
  --shadow: 0 8px 24px rgba(20, 33, 28, .14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1714;
    --surface: #16201C;
    --surface-2: #1C2924;
    --ink: #E6EDEA;
    --muted: #9DB0A8;
    --line: #2B3A34;
    --line-input: #6F8179;
    --accent: #5FD3A8;
    --accent-hover: #86E0BE;
    --accent-ink: #0F1714;
    --accent-soft: #173A2E;
    --danger: #FF8A80;
    --danger-soft: #3C1D1A;
    --warn: #FBBF5A;
    --warn-soft: #3A2C12;
    --info: #8AB4FF;
    --focus: #FBBF5A;
    --shadow: 0 8px 24px rgba(0, 0, 0, .5);
  }
}
:root[data-theme="dark"] {
  --bg: #0F1714;
  --surface: #16201C;
  --surface-2: #1C2924;
  --ink: #E6EDEA;
  --muted: #9DB0A8;
  --line: #2B3A34;
  --line-input: #6F8179;
  --accent: #5FD3A8;
  --accent-hover: #86E0BE;
  --accent-ink: #0F1714;
  --accent-soft: #173A2E;
  --danger: #FF8A80;
  --danger-soft: #3C1D1A;
  --warn: #FBBF5A;
  --warn-soft: #3A2C12;
  --info: #8AB4FF;
  --focus: #FBBF5A;
  --shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---------- Typographie : une seule famille (Public Sans), chiffres tabulaires ---------- */
h1, h2, h3, .counter .n, h3.sub-title, .kpi .n {
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.01em;
}
h1 { font-size: clamp(1.5rem, 3.2vw, 1.75rem); line-height: 1.3; }
h2 { font-size: 1.25rem; line-height: 1.4; }
td, .counter .n, .kpi .n, input, .ux-res-meta { font-variant-numeric: tabular-nums; }

/* ---------- Champs : bordure contrastée, rayon 6 px ---------- */
input, select, textarea { border-color: var(--line-input); border-radius: 6px; }
.panel, .kpi, .counter { border-radius: 10px; }

/* ---------- Boutons : survol plus net ---------- */
.btn-primary:hover, a.btn.btn-primary:hover { background: var(--accent-hover); filter: none; }

/* ---------- Aide de format (non bloquante) ---------- */
.ux-hint { margin: 4px 0 0; font-size: 0.85rem; color: var(--warn); }
.ux-hint::before { content: "ⓘ "; }

/* ---------- Notifications (remplacent les alertes du navigateur) ---------- */
.ux-toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000;
  display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px));
}
.ux-toast {
  display: flex; align-items: flex-start; gap: 12px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 0.95rem;
}
.ux-toast.error { border-left-color: var(--danger); }
.ux-toast.warn { border-left-color: var(--warn); }
.ux-toast p { margin: 0; flex: 1; }
.ux-toast button {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  min-width: 32px; min-height: 32px; font-size: 1.1rem; line-height: 1; padding: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .ux-toast { animation: ux-in .18s ease-out; }
  @keyframes ux-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ---------- Recherche rapide (Ctrl+K) ---------- */
.ux-search-btn { display: inline-flex; align-items: center; gap: 8px; }
.ux-search-btn kbd, .ux-dlg kbd {
  font: 600 0.75rem/1 "Public Sans", system-ui, sans-serif;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 3px 5px; color: var(--muted); background: var(--surface-2);
}
.ux-dlg {
  width: min(640px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 64px));
  margin: 10vh auto auto; padding: 0; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.ux-dlg::backdrop { background: rgba(10, 20, 16, .45); }
.ux-dlg form { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.ux-dlg input[type="search"] { flex: 1; min-height: 44px; font-size: 1.05rem; border: 0; background: transparent; padding: 0 4px; }
.ux-dlg input[type="search"]:focus-visible { outline: none; }
.ux-dlg .ux-help { padding: 10px 16px; margin: 0; color: var(--muted); font-size: 0.9rem; }
.ux-dlg ul { list-style: none; margin: 0; padding: 6px; overflow-y: auto; max-height: 420px; }
.ux-dlg li button {
  width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left;
  background: none; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; color: var(--ink); min-height: 48px;
}
.ux-dlg li button:hover, .ux-dlg li button.act { background: var(--accent-soft); }
.ux-res-name { font-weight: 600; grid-column: 1; grid-row: 1; }
.ux-res-meta { color: var(--muted); font-size: 0.85rem; grid-column: 1; grid-row: 2; }
.ux-res-badge { grid-column: 2; grid-row: 1 / span 2; justify-self: end; align-self: center; font-size: 0.8rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.ux-res-badge.done { background: var(--accent-soft); color: var(--accent); }

/* ---------- Bandeau « brouillon restauré » ---------- */
.ux-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 12px 0 0; padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--ink); font-size: 0.92rem; }
.ux-draft button { min-height: 32px; }

@media print { .ux-toasts, .ux-search-btn { display: none !important; } }
@media (hover: none), (max-width: 640px) { .ux-search-btn kbd { display: none; } }

/* ==========================================================================
   Navigation latérale (tous les comptes) et sous-onglets « Dossiers traités »
   ========================================================================== */
.sidebar .tabs { gap: 4px; }
.tab { display: flex; align-items: center; gap: 12px; font-weight: 600; }
.tab::before {
  content: ""; flex: 0 0 20px; width: 20px; height: 20px;
  background: currentColor;
  -webkit-mask: var(--ico) center / 20px 20px no-repeat; mask: var(--ico) center / 20px 20px no-repeat;
}
.tab.tab-sep { margin-top: 10px; position: relative; }
.tab.tab-sep::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: -8px;
  border-top: 1px solid var(--line);
}
.tab[data-view="rat"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 3-6.7L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3C/svg%3E"); }
.tab[data-view="dce"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 21h18'/%3E%3Cpath d='M5 21V7l7-4 7 4v14'/%3E%3Cpath d='M9 21v-6h6v6'/%3E%3C/svg%3E"); }
.tab[data-view="renonc"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z'/%3E%3Cpath d='M14 3v6h6'/%3E%3Cpath d='M9.5 12.5l5 5'/%3E%3Cpath d='M14.5 12.5l-5 5'/%3E%3C/svg%3E"); }
.tab[data-view="2no"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3v18'/%3E%3Cpath d='M5 6h12l3 3-3 3H5z'/%3E%3C/svg%3E"); }
.tab[data-view="archives"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='4' rx='1'/%3E%3Cpath d='M5 8v11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8'/%3E%3Cpath d='M10 12h4'/%3E%3C/svg%3E"); }
.tab[data-view="comptes"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2'/%3E%3Ccircle cx='9' cy='7' r='4'/%3E%3Cpath d='M22 21v-2a4 4 0 0 0-3-3.9'/%3E%3Cpath d='M16 3.1a4 4 0 0 1 0 7.8'/%3E%3C/svg%3E"); }
.tab[data-view="journal"] { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M12 7v5l3 2'/%3E%3C/svg%3E"); }

/* Sous-onglets : une liste à la fois, avec le nombre de dossiers de chaque type */
.subtabs {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 6px;
  margin: 0 0 18px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.subtab {
  min-width: 0; min-height: 48px; white-space: normal; text-align: center; line-height: 1.25;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px 14px; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted); font-weight: 600; font-size: 0.95rem; cursor: pointer;
}
.subtab:hover { background: var(--accent-soft); color: var(--accent); }
.subtab.active { background: var(--accent); color: var(--accent-ink); }
.subtab-n {
  min-width: 24px; padding: 1px 8px; border-radius: 999px; font-size: 0.8rem;
  background: var(--surface-2); color: var(--ink); font-variant-numeric: tabular-nums;
}
.subtab-n:empty { display: none; }
.subtab.active .subtab-n { background: rgba(255, 255, 255, .22); color: inherit; }
.subtab:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Harmonisation des espacements et des tableaux */
.panel { padding: 24px; }
.panel + .panel { margin-top: 20px; }
.list-head h2 { font-size: 1.15rem; }
thead th { position: sticky; top: 0; z-index: 1; }
tbody tr:hover td { background: var(--surface-2); }
th, td { padding: 10px 12px; }

/* Tablette et mobile */
@media (max-width: 960px) {
  .panel { padding: 18px; }
}
@media (max-width: 640px) {
  .subtabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .subtab { font-size: 0.88rem; padding: 8px 10px; }
  .head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
}


/* Tableaux : hauteur limitee pour garder la barre de defilement horizontale visible */
.table-wrap { max-height: 70vh; overflow: auto; }
.table-wrap thead th { background: var(--surface, #fff); z-index: 2; }
