/* dashboard.css — couche « design system » du tableau de bord de FCD Gen.

   Les composants viennent du design system FCD de l'Espace Notarial
   (NotantisApp/fcd-design-system/fcd-ds/src/design-system) : stat, card, pill, table, rowlist,
   empty state, tag, gauge, kv — mêmes noms de classes, même grammaire, mêmes rayons décroissants
   (un enfant a toujours un rayon plus petit que son parent).

   Les JETONS, eux, restent ceux de FCD Gen : bleu Ouidou #2962FF, surfaces et traits de
   styles.css. Le bloc ci-dessous est la seule couture entre les deux — un composant lit toujours
   une variable, jamais une valeur, donc rebrancher le tableau de bord sur la palette FCD
   (#064977) reviendrait à ne changer que ce bloc.

   Les polices du DS (Outfit / Instrument Sans) ne sont pas reprises : elles supposent un appel à
   Google Fonts, or l'outil ne parle à personne d'autre qu'à l'API Google. C'est l'ÉCHELLE
   typographique du DS qui est reprise (chiffre-clé maigre et large, libellés en capitales
   monospace, chiffres tabulaires), portée par les familles déjà chargées.

   Tout est cantonné à #viewHome et aux deux dialogues du tableau de bord : les classes du DS
   (.empty, .pill, .card…) portent des noms qui existent ailleurs dans l'outil, elles ne doivent
   pas déborder. */

#viewHome,
#widgetsDialog,
#dashTplDialog {
  /* — marque — */
  --navy: var(--blue);
  --navy-deep: var(--blue-hover);
  --brand-surface: var(--blue);
  --on-brand: var(--on-blue);

  /* — texte et traits (l'outil définit déjà --ink, --ink-2, --line) — */
  --muted: var(--ink-3);
  --line-2: var(--line);

  /* — surfaces — */
  --surf: var(--surface);
  --surf-2: var(--surface-3);
  --surf-line: var(--line);
  --glass: var(--surface-3);
  --glass-2: var(--surface-2);
  --ctl-line: var(--line-strong);

  /* — sémantique : jamais seule à porter l'information (RGAA 1.4.1) — */
  --ok: var(--ok-fg);       --ok-soft: var(--ok-bg);
  --warn: var(--warn-fg);   --warn-soft: var(--warn-bg);
  --crit: var(--err-fg);    --crit-soft: var(--err-bg);
  --info: var(--blue);      --info-soft: var(--blue-bg);

  /* — rayons : quatre valeurs, plus la pilule — */
  --r-card: 14px;
  --r-block: 12px;
  --r-ctl: 10px;
  --r-sm: 8px;
  --r-pill: 999px;

  --display: var(--font);
}

/* Sprite du DS : contour hérité de currentColor, jamais de remplissage. Cantonné à .dsi pour ne
   pas éteindre les SVG pleins de l'outil (l'étincelle de l'assistant, notamment). */
#viewHome .dsi,
#widgetsDialog .dsi,
#dashTplDialog .dsi {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ============================================================
   1. En-tête de vue
   ============================================================ */

#viewHome .view-head .eyebrow {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--blue);
}
#viewHome .view-head h1 {
  font-family: var(--display);
  font-weight: 300;
  font-size: 27px;
  letter-spacing: -.02em;
  line-height: 1.1;
}

/* La vue est une grille fermée : c'est elle qui défile, pas la page. */
#viewHome .view-body { gap: 0; padding-bottom: 20px; }

/* ============================================================
   2. Barre du tableau de bord — onglets et personnalisation
   ============================================================ */

.dash { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.dash-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.dash-tabs { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.dash-tools { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.dash-tools .btn { display: inline-flex; align-items: center; gap: 7px; }

.dash-tab {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--glass-2);
  border: 1px solid var(--ctl-line);
  border-radius: var(--r-pill);
  padding: 0 4px 0 0;
}
.dash-tab.is-active { background: var(--brand-surface); border-color: var(--brand-surface); }
.dash-tab-label {
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 7px 14px;
  border-radius: var(--r-pill);
}
.dash-tab.is-active .dash-tab-label { color: var(--on-brand); }
.dash-tab:not(.is-active):hover { background: var(--surface-hover); }

.dash-tab-remove {
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
  opacity: .6;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  padding: 0;
}
.dash-tab.is-active .dash-tab-remove { color: var(--on-brand); }
.dash-tab-remove:hover { opacity: 1; background: rgba(255, 255, 255, .22); }
.dash-tab:not(.is-active) .dash-tab-remove:hover { background: var(--err-bg); color: var(--err-fg); }

.dash-tab-add {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--ctl-line);
  background: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
}
.dash-tab-add:hover { border-color: var(--blue); color: var(--blue); border-style: solid; }

.dash-tab-input {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  width: 11ch;
  padding: 6px 12px;
  border: 1px solid var(--blue);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink);
}

.dash-hint {
  margin: -4px 0 12px;
  font-size: 12.5px;
  color: var(--muted);
  max-width: 82ch;
  line-height: 1.5;
}

/* ============================================================
   3. La grille — 12 colonnes sur 12 lignes, fermée

   La hauteur de ligne est posée par le script (--dash-rowh) sur la place réellement disponible :
   un tableau de bord dont il faut faire défiler le bas ne montre plus tout d'un coup d'œil.
   Sous 760 px de large, la grille s'empile et le glisser-déposer s'éteint.
   ============================================================ */

.dash-grid {
  --dash-rowh: 46px;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  grid-auto-rows: var(--dash-rowh);
  gap: 14px;
  position: relative;
  /* La grille garde sa hauteur naturelle : c'est --dash-rowh, mesuré sur la place disponible, qui
     la fait tomber juste. La laisser rétrécir comme un élément flex ordinaire l'écrasait à zéro
     dans une fenêtre courte, cartes comprises. Sous le plancher de hauteur de ligne, elle déborde
     et c'est la vue qui défile — mieux vaut défiler que rendre les cartes illisibles. */
  flex: 0 0 auto;
}
.dash-grid.is-empty { display: block; grid-template-columns: none; }
.dash-grid.is-stacked { grid-template-columns: 1fr; grid-auto-rows: minmax(190px, auto); }
.dash-grid.is-stacked > .widget { grid-area: auto !important; }

/* ============================================================
   4. Le cadre d'un widget
   ============================================================ */

.widget {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  /* Verre depoli depuis le 17/09/2026, comme .panel : les widgets flottent sur le decor anime du
     fond. Les jetons --glass* sont definis dans styles.css, charge avant celui-ci. Le repli opaque
     s'applique d'abord ; le verre ne prend la main que si le navigateur sait flouter le fond. */
  background: var(--voile-widget, var(--surf));
  border: 1px solid var(--glass-line, var(--surf-line));
  border-radius: var(--r-card);
  box-shadow: var(--shadow-bloc);
  overflow: hidden;
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .widget {
    /* Seul le flou est conditionnel. Le fond ne l'est plus : c'est un degrade diagonal pose sur la
       regle de base, qui tient sans backdrop-filter — il sera juste moins profond. La bordure reste
       visible, contrairement aux panneaux ou c'etait un second degrade qui la dessinait. */
    -webkit-backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
    backdrop-filter: blur(var(--glass-blur, 16px)) saturate(180%);
  }
  /* Un widget « nu » porte deja sa propre carte : le verre y ferait une double epaisseur. */
  .widget-bare { -webkit-backdrop-filter: none; backdrop-filter: none; }
}
/* Le contenu porte déjà sa propre carte : le cadre se réduit à la couche d'édition, sans quoi on
   obtiendrait deux bordures concentriques. */
.widget-bare { background: none; border: none; box-shadow: none; }

.widget-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px 9px;
  color: var(--muted);
}
.widget-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-link {
  margin-left: auto;
  border: none;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  white-space: nowrap;
  padding: 0;
}
.widget-link:hover { text-decoration: underline; }

.widget-body { flex: 1; min-height: 0; overflow: auto; padding: 0 16px 14px; }
.widget-bare > .widget-body { padding: 0; overflow: hidden; }
.widget-bare > .widget-body > * { height: 100%; }

/* --- Édition ---
   Toute la carte se saisit par son en-tête ; .widget-remove et .widget-resize sont exclus de la
   saisie, sinon ces commandes ne recevraient jamais leur clic. */
.widget-editing { border-color: var(--line-strong); }
.widget-editing .widget-body { overflow: hidden; pointer-events: none; opacity: .62; }
.widget-bare.widget-editing {
  background: var(--surf);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
}
.widget-editing.is-grabbed {
  z-index: 20;
  box-shadow: var(--shadow-lg);
  border-color: var(--blue);
  opacity: .95;
}
.widget-editing.is-swap-target { outline: 2px dashed var(--blue); outline-offset: -3px; }

.widget-handle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  background: var(--blue-bg);
  color: var(--blue);
  cursor: grab;
  touch-action: none;
  user-select: none;
}
body.dash-dragging .widget-handle { cursor: grabbing; }
.widget-handle-title {
  flex: 1;
  min-width: 0;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-remove {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: none;
  color: inherit;
  cursor: pointer;
  padding: 0;
}
.widget-remove:hover { color: var(--err-fg); border-color: var(--err-fg); }

.widget-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
}
.widget-editing { position: relative; }
.widget-resize::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--blue);
  border-bottom: 2px solid var(--blue);
  opacity: .55;
}
.widget-resize:hover::after { opacity: 1; }

/* Aperçu du dépôt : libre, échange, ou refusé. */
.dash-ghost { border-radius: var(--r-card); pointer-events: none; z-index: 10; }
.dash-ghost.is-free { background: var(--blue-bg); border: 1.5px dashed var(--blue); }
.dash-ghost.is-swap { background: var(--blue-bg); border: 1.5px solid var(--blue); }
.dash-ghost.is-blocked { background: var(--err-bg); border: 1.5px dashed var(--err-fg); }

/* ============================================================
   5. Composants du design system
   ============================================================ */

/* --- StatCard : la ligne du bas porte ce qui change la décision --- */
#viewHome .stat {
  height: 100%;
  border-radius: var(--r-block);
  background: var(--surf);
  border: 1px solid var(--surf-line);
  box-shadow: var(--shadow);
  padding: 14px 17px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: center;
}
/* En édition, le cadre porte déjà la carte : la StatCard perd la sienne, et se resserre — la
   poignée lui prend une trentaine de pixels sur une carte qui en fait cent. */
#viewHome .widget-bare.widget-editing .stat {
  border: none;
  box-shadow: none;
  background: none;
  padding: 8px 14px;
  gap: 2px;
}
#viewHome .widget-bare.widget-editing .stat-v { font-size: 1.5rem; }
#viewHome .stat-l {
  font-size: 11.5px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
#viewHome .stat-v {
  font-family: var(--display);
  font-weight: 300;
  font-size: clamp(1.7rem, 3.4vw, 2.15rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
#viewHome .stat-n { font-size: 11.5px; font-weight: 600; line-height: 1.35; }
#viewHome .stat-n--muted { color: var(--muted); font-weight: 500; }
#viewHome .stat-n--ok { color: var(--ok); }
#viewHome .stat-n--warn { color: var(--warn); }
#viewHome .stat-n--crit { color: var(--crit); }

/* --- Pill : la couleur ne code jamais seule, elle renforce un libellé écrit --- */
#viewHome .pill,
#dashTplDialog .pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--r-pill);
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
#viewHome .pill--ok, #dashTplDialog .pill--ok { background: var(--ok-soft); color: var(--ok); }
#viewHome .pill--warn, #dashTplDialog .pill--warn { background: var(--warn-soft); color: var(--warn); }
#viewHome .pill--crit, #dashTplDialog .pill--crit { background: var(--crit-soft); color: var(--crit); }
#viewHome .pill--info, #dashTplDialog .pill--info { background: var(--info-soft); color: var(--info); }
#viewHome .pill--flat, #dashTplDialog .pill--flat { background: var(--surface-2); color: var(--muted); }

/* --- DataTable --- */
/* Le contenu s'adapte à la carte, pas à la fenêtre : une même carte est tantôt sur 12 colonnes,
   tantôt sur 3. Sans requête de conteneur, le tableau déborderait dès qu'on la rétrécit. */
.widget { container-type: inline-size; }
#viewHome .tablewrap { overflow-x: auto; }
@container (max-width: 470px) {
  #viewHome .ds-table th:nth-child(3),
  #viewHome .ds-table td:nth-child(3) { display: none; }   /* la date passe à la trappe avant le reste */
}
@container (max-width: 360px) {
  #viewHome .ds-table td.right .btn:first-child { display: none; }  /* « Éditer » : « Ouvrir » suffit */
}
#viewHome .ds-table { border-collapse: collapse; width: 100%; }
#viewHome .ds-table thead th {
  text-align: left;
  padding: 0 12px 9px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
#viewHome .ds-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  vertical-align: middle;
}
#viewHome .ds-table tbody tr:last-child td { border-bottom: none; }
#viewHome .ds-table tbody tr:hover { background: var(--surface-2); }
#viewHome .ds-table td.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}
#viewHome .ds-table td.right { text-align: right; }
#viewHome .ds-table td.nowrap { white-space: nowrap; }

#viewHome .cellbox { display: flex; align-items: center; gap: 10px; min-width: 0; }
#viewHome .cellbox-txt { min-width: 0; }
#viewHome .cellbox b {
  display: block;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#viewHome .cellbox small,
#viewHome .w-row small {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Vignette de type, reprise du .thumb du DS : deux lettres, jamais une image à charger. */
#viewHome .thumb {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--blue-bg);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .04em;
  font-weight: 600;
}

/* --- Liste de lignes cliquables --- */
#viewHome .w-list { display: flex; flex-direction: column; gap: 2px; }
#viewHome .w-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 6px;
  border-radius: var(--r-sm);
}
#viewHome .w-row:hover { background: var(--surface-2); }
#viewHome .w-row-open {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  padding: 5px 4px;
  border-radius: var(--r-sm);
}
#viewHome .w-row-main { flex: 1; min-width: 0; }
#viewHome .w-row-main b {
  display: block;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#viewHome .w-row-side { flex: none; }

/* --- RowList : une ligne = une chose à faire --- */
#viewHome .rowlist { display: flex; flex-direction: column; }
#viewHome .rowl {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
#viewHome .rowl:last-child { border-bottom: none; }
#viewHome .rowl .ico {
  width: 28px;
  height: 28px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
}
#viewHome .rowl .ico--warn { background: var(--warn-soft); color: var(--warn); }
#viewHome .rowl .ico--ok { background: var(--ok-soft); color: var(--ok); }
#viewHome .rowl .txt { min-width: 0; flex: 1; font-size: 13px; color: var(--ink-2); line-height: 1.5; }

#viewHome .linkbtn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--blue);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* --- Tuiles d'action --- */
#viewHome .w-tiles {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
}
#viewHome .w-tile {
  display: flex;
  flex-direction: column;
  gap: 5px;
  text-align: left;
  padding: 12px 13px;
  border: 1px solid var(--surf-line);
  border-radius: var(--r-block);
  background: var(--surf-2);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
#viewHome .w-tile:hover { border-color: var(--blue); background: var(--blue-bg); }
/* Vignettes isometriques depuis le 17/09/2026 (voir assets/icones/). 72 px et non 30 : une
   illustration 3D ne se lit pas a la taille d'un pictogramme de trait, et a 44 px elle restait
   trop petite. Les PNG sont detoures, donc plus de pastille de fond : le sujet se pose
   directement sur la tuile en verre. */
#viewHome .w-tile-icon {
  width: 72px;
  height: 72px;
  display: grid;
  place-items: center;
  margin-bottom: 2px;
}
/* Tuile sans illustration : le pictogramme occupe la meme empreinte de 72 px, dans une pastille.
   La grille reste ainsi reguliere quelle que soit la matiere du visuel. */
#viewHome .w-tile-icon--picto {
  background: var(--blue-bg);
  color: var(--blue);
  border-radius: var(--r-sm);
}
#viewHome .w-tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform .18s ease;
}
/* Le survol ne peut plus recolorer un pictogramme : il fait respirer la vignette. */
#viewHome .w-tile:hover .w-tile-icon img { transform: scale(1.07); }
@media (prefers-reduced-motion: reduce) {
  #viewHome .w-tile-icon img { transition: none; }
  #viewHome .w-tile:hover .w-tile-icon img { transform: none; }
}
#viewHome .w-tile-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
#viewHome .w-tile-desc { font-size: 11.5px; line-height: 1.35; color: var(--muted); }

/* --- Jauges (répartition par type) --- */
#viewHome .w-usage-list { display: flex; flex-direction: column; gap: 12px; }
#viewHome .w-usage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
}
#viewHome .w-usage-pct {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
#viewHome .gauge {
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--ring-track);
  overflow: hidden;
}
#viewHome .gauge > i { display: block; height: 100%; background: var(--blue); border-radius: var(--r-pill); }

/* --- kv : clé à gauche, valeur à droite --- */
#viewHome .kv { display: flex; flex-direction: column; margin: 0; }
#viewHome .kv > div {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
#viewHome .kv > div:last-child { border-bottom: none; }
#viewHome .kv dt { color: var(--muted); margin: 0; }
#viewHome .kv dd { margin: 0; text-align: right; display: flex; align-items: center; gap: 8px; }

/* --- Tags --- */
#viewHome .thgroup { margin-bottom: 14px; }
#viewHome .thgroup:last-child { margin-bottom: 0; }
#viewHome .thgroup h4 {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
#viewHome .tagrow { display: flex; gap: 6px; flex-wrap: wrap; }
#viewHome .tg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--blue);
  background: var(--blue-bg);
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
}
#viewHome .tg:hover { border-color: var(--blue); }
#viewHome .tg-n { font-family: var(--mono); font-size: 10px; opacity: .7; }

/* --- Aperçu du menu --- */
#viewHome .navpreview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
#viewHome .navpreview-item {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 5px 11px;
}
#viewHome .navpreview-item:first-child { border-color: var(--blue); color: var(--blue); }

/* --- EmptyState : une donnée absente se déclare, elle ne s'omet pas ---
   `.empty` existe déjà dans styles.css, où c'est le voile plein écran de l'aperçu vide :
   `position:absolute; inset:0`. Sans la remise à zéro ci-dessous, l'état vide d'un widget se
   calait sur .dash-grid (le premier ancêtre positionné) et recouvrait tout le tableau de bord —
   les autres cartes restaient en place, simplement cachées dessous. */
#viewHome .empty {
  position: static;
  inset: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 100%;
  min-height: 130px;
  text-align: center;
  padding: 24px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-block);
  background: var(--surf-2);
  color: var(--muted);
}
#viewHome .empty .dsi { color: var(--ink-3); opacity: .5; margin-bottom: 6px; }
#viewHome .empty h4 { font-family: var(--display); font-weight: 600; font-size: 14.5px; margin: 0; color: var(--ink); }
#viewHome .empty p { margin: 0; font-size: 12.5px; max-width: 44ch; }
#viewHome .dash-grid.is-empty .empty { min-height: 240px; gap: 8px; }
#viewHome .dash-grid.is-empty .empty .btn { margin-top: 8px; }

/* ============================================================
   6. Bibliothèque de widgets, et galerie de modèles
   ============================================================ */

#wlibList { max-height: 58vh; overflow: auto; }
.wlib-group { margin-bottom: 16px; }
.wlib-group:last-child { margin-bottom: 0; }
.wlib-group-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 8px;
}
.wlib-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--surf-line);
  border-radius: var(--r-block);
  background: var(--surf);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.wlib-item:hover { border-color: var(--blue); }
.wlib-item.is-added { background: var(--blue-bg); border-color: var(--blue-bg); }
.wlib-icon {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  display: grid;
  place-items: center;
}
.wlib-item.is-added .wlib-icon { background: var(--surface); color: var(--blue); }
.wlib-text { flex: 1; min-width: 0; }
.wlib-name { display: block; font-size: 13px; font-weight: 600; color: var(--ink); }
.wlib-desc { display: block; font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }
.wlib-action { flex: none; color: var(--ink-3); }
.wlib-item.is-added .wlib-action { color: var(--ok-fg); }

#dashTplGrid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.tplcard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  padding: 14px 15px;
  border: 1px solid var(--surf-line);
  border-radius: var(--r-block);
  background: var(--surf);
  cursor: pointer;
  font: inherit;
  color: inherit;
}
.tplcard:hover { border-color: var(--blue); }
.tplcard.is-on { border-color: var(--blue); background: var(--blue-bg); }
.tplcard-head { display: flex; align-items: center; gap: 8px; color: var(--blue); }
.tplcard-head b { font-size: 14px; color: var(--ink); }
.tplcard-desc { font-size: 12px; color: var(--muted); line-height: 1.45; flex: 1; }
.tplcard-meta { font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }

/* Miniature de la grille : choisir des yeux plutôt que de lire. */
.tplminis { display: flex; gap: 6px; }
.mini {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(12, 1fr);
  gap: 1px;
  width: 74px;
  height: 52px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-2);
}
.mini > i { background: var(--blue); opacity: .45; border-radius: 1px; }
.tplcard.is-on .mini > i, .tplcard:hover .mini > i { opacity: .8; }

/* ============================================================
   7. Fenêtres étroites — la grille s'empile, l'édition s'éteint
   ============================================================ */

@media (max-width: 860px) {
  .dash-tools { margin-left: 0; }
  #viewHome .w-tiles { grid-template-columns: 1fr 1fr; }
}
