/* ═══════════════════════════════════════════════════════════════════════════
   CHAUFFAGE CONNECTÉ — overlay plein écran depuis le profil Service client.
   Desktop d'abord : grille de cartes multi-colonnes, une carte par logement.
   Les logements qui demandent une action remontent en tête, portés par un rail
   de couleur à gauche. Sous 900px la grille tombe à une colonne, sous 640px
   les interrupteurs passent sous le nom de la pièce.
   Jetons de base.css uniquement — pas ceux de la messagerie.
   ═══════════════════════════════════════════════════════════════════════════ */

.ht-page {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink-1);
  font-family: Inter, system-ui, sans-serif;
  animation: htIn var(--dur-base) var(--ease-out);
}
.ht-page.is-closing { animation: htOut 180ms var(--ease) forwards; }
@keyframes htIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes htOut { to { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) {
  .ht-page, .ht-page.is-closing { animation: none; }
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.ht-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: calc(13px + var(--safe-top)) 22px 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--line-1);
  flex: none;
}
.ht-top-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--r-md);
  background: var(--accent-soft);
  color: var(--accent);
}
.ht-top-icon svg { width: 21px; height: 21px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ht-top-text { flex: 1; min-width: 0; }
.ht-top-text h1 {
  margin: 0;
  font-size: var(--t-18);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-tight);
}
.ht-sub {
  margin: 3px 0 0;
  color: var(--ink-3);
  font-size: var(--t-12);
  font-variant-numeric: tabular-nums;
}

.ht-fresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 4px 9px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-1);
  background: var(--surface-2);
  color: var(--ink-3);
  font-size: var(--t-11);
  font-weight: var(--w-semibold);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ht-fresh[hidden] { display: none; }
.ht-fresh-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  flex: none;
}
.ht-fresh.is-stale {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line-1));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}
.ht-fresh.is-stale .ht-fresh-dot { background: var(--warn); }

.ht-icon-btn,
.ht-close {
  height: 36px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  flex: none;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.ht-icon-btn { width: 36px; display: inline-flex; align-items: center; justify-content: center; }
.ht-icon-btn svg { width: 17px; height: 17px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ht-close { width: 36px; font-size: 15px; line-height: 1; }
.ht-icon-btn:hover,
.ht-close:hover { background: var(--surface-2); color: var(--ink-1); border-color: var(--line-2); }
.ht-icon-btn:focus-visible,
.ht-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ht-icon-btn.is-busy svg { animation: htSpin .9s linear infinite; }
.ht-icon-btn:disabled { cursor: progress; color: var(--ink-4); }
@keyframes htSpin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .ht-icon-btn.is-busy svg { animation: none; opacity: .5; }
}

/* ── Corps ───────────────────────────────────────────────────────────────── */
.ht-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 22px calc(30px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

/* ── Bandeau de chiffres ─────────────────────────────────────────────────── */
.ht-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 12px;
}
.ht-stats[hidden] { display: none; }
.ht-stat {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 11px 15px 12px;
  border-left: 1px solid var(--line-1);
  text-align: left;
  font: inherit;
  color: inherit;
  background: transparent;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
}
.ht-stat:first-child { border-left: 0; }
.ht-stat-value {
  font-size: var(--t-20);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-display);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.ht-stat-label {
  font-size: 10px;
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-4);
}
.ht-stat[data-tone="warn"] .ht-stat-value { color: var(--warn); }
.ht-stat.is-action { cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.ht-stat.is-action:hover { background: var(--surface-2); }
.ht-stat.is-action:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ── Bandeau d'alertes ───────────────────────────────────────────────────── */
.ht-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.ht-alert[hidden] { display: none; }
.ht-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-2);
  background: var(--surface);
  font: inherit;
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.ht-chip svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ht-chip:hover { transform: translateY(-1px); }
.ht-chip:active { transform: none; }
.ht-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ht-chip.is-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 32%, var(--line-1));
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
}
.ht-chip.is-danger:hover { background: color-mix(in srgb, var(--danger) 15%, var(--surface)); }
.ht-chip.is-cold {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line-1));
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.ht-chip.is-cold:hover { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.ht-chip.is-warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line-1));
  background: color-mix(in srgb, var(--warn) 10%, var(--surface));
}
.ht-chip.is-warn:hover { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); }

.ht-ok {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 13px;
  border-radius: var(--r-md);
  border: 1px solid color-mix(in srgb, var(--ok) 26%, var(--line-1));
  background: color-mix(in srgb, var(--ok) 7%, var(--surface));
  color: var(--ok);
  font-size: var(--t-12);
  font-weight: var(--w-medium);
}
.ht-ok svg { width: 15px; height: 15px; stroke: currentColor; stroke-width: 2.4; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Barre d'outils collante ─────────────────────────────────────────────── */
.ht-tools {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 18px 0 10px;
  margin-top: -18px;
  background: var(--bg);
}

.ht-search {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  flex: 1 1 240px;
  max-width: 330px;
  color: var(--ink-4);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.ht-search svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.9; fill: none; stroke-linecap: round; flex: none; }
.ht-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--t-13);
  color: var(--ink-1);
  outline: none;
}
.ht-search input::placeholder { color: var(--ink-4); }
.ht-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.ht-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ht-kbd {
  flex: none;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-2);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-4);
  font-family: inherit;
  font-size: 10px;
  font-weight: var(--w-semibold);
  line-height: 1;
}
.ht-search:focus-within .ht-kbd { display: none; }

.ht-filter {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.ht-filter button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font: inherit;
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  padding: 5px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ht-filter button:hover { color: var(--ink-1); }
.ht-filter button.is-active {
  background: var(--surface);
  color: var(--ink-1);
  box-shadow: var(--sh-1);
}
.ht-filter button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.ht-sort {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 4px 0 10px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-md);
  background: var(--surface);
}
.ht-sort-label {
  font-size: 10px;
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-4);
  white-space: nowrap;
}
.ht-sort select {
  appearance: none;
  border: 0;
  background: transparent url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%238890a0' stroke-width='1.6' stroke-linecap='round'/></svg>") right 8px center no-repeat;
  padding: 0 22px 0 4px;
  height: 100%;
  font: inherit;
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  cursor: pointer;
  outline: none;
}
.ht-sort:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.ht-count {
  margin-left: auto;
  color: var(--ink-4);
  font-size: var(--t-12);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Filtre secondaire (pièces froides / batteries) */
.ht-focus {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}
.ht-focus[hidden] { display: none; }
.ht-focus-label {
  font-size: 10px;
  font-weight: var(--w-semibold);
  letter-spacing: var(--ls-wider);
  text-transform: uppercase;
  color: var(--ink-4);
}
.ht-focus-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 3px 3px 10px;
  border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--line-1));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
  font-size: var(--t-12);
  font-weight: var(--w-semibold);
}
.ht-focus-pill button {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.ht-focus-pill button:hover { background: color-mix(in srgb, var(--accent) 16%, transparent); }

/* Légende */
.ht-legend {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 0 14px;
  font-size: var(--t-11);
  color: var(--ink-4);
}
.ht-legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.ht-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex: none;
}
.ht-swatch.is-cold { background: #bfdbfe; box-shadow: inset 0 0 0 1px rgba(37, 99, 235, .3); }
.ht-swatch.is-warm { background: #fed7aa; box-shadow: inset 0 0 0 1px rgba(234, 88, 12, .3); }
.ht-swatch.is-hot { background: #fecaca; box-shadow: inset 0 0 0 1px rgba(220, 38, 38, .3); }

/* ── Grille ──────────────────────────────────────────────────────────────── */
.ht-grid {
  column-width: 430px;
  column-gap: 12px;
}

.ht-card {
  position: relative;
  display: flex;
  flex-direction: column;
  break-inside: avoid;
  margin: 0 0 12px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.ht-card:hover { border-color: var(--line-2); }
.ht-card[data-level="danger"] { border-color: color-mix(in srgb, var(--danger) 26%, var(--line-1)); }
.ht-card[data-level="warn"] { border-color: color-mix(in srgb, var(--warn) 26%, var(--line-1)); }

.ht-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
}
.ht-card[data-level="danger"] .ht-rail { background: var(--danger); }
.ht-card[data-level="warn"] .ht-rail { background: var(--warn); }

.ht-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px 10px 16px;
  border-bottom: 1px solid var(--line-1);
}
.ht-card-title { min-width: 0; }
.ht-card-head h2 {
  margin: 0;
  font-size: var(--t-14);
  font-weight: var(--w-bold);
  letter-spacing: var(--ls-tight);
  line-height: var(--lh-snug);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ht-card-sum {
  margin: 2px 0 0;
  font-size: var(--t-11);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ht-card-tags {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: none;
}
.ht-tag {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: 10px;
  font-weight: var(--w-bold);
  letter-spacing: .01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ht-tag.is-danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 11%, transparent); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.ht-tag.is-cold { color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, transparent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }
.ht-tag.is-warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 26%, transparent); }

.ht-rooms { display: flex; flex-direction: column; }

.ht-room {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 16px;
  border-top: 1px solid var(--line-1);
  min-height: 44px;
}
.ht-rooms > .ht-room:first-child { border-top: 0; }
.ht-room.is-multi {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 7px;
  padding-bottom: 10px;
}
.ht-room-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.ht-room-name {
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  color: var(--ink-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ht-room-meta { display: inline-flex; align-items: center; gap: 5px; }
.ht-room-actions { display: inline-flex; align-items: center; justify-content: flex-end; }
.ht-room-tag {
  font-size: 10px;
  font-weight: var(--w-semibold);
  letter-spacing: .02em;
  color: var(--ink-4);
  padding: 0 6px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  white-space: nowrap;
}

/* Plusieurs radiateurs : une ligne nommée par appareil */
.ht-rads {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 9px;
  border-left: 2px solid var(--line-1);
  margin-left: 1px;
}
.ht-rad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}
.ht-rad-name {
  font-size: var(--t-12);
  color: var(--ink-3);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Badges de pièce ─────────────────────────────────────────────────────── */
.ht-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  font-size: var(--t-11);
  font-weight: var(--w-semibold);
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ht-badge.is-muted {
  color: var(--ink-4);
  border-color: var(--line-1);
  background: var(--surface-2);
  font-weight: var(--w-medium);
}
.ht-temp.is-cold { color: #1e40af; background: rgba(37, 99, 235, .14); border-color: rgba(37, 99, 235, .26); }
.ht-temp.is-warm { color: #9a3412; background: rgba(234, 88, 12, .14); border-color: rgba(234, 88, 12, .28); }
.ht-temp.is-hot { color: #b91c1c; background: rgba(220, 38, 38, .14); border-color: rgba(220, 38, 38, .28); }
.ht-badge-alert {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-color: color-mix(in srgb, var(--warn) 32%, transparent);
}
.ht-bang {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--warn);
  color: #fff;
  font-size: 9.5px;
  font-weight: var(--w-bold);
  line-height: 1;
  flex: none;
}

/* Batterie */
.ht-batt {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--r-pill);
  border: 1px solid var(--line-1);
  background: var(--surface-2);
  color: var(--ink-4);
  font-size: 10px;
  font-weight: var(--w-semibold);
  font-variant-numeric: tabular-nums;
}
.ht-batt svg { width: 13px; height: 13px; stroke: currentColor; stroke-width: 1.7; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ht-batt.is-muted { opacity: .55; }
.ht-batt.is-low {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 34%, var(--line-1));
  background: color-mix(in srgb, var(--warn) 12%, var(--surface));
  padding: 0 6px 0 4px;
}
.ht-batt-num { font-size: 10px; font-weight: var(--w-bold); }

/* ── Interrupteur radiateur ──────────────────────────────────────────────── */
.ht-sw {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px 0 4px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--ink-2);
  font: inherit;
  font-size: var(--t-11);
  font-weight: var(--w-semibold);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.ht-sw:hover:not(.is-offline) { border-color: var(--line-3); }
.ht-sw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ht-sw-track {
  position: relative;
  width: 30px;
  height: 18px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--line-3);
  transition: background var(--dur-base) var(--ease);
}
.ht-sw-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .28);
  transition: left var(--dur-base) var(--ease-out);
}
.ht-sw.is-on {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--ok) 48%, var(--line-2));
  color: var(--ok);
}
.ht-sw.is-on .ht-sw-track { background: var(--ok); }
.ht-sw.is-on .ht-sw-knob { left: 14px; }
.ht-sw-label { line-height: 1; }
.ht-sw.is-offline {
  cursor: not-allowed;
  border-style: dashed;
  border-color: var(--line-2);
  background: transparent;
  color: var(--ink-4);
}
.ht-sw.is-offline .ht-sw-track { background: var(--line-2); opacity: .55; }
.ht-sw.is-offline:hover { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--line-2)); }
.ht-sw[aria-busy="true"] { opacity: .55; cursor: progress; }
@media (prefers-reduced-motion: reduce) {
  .ht-sw-knob { transition: none; }
}

/* ── Non rattachés ───────────────────────────────────────────────────────── */
.ht-unlinked:empty { display: none; }
.ht-un {
  margin-top: 20px;
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
}
.ht-un-head {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--ink-1);
  transition: background var(--dur-fast) var(--ease);
}
.ht-un-head:hover { background: var(--surface-2); }
.ht-un-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ht-un-chev { display: inline-flex; color: var(--ink-4); flex: none; transition: transform var(--dur-fast) var(--ease); }
.ht-un-chev svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ht-un-chev.is-open { transform: rotate(90deg); }
.ht-un-title { font-size: var(--t-13); font-weight: var(--w-bold); letter-spacing: var(--ls-tight); }
.ht-un-count {
  font-size: 10px;
  font-weight: var(--w-bold);
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  font-variant-numeric: tabular-nums;
}
.ht-un-types { display: inline-flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.ht-un-tag {
  font-size: 10px;
  font-weight: var(--w-semibold);
  color: var(--ink-3);
  background: var(--surface-2);
  border: 1px solid var(--line-1);
  border-radius: var(--r-pill);
  padding: 1px 7px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ht-un-tag.is-plain { background: transparent; color: var(--ink-4); }
.ht-un-body { border-top: 1px solid var(--line-1); padding: 12px 14px 6px; }
.ht-un-body[hidden] { display: none; }
.ht-un-note {
  margin: 0 0 10px;
  font-size: var(--t-12);
  line-height: 1.5;
  color: var(--ink-3);
  max-width: 78ch;
}
.ht-un-note code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .92em;
  padding: 1px 4px;
  border-radius: var(--r-xs);
  background: var(--surface-2);
  border: 1px solid var(--line-1);
}
.ht-un-search {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  margin-bottom: 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-4);
  max-width: 300px;
  width: 100%;
}
.ht-un-search svg { width: 14px; height: 14px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; flex: none; }
.ht-un-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: var(--t-12);
  color: var(--ink-1);
  outline: none;
}
.ht-un-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ht-un-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 0 18px;
  max-height: 340px;
  overflow-y: auto;
  padding-bottom: 8px;
}
.ht-un-row {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 0;
  border-top: 1px solid var(--line-1);
  font-size: var(--t-12);
  min-width: 0;
}
.ht-un-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); flex: none; }
.ht-un-dot.is-off { background: transparent; border: 1px dashed var(--ink-4); }
.ht-un-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-1);
}
.ht-un-room { flex: none; color: var(--ink-4); font-size: 10.5px; white-space: nowrap; }
.ht-un-state { flex: none; color: var(--ink-4); font-size: 10.5px; white-space: nowrap; }
.ht-un-state.is-off { color: var(--warn); }
.ht-un-empty { margin: 4px 0 12px; color: var(--ink-3); font-size: var(--t-12); }

/* ── États ───────────────────────────────────────────────────────────────── */
.ht-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 44px 24px;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  text-align: center;
}
.ht-state-title { margin: 0; font-size: var(--t-14); font-weight: var(--w-bold); color: var(--ink-1); }
.ht-state-text { margin: 0; font-size: var(--t-12); color: var(--ink-3); max-width: 52ch; line-height: 1.5; }
.ht-state .ht-btn { margin-top: 8px; }
.ht-state.is-error { border-color: color-mix(in srgb, var(--danger) 30%, var(--line-2)); }
.ht-btn {
  appearance: none;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink-1);
  font: inherit;
  font-size: var(--t-13);
  font-weight: var(--w-semibold);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.ht-btn:hover { background: var(--surface-2); }
.ht-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Squelette de chargement */
.ht-skel {
  border: 1px solid var(--line-1);
  border-radius: var(--r-lg);
  background: var(--surface);
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ht-skel-head { display: flex; justify-content: space-between; gap: 12px; }
.ht-skel-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.ht-skel-bar {
  height: 10px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-sunken) 50%, var(--surface-2) 100%);
  background-size: 220% 100%;
  animation: htShimmer 1.4s var(--ease) infinite;
}
@keyframes htShimmer {
  from { background-position: 140% 0; }
  to { background-position: -40% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .ht-skel-bar { animation: none; }
}

/* Toast */
.ht-toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 10px);
  z-index: 12100;
  max-width: min(540px, calc(100vw - 32px));
  padding: 9px 16px;
  border-radius: var(--r-pill);
  background: var(--ink-1);
  color: var(--surface);
  font-size: var(--t-13);
  font-weight: var(--w-medium);
  box-shadow: var(--sh-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease), transform var(--dur-base) var(--ease-out);
}
.ht-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ── Mode sombre ─────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
  .ht-temp.is-cold { color: #bfdbfe; background: rgba(96, 165, 250, .2); border-color: rgba(96, 165, 250, .34); }
  .ht-temp.is-warm { color: #fdba74; background: rgba(251, 146, 60, .2); border-color: rgba(251, 146, 60, .34); }
  .ht-temp.is-hot { color: #fecaca; background: rgba(248, 113, 113, .2); border-color: rgba(248, 113, 113, .34); }
  .ht-swatch.is-cold { background: #60a5fa; box-shadow: none; }
  .ht-swatch.is-warm { background: #fb923c; box-shadow: none; }
  .ht-swatch.is-hot { background: #f87171; box-shadow: none; }
  .ht-bang { color: #141a21; }
  .ht-sw-knob { background: #f0f3f6; }
  .ht-fresh { background: var(--surface-2); }
  .ht-toast { background: #f0f3f6; color: #141a21; }
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .ht-grid { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
}

@media (max-width: 900px) {
  .ht-body { padding: 14px 14px calc(24px + var(--safe-bottom)); }
  .ht-top { padding: calc(12px + var(--safe-top)) 14px 12px; }
  .ht-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ht-stat:nth-child(3) { border-left: 0; }
  .ht-stat:nth-child(n + 3) { border-top: 1px solid var(--line-1); }
  .ht-search { max-width: none; flex: 1 1 100%; }
  .ht-count { margin-left: 0; }
  .ht-un-list { grid-template-columns: minmax(0, 1fr); }
  .ht-fresh { display: none; }
}

@media (max-width: 640px) {
  .ht-top-text h1 { font-size: var(--t-16); }
  .ht-sub { font-size: var(--t-11); }
  .ht-top-icon { display: none; }
  .ht-tools { gap: 8px; padding-top: 14px; margin-top: -14px; }
  .ht-filter { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .ht-filter::-webkit-scrollbar { display: none; }
  .ht-filter button { flex: 0 0 auto; }
  .ht-sort { flex: 1 1 auto; justify-content: space-between; }
  .ht-count { width: 100%; }
  .ht-sw { height: 32px; }
  .ht-card-head { flex-direction: column; gap: 6px; }
  .ht-card-tags { justify-content: flex-start; }
  .ht-un-types { display: none; }
  .ht-legend { gap: 10px; }
}
