/* ==========================================================================
   ENSP/TA — Design system v3
   Fichier 3/4 : composants.
   Les noms de classes historiques (card, btn, tbl, badge, kpi, alert, field…) sont conservés :
   toutes les vues existantes en profitent sans modification.
   ========================================================================== */

/* --- Boutons --- */
.btn {
  --b-bg: var(--primary); --b-fg: var(--on-primary); --b-bd: transparent; --b-hover: var(--primary-hover);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--b-bd); background: var(--b-bg); color: var(--b-fg); font-size: .875rem; font-weight: 700; line-height: 1; white-space: nowrap; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .16) inset, 0 1px 2px rgba(14, 26, 51, .2);
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.btn:hover { background: var(--b-hover); color: var(--b-fg); text-decoration: none; }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .i { width: 17px; height: 17px; }
.btn[disabled], .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--b-fg); border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-sm { height: 32px; padding: 0 12px; font-size: .8125rem; border-radius: 9px; gap: 6px; }
.btn-sm .i { width: 15px; height: 15px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: .9375rem; border-radius: 13px; }
.btn-block { width: 100%; }
.btn-outline { --b-bg: var(--surface); --b-fg: var(--ink); --b-bd: var(--line-strong); --b-hover: var(--surface-2); box-shadow: var(--sh-1); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { --b-bg: transparent; --b-fg: var(--muted); --b-hover: var(--bg-sunk); box-shadow: none; }
.btn-ghost:hover { color: var(--ink); }
.btn-soft { --b-bg: var(--primary-soft); --b-fg: var(--primary); --b-hover: var(--primary-soft-2); box-shadow: none; }
.btn-vert { --b-bg: var(--success); --b-hover: var(--success-hover); }
.btn-rouge { --b-bg: var(--danger); --b-hover: var(--danger-hover); }
.btn-vert, .btn-rouge { --b-fg: #fff; }
:root[data-theme="dark"] .btn-vert, :root[data-theme="dark"] .btn-rouge { --b-fg: #0A1022; }
.btn-icon { width: 40px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }

/* --- Badges et pastilles --- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: var(--r-pill); font-size: .75rem; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--bg-sunk); color: var(--muted); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge.no-dot::before { display: none; }
.badge.no-dot { padding-left: 10px; }
.badge-bleu { background: var(--primary-soft); color: var(--primary); }
.badge-vert { background: var(--success-soft); color: var(--success); }
.badge-rouge { background: var(--danger-soft); color: var(--danger); }
.badge-ambre { background: var(--accent-soft); color: var(--accent-ink); }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); font-size: .8125rem; font-weight: 500; text-decoration: none; transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast); }
a.chip:hover, button.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.is-active { background: var(--primary-soft); border-color: var(--primary-soft-2); color: var(--primary); }
.chip .i { width: 14px; height: 14px; }

/* --- Cartes et grilles --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); margin-bottom: var(--gap); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 18px; min-height: 52px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; }
.card-head > .muted-sm, .card-head > a { font-size: var(--fs-sm); }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card.is-flat { box-shadow: none; }
.card.is-accent { border-top: 3px solid var(--accent); }
a.card, .card.is-link { display: block; color: inherit; text-decoration: none; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t); }
a.card:hover, .card.is-link:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--primary-soft-2); text-decoration: none; }
.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-aside { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.grid > .card, .grid > .stat, .grid > .kpi { margin-bottom: 0; }
.grid > div > .card:last-child { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid, .filters + .grid, .alert + .grid { margin-top: var(--gap); }
@media (max-width: 1180px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-aside { grid-template-columns: 1fr; } }
@media (max-width: 900px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 440px) { .grid-4 { grid-template-columns: 1fr; } }

/* --- Tuiles de statistiques --- */
.stat, .kpi { position: relative; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-1); }
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-ico { flex: none; width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.stat-ico .i { width: 18px; height: 18px; }
.stat-ico.tone-green { background: var(--success-soft); color: var(--success); }
.stat-ico.tone-amber { background: var(--accent-soft); color: var(--accent-ink); }
.stat-ico.tone-red { background: var(--danger-soft); color: var(--danger); }
.stat-ico.tone-neutral { background: var(--bg-sunk); color: var(--muted); }
.stat-label { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; line-height: 1.25; }
.stat-val { font-family: var(--font-display); font-size: 2.25rem; font-weight: 600; line-height: 1.05; letter-spacing: -.02em; color: var(--ink); font-variant-numeric: lining-nums; margin-top: 4px; }
.stat-val small { font-family: var(--font-ui); font-size: .875rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.stat-foot { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; color: var(--muted); font-size: var(--fs-sm); margin-top: 2px; }
.delta { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px 2px 6px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--bg-sunk); color: var(--muted); font-variant-numeric: tabular-nums; }
.delta .i { width: 13px; height: 13px; }
.delta.up { background: var(--success-soft); color: var(--success); }
.delta.down { background: var(--danger-soft); color: var(--danger); }
.spark { margin-left: auto; flex: none; width: 88px; height: 30px; overflow: visible; }
.spark path { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark .area { fill: var(--viz-1-soft); stroke: none; }
.spark circle { fill: var(--viz-1); stroke: var(--surface); stroke-width: 2; }
/* Ancien balisage .kpi (label / value / sub) restylé comme une tuile */
.kpi .label { color: var(--muted); font-size: var(--fs-sm); font-weight: 500; display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; }
.kpi .label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--kpi-c, var(--primary)); flex: none; }
.kpi .value { font-family: var(--font-display); font-size: 1.875rem; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; color: var(--ink); margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: var(--fs-sm); }
.kpi.rouge { --kpi-c: var(--danger); } .kpi.vert { --kpi-c: var(--success); } .kpi.ambre { --kpi-c: var(--accent); }

/* --- Tableaux --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap.is-sticky { max-height: 70vh; overflow: auto; }
.is-sticky .tbl thead th { position: sticky; top: 0; z-index: 1; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .875rem; }
.tbl th { padding: 11px 16px; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); border-top: 0; text-transform: none; }
.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; text-align: left; color: var(--text); }
.tbl tbody tr { transition: background var(--t-fast); }
.tbl tbody tr:hover td { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tr[data-href] { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums lining-nums; }
.tbl tfoot td { padding: 12px 16px; font-weight: 600; color: var(--ink); background: var(--surface-2); border-top: 1px solid var(--line); border-bottom: 0; }
.tbl .row-actions { white-space: nowrap; text-align: right; }
.tbl .row-actions > * { vertical-align: middle; }
.tbl a:not(.btn):not(.badge) { font-weight: 500; }
.tbl-compact th, .tbl-compact td { padding: 8px 12px; }
.tbl-compact { font-size: .8125rem; }
.card > .table-wrap:first-child .tbl thead tr:first-child th:first-child { border-top-left-radius: calc(var(--r-lg) - 1px); }
.card > .table-wrap:first-child .tbl thead tr:first-child th:last-child { border-top-right-radius: calc(var(--r-lg) - 1px); }
.card-head + .table-wrap .tbl thead th { border-top: 0; }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user > div { min-width: 0; line-height: 1.3; }
.cell-user b { display: block; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-user small { display: block; color: var(--muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Formulaires --- */
.form-grid { display: grid; gap: 18px 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } }
.field { min-width: 0; }
.field label, label.lbl { display: block; margin-bottom: 6px; color: var(--ink); font-size: var(--fs-sm); font-weight: 600; }
.field label .req { color: var(--danger); margin-left: 2px; }
.field .help { margin-top: 6px; color: var(--muted); font-size: var(--fs-xs); line-height: 1.45; }
.field .err { margin-top: 6px; color: var(--danger); font-size: var(--fs-sm); font-weight: 500; line-height: 1.4; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], input[type=search], input[type=url], input[type=datetime-local], input[type=file], select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--ink);
  font-size: .9375rem; line-height: 1.4; box-shadow: inset 0 1px 0 rgba(14, 26, 51, .02); transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
textarea { height: auto; min-height: 104px; padding: 10px 12px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:hover, select:hover, textarea:hover { border-color: var(--subtle); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
select { appearance: none; -webkit-appearance: none; background-image: var(--chev); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 38px; cursor: pointer; }
input[disabled], select[disabled], textarea[disabled], input[readonly] { background: var(--bg-sunk); color: var(--muted); cursor: not-allowed; }
input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
input[type=file] { height: auto; padding: 7px; cursor: pointer; }
input[type=file]::file-selector-button { margin-right: 12px; padding: 7px 14px; border: 0; border-radius: 8px; background: var(--primary-soft); color: var(--primary); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--primary-soft-2); }
input[type=checkbox], input[type=radio] { appearance: none; -webkit-appearance: none; flex: none; width: 18px; height: 18px; margin: 0; padding: 0; display: inline-grid; place-content: center; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; vertical-align: -4px; box-shadow: none; transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast); }
input[type=checkbox] { border-radius: 6px; }
input[type=radio] { border-radius: 50%; }
input[type=checkbox]:checked { background-color: var(--primary); border-color: var(--primary); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); background-size: 13px; background-position: center; background-repeat: no-repeat; }
:root[data-theme="dark"] input[type=checkbox]:checked { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230A1022' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 12.5 4.5 4.5L19 7.5'/%3E%3C/svg%3E"); }
input[type=radio]:checked { border-color: var(--primary); background: radial-gradient(circle, var(--primary) 0 4.5px, transparent 5.5px), var(--surface); }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: none; box-shadow: var(--ring); }
.check { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; color: var(--text); line-height: 1.45; cursor: pointer; }
.check input { margin-top: 1px; }
.input-icon { position: relative; }
.input-icon > .i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--subtle); pointer-events: none; }
.input-icon input { padding-left: 40px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 24px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 14px; padding: 14px 16px; margin-bottom: var(--gap); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.filters .field { flex: 1 1 170px; min-width: 150px; }
.filters .field label { margin-bottom: 4px; color: var(--muted); font-size: var(--fs-xs); }
.filters input, .filters select { height: 38px; font-size: .875rem; }
.filters .field[style*="flex:0"], .filters .field:has(> .btn:only-child) { flex: 0 0 auto; min-width: 0; }

/* --- Alertes --- */
.alert { --a-bg: var(--primary-soft); --a-bd: var(--primary-soft-2); --a-fg: var(--primary); --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 8h.01M11 12h1v4h1'/%3E%3C/svg%3E");
  position: relative; margin-bottom: var(--gap); padding: 14px 44px 14px 48px; border: 1px solid var(--a-bd); border-radius: 14px; background: var(--a-bg); color: var(--ink); font-size: .9rem; line-height: 1.55; }
.alert::before { content: ""; position: absolute; left: 16px; top: 15px; width: 20px; height: 20px; background: var(--a-fg); -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat; }
.alert strong { color: inherit; }
.alert ul { margin: 6px 0 0; padding-left: 1.1rem; }
.alert a { font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.alert .alert-x { position: absolute; right: 8px; top: 8px; width: 30px; height: 30px; display: grid; place-items: center; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.alert .alert-x:hover { background: rgba(14, 26, 51, .07); color: var(--ink); }
.alert-success { --a-bg: var(--success-soft); --a-bd: var(--success-soft-2); --a-fg: var(--success); --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='m9 12 2 2 4-4'/%3E%3C/svg%3E"); }
.alert-warning { --a-bg: var(--accent-soft); --a-bd: var(--accent-soft-2); --a-fg: var(--accent-ink); --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 9v4M12 16.5h.01'/%3E%3Cpath d='M10.363 3.591 2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z'/%3E%3C/svg%3E"); }
.alert-error { --a-bg: var(--danger-soft); --a-bd: var(--danger-soft-2); --a-fg: var(--danger); --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 8v4M12 16h.01'/%3E%3C/svg%3E"); }
.alert.mb0 { margin-bottom: 0; }

/* --- États vides --- */
.empty { text-align: center; padding: 52px 24px; color: var(--muted); }
.empty .ico { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 20px; display: grid; place-items: center; background: var(--bg-sunk); color: var(--subtle); }
.empty .ico .i { width: 26px; height: 26px; stroke-width: 1.5; }
.empty b, .empty strong { display: block; margin-bottom: 4px; color: var(--ink); font-size: var(--fs-md); }
.empty p { max-width: 46ch; margin: 0 auto 16px; line-height: 1.55; }

/* --- Onglets et contrôle segmenté --- */
.tabs { display: flex; gap: 2px; margin-bottom: var(--gap); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 11px 16px; border: 0; background: none; color: var(--muted); font-size: .875rem; font-weight: 600; white-space: nowrap; text-decoration: none; }
.tabs a:hover, .tabs button:hover { color: var(--ink); text-decoration: none; }
.tabs a.active, .tabs .active, .tabs [aria-selected="true"] { color: var(--primary); }
.tabs a.active::after, .tabs .active::after, .tabs [aria-selected="true"]::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; border-radius: 2px 2px 0 0; background: var(--primary); }
.tabs .badge { height: 20px; padding: 0 7px; font-size: 11px; }
.tabs .badge::before { display: none; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--bg-sunk); }
.seg a, .seg button { padding: 6px 14px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-size: var(--fs-sm); font-weight: 600; text-decoration: none; }
.seg .is-active, .seg [aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.tab-panel[hidden] { display: none; }

/* --- Progression --- */
.progress { height: 8px; background: var(--viz-track); border-radius: var(--r-pill); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--primary); transition: width .7s var(--ease); }
.progress.is-good > span { background: var(--success); } .progress.is-warn > span { background: var(--accent); } .progress.is-bad > span { background: var(--danger); }
.progress.is-lg { height: 12px; }
.meter { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.meter .progress { flex: 1; }
.meter .n { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.meter-stack { display: grid; gap: 7px; }
.meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: var(--fs-sm); color: var(--text); }
.meter-head b { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 600; }
.ring-wrap { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring { width: 88px; height: 88px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.4; }
.ring .ring-bg { stroke: var(--viz-track); }
.ring .ring-fg { stroke: var(--primary); stroke-linecap: round; transition: stroke-dasharray .9s var(--ease); }
.ring.is-good .ring-fg { stroke: var(--success); } .ring.is-warn .ring-fg { stroke: var(--accent); } .ring.is-bad .ring-fg { stroke: var(--danger); }
.ring-label { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; line-height: 1.1; }
.ring-label b { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; color: var(--ink); }
.ring-label small { font-size: 10.5px; color: var(--muted); }

/* --- Chronologie --- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 28px; font-size: .9rem; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child { padding-bottom: 0; }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 3px solid var(--primary); }
.timeline time { display: block; margin-bottom: 2px; color: var(--muted); font-size: var(--fs-xs); }

/* --- Listes de définitions --- */
.dl { display: grid; grid-template-columns: minmax(110px, max-content) 1fr; gap: 12px 28px; margin: 0; font-size: .9rem; align-items: baseline; }
.dl dt { color: var(--muted); font-weight: 500; }
.dl dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 720px) { .dl { grid-template-columns: 1fr; gap: 2px; } .dl dt { margin-top: 12px; font-size: var(--fs-xs); } .dl dt:first-child { margin-top: 0; } }

/* --- Pagination --- */
.pagination { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; list-style: none; padding: 0; margin: 22px 0 0; }
.pagination li a, .pagination li span { display: inline-grid; place-items: center; min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font-size: var(--fs-sm); font-weight: 500; text-decoration: none; }
.pagination li a:hover { border-color: var(--primary); color: var(--primary); }
.pagination li.active span { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.pagination li.disabled span { color: var(--subtle); background: var(--surface-2); }

/* --- Avatars --- */
.avatar { --h: 220; flex: none; width: 36px; height: 36px; display: inline-grid; place-items: center; border-radius: 12px; background: hsl(var(--h) 62% 93%); color: hsl(var(--h) 55% 26%); font-size: .8125rem; font-weight: 600; letter-spacing: .01em; user-select: none; }
:root[data-theme="dark"] .avatar { background: hsl(var(--h) 38% 22%); color: hsl(var(--h) 85% 84%); }
.avatar-sm { width: 28px; height: 28px; border-radius: 9px; font-size: .6875rem; }
.avatar-lg { width: 56px; height: 56px; border-radius: 18px; font-size: 1.125rem; }
.avatar-xl { width: 88px; height: 88px; border-radius: 26px; font-size: 1.75rem; font-family: var(--font-display); }
.avatar-round { border-radius: 50%; }

/* --- Lignes d'alerte intelligentes (Centre d'attention) --- */
.insights { display: flex; flex-direction: column; }
.insight { --sev: var(--primary); --sev-soft: var(--primary-soft); position: relative; display: flex; align-items: center; gap: 14px; padding: 14px 20px; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line-soft); transition: background var(--t-fast); }
.insight:last-child { border-bottom: 0; }
.insight:hover { background: var(--surface-2); text-decoration: none; }
.insight.sev-critical { --sev: var(--danger); --sev-soft: var(--danger-soft); }
.insight.sev-warning { --sev: var(--accent-ink); --sev-soft: var(--accent-soft); }
.insight.sev-info { --sev: var(--primary); --sev-soft: var(--primary-soft); }
.insight.sev-good { --sev: var(--success); --sev-soft: var(--success-soft); }
.insight-ico { flex: none; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--sev-soft); color: var(--sev); }
.insight-txt { flex: 1; min-width: 0; line-height: 1.35; }
.insight-txt b { display: block; color: var(--ink); font-weight: 600; font-size: var(--fs-base); }
.insight-txt small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-sm); }
.insight-txt .why { display: block; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg-sunk); color: var(--muted); font-size: var(--fs-xs); line-height: 1.5; }
.insight-meta { flex: none; display: flex; align-items: center; gap: 10px; color: var(--subtle); }
.insight-count { min-width: 30px; height: 30px; padding: 0 9px; display: inline-grid; place-items: center; border-radius: var(--r-pill); background: var(--sev-soft); color: var(--sev); font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; }
.insight-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.insights.is-compact .insight { padding: 10px 12px; border-radius: 12px; border-bottom: 0; }
.insights.is-compact .insight-ico { width: 32px; height: 32px; border-radius: 10px; }
.insights.is-compact .insight-txt b { font-size: var(--fs-sm); }
.sev-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--sev, var(--primary)); }

/* --- Tuiles de modules (accueil) --- */
.tile { display: flex; align-items: flex-start; gap: 14px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--sh-1); color: inherit; text-decoration: none; transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease), border-color var(--t); }
.tile:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--primary-soft-2); text-decoration: none; }
.tile b { display: block; color: var(--ink); font-size: var(--fs-md); }
.tile small { display: block; margin-top: 2px; color: var(--muted); font-size: var(--fs-sm); line-height: 1.45; }
.tile .stat-ico { width: 42px; height: 42px; border-radius: 13px; }

/* --- Divers --- */
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li { border-bottom: 1px solid var(--line-soft); }
.menu-list li:last-child { border-bottom: 0; }
.menu-list li a { display: block; padding: 12px 4px; color: var(--ink); font-weight: 500; }
.menu-list li a:hover { color: var(--primary); text-decoration: none; }
details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details.inline { display: inline-block; vertical-align: middle; }
details.inline[open] { display: block; }
.codeblock { position: relative; display: block; padding: 16px 56px 16px 18px; border-radius: 14px; background: #0B1431; color: #DCE6FF; font: 13px/1.65 var(--font-mono); white-space: pre-wrap; word-break: break-all; user-select: all; }
.codeblock + .copy-row { margin-top: 10px; }
.skeleton { color: transparent !important; border-radius: 8px; background: linear-gradient(90deg, var(--bg-sunk) 25%, var(--surface-3) 37%, var(--bg-sunk) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }
.note { padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: var(--fs-sm); }
.divider { height: 1px; background: var(--line-soft); margin: 18px 0; border: 0; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); font-size: .9rem; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv b { color: var(--ink); }

/* ==========================================================================
   v4 « FREECOM » : cartes à en-tête barré, tuiles colorées, boîtes d'information
   ========================================================================== */
.btn-lime { --b-bg: var(--lime); --b-fg: var(--on-lime); --b-hover: var(--lime-hover); }

/* Pictogramme plein des tuiles (une couleur par sens, jamais seule : toujours avec un libellé) */
.stat, .kpi { border-radius: var(--r-tile); padding: 16px 18px; }
.stat-ico { width: 40px; height: 40px; border-radius: 12px; background: var(--t-blue); color: #fff; }
.stat-ico .i { width: 20px; height: 20px; }
.stat-ico.tone-green { background: var(--t-green); color: #fff; }
.stat-ico.tone-amber { background: var(--t-yellow); color: var(--on-yellow); }
.stat-ico.tone-red { background: var(--t-red); color: #fff; }
.stat-ico.tone-purple { background: var(--t-purple); color: #fff; }
.stat-ico.tone-teal { background: var(--t-teal); color: #fff; }
.stat-ico.tone-neutral { background: var(--t-navy); color: #fff; }
.stat-label { font-weight: 600; }
.stat-val, .kpi .value { font-family: var(--font-display); font-weight: 800; letter-spacing: -.025em; }
.stat-val { font-size: 2.1rem; }
.stat.is-link:hover { border-color: var(--primary-soft-2); }

/* Variante pleine : la tuile entière est colorée (comme les boîtes Mikhmon de FREECOM) */
.stat.is-solid { --st: var(--t-blue); --st-fg: var(--on-tile); border-color: transparent; background: var(--st); color: var(--st-fg); box-shadow: 0 12px 24px -16px rgba(0, 0, 0, .55); }
.stat.is-solid .stat-label, .stat.is-solid .stat-foot, .stat.is-solid .stat-val small { color: var(--st-fg); opacity: .92; }
.stat.is-solid .stat-val { color: var(--st-fg); }
.stat.is-solid .stat-ico { background: rgba(255, 255, 255, .2); color: var(--st-fg); }
.stat.is-solid .delta { background: rgba(255, 255, 255, .2); color: var(--st-fg); }
.stat.is-solid .spark path { stroke: var(--st-fg); } .stat.is-solid .spark .area { fill: rgba(255, 255, 255, .2); } .stat.is-solid .spark circle { fill: var(--st-fg); stroke: var(--st); }
.stat.is-solid.tone-green { --st: var(--t-green); }
.stat.is-solid.tone-amber { --st: var(--t-yellow); --st-fg: var(--on-yellow); }
.stat.is-solid.tone-red { --st: var(--t-red); }
.stat.is-solid.tone-purple { --st: var(--t-purple); }
.stat.is-solid.tone-teal { --st: var(--t-teal); }
.stat.is-solid.tone-neutral { --st: var(--t-navy); }
a.stat.is-solid:hover { transform: translateY(-2px); filter: brightness(1.05); }

/* Boîte d'information : pavé de couleur à gauche, lignes de texte à droite */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)); gap: 14px; }
.tile-boxes { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; }
.info-tile { display: flex; align-items: stretch; min-width: 0; min-height: 88px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-tile); box-shadow: var(--sh-1); color: inherit; text-decoration: none; }
a.info-tile { transition: transform var(--t) var(--ease), box-shadow var(--t) var(--ease); }
a.info-tile:hover { transform: translateY(-2px); box-shadow: var(--sh-2); text-decoration: none; }
.info-tile .it-ico { flex: none; width: 72px; display: grid; place-items: center; background: var(--t-blue); color: #fff; }
.info-tile .it-ico .i { width: 30px; height: 30px; stroke-width: 1.6; }
.info-tile .it-body { padding: 12px 14px; min-width: 0; font-size: .9rem; line-height: 1.55; color: var(--text); }
.info-tile .it-body b { font-weight: 700; color: var(--ink); }
.info-tile .it-body .it-big { display: block; font: 800 1.5rem/1.15 var(--font-display); letter-spacing: -.02em; color: var(--ink); }
.info-tile.tone-green .it-ico { background: var(--t-green); }
.info-tile.tone-amber .it-ico { background: var(--t-yellow); color: var(--on-yellow); }
.info-tile.tone-red .it-ico { background: var(--t-red); }
.info-tile.tone-purple .it-ico { background: var(--t-purple); }
.info-tile.tone-teal .it-ico { background: var(--t-teal); }
.info-tile.tone-neutral .it-ico { background: var(--t-navy); }

/* Boîte colorée (grand chiffre + libellé), version lien ou simple bloc */
.box { --bx: var(--t-blue); --bx-fg: var(--on-tile); display: grid; align-content: space-between; gap: 8px; min-height: 104px; padding: 14px 16px; border-radius: var(--r-tile); background: var(--bx); color: var(--bx-fg); text-decoration: none; box-shadow: 0 12px 24px -16px rgba(0, 0, 0, .55); transition: transform var(--t) var(--ease), filter var(--t); }
a.box:hover { transform: translateY(-2px); filter: brightness(1.06); color: var(--bx-fg); text-decoration: none; }
.box b { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; color: inherit; font: 800 2rem/1.1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.box b small { font: 700 .95rem var(--font-ui); color: inherit; opacity: .92; letter-spacing: 0; }
.box > span { display: flex; align-items: center; gap: 6px; font-size: .88rem; font-weight: 700; opacity: .95; }
.box.tone-green { --bx: var(--t-green); } .box.tone-red { --bx: var(--t-red); } .box.tone-purple { --bx: var(--t-purple); } .box.tone-teal { --bx: var(--t-teal); } .box.tone-neutral { --bx: var(--t-navy); }
.box.tone-amber { --bx: var(--t-yellow); --bx-fg: var(--on-yellow); }

/* Cartes : en-tête barré (signature FREECOM) */
.card-head { background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px) 0 0; padding: 12px 18px; min-height: 52px; }
.card-head h2, .card-head h3 { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-size: 1.02rem; font-weight: 700; letter-spacing: -.01em; }
.card-head h2::before, .card-head h3::before { content: ""; flex: none; width: 4px; height: 16px; border-radius: 4px; background: var(--primary); }
.card-head h2 .i, .card-head h3 .i { color: var(--muted); }
.card-body { padding: 18px; }
.card-foot { border-radius: 0 0 calc(var(--r-lg) - 1px) calc(var(--r-lg) - 1px); }

/* Tableaux : en-têtes compacts en capitales, comme le journal Hotspot de FREECOM */
.tbl th { background: var(--surface-2); }

/* Champ mot de passe : bouton « afficher » à droite, pictogramme optionnel à gauche */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 46px; }
.pw-wrap.input-icon input { padding-left: 40px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--subtle); }
.pw-toggle:hover { background: var(--bg-sunk); color: var(--ink); }

/* Avatar du compte dans la barre du haut */
.topbar .avatar { background: linear-gradient(135deg, var(--lime), var(--t-blue)); color: #0B1730; font-family: var(--font-display); font-weight: 800; }

/* Tableaux défilants : contient les éléments positionnés en absolu (ex. libellés .sr-only des dernières colonnes),
   qui sinon échappent au conteneur et élargissent toute la page. */
.table-wrap { position: relative; }
