/* =====================================================================
   Interface du bot — principes de design d'Emil Kowalski (skill emil-design-eng) :
   - n'animer que ce qui est rare et utile (le tableau se rafraîchit toutes les 15 s : les
     chiffres ne bougent pas) ; courbes personnalisées ; < 300 ms ; jamais depuis scale(0)
   - boutons qui répondent à la pression (scale 0.97) ; survol réservé aux souris
   - uniquement transform / opacity animés ; mouvement réduit respecté
   ===================================================================== */

:root {
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f4f4f5;
  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --grid: rgba(0, 0, 0, 0.06);
  --ink: #0a0a0a;
  --ink-2: #52525b;
  --ink-3: #8a8a93;
  --inverse: #ffffff;

  --series: #2a78d6;
  --series-fill: rgba(42, 120, 214, 0.1);
  --good: #0a7d0a;
  --good-bg: rgba(10, 125, 10, 0.08);
  --critical: #c42f2f;
  --critical-bg: rgba(196, 47, 47, 0.07);
  --warning: #9a6700;
  --warning-bg: rgba(237, 161, 0, 0.1);
  --focus: #2a78d6;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 1px rgba(0, 0, 0, 0.02);
  --shadow-pop: 0 12px 32px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

/* Sombre : réglage du système (sauf choix « clair » explicite) ou choix « sombre » explicite */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0a;
    --surface: #141414;
    --surface-2: #1c1c1e;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --grid: rgba(255, 255, 255, 0.07);
    --ink: #ededed;
    --ink-2: #a1a1aa;
    --ink-3: #71717a;
    --inverse: #0a0a0a;
    --series: #3987e5;
    --series-fill: rgba(57, 135, 229, 0.14);
    --good: #3cc23c;
    --good-bg: rgba(60, 194, 60, 0.1);
    --critical: #ef6b6b;
    --critical-bg: rgba(239, 107, 107, 0.1);
    --warning: #e5b53b;
    --warning-bg: rgba(229, 181, 59, 0.1);
    --focus: #3987e5;
    --shadow: none;
    --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1c1c1e;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --grid: rgba(255, 255, 255, 0.07);
  --ink: #ededed;
  --ink-2: #a1a1aa;
  --ink-3: #71717a;
  --inverse: #0a0a0a;
  --series: #3987e5;
  --series-fill: rgba(57, 135, 229, 0.14);
  --good: #3cc23c;
  --good-bg: rgba(60, 194, 60, 0.1);
  --critical: #ef6b6b;
  --critical-bg: rgba(239, 107, 107, 0.1);
  --warning: #e5b53b;
  --warning-bg: rgba(229, 181, 59, 0.1);
  --focus: #3987e5;
  --shadow: none;
  --shadow-pop: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.06);
  color-scheme: dark;
}

/* Changement de thème : fondu court (repli si les View Transitions ne sont pas disponibles) */
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 240ms; animation-timing-function: ease; }
.theme-fading *,
.theme-fading *::before,
.theme-fading *::after {
  transition: background-color 240ms ease, color 240ms ease, border-color 240ms ease,
              fill 240ms ease, stroke 240ms ease !important;
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--series); text-underline-offset: 3px; }
h1 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 14px; margin: 0 0 14px; color: var(--ink-2); font-weight: 600; letter-spacing: -0.005em; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

/* ---------------------------------------------------------------- barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 650; letter-spacing: -0.01em; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.badge {
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
  padding: 2px 8px; border-radius: 99px;
  color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--border);
}
.badge-live { color: var(--critical); background: var(--critical-bg); border-color: transparent; }
.alive { font-size: 13px; color: var(--ink-2); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.alive::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); }
.alive.ok::before { background: var(--good); box-shadow: 0 0 0 3px var(--good-bg); }
.alive.ko { color: var(--critical); font-weight: 600; }
.alive.ko::before { background: var(--critical); box-shadow: 0 0 0 3px var(--critical-bg); }
@media (max-width: 520px) { .alive { display: none; } }

/* ---------------------------------------------------------------- bouton de thème */
.theme-toggle {
  position: relative; width: 40px; height: 40px; padding: 0;
  display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  cursor: pointer; touch-action: manipulation;
  transition: transform 160ms var(--ease-out);
}
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle svg {
  grid-area: 1 / 1; width: 18px; height: 18px;
  transition: transform 220ms var(--ease-out), opacity 220ms var(--ease-out), filter 220ms var(--ease-out);
}
.icon-moon { opacity: 0; transform: rotate(-60deg) scale(0.6); filter: blur(2px); }
.theme-toggle[aria-pressed="true"] .icon-sun { opacity: 0; transform: rotate(60deg) scale(0.6); filter: blur(2px); }
.theme-toggle[aria-pressed="true"] .icon-moon { opacity: 1; transform: none; filter: none; }

/* ---------------------------------------------------------------- mise en page */
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; display: grid; gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; min-width: 0; box-shadow: var(--shadow);
}

/* Apparition au 1er chargement seulement (jamais au rafraîchissement) : cascade courte */
.stagger > * { animation: rise 320ms var(--ease-out) both; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(n+6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

/* ---------------------------------------------------------------- chiffres clés */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; min-width: 0; box-shadow: var(--shadow);
}
.kpi-label { font-size: 12.5px; color: var(--ink-2); }
.kpi-value {
  font-size: clamp(20px, 2.6vw, 28px); font-weight: 650; letter-spacing: -0.025em;
  margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.pos { color: var(--good); }
.neg { color: var(--critical); }

/* ---------------------------------------------------------------- alertes & propositions */
.alert { border-radius: var(--radius); padding: 14px 16px; border: 1px solid transparent; }
.alert-critical { background: var(--critical-bg); border-color: color-mix(in srgb, var(--critical) 35%, transparent); }
.cb { display: flex; gap: 14px; justify-content: space-between; align-items: center; flex-wrap: wrap; }
.cb strong { color: var(--critical); letter-spacing: 0.01em; }
.proposals { display: grid; gap: 10px; }
.proposal {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--warning);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  display: flex; gap: 14px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}
.proposal.sell { border-left-color: var(--critical); }
.proposal .title { font-weight: 650; letter-spacing: -0.01em; }

/* ---------------------------------------------------------------- boutons */
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  position: relative; overflow: hidden;
  appearance: none; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink);
  border-radius: var(--radius-sm); padding: 0 16px; min-height: 44px;
  font: inherit; font-weight: 600; letter-spacing: -0.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  cursor: pointer; text-decoration: none; user-select: none; touch-action: manipulation;
  transition: transform 160ms var(--ease-out);
}
.btn:active { transform: scale(0.97); }
.btn:disabled { cursor: default; }
.btn-primary { background: var(--ink); color: var(--inverse); border-color: var(--ink); }
.btn-danger { background: var(--critical); color: #fff; border-color: var(--critical); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-block { width: 100%; margin-top: 18px; }
@media (hover: hover) and (pointer: fine) {
  .btn { transition: transform 160ms var(--ease-out), background-color 150ms ease, border-color 150ms ease; }
  .btn:hover { border-color: var(--ink-3); }
  .btn-primary:hover, .btn-danger:hover { filter: brightness(1.08); border-color: transparent; }
  .theme-toggle:hover { border-color: var(--ink-3); }
  tbody tr:hover td { background: var(--surface-2); }
}

/* État « envoi en cours » : le libellé se fond dans un flou (masque la transition), un indicateur tourne vite */
.btn .btn-label { transition: filter 200ms ease, opacity 200ms ease; }
.btn[data-loading] .btn-label { filter: blur(2px); opacity: 0.35; }
.btn .spinner {
  position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  opacity: 0; transform: scale(0.8);
  transition: opacity 200ms ease, transform 200ms var(--ease-out);
}
.btn[data-loading] .spinner { opacity: 1; transform: scale(1); animation: spin 600ms linear infinite; }
@keyframes spin { to { rotate: 360deg; } }

/* Maintenir pour confirmer (motif « hold to delete ») : lent quand on décide, rapide quand on relâche */
.btn-hold .hold-fill {
  position: absolute; inset: 0; display: inline-flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, #000 22%, var(--critical)); color: #fff;
  clip-path: inset(0 100% 0 0);
  transition: clip-path 200ms var(--ease-out);
}
.btn-hold.holding .hold-fill { clip-path: inset(0 0 0 0); transition: clip-path 2s linear; }

/* ---------------------------------------------------------------- tableaux */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { font-size: 12px; color: var(--ink-3); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
td.wrap-cell { white-space: normal; min-width: 180px; color: var(--ink-2); }
.empty { color: var(--ink-3); padding: 14px 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12.5px; font-weight: 600; }
.pill.pos { background: var(--good-bg); }
.pill.neg { background: var(--critical-bg); }
@media (max-width: 900px) {
  th, td { padding: 9px 6px; }
  table { font-size: 13px; }
  .hide-sm { display: none; }   /* quantité et prix d'entrée : détail secondaire en portrait */
}

/* ---------------------------------------------------------------- graphique */
.chart { position: relative; height: 240px; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-3); font-size: 11px; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series-fill); }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.tip {
  position: absolute; pointer-events: none; white-space: nowrap;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; box-shadow: var(--shadow-pop);
}
.chart-empty { color: var(--ink-3); display: grid; place-items: center; position: absolute; inset: 0; text-align: center; padding: 0 16px; }

/* ---------------------------------------------------------------- blocs divers */
.params { display: grid; gap: 8px; }
.param { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--grid); padding-bottom: 8px; }
.list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.list li { padding: 8px 0; border-bottom: 1px solid var(--grid); color: var(--ink-2); }
.list li:last-child { border-bottom: 0; }
.share { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.share-track { width: 100px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; flex: 0 0 auto; }
.share-bar { height: 100%; border-radius: 3px; background: var(--series); }
.share-bar.over { background: var(--critical); }
.share span { font-size: 13px; color: var(--ink-2); }
.senti { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.senti-item { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 2px; background: var(--surface-2); }
.senti-asset { font-size: 12px; color: var(--ink-2); }
.score { display: inline-block; min-width: 46px; font-weight: 650; font-size: 13px; }
#news a { color: var(--ink); text-decoration: none; }
@media (hover: hover) and (pointer: fine) { #news a:hover { text-decoration: underline; } }

/* ---------------------------------------------------------------- toast (esprit Sonner) */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20;
  max-width: min(460px, calc(100% - 32px)); white-space: pre-line;
  background: var(--ink); color: var(--inverse);
  padding: 12px 16px; border-radius: 12px; box-shadow: var(--shadow-pop); font-size: 14px;
  opacity: 0; transform: translate(-50%, 100%); pointer-events: none;
  transition: opacity 200ms ease, transform 200ms var(--ease-out);   /* sortie : rapide */
}
.toast[data-open] {
  opacity: 1; transform: translate(-50%, 0); pointer-events: auto;
  transition: opacity 400ms ease, transform 400ms ease;             /* entrée : plus douce */
}
.toast .toast-text { transition: filter 180ms ease, opacity 180ms ease; }
.toast[data-swap] .toast-text { filter: blur(2px); opacity: 0.4; }

/* ---------------------------------------------------------------- fenêtre de confirmation */
dialog.dialog {
  border: 1px solid var(--border); border-radius: 16px; padding: 22px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
  width: min(420px, calc(100% - 32px));
  opacity: 0; transform: scale(0.96);
  transition: opacity 150ms ease, transform 150ms var(--ease-out),
              overlay 150ms allow-discrete, display 150ms allow-discrete;   /* fermeture rapide */
}
dialog.dialog[open] {
  opacity: 1; transform: none;
  transition: opacity 200ms ease, transform 220ms var(--ease-out),
              overlay 220ms allow-discrete, display 220ms allow-discrete;
}
@starting-style { dialog.dialog[open] { opacity: 0; transform: scale(0.96); } }
dialog.dialog::backdrop {
  background: rgba(0, 0, 0, 0); -webkit-backdrop-filter: blur(0); backdrop-filter: blur(0);
  transition: background-color 200ms ease, overlay 200ms allow-discrete, display 200ms allow-discrete;
}
dialog.dialog[open]::backdrop { background: rgba(0, 0, 0, 0.45); }
@starting-style { dialog.dialog[open]::backdrop { background: rgba(0, 0, 0, 0); } }
.dialog h2 { font-size: 17px; color: var(--ink); margin: 0 0 6px; }
.dialog p { margin: 0 0 18px; }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------------------------------------------------------------- connexion */
.login-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 16px; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
  padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow-pop);
  animation: rise 360ms var(--ease-out) both;
}
.login-card label { display: block; font-size: 13px; color: var(--ink-2); margin-top: 12px; }
.login-card input {
  width: 100%; padding: 0 12px; min-height: 46px; font: inherit; margin-top: 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--ink);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.login-card input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.login-top { position: fixed; top: 12px; right: 12px; }

/* ---------------------------------------------------------------- mouvement réduit : fondus seulement */
@media (prefers-reduced-motion: reduce) {
  .stagger > *, .login-card { animation: fade 200ms ease both; }
  @keyframes fade { from { opacity: 0; } }
  .btn, .theme-toggle, .theme-toggle svg, .btn .spinner { transition-property: opacity, filter; }
  .btn:active, .theme-toggle:active { transform: none; }
  .toast, .toast[data-open] { transform: translate(-50%, 0); }
  dialog.dialog, dialog.dialog[open] { transform: none; }
  .btn[data-loading] .spinner { animation-duration: 1.2s; }
}

/* ---------------------------------------------------------------- onglets (bloc 18) */
.tabs {
  max-width: 1100px; margin: 0 auto; padding: 12px 16px 0; display: flex; gap: 4px;
  position: relative;
}
.tab {
  appearance: none; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink-2);
  background: transparent; border: 1px solid transparent; border-radius: 99px;
  padding: 0 16px; min-height: 40px; cursor: pointer;
  transition: color 150ms ease, background-color 150ms ease, transform 160ms var(--ease-out);
}
.tab[aria-selected="true"] { color: var(--ink); background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.tab:active { transform: scale(0.97); }
.tab:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .tab:hover { color: var(--ink); } }
.tabpanel { display: grid; gap: 14px; }

/* ---------------------------------------------------------------- objectifs */
.goal-form { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.goal-form label { font-size: 13px; color: var(--ink-2); display: grid; gap: 6px; }
.goal-form input, .chat-form textarea {
  width: 100%; padding: 0 12px; min-height: 44px; font: inherit; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--bg);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.goal-form input:focus, .chat-form textarea:focus {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
.goal-form input[aria-invalid="true"] { border-color: var(--critical); }
.goal-form-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.goal-base { margin: 12px 0 0; }
@media (max-width: 760px) { .goal-form { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .goal-form { grid-template-columns: 1fr; } }

.goal-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 14px; }
.goal-list:empty { display: none; }
.goal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: grid; gap: 12px; align-content: start; min-width: 0;
}
.goal-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px 10px; flex-wrap: wrap; }
.goal-title { font-weight: 650; letter-spacing: -0.01em; }
.goal-sub { font-size: 13px; color: var(--ink-2); }
.verdict { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 99px;
  font-size: 12.5px; font-weight: 650; background: var(--surface-2); color: var(--ink-2); max-width: 100%; }
.verdict.v-good { background: var(--good-bg); color: var(--good); }
.verdict.v-mid { background: var(--warning-bg); color: var(--warning); }
.verdict.v-bad { background: var(--critical-bg); color: var(--critical); }
.goal-stats { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.goal-stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.goal-stat .kpi-value { font-size: 20px; white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.25; }
.meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.meter > div { height: 100%; border-radius: 4px; background: var(--series); transform-origin: left; }
.meter-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.goal-text { font-size: 13.5px; color: var(--ink-2); white-space: pre-line; margin: 0; }
.goal-actions { display: flex; justify-content: flex-end; }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; }

/* ---------------------------------------------------------------- conversation */
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; }
.chat-head h2 { margin: 0; }
.chat-log { display: grid; gap: 10px; max-height: 460px; overflow-y: auto; padding: 2px; margin-bottom: 12px;
  overscroll-behavior: contain; }
.chat-log:empty { display: none; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 14.5px; white-space: pre-line;
  overflow-wrap: anywhere; }
.msg-user { justify-self: end; background: var(--ink); color: var(--inverse); border-bottom-right-radius: 6px; }
.msg-bot { justify-self: start; background: var(--surface-2); color: var(--ink); border-bottom-left-radius: 6px; }
.msg-meta { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }
.msg-pending { color: var(--ink-3); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.chip { appearance: none; font: inherit; font-size: 13px; color: var(--ink); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 99px; padding: 0 12px; min-height: 36px; cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 150ms ease; }
.chip:active { transform: scale(0.97); }
@media (hover: hover) and (pointer: fine) { .chip:hover { border-color: var(--ink-3); } }
.chat-form { display: flex; gap: 8px; align-items: flex-end; }
.chat-form textarea { padding: 10px 12px; resize: none; min-height: 48px; max-height: 160px; line-height: 1.4; }
.chat-form .btn { min-height: 48px; flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  .tab, .chip { transition-property: color, background-color, border-color; }
  .tab:active, .chip:active { transform: none; }
}

/* =====================================================================
   APPARENCE PERSONNALISABLE (bloc 19)
   Couleur d'accent choisie par l'utilisateur -> --accent (brute), --accent-text (texte lisible
   4,5:1), --accent-line (traits 3:1), --accent-ink (texte posé sur l'accent). Calculées par theme.js.
   Trois styles : sobre (défaut), tech, terminal. Chacun existe en clair et en sombre.
   ===================================================================== */
:root[data-style] {
  --series: var(--accent-line, #2a78d6);
  --series-fill: color-mix(in srgb, var(--accent, #2a78d6) 12%, transparent);
  --focus: var(--accent-text, #2a78d6);
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-num: var(--font-ui);
}
a { color: var(--accent-text, var(--series)); }
.btn-primary { background: var(--accent-btn, var(--ink)); color: var(--accent-ink, var(--inverse)); border-color: var(--accent-btn, var(--ink)); }
.tab[aria-selected="true"] { box-shadow: var(--shadow), inset 0 -2px 0 var(--accent-line, transparent); }
.msg-user { background: var(--accent-btn, var(--ink)); color: var(--accent-ink, var(--inverse)); }
.chip:focus-visible, .tab:focus-visible { outline-color: var(--focus); }
.kpi-value, td.num, .goal-stat .kpi-value { font-family: var(--font-num); }

/* ---------------------------------------------------------------- style TECH
   Grille de points discrète, halo de la couleur d'accent en haut de page, cartes translucides,
   chiffres à chasse fixe, titres en petites capitales, bouton principal lumineux. */
:root[data-style="tech"] {
  --bg: #f5f6fa; --surface: #ffffff; --surface-2: #eef0f6;
  --border: rgba(20, 30, 60, 0.09); --border-strong: rgba(20, 30, 60, 0.16);
  --ink: #0b1020; --ink-2: #4b5268; --ink-3: #868ca0;
  --radius: 16px; --radius-sm: 11px;
  --font-num: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --glass: color-mix(in srgb, var(--surface) 82%, transparent);
  --shadow: 0 1px 2px rgba(20, 30, 60, 0.05), 0 8px 24px -12px rgba(20, 30, 60, 0.12);
}
:root[data-style="tech"][data-theme="dark"] {
  --bg: #070a12; --surface: #0e1422; --surface-2: #151c2d;
  --border: rgba(160, 180, 255, 0.09); --border-strong: rgba(160, 180, 255, 0.18);
  --ink: #e6eaf5; --ink-2: #9aa3bd; --ink-3: #69718a; --inverse: #070a12;
  --shadow: none; --glass: color-mix(in srgb, var(--surface) 70%, transparent);
}
@media (prefers-color-scheme: dark) {
  :root[data-style="tech"]:not([data-theme="light"]) {
    --bg: #070a12; --surface: #0e1422; --surface-2: #151c2d;
    --border: rgba(160, 180, 255, 0.09); --border-strong: rgba(160, 180, 255, 0.18);
    --ink: #e6eaf5; --ink-2: #9aa3bd; --ink-3: #69718a; --inverse: #070a12;
    --shadow: none; --glass: color-mix(in srgb, var(--surface) 70%, transparent);
  }
}
[data-style="tech"] body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 70% 40% at 50% -8%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 70%),
    radial-gradient(color-mix(in srgb, var(--ink) 10%, transparent) 1px, transparent 1.2px);
  background-size: 100% 100%, 22px 22px;
  background-attachment: fixed;
}
[data-style="tech"] .card, [data-style="tech"] .kpi, [data-style="tech"] .goal, [data-style="tech"] .proposal {
  background: var(--glass);
  border-color: color-mix(in srgb, var(--accent) 14%, var(--border));
}
[data-style="tech"] .kpi { position: relative; overflow: hidden; }
[data-style="tech"] .kpi::before {        /* fil lumineux en haut de chaque chiffre clé */
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 70%, transparent), transparent);
}
[data-style="tech"] h2, [data-style="tech"] .kpi-label, [data-style="tech"] .goal-stat .kpi-label {
  text-transform: uppercase; letter-spacing: 0.09em; font-size: 11px; font-weight: 650;
}
[data-style="tech"] h2 { color: var(--accent-text); }
[data-style="tech"] .kpi-value { letter-spacing: -0.02em; }
[data-style="tech"] .badge { font-family: var(--font-num); letter-spacing: 0.06em; }
[data-style="tech"] .btn-primary {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, transparent),
              0 8px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent);
}
[data-style="tech"] .tab[aria-selected="true"] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}
[data-style="tech"] .chart .line { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent)); }
[data-style="tech"] .meter > div, [data-style="tech"] .share-bar {
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent-line) 70%, transparent), var(--accent-line));
}

/* ---------------------------------------------------------------- style TERMINAL
   Tout en chasse fixe, angles vifs, titres « > », lignes de balayage à peine visibles en sombre. */
:root[data-style="terminal"] {
  --bg: #f3f1ea; --surface: #fbfaf6; --surface-2: #ece9df;
  --border: rgba(30, 35, 30, 0.14); --border-strong: rgba(30, 35, 30, 0.26);
  --grid: rgba(30, 35, 30, 0.09);
  --ink: #1b211d; --ink-2: #4f5a52; --ink-3: #7f8a82;
  --radius: 4px; --radius-sm: 3px; --shadow: none;
  --font-ui: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --font-num: var(--font-ui);
}
:root[data-style="terminal"][data-theme="dark"] {
  --bg: #05070a; --surface: #0b0f14; --surface-2: #111820;
  --border: rgba(180, 255, 210, 0.1); --border-strong: rgba(180, 255, 210, 0.2);
  --grid: rgba(180, 255, 210, 0.07);
  --ink: #d5e6dc; --ink-2: #93a89b; --ink-3: #647569; --inverse: #05070a;
  --shadow-pop: 0 0 0 1px rgba(180, 255, 210, 0.14), 0 20px 50px rgba(0, 0, 0, 0.7);
}
@media (prefers-color-scheme: dark) {
  :root[data-style="terminal"]:not([data-theme="light"]) {
    --bg: #05070a; --surface: #0b0f14; --surface-2: #111820;
    --border: rgba(180, 255, 210, 0.1); --border-strong: rgba(180, 255, 210, 0.2);
    --grid: rgba(180, 255, 210, 0.07);
    --ink: #d5e6dc; --ink-2: #93a89b; --ink-3: #647569; --inverse: #05070a;
    --shadow-pop: 0 0 0 1px rgba(180, 255, 210, 0.14), 0 20px 50px rgba(0, 0, 0, 0.7);
  }
}
[data-style="terminal"] body { font-family: var(--font-ui); font-size: 14px; }
[data-style="terminal"] h2 { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; color: var(--accent-text); }
[data-style="terminal"] h2::before { content: "> "; }
[data-style="terminal"] .btn, [data-style="terminal"] .tab, [data-style="terminal"] .chip {
  text-transform: uppercase; letter-spacing: 0.06em; font-size: 12.5px;
}
[data-style="terminal"] .card, [data-style="terminal"] .kpi, [data-style="terminal"] .goal, [data-style="terminal"] .proposal {
  border-color: color-mix(in srgb, var(--accent) 22%, var(--border));
}
[data-style="terminal"] .kpi-value { letter-spacing: -0.01em; }
[data-style="terminal"] .kpi-value::after { content: "_"; color: var(--accent-text); opacity: 0.8; margin-left: 2px; }
[data-style="terminal"] .goal-stat .kpi-value::after { content: none; }
[data-style="terminal"] .pill, [data-style="terminal"] .badge, [data-style="terminal"] .verdict,
[data-style="terminal"] .tab, [data-style="terminal"] .chip, [data-style="terminal"] .msg { border-radius: 3px; }
[data-style="terminal"][data-theme="dark"] body::after,
:root[data-style="terminal"]:not([data-theme="light"]) body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 50;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.18) 0 1px, transparent 1px 3px);
  opacity: 0.22;
}
@media (prefers-color-scheme: light) {
  :root[data-style="terminal"]:not([data-theme="dark"]) body::after { content: none; }
}

/* ---------------------------------------------------------------- fenêtre « Apparence » */
.icon-btn {
  width: 40px; height: 40px; padding: 0; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  cursor: pointer; touch-action: manipulation; transition: transform 160ms var(--ease-out);
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) { .icon-btn:hover { border-color: var(--ink-3); } }
dialog.prefs { width: min(560px, calc(100vw - 24px)); }
.prefs h3 { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 18px 0 8px; }
.prefs h3:first-of-type { margin-top: 4px; }
.style-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.style-opt {
  appearance: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface);
  padding: 8px; display: grid; gap: 6px; transition: transform 160ms var(--ease-out), border-color 150ms ease;
}
.style-opt:active { transform: scale(0.97); }
.style-opt[aria-checked="true"] { border-color: var(--accent-line); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.style-opt .name { font-weight: 650; font-size: 13.5px; }
.style-opt .desc { font-size: 12px; color: var(--ink-2); line-height: 1.35; }
.style-thumb { height: 54px; border-radius: 6px; position: relative; overflow: hidden; border: 1px solid var(--border); }
.style-thumb::before, .style-thumb::after { content: ""; position: absolute; }
.thumb-sobre { background: #f4f4f5; }
.thumb-sobre::before { inset: 10px 10px auto 10px; height: 18px; background: #fff; border-radius: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.thumb-sobre::after { left: 10px; bottom: 9px; width: 40%; height: 8px; border-radius: 4px; background: var(--accent); }
.thumb-tech {
  background-color: #070a12;
  background-image: radial-gradient(ellipse 80% 70% at 50% 0, color-mix(in srgb, var(--accent) 45%, transparent), transparent 70%),
                    radial-gradient(rgba(255,255,255,.18) 1px, transparent 1.2px);
  background-size: 100% 100%, 8px 8px;
}
.thumb-tech::before { inset: 10px 10px auto 10px; height: 18px; border-radius: 6px; background: rgba(20,28,45,.75); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.thumb-tech::after { left: 10px; bottom: 9px; width: 40%; height: 8px; border-radius: 4px; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.thumb-terminal { background: repeating-linear-gradient(0deg, #05070a 0 2px, #0a0e12 2px 3px); }
.thumb-terminal::before { content: "> _"; left: 10px; top: 8px; font: 700 13px ui-monospace, Menlo, monospace; color: var(--accent); }
.thumb-terminal::after { left: 10px; right: 10px; bottom: 10px; height: 1px; border-top: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--surface); cursor: pointer; padding: 0;
  box-shadow: 0 0 0 1px var(--border-strong); transition: transform 160ms var(--ease-out), box-shadow 150ms ease;
}
.swatch:active { transform: scale(0.92); }
.swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--ink); }
.swatch-custom { position: relative; overflow: hidden;
  background: conic-gradient(#f43f5e, #f97316, #eab308, #22c55e, #06b6d4, #6366f1, #d946ef, #f43f5e); }
.swatch-custom input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 3px; gap: 3px; background: var(--surface-2); }
.segmented button { appearance: none; font: inherit; font-size: 13.5px; font-weight: 600; color: var(--ink-2); background: transparent; border: 0;
  border-radius: calc(var(--radius-sm) - 3px); min-height: 36px; padding: 0 14px; cursor: pointer; transition: transform 160ms var(--ease-out); }
.segmented button:active { transform: scale(0.96); }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.prefs-note { min-height: 1.4em; margin: 8px 0 0; }
.prefs-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 20px; flex-wrap: wrap; }
@media (max-width: 480px) { .style-options { grid-template-columns: 1fr; } .style-opt { grid-template-columns: 90px 1fr; align-items: center; } .style-thumb { grid-row: span 2; } }
@media (prefers-reduced-motion: reduce) {
  .style-opt:active, .swatch:active, .segmented button:active, .icon-btn:active { transform: none; }
}
/* barre du haut sur téléphone : 4 éléments tiennent sur une ligne */
.brand { white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { gap: 6px; padding: 10px 12px; }
  .topbar .btn-ghost { padding: 0 10px; font-size: 13px; }
  .topbar .badge { display: none; }
}
/* chiffres à chasse fixe (plus larges) : taille adaptée pour ne jamais tronquer le capital */
[data-style="tech"] .kpi-value, [data-style="terminal"] .kpi-value { font-size: clamp(16px, 2.3vw, 26px); letter-spacing: -0.03em; }

/* =====================================================================
   BLOC 20 — appli installable, mini-courbes, bougies, carte de chaleur, écran de veille
   ===================================================================== */
.topbar { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* mini-courbes sous les chiffres clés : tracé seul, sans axes (la tendance d'un coup d'œil) */
.spark { display: block; width: 100%; height: 30px; margin-top: 8px; overflow: visible; }
.spark path.l { fill: none; stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark path.a { stroke: none; opacity: 0.12; }
.spark .s-accent { stroke: var(--series); fill: var(--series); }
.spark .s-good { stroke: var(--good); fill: var(--good); }
.spark .s-bad { stroke: var(--critical); fill: var(--critical); }
.spark circle { stroke: var(--surface); stroke-width: 2; }

/* en-tête de carte avec outils */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.card-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.card-tools .segmented button { min-height: 32px; padding: 0 12px; font-size: 13px; }

/* bougies */
.chart-candles { height: 320px; }
@media (max-width: 520px) { .chart-candles { height: 260px; } }
.chart-candles .c-up { fill: var(--good); stroke: var(--good); }
.chart-candles .c-down { fill: var(--critical); stroke: var(--critical); }
.chart-candles .wick { stroke-width: 1; }
.chart-candles .sma-f { fill: none; stroke: var(--series); stroke-width: 1.6; }
.chart-candles .sma-s { fill: none; stroke: var(--ink-3); stroke-width: 1.4; stroke-dasharray: 4 3; }
.chart-candles .lvl { stroke-width: 1.2; stroke-dasharray: 6 4; }
.chart-candles .lvl-entry { stroke: var(--ink-2); }
.chart-candles .lvl-stop { stroke: var(--critical); }
.chart-candles .lvl-native { stroke: var(--warning); stroke-dasharray: 2 3; }
.chart-candles .lvl-label { font-size: 11px; font-weight: 600; paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.chart-candles .mk-buy { fill: var(--good); stroke: var(--surface); stroke-width: 1.5; }
.chart-candles .mk-sell { fill: var(--critical); stroke: var(--surface); stroke-width: 1.5; }
.chart-candles .cross { stroke: var(--ink-3); stroke-dasharray: 3 3; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid; }
.legend i.dash { border-top-style: dashed; }
.legend i.dot { border-top-style: dotted; }
.legend b.tri { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.legend b.up { border-bottom: 8px solid var(--good); }
.legend b.down { border-top: 8px solid var(--critical); }

/* carte de chaleur */
.heat-wrap { overflow-x: auto; }
.heat { display: grid; grid-template-columns: 44px repeat(8, minmax(34px, 1fr)); gap: 4px; min-width: 360px; }
.heat .h-col, .heat .h-row { font-size: 11.5px; color: var(--ink-3); display: grid; place-items: center; }
.heat .h-row { justify-items: start; }
.heat .cell {
  appearance: none; border: 0; font: inherit; font-size: 11.5px; font-weight: 600; font-family: var(--font-num);
  min-height: 34px; border-radius: 6px; background: var(--surface-2); color: var(--ink-3); cursor: pointer;
  display: grid; place-items: center; transition: transform 160ms var(--ease-out);
}
.heat .cell:active { transform: scale(0.94); }
.heat .cell[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 1px; }

/* écran de veille */
.veille {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); color: var(--ink);
  display: grid; place-items: center; padding: 24px; cursor: pointer; user-select: none;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
}
.veille-inner { display: grid; justify-items: center; gap: 6px; text-align: center; transition: transform 1.2s var(--ease-in-out); }
.veille-clock { font-family: var(--font-num); font-size: clamp(56px, 14vw, 150px); font-weight: 300; letter-spacing: -0.04em; line-height: 1; }
.veille-date { color: var(--ink-2); font-size: clamp(14px, 2.4vw, 20px); margin-bottom: clamp(18px, 5vh, 48px); }
.veille-label { color: var(--ink-3); font-size: 13px; text-transform: uppercase; letter-spacing: 0.1em; }
.veille-equity { font-family: var(--font-num); font-size: clamp(34px, 8vw, 84px); font-weight: 650; letter-spacing: -0.03em; line-height: 1.05; }
.veille-day { font-family: var(--font-num); font-size: clamp(18px, 3.4vw, 30px); font-weight: 600; }
.veille-alert { margin-top: 14px; padding: 10px 16px; border-radius: var(--radius-sm); background: var(--critical-bg); color: var(--critical); font-weight: 650; max-width: 640px; }
.veille-pos { list-style: none; margin: clamp(16px, 4vh, 36px) 0 0; padding: 0; display: grid; gap: 6px; font-family: var(--font-num); font-size: clamp(14px, 2.2vw, 19px); }
.veille-foot { margin-top: 18px; font-size: 13px; color: var(--ink-3); }
.veille-hint { position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 12px; color: var(--ink-3); margin: 0; }
@media (prefers-reduced-motion: reduce) { .veille-inner { transition: none; } .heat .cell:active { transform: none; } }
@media (max-width: 420px) { .kpis .kpi-value { font-size: 17px; letter-spacing: -0.03em; } }

/* ---------------------------------------------------------------- 5 onglets (bloc 21) */
.tabs { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-padding: 16px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; white-space: nowrap; position: relative; }
.tab-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 6px; vertical-align: 2px;
  background: var(--critical); box-shadow: 0 0 0 3px var(--critical-bg);
}
.tab-dot[hidden] { display: none; }
.global { display: grid; gap: 14px; }
.proposals:empty { display: none; }
.global:not(:has(> section:not([hidden]):not(:empty))) { display: none; }
@media (max-width: 520px) { .tab { padding: 0 13px; font-size: 13.5px; } }

/* =====================================================================
   FOND D'ÉCRAN PERSONNEL (bloc 22) — photo + flou + voile ; cartes presque opaques pour que le
   texte reste lisible quelle que soit la photo (clair, sombre, très contrasté)
   ===================================================================== */
.wallpaper { display: none; }
[data-bg="on"] .wallpaper {
  display: block; position: fixed; inset: -48px; z-index: -1; pointer-events: none;
  background-image: var(--wall); background-size: cover; background-position: center;
  filter: blur(var(--wall-blur, 0px));
}
[data-bg="on"] .wallpaper::after {
  content: ""; position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) var(--wall-dim, 45%), transparent);
}
[data-bg="on"] .wrap .card, [data-bg="on"] .wrap .kpi, [data-bg="on"] .wrap .goal, [data-bg="on"] .wrap .proposal {
  background: color-mix(in srgb, var(--surface) 90%, transparent);
}
[data-bg="on"] .wrap .alert-critical {
  background: linear-gradient(var(--critical-bg), var(--critical-bg)), color-mix(in srgb, var(--surface) 94%, transparent);
}
[data-bg="on"] .tab { background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
[data-bg="on"] .tab[aria-selected="true"] { background: var(--surface); }
[data-bg="on"][data-bg-veille="on"] .veille { background: color-mix(in srgb, var(--bg) 50%, transparent); }
[data-bg="on"][data-bg-veille="on"] .veille-inner, [data-bg="on"][data-bg-veille="on"] .veille-hint {
  text-shadow: 0 1px 2px var(--bg), 0 0 18px var(--bg), 0 0 36px var(--bg);
}

/* réglages du fond dans la fenêtre Apparence */
.wall-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.wall-thumb {
  width: 120px; height: 72px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface-2); background-size: cover; background-position: center;
  display: grid; place-items: center; font-size: 12px; color: var(--ink-3); flex: 0 0 auto; overflow: hidden;
}
[data-bg="on"] .wall-thumb { background-image: var(--wall); }
[data-bg="on"] .wall-thumb span { display: none; }
.wall-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.wall-settings { display: grid; gap: 8px; margin-top: 12px; }
.range-row { display: grid; grid-template-columns: 56px 1fr 44px; align-items: center; gap: 10px; font-size: 13.5px; color: var(--ink-2); }
.range-row input[type="range"] { width: 100%; accent-color: var(--accent-line); min-height: 32px; }
.range-row output { font-family: var(--font-num); font-size: 12.5px; text-align: right; color: var(--ink); }
.check-row { display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--ink); min-height: 36px; }
.check-row input { width: 18px; height: 18px; accent-color: var(--accent-line); }
dialog.prefs { max-height: calc(100dvh - 24px); overflow-y: auto; }
