/* LEC Back: base styles and components (documented in backend/docs/UI_KIT.md).
   CSP: no inline style attribute anywhere. Every visual variant is a class here. */

/* --- reset ------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; }
img, svg, video, iframe { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul[role="list"], ol[role="list"] { list-style: none; padding: 0; }
[hidden], .is-hidden { display: none !important; }

/* --- page ---------------------------------------------------------------------------- */
body {
  min-height: 100vh;
  font-family: var(--font-ui);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--text);
  background:
    radial-gradient(1100px 560px at 8% -12%, var(--bg-glow-1), transparent 62%),
    radial-gradient(900px 520px at 108% 4%, var(--bg-glow-2), transparent 60%),
    linear-gradient(var(--grid-line) 1px, transparent 1px) 0 0 / 100% 32px,
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }

.skip-link { position: absolute; left: var(--s-3); top: -60px; z-index: 100; padding: var(--s-2) var(--s-3);
  background: var(--accent); color: var(--accent-ink); border-radius: var(--r-sm); text-decoration: none; }
.skip-link:focus { top: var(--s-3); }

.page { width: 100%; max-width: var(--page-max); margin: 0 auto; padding: var(--s-5) var(--s-5) var(--s-8); }
.page-wide { max-width: none; }
.page-full { max-width: none; padding: 0; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s-4);
  margin-bottom: var(--s-5); }
.page-title { font-family: var(--font-title); font-weight: 400; font-size: var(--text-3xl); line-height: 1.05;
  letter-spacing: 0.01em; }
.page-subtitle { color: var(--text-muted); margin-top: var(--s-1); }
.section-title { font-family: var(--font-title); font-weight: 400; font-size: var(--text-xl); margin-bottom: var(--s-3); }
.eyebrow { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-faint);
  font-weight: 600; }

/* --- text utilities ------------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.num { text-align: right; white-space: nowrap; }
.small { font-size: var(--text-sm); }
.xsmall { font-size: var(--text-xs); }
.strong { font-weight: 600; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-danger { color: var(--danger); }
.text-info { color: var(--info); } .text-accent { color: var(--accent); }
.tirage-text { font-family: var(--font-tirage); font-size: 1.15rem; line-height: 1.75; white-space: pre-wrap;
  max-width: 68ch; }
kbd, .kbd { font-family: var(--font-mono); font-size: var(--text-xs); padding: 1px 6px; border-radius: 6px;
  border: 1px solid var(--border-strong); background: var(--surface-2); }
a.link { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

/* --- layout utilities ------------------------------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s-6); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.cluster-lg { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-4); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-width: 0; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: var(--s-4); }
.grid-2 { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); }
.grid-3 { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); }
.grid-4 { display: grid; gap: var(--s-4); grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.span-2 { grid-column: span 2; }
@media (max-width: 720px) { .span-2 { grid-column: auto; } }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--s-4) 0; }

/* --- icons --------------------------------------------------------------------------------- */
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 24px; height: 24px; }

/* --- topbar (desktop) ------------------------------------------------------------------ */
.topbar { position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center;
  gap: var(--s-4); padding: 0 var(--s-4); background: var(--overlay); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px) saturate(140%); -webkit-backdrop-filter: blur(14px) saturate(140%); }
.brand { display: flex; align-items: center; gap: var(--s-2); text-decoration: none; flex: none; }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.brand-name { font-family: var(--font-title); font-size: 1.25rem; white-space: nowrap; }
.brand-tag { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--accent); border: 1px solid var(--border-strong);
  border-radius: var(--r-pill); padding: 0 7px; line-height: 18px; }
.nav { display: flex; align-items: center; gap: 2px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav-link { position: relative; display: inline-flex; align-items: center; gap: 7px; padding: 7px 10px;
  border-radius: var(--r-pill); color: var(--text-muted); text-decoration: none; font-size: var(--text-sm);
  font-weight: 600; white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active { color: var(--text); background: var(--accent-soft); }
.nav-link.is-active .icon { color: var(--accent); }
.nav-badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--accent);
  color: var(--accent-ink); font-size: 11px; line-height: 20px; text-align: center; font-weight: 600; }
.nav-link .dot { position: absolute; top: 5px; right: 5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); flex: none; }
.ext-links { display: flex; align-items: center; gap: 2px; }
.ext-link { font-size: var(--text-xs); color: var(--text-faint); text-decoration: none; padding: 6px 8px;
  border-radius: var(--r-pill); white-space: nowrap; }
.ext-link:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle .icon-light { display: none; }
:root[data-theme="light"] .theme-toggle .icon-light { display: block; }
:root[data-theme="light"] .theme-toggle .icon-dark { display: none; }
@media (max-width: 1480px) { .ext-links { display: none; } }
@media (max-width: 1220px) { .nav-link span:not(.nav-badge) { display: none; } .nav-link { padding: 8px; } .brand-name { display: none; } }
@media (max-width: 899px) { .nav, .topbar-tools { display: none; } .brand-name { display: inline; } }
@media (max-width: 520px) {
  .topbar { gap: var(--s-2); padding: 0 var(--s-3); }
  .brand-name { display: none; }
}

/* --- account / generic dropdown menu (details + summary) ------------------------------------ */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel { position: absolute; right: 0; top: calc(100% + 8px); min-width: 240px; z-index: 60; padding: var(--s-2);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); }
.menu-panel-up { top: auto; bottom: calc(100% + 8px); }
.menu-head { padding: var(--s-2) var(--s-3) var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-2); }
.menu-item { display: flex; align-items: center; gap: var(--s-2); width: 100%; padding: 9px var(--s-3); border: 0;
  border-radius: var(--r-sm); background: none; text-align: left; text-decoration: none; color: var(--text); cursor: pointer;
  font-size: var(--text-sm); }
.menu-item:hover { background: var(--surface-2); }
.menu-sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }
.account-chip { display: inline-flex; align-items: center; gap: var(--s-2); padding: 4px 10px 4px 4px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--surface); font-size: var(--text-sm); font-weight: 600; }
.avatar { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px;
  background: linear-gradient(135deg, var(--lec-rose), var(--lec-pervenche)); color: var(--lec-bordeaux); }
@media (max-width: 599px) { .account-name { display: none; } }

/* --- bottom tab bar (mobile) -------------------------------------------------------------- */
.tabbar { display: none; }
@media (max-width: 899px) {
  body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; z-index: 45; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--overlay); border-top: 1px solid var(--border); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
  .tab-item, .tabbar .menu > summary { position: relative; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; height: var(--tabbar-h); color: var(--text-faint); text-decoration: none;
    font-size: 11px; font-weight: 600; }
  .tab-item.is-active { color: var(--accent); }
  .tab-item .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); height: 18px; min-width: 18px; line-height: 18px; }
  .tab-item .dot { position: absolute; top: 9px; left: calc(50% + 9px); }
  .tabbar .menu-panel { position: fixed; right: var(--s-3); left: var(--s-3); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
    top: auto; max-height: 70vh; overflow-y: auto; }
  .page { padding: var(--s-4) var(--s-4) var(--s-7); }
  .page-title { font-size: 2.1rem; }
}

/* --- cards -------------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow);
  padding: var(--s-5); min-width: 0; }
.card-tight { padding: var(--s-4); }
.card-flush { padding: 0; overflow: hidden; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-title { font-size: var(--text-base); font-weight: 600; display: flex; align-items: center; gap: var(--s-2); }
.card-footer { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.card-accent { border-left: 3px solid var(--accent); }
.card-dashed { border-style: dashed; box-shadow: none; background: transparent; }
.card-interactive { transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease); text-decoration: none; display: block; }
.card-interactive:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.card-vital { border-color: var(--vital); box-shadow: 0 0 0 1px var(--vital), 0 12px 34px color-mix(in srgb, var(--vital) 30%, transparent); }

/* --- stats (KPI tiles) ------------------------------------------------------------------------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-faint); font-weight: 600; }
.stat-value { font-family: var(--font-mono); font-size: 2rem; font-weight: 600; line-height: 1.15; letter-spacing: -0.03em; }
.stat-value-sm { font-size: 1.4rem; }
.stat-delta { font-family: var(--font-mono); font-size: var(--text-xs); }
.stat-delta.up { color: var(--ok); } .stat-delta.down { color: var(--danger); }
.spark { width: 100%; height: 40px; margin-top: var(--s-2); }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round;
  vector-effect: non-scaling-stroke; }
.spark .spark-area { fill: var(--accent-soft); stroke: none; }

/* --- gauge (use <meter> or <progress>: no inline width needed) ------------------------------- */
meter.gauge, progress.gauge { -webkit-appearance: none; appearance: none; width: 100%; height: 10px; border: 0;
  border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; display: block; }
meter.gauge::-webkit-meter-bar { background: var(--surface-3); border: 0; border-radius: var(--r-pill); height: 10px; }
meter.gauge::-webkit-meter-optimum-value { background: var(--ok); border-radius: var(--r-pill); }
meter.gauge::-webkit-meter-suboptimum-value { background: var(--warn); border-radius: var(--r-pill); }
meter.gauge::-webkit-meter-even-less-good-value { background: var(--danger); border-radius: var(--r-pill); }
meter.gauge:-moz-meter-optimum::-moz-meter-bar { background: var(--ok); }
meter.gauge:-moz-meter-sub-optimum::-moz-meter-bar { background: var(--warn); }
meter.gauge:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: var(--danger); }
progress.gauge::-webkit-progress-bar { background: var(--surface-3); border-radius: var(--r-pill); }
progress.gauge::-webkit-progress-value { background: linear-gradient(90deg, var(--lec-rose), var(--lec-pervenche)); border-radius: var(--r-pill); }
progress.gauge::-moz-progress-bar { background: linear-gradient(90deg, var(--lec-rose), var(--lec-pervenche)); border-radius: var(--r-pill); }

/* --- buttons -------------------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); min-height: 38px;
  padding: 0 var(--s-4); border-radius: var(--r-pill); border: 1px solid var(--border-strong); background: var(--surface-2);
  color: var(--text); font-weight: 600; font-size: var(--text-sm); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform 80ms var(--ease); }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn-secondary { background: var(--info-soft); border-color: transparent; color: var(--text); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--text-xs); }
.btn-lg { min-height: 46px; padding: 0 var(--s-5); font-size: var(--text-base); }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }
.btn-block { width: 100%; }
.btn .spinner, .htmx-request.btn .spinner { display: none; }
.btn.is-loading .spinner, .htmx-request.btn .spinner { display: inline-block; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: lec-spin 0.7s linear infinite; }

/* --- badges and dots -------------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: var(--r-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; background: var(--surface-3); color: var(--text-muted); }
.badge-urgent { background: var(--lec-jaune); color: var(--lec-bordeaux); text-transform: uppercase; letter-spacing: 0.08em; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-muted { background: transparent; border: 1px solid var(--border-strong); color: var(--text-faint); }
.badge-shadow { background: transparent; border: 1px dashed var(--info); color: var(--info); }
.badge-live { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="light"] .badge-urgent { background: var(--lec-jaune); color: var(--lec-bordeaux); }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); flex: none; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-error { background: var(--danger); }
.dot-idle { background: var(--text-faint); }
.dot-paused { background: transparent; border: 2px solid var(--text-faint); }
.dot-shadow { background: transparent; border: 2px dashed var(--info); }
.dot-live { background: var(--accent); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent);
  animation: lec-pulse 1.6s var(--ease) infinite; }
.dot-vital { background: var(--vital); animation: lec-pulse-vital 1.1s var(--ease) infinite; }

/* --- chips ------------------------------------------------------------------------------------ */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 var(--s-3); border-radius: var(--r-pill);
  border: 1px solid var(--border-strong); background: transparent; color: var(--text-muted); font-size: var(--text-sm);
  font-weight: 600; cursor: pointer; text-decoration: none; }
.chip:hover { color: var(--text); background: var(--surface-2); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .count { font-family: var(--font-mono); font-size: 11px; opacity: 0.8; }

/* --- tabs --------------------------------------------------------------------------------------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none;
  margin-bottom: var(--s-4); }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px var(--s-3); border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--text-muted); font-weight: 600; font-size: var(--text-sm); text-decoration: none; cursor: pointer;
  white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.is-active, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab .count { font-family: var(--font-mono); font-size: 11px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-3); }

/* --- tables ------------------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table th { text-align: left; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint);
  font-weight: 600; padding: 10px var(--s-3); border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px var(--s-3); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .actions { text-align: right; white-space: nowrap; }
.table tr.is-urgent td:first-child { box-shadow: inset 3px 0 0 var(--lec-jaune); }
@media (max-width: 720px) {
  .table-stack thead { display: none; }
  .table-stack tr { display: block; padding: var(--s-3); border-bottom: 1px solid var(--border); }
  .table-stack td { display: flex; justify-content: space-between; gap: var(--s-3); padding: 4px 0; border: 0; }
  .table-stack td[data-label]::before { content: attr(data-label); color: var(--text-faint); font-size: var(--text-xs); }
  .table-stack .actions { justify-content: flex-end; padding-top: var(--s-2); }
}

/* --- forms -------------------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: var(--text-sm); font-weight: 600; }
.help { font-size: var(--text-xs); color: var(--text-faint); }
.field-error { font-size: var(--text-xs); color: var(--danger); }
.input, .select, .textarea { width: 100%; min-height: 40px; padding: 8px var(--s-3); border-radius: var(--r-sm);
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); transition: border-color var(--dur) var(--ease); }
.input::placeholder, .textarea::placeholder { color: var(--text-faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.textarea.mono { font-size: var(--text-sm); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.input-search { padding-left: 38px; background-image: none; }
.search-wrap { position: relative; }
.search-wrap .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.checkbox { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); cursor: pointer; }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }
.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-2); cursor: pointer; font-size: var(--text-sm); }
.switch input { appearance: none; -webkit-appearance: none; width: 40px; height: 22px; border-radius: var(--r-pill);
  background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background var(--dur); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-muted); transition: transform var(--dur) var(--ease), background var(--dur); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(18px); background: var(--accent-ink); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
fieldset { border: 1px solid var(--border); border-radius: var(--r); padding: var(--s-4); margin: 0; }
legend { padding: 0 var(--s-2); font-weight: 600; font-size: var(--text-sm); }

/* --- alerts (banners) -------------------------------------------------------------------------- */
.alert { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-4); border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface-2); }
.alert .icon { margin-top: 2px; }
.alert-title { font-weight: 600; }
.alert-info { background: var(--info-soft); border-color: transparent; }
.alert-info .icon { color: var(--info); }
.alert-warning { background: var(--warn-soft); border-color: transparent; }
.alert-warning .icon { color: var(--warn); }
.alert-critical { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.alert-critical .icon { color: var(--danger); }
.alert-vital { background: color-mix(in srgb, var(--vital) 18%, var(--surface)); border-color: var(--vital); }
.alert-vital .icon { color: var(--vital); }

/* --- empty state, skeletons --------------------------------------------------------------------- */
.empty { text-align: center; padding: var(--s-7) var(--s-4); color: var(--text-muted); }
.empty-title { font-family: var(--font-title); font-size: var(--text-xl); color: var(--text); margin-bottom: var(--s-2); }
.empty .icon { width: 36px; height: 36px; margin: 0 auto var(--s-3); color: var(--accent); }
.empty .cluster { justify-content: center; margin-top: var(--s-3); }
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--r-sm); }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--text) 7%, transparent), transparent);
  animation: lec-shimmer 1.4s infinite; }
.skeleton-line { height: 12px; margin: 8px 0; }
.skeleton-line.short { width: 40%; } .skeleton-line.medium { width: 70%; }
.skeleton-block { height: 96px; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }

/* --- toasts -------------------------------------------------------------------------------------- */
.toasts { position: fixed; z-index: 90; right: var(--s-4); bottom: var(--s-4); display: flex; flex-direction: column;
  gap: var(--s-2); width: min(380px, calc(100vw - 2 * var(--s-4))); pointer-events: none; }
@media (max-width: 899px) { .toasts { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--s-3)); } }
.toast { position: relative; overflow: hidden; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-pop);
  pointer-events: auto; animation: lec-toast-in 220ms var(--ease); font-size: var(--text-sm); }
.toast.is-leaving { animation: lec-toast-out 180ms var(--ease) forwards; }
.toast-message { flex: 1 1 auto; }
.toast-ok { border-left: 3px solid var(--ok); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--info); }
.toast-warn { border-left: 3px solid var(--warn); }
.toast-action { flex: none; }
.toast-progress { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent);
  transform-origin: left center; }
.toast-progress.is-running { animation-name: lec-countdown; animation-timing-function: linear; animation-fill-mode: forwards; }
.toast-progress.d-3 { animation-duration: 3s; } .toast-progress.d-5 { animation-duration: 5s; }
.toast-progress.d-8 { animation-duration: 8s; } .toast-progress.d-10 { animation-duration: 10s; }

/* --- audio player, iframes ----------------------------------------------------------------------- */
audio.player { width: 100%; max-width: 420px; height: 38px; }
.frame-page { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); }
@media (max-width: 899px) { .frame-page { height: calc(100vh - var(--topbar-h) - var(--tabbar-h)); } }
.frame-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-2) var(--s-4); border-bottom: 1px solid var(--border); background: var(--surface); }
.frame { flex: 1 1 auto; width: 100%; border: 0; background: var(--surface); }

/* --- login --------------------------------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s-5); }
.login-card { width: min(420px, 100%); text-align: center; }
.login-logo { margin: 0 auto var(--s-5); width: 220px; height: auto; background: var(--lec-creme); border-radius: var(--r);
  padding: var(--s-3) var(--s-4); }

/* --- HTMX (indicator styles are disabled in htmx-config for the CSP) ------------------------------ */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.htmx-swapping { opacity: 0.4; transition: opacity 120ms ease-out; }
.htmx-added { animation: lec-fade-in 240ms var(--ease); }

/* --- styleguide helpers ---------------------------------------------------------------------------- */
.sg-section { scroll-margin-top: calc(var(--topbar-h) + var(--s-4)); }
.sg-swatch { height: 64px; border-radius: var(--r); border: 1px solid var(--border); }
.sg-bordeaux { background: var(--lec-bordeaux); } .sg-rose { background: var(--lec-rose); } .sg-creme { background: var(--lec-creme); }
.sg-pervenche { background: var(--lec-pervenche); } .sg-jaune { background: var(--lec-jaune); } .sg-menthe { background: var(--lec-menthe); }
.sg-log { max-height: 180px; overflow-y: auto; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--text-muted); }

/* --- animations -------------------------------------------------------------------------------- */
@keyframes lec-spin { to { transform: rotate(360deg); } }
@keyframes lec-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes lec-pulse-vital {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--vital) 70%, transparent); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes lec-shimmer { to { transform: translateX(100%); } }
@keyframes lec-toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes lec-toast-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes lec-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes lec-fade-in { from { opacity: 0; } to { opacity: 1; } }

@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; }
  .dot-live, .dot-vital { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
}
