/* Thème commun (Observatoire, Projets) : jetons clair / sombre et composants de carte. */
.viz-root {
  color-scheme: light;
  --surface-1: #fcfcfb; --page: #f9f9f7;
  --text-primary: #0b0b0b; --text-secondary: #52514e; --muted: #898781;
  --grid: #e1e0d9; --axis: #c3c2b7; --border: rgba(11,11,11,0.10);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --o1: #86b6ef; --o2: #2a78d6; --o3: #104281;
  --seq-lo: #cde2fb; --seq-hi: #0d366b;
  --div-neg: #2a78d6; --div-mid: #f0efec; --div-pos: #e34948;
  --code-bg: #f3f2ee;
  --b1: #86b6ef; --b2: #5598e7; --b3: #2a78d6; --b4: #1c5cab; --b5: #104281;  /* ordinal validé (pluie) */
}
@media (prefers-color-scheme: dark) {
  .viz-root {
    color-scheme: dark;
    --surface-1: #1a1a19; --page: #0d0d0d;
    --text-primary: #f0efec; --text-secondary: #c3c2b7; --muted: #898781;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255,255,255,0.10);
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --o1: #184f95; --o2: #3987e5; --o3: #9ec5f4;
    --seq-lo: #1a2a40; --seq-hi: #9ec5f4;
    --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
    --code-bg: #111110;
    --b1: #184f95; --b2: #256abf; --b3: #3987e5; --b4: #6da7ec; --b5: #9ec5f4;  /* sombre : plus de pluie = plus clair */
  }
}
[hidden] { display: none !important; }  /* sinon .grid (Tailwind) l'emporte sur l'attribut hidden */
body { background: var(--page); color: var(--text-primary); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
.card, .tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; }
.card { padding: 14px 16px; position: relative; min-width: 0; }  /* min-width : la grille peut rétrécir au redimensionnement */
.card h3 { font-weight: 600; font-size: 15px; padding-right: 130px; }
.sub { color: var(--text-secondary); font-size: 12px; margin-bottom: 6px; }
.chart { height: 300px; } .chart-tall { height: 380px; }
.tile { padding: 12px 14px; }
.tile-label { color: var(--text-secondary); font-size: 12px; }
.tile-value { font-size: 26px; font-weight: 600; margin: 2px 0; }
.tile-sub { font-size: 12px; }
.card-actions { position: absolute; top: 12px; right: 14px; display: flex; gap: 6px; }
.btn-sm { font-size: 12px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 6px; padding: 1px 8px; }
.btn-sm:hover { color: var(--text-primary); }
.tbl { max-height: 300px; overflow: auto; font-size: 12px; font-variant-numeric: tabular-nums; }
.tbl table { width: 100%; } .tbl th { text-align: left; position: sticky; top: 0; background: var(--surface-1); }
.tbl td, .tbl th { padding: 2px 6px; border-bottom: 1px solid var(--grid); }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 3px 12px; font-size: 13px; }
.chip[aria-pressed="true"] { background: var(--text-primary); color: var(--surface-1); }
.badge { display: inline-block; font-size: 11px; border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; margin-left: 4px; color: var(--text-secondary); }
#panel.htmx-request { opacity: .5; transition: opacity .2s; }
select { background: var(--surface-1); border: 1px solid var(--border); border-radius: 6px; padding: 2px 6px; font-size: 13px; }
.muted { color: var(--text-secondary); }
/* Onglets */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--grid); overflow-x: auto; }
.tab { padding: 8px 14px; font-size: 14px; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--s1); font-weight: 600; }
/* Onglet données */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 6px; }
.flow-step { flex: 1 1 150px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 12px; }
.flow-step b { display: block; font-size: 13px; margin-bottom: 2px; color: var(--text-primary); }
.flow-arrow { align-self: center; color: var(--muted); }
pre.code { background: var(--code-bg); border: 1px solid var(--border); border-radius: 8px; overflow-x: auto; font-size: 12px; line-height: 1.45; }
pre.code code.hljs { background: transparent; padding: 10px 12px; }
details.sql { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
details.sql summary { cursor: pointer; font-size: 14px; }
details.sql[open] summary { margin-bottom: 6px; }
details.sql:target, details.sql.flash { outline: 2px solid var(--s1); }
.rust-badge { border-color: #ce422b; color: #ce422b; }
.rust-step { border-color: #ce422b88; }
code.inline { font-size: 12px; background: var(--code-bg); border-radius: 4px; padding: 0 4px; }

/* Téléphone : les boutons d'un bloc passent au-dessus du titre au lieu de lui réserver 130 px à droite */
@media (max-width: 640px) {
  .card { display: flex; flex-direction: column; padding: 12px; }
  .card h3 { padding-right: 0; }
  .card-actions { position: static; order: -1; align-self: flex-end; margin-bottom: 4px; }
  .tile-value { font-size: 22px; }
  .chart-tall { height: 340px; }
}
