/* Console v3 — design system « croquis » MeilCard (repris de la console v2 + maquette validée).
   Tokens et composants identiques à la v2 pour une transition sans surprise visuelle. */
:root {
    --bg: #eef3ee;
    --card: #ffffff;
    --line: #e3e8ef;
    --text: #1f2937;
    --muted: #6b7280;
    --sidebar-bg: #1b2533;
    --sidebar-text: #aeb9c6;
    --accent: #3b6fe0;
    --accent-soft: rgba(59, 111, 224, .12);
    --green: #16a34a;
    --red: #e5484d;
    --amber: #d97706;
    --radius: 7px;
    --mc-sketch-stroke: hsl(218, 69%, 67%);
    --mc-sketch-stroke-active: hsl(96, 77%, 61%);
    --mc-sketch-hover: hsl(218, 75%, 38%);
    --mc-sketch-fill: hsla(96, 72%, 45%, 0.75);
    --mc-sketch-width: 1.3px;
    --mc-sketch-transition: .25s;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.app { display: flex; min-height: 100vh; }
button { font-family: inherit; }

/* ----------------------------------------------------------------- sidebar */
.sidebar {
    width: 248px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 12px;
}

/* bloc hostname (tête de sidebar) */
.host-head {
    display: flex; align-items: center; gap: 10px; width: 100%;
    background: none; border: none; color: inherit; cursor: pointer;
    padding: 8px; border-radius: var(--radius); text-align: left; transition: background .15s;
}
.host-head:hover { background: rgba(255, 255, 255, .06); }
.host-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    display: grid; place-items: center; font-weight: 700; font-size: 15px; color: #fff;
    box-shadow: inset 0 0 0 var(--mc-sketch-width) var(--mc-sketch-stroke);
    position: relative;
}
.host-avatar .dot {
    position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px;
    border-radius: 50%; border: 2px solid var(--sidebar-bg);
    background: var(--muted);
}
.host-avatar .dot.on { background: var(--mc-sketch-stroke-active); }
.host-name { color: #fff; font-size: 15px; font-weight: 600; line-height: 1.15; }
.host-sub { font-size: 11px; color: var(--sidebar-text); }
.host-chevron {
    margin-left: auto; width: 16px; height: 16px; flex-shrink: 0;
    stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
    transition: transform var(--mc-sketch-transition);
}
.host-open .host-chevron { transform: rotate(180deg); }

/* menu système repliable sous le hostname */
.sysnav {
    overflow: hidden; max-height: 0; transition: max-height .3s ease;
    display: flex; flex-direction: column; gap: 2px; padding: 0 4px;
}
.sysnav.open { max-height: 320px; }
.sidebar-sep { border: none; border-top: 1px solid rgba(255, 255, 255, .08); margin: 10px 4px; }

.nav-item {
    display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
    background: none; border: none; color: var(--sidebar-text); padding: 9px 11px;
    border-radius: var(--radius); cursor: pointer; font-size: 13.5px; transition: .12s;
}
.nav-item svg {
    width: 17px; height: 17px; flex-shrink: 0; fill: none; stroke: currentColor;
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active { background: var(--accent); color: #fff; }

/* section Pages (arbre des pages utilisateur — vide en lot 1) */
.pages-label {
    display: flex; align-items: center; padding: 4px 12px 6px; font-size: 10.5px;
    letter-spacing: .09em; text-transform: uppercase; color: #7d8a99;
}
.pages-empty { padding: 4px 12px; font-size: 12px; color: #7d8a99; font-style: italic; line-height: 1.5; }

/* arbre des pages utilisateur (dossiers = répertoires sur disque) */
.tree { list-style: none; margin: 0; padding: 0; font-size: 13.5px; overflow-y: auto; }
.tree ul { list-style: none; margin: 0; padding-left: 17px; }
.tree-row {
    display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
    background: none; border: none; color: var(--sidebar-text); padding: 7px 10px;
    border-radius: var(--radius); cursor: pointer; transition: .12s; font-size: 13.5px;
}
.tree-row:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.tree-row.active { background: var(--accent); color: #fff; }
.tree-row svg {
    width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor;
    stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.tree-row .tw { width: 11px; height: 11px; margin-left: -3px; transition: transform .2s; }
.folder.open > .tree-row .tw { transform: rotate(90deg); }
.tree-row .emoji { width: 16px; text-align: center; font-size: 13px; }

.sidebar-foot { margin-top: auto; }
/* « Nouvelle page… » : juste sous la dernière page de l'arbre, en ligne discrète (le bouton
   plein format se retrouvait tout en bas de la sidebar, invisible depuis les pages chargées). */
.btn-newpage {
    display: flex; align-items: center; gap: 7px; align-self: flex-start;
    background: transparent; color: #7d8a99; cursor: pointer;
    border: 1px dashed rgba(255, 255, 255, .22); border-radius: var(--radius);
    padding: 4px 10px; font-size: 12px; margin: 6px 4px 0;
    transition: background var(--mc-sketch-transition), color var(--mc-sketch-transition);
}
.btn-newpage:hover { background: var(--mc-sketch-fill); color: #fff; }
.brand-mini {
    display: flex; gap: 8px; align-items: center; padding: 12px 6px 2px;
    font-size: 11.5px; color: #7d8a99; border-top: 1px solid rgba(255, 255, 255, .08); margin-top: 12px;
}
.brand-mini .logo { color: var(--accent); font-size: 15px; }

/* ----------------------------------------------------------------- main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; gap: 12px; padding: 13px 22px;
    background: var(--card); border-bottom: 1px solid var(--line);
}
.page-title { margin: 0; font-size: 18px; font-weight: 600; }
.spacer { flex: 1; }

.content { padding: 22px; max-width: 1120px; width: 100%; margin: 0 auto; }

/* ----------------------------------------------------------------- contrôles */
.badge {
    background: #f3f5f9; border: 1px solid var(--line); border-radius: var(--radius);
    padding: 5px 12px; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.badge b { color: var(--text); }
.badge.ok { background: rgba(22, 163, 74, .1); border-color: rgba(22, 163, 74, .25); }
.badge.ok b { color: var(--green); }
.badge.ko { background: rgba(229, 72, 77, .1); border-color: rgba(229, 72, 77, .25); }
.badge.ko b { color: var(--red); }

select, input {
    background: #fff; color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; font-size: 13px;
}
input::placeholder { color: #9aa4b2; }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
    background: transparent; color: var(--text); border: var(--mc-sketch-width) solid var(--mc-sketch-stroke);
    border-radius: var(--radius); padding: 7px 13px; cursor: pointer; font-size: 13px;
    transition: border-color var(--mc-sketch-transition), color var(--mc-sketch-transition),
                background var(--mc-sketch-transition);
}
.btn:hover { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); }
.btn.primary { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); }
.btn.primary:hover { background: var(--mc-sketch-fill); color: #fff; }
.btn.ghost { padding: 5px 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--muted); }
.btn.danger:hover { border-color: var(--red); color: var(--red); }

/* ----------------------------------------------------------------- cartes / tables */
.card {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 16px 18px; margin-bottom: 18px; box-shadow: var(--shadow);
}
/* Configuration : blocs sur DEUX colonnes à flux naturel — quand la page rétrécit, les blocs
   de la seconde colonne redescendent sous la première. break-inside évite de couper une carte. */
.config-grid { columns: 2; column-gap: 18px; }
.config-grid > .card { break-inside: avoid; width: 100%; display: inline-block; margin-bottom: 18px; }
@media (max-width: 1180px) { .config-grid { columns: 1; } }
/* Gros séparateur pleine largeur — l'Atelier de design intégré au bas de la Configuration. */
.cfg-section-break {
    margin: 14px 0 18px; padding-top: 22px; border-top: 2px solid var(--line);
}
.cfg-section-break h2 { margin: 0 0 4px; font-size: 20px; font-weight: 700; }
.cfg-section-break .hint { margin: 0; max-width: 720px; }
/* Section rétractable (Avancé) : titre cliquable + chevron qui pivote. */
h2.collapsible { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 6px; }
h2.collapsible .chev { display: inline-block; transition: transform .15s; color: var(--muted); }
h2.collapsible.open .chev { transform: rotate(90deg); }
h2.collapsible .count { color: var(--muted); font-size: 12px; font-weight: 400; }
/* Liste des clés bornée (~10 lignes visibles) et défilante, entête collante. */
.keys-scroll { max-height: 440px; overflow-y: auto; }
.keys-scroll thead th { position: sticky; top: 0; background: var(--card); z-index: 1; }

/* ------------------------------------------------------------- éditeur de code (CodeDialog)
   Textarea TRANSPARENTE superposée au rendu colorisé (react-syntax-highlighter, vendorisé) :
   les deux partagent EXACTEMENT la même métrique de police et le même padding, synchronisés
   au défilement. Les !important neutralisent les styles inline du thème Prism (pre/code) —
   seules les couleurs des tokens (spans) survivent. */
.modal.code-modal { max-width: 920px; width: 92vw; }
.code-wrap { position: relative; height: 62vh; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
/* ⚠ spécificité : .code-wrap .code-ta doit BATTRE la règle générique `.modal textarea`
   (police proportionnelle 13px + padding 8/10) — sinon la superposition se désaligne. */
.code-hl, .code-wrap .code-ta {
    position: absolute; inset: 0; margin: 0; overflow: auto;
    font: 12.5px/1.55 ui-monospace, 'Cascadia Mono', Consolas, monospace;
    white-space: pre; tab-size: 2; box-sizing: border-box;
    border: none; border-radius: 0;
}
.code-hl { padding: 0; overflow: hidden; pointer-events: none; color: var(--ink, #1f2430); }
.code-hl pre {
    margin: 0 !important; padding: 12px 14px !important; background: none !important;
    border: none !important; border-radius: 0 !important;
    font: inherit !important; line-height: inherit !important; tab-size: 2 !important;
    white-space: pre !important; overflow: visible !important; box-sizing: border-box;
}
.code-hl code {
    font: inherit !important; line-height: inherit !important; background: none !important;
    white-space: pre !important; tab-size: 2 !important;
}
.code-wrap .code-ta { padding: 12px 14px; }
/* même combat de spécificité : transparence et caret doivent battre `.modal textarea` */
.code-wrap .code-ta {
    background: transparent; color: transparent; caret-color: var(--ink, #1f2430);
    border: none; outline: none; resize: none;
}
.code-wrap .code-ta:focus { outline: none; border: none; box-shadow: none; }
.code-wrap .code-ta::selection { background: rgba(100, 140, 220, .25); color: transparent; }
.code-error { color: var(--red, #c62828); font-size: 12.5px; margin: 8px 2px 0; }
/* tokens */
.tok-com { color: #8a8f98; font-style: italic; }
.tok-str { color: #2e7d32; }
.tok-key { color: #1565c0; }
.tok-num { color: #b26a00; }
.tok-kw  { color: #7b1fa2; }

/* -------------------------------------------------- arbre des pages : actions au survol + DnD
   Poignée ⠿ (drag natif, saisie sans relâcher) et poubelle, visibles uniquement au survol de
   la ligne ; pendant le glisser, un TRAIT marque l'entre-deux exact d'insertion (moitié haute
   d'une page = avant, moitié basse = après) et un dossier survolé se teinte (dépôt dedans). */
.tree li.page-leaf { position: relative; }
.tree li.page-leaf .tree-row { padding-right: 46px; }
.row-actions {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    display: none; align-items: center; gap: 2px;
}
.tree li.page-leaf:hover > .row-actions { display: inline-flex; }
.row-act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; padding: 0; border: none; background: none;
    color: rgba(255, 255, 255, .45); border-radius: 4px;
}
.row-act svg { width: 13px; height: 13px; fill: currentColor; stroke: currentColor; stroke-width: 1.6; }
.row-act.grip svg { stroke: none; }
.row-act.del svg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.row-act.grip { cursor: grab; }
.row-act.grip:active { cursor: grabbing; }
.row-act:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.row-act.del:hover { color: #ff8a80; }
.tree .tree-row { position: relative; }
.tree-row.drop-before::before, .tree-row.drop-after::after {
    content: ''; position: absolute; left: 4px; right: 4px; height: 0;
    border-top: 2px solid var(--mc-sketch-stroke-active, #7bc96f);
    pointer-events: none;
}
.tree-row.drop-before::before { top: -1px; }
.tree-row.drop-after::after { bottom: -1px; }
.tree-row.drop-into, .pages-label.drop-into {
    background: rgba(123, 201, 111, .16);
    border-radius: 6px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }
.group-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 15px; font-weight: 600; }
.group-title .count { color: var(--muted); font-size: 12px; font-weight: 400; }
.group-title .grow { flex: 1; }
.btn.rescan { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; font-size: 12.5px; color: var(--muted); }
.btn.rescan:hover { color: var(--mc-sketch-stroke-active); }
.btn.rescan svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
td.id { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; color: var(--accent); }
.val { font-variant-numeric: tabular-nums; font-weight: 600; }
.ts { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; margin-top: 2px; }

td.name .dev-name { font-weight: 500; }
td.name .dev-id {
    margin: 2px 0 0 10px;
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11px; color: var(--muted);
    cursor: pointer; width: fit-content;
}
td.name .dev-id:hover { color: var(--accent); text-decoration: underline; }

td.role .dev-type { margin: 4px 0 0 2px; font-size: 11px; color: var(--muted); }
.val .unit { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 3px; }
.val .text-value { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; }
.pill { border-radius: 20px; padding: 2px 10px; font-size: 11px; font-weight: 600; }
.pill.sensor { background: hsla(218, 69%, 60%, .16); color: var(--mc-sketch-hover); }
.pill.actuator { background: var(--mc-sketch-fill); color: #294a12; }
.state-on { color: hsl(96, 60%, 38%); font-weight: 700; }
.state-off { color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
/* actions device en icônes nues : le cerclage (bord + fond) n'apparaît qu'au survol */
.icon-act {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0;
    background: none; border: 1px solid transparent; border-radius: 8px;
    color: var(--muted); cursor: pointer;
}
.icon-act svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-act:hover { color: var(--text); border-color: var(--border); background: rgba(0, 0, 0, .04); }
.icon-act.danger:hover { color: var(--red); border-color: var(--red); }
.hint { color: var(--muted); margin: 0 0 12px; }
code { background: #f3f5f9; padding: 1px 6px; border-radius: 5px; }
.newrow { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* toggle « croquis » */
.switch { position: relative; display: inline-block; width: 46px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer; inset: 0; border-radius: 24px;
    background: transparent; box-shadow: inset 0 0 0 var(--mc-sketch-width) var(--mc-sketch-stroke);
    transition: box-shadow var(--mc-sketch-transition);
}
.switch .slider::before {
    content: ""; position: absolute; box-sizing: border-box;
    height: 16px; width: 16px; left: 4px; top: 4px; border-radius: 50%;
    background: transparent; border: var(--mc-sketch-width) solid var(--mc-sketch-stroke);
    transition: transform .2s, background-color var(--mc-sketch-transition), border-color var(--mc-sketch-transition);
}
.switch input:checked + .slider { box-shadow: inset 0 0 0 var(--mc-sketch-width) var(--mc-sketch-stroke-active); }
.switch input:checked + .slider::before { background: var(--mc-sketch-fill); border-color: var(--mc-sketch-stroke-active); transform: translateX(22px); }
.switch:hover .slider::before { border-color: var(--mc-sketch-hover); }
.switch input:disabled + .slider { opacity: .5; cursor: not-allowed; }

/* états de valeur (repris v2 : blip série, hors-ligne) */
.val.stale { opacity: .45; transition: opacity var(--mc-sketch-transition); }
.val.offline { opacity: .55; }
.offline-mark { color: var(--amber); font-weight: 600; font-size: 12px; white-space: nowrap; }

/* ----------------------------------------------------------------- builder de règles */
.ai-bar {
    display: flex; gap: 9px; align-items: center; margin-bottom: 14px;
    border: var(--mc-sketch-width) dashed var(--mc-sketch-stroke-active); border-radius: var(--radius);
    padding: 8px 8px 8px 12px; background: hsla(96, 72%, 45%, .05);
}
.ai-bar .ai-ic { font-size: 15px; }
.ai-bar input { flex: 1; border: none; background: transparent; font-size: 13px; padding: 4px 2px; }
.ai-bar input:focus { outline: none; box-shadow: none; }

.rule-list-row {
    display: flex; align-items: center; gap: 12px; padding: 10px 8px;
    border-bottom: 1px solid var(--line); border-radius: 5px;
}
.rule-list-row:last-of-type { border-bottom: none; }
.rule-list-row:hover { background: var(--accent-soft); }
.rule-list-row.editing { background: hsla(96, 72%, 45%, .10); box-shadow: inset 2px 0 0 var(--mc-sketch-stroke-active); }
.rule-list-row .rl-main { flex: 1; cursor: pointer; min-width: 0; }
.rule-list-row .r-name { font-weight: 600; }
.rule-list-row .r-desc { color: var(--muted); font-size: 12px; }
.rule-list-row .r-outs { display: flex; gap: 4px; flex-wrap: wrap; }
.out-chip {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11px;
    border: 1px solid var(--mc-sketch-stroke); border-radius: 12px; padding: 2px 8px;
    color: var(--mc-sketch-hover); background: #fff; white-space: nowrap;
    display: inline-flex; align-items: center; gap: 4px;
}
/* Projection de l'état live d'une sortie : ON = vert (pulse doux), OFF = grisé. */
.out-chip.on {
    background: rgba(22, 163, 74, .12); color: var(--green); border-color: rgba(22, 163, 74, .4);
    animation: out-pulse 1.8s ease-in-out infinite;
}
.out-chip.off { background: #eef1f6; color: var(--muted); border-color: var(--line); }
/* « Respiration » discrète du halo vert : attire l'œil sans clignotement agressif. */
@keyframes out-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); border-color: rgba(22, 163, 74, .35); }
    50%      { box-shadow: 0 0 6px 1px rgba(22, 163, 74, .35); border-color: rgba(22, 163, 74, .7); }
}
@media (prefers-reduced-motion: reduce) {
    .out-chip.on { animation: none; }
}

/* Pastille d'état live d'une condition device (when) : verte = vraie, grise = fausse, creuse = non évaluée. */
.cond-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 5px 0 1px; flex: 0 0 auto; }
.cond-dot.on { background: var(--green); box-shadow: 0 0 0 2px rgba(22, 163, 74, .18); }
.cond-dot.off { background: #cbd5e1; }
.cond-dot.unknown { background: transparent; border: 1px solid var(--line); }
/* règle hébergée sur une autre plateforme du cluster : puce 🍇 + nom */
.origin-chip {
    font-size: 10.5px; font-weight: 600; border-radius: 10px; padding: 1px 7px;
    background: rgba(123, 87, 194, .12); color: #7b57c2; white-space: nowrap;
}
.rule-origin { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; }
.rule-origin select { padding: 4px 8px; }
.chip-x { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 12px; padding: 0; }
.chip-x:hover { color: var(--red); }

.rules-layout { display: grid; grid-template-columns: 1.45fr 1fr; gap: 20px; align-items: start; margin-top: 14px; }
@media (max-width: 980px) { .rules-layout { grid-template-columns: 1fr; } }
.rule-name { font-size: 15px; font-weight: 600; min-width: 260px; }
.rule-desc { width: 100%; margin-top: 4px; }

/* ---- Volet d'édition inline : la ligne éditée se déroule en panneau sous son en-tête ---- */
/* La coquille reprend .rule-list-row.editing mais passe en bloc (en-tête + corps empilés) et
   se démarque en carte surélevée. Le corps est un « volet roulant » (grid 0fr → 1fr). */
.rule-list-row.rule-edit-shell {
    display: block; padding: 0; gap: 0; margin: 8px 0; overflow: hidden;
    border: 1px solid var(--mc-sketch-stroke-active); border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .09);
}
.rule-list-row.rule-edit-shell:hover { background: hsla(96, 72%, 45%, .10); }   /* neutralise le survol de .rule-list-row */
.rl-edit-head {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border-bottom: 1px solid var(--line);
}
/* Nom éditable fusionné dans la ligne — remplace le champ « Nom » de l'ancien panneau. */
.rule-name-inline {
    flex: 1; min-width: 160px; border: none; background: transparent; padding: 4px 2px;
}
.rule-name-inline:focus { outline: none; box-shadow: inset 0 -1px 0 var(--accent); }
.rl-collapse { padding: 3px 9px; line-height: 1; }

.rule-editor-body {
    display: grid; grid-template-rows: 0fr; overflow: hidden;
    transition: grid-template-rows .24s ease;
}
.rule-edit-shell.open .rule-editor-body { grid-template-rows: 1fr; }
.rule-editor-inner { min-height: 0; padding: 6px 14px 0; }

/* Enregistrer / Fermer ancrés en bas à droite du volet. */
.editor-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 18px; padding: 12px 0 4px; border-top: 1px solid var(--line);
}
@media (prefers-reduced-motion: reduce) {
    .rule-editor-body { transition: none; }
}

.wt-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
.trigger-row {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    border: var(--mc-sketch-width) solid var(--line); border-radius: var(--radius);
    padding: 9px 11px; margin-bottom: 8px; background: #fff;
}
.trigger-row select, .trigger-row input { padding: 5px 8px; font-size: 13px; }
.trigger-row .grow-input { flex: 1; min-width: 160px; font-family: ui-monospace, Consolas, monospace; }
.trigger-row .arrow { color: var(--muted); font-size: 15px; }
.trigger-row .trig-del { padding: 2px 8px; margin-left: auto; }
.ttype {
    display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
    border-radius: 12px; padding: 3px 10px; white-space: nowrap;
}
.ttype.device { background: hsla(218, 69%, 60%, .16); color: var(--mc-sketch-hover); }
.ttype.time { background: rgba(217, 119, 6, .14); color: var(--amber); }
.io-pill {
    font-size: 11.5px; font-weight: 700; border-radius: 12px; padding: 3px 11px; cursor: pointer;
    border: var(--mc-sketch-width) solid transparent; letter-spacing: .03em;
}
.io-pill.on { background: var(--mc-sketch-fill); color: #1c3a08; }
.io-pill.off { background: #eef1f6; color: var(--muted); border-color: var(--line); }
.io-pill.none { background: transparent; color: var(--muted); border-color: var(--line); border-style: dashed; }
.io-pill.notify-on { background: rgba(229, 72, 77, .12); color: var(--red); border-color: rgba(229, 72, 77, .3); }
.guard-set { color: hsl(266, 45%, 45%); border-color: hsla(266, 45%, 45%, .35); background: hsla(266, 45%, 45%, .07); }
.guard-input { color: hsl(266, 45%, 45%); width: 110px; font-family: ui-monospace, Consolas, monospace; }
.notify-row { width: 100%; display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.notify-row .notify-msg { flex: 1; min-width: 200px; }
.notify-row .notify-cd { width: 110px; }
.delay-ghost {
    font-size: 11.5px; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px;
    padding: 3px 9px; background: none; cursor: pointer;
}
.delay-ghost:hover { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); }
.delay-set {
    font-size: 11.5px; color: var(--amber); border: 1px solid rgba(217, 119, 6, .35); border-radius: 12px;
    padding: 3px 9px; background: rgba(217, 119, 6, .07); display: inline-flex; align-items: center; gap: 4px;
}
.after-input { width: 56px; border: none; background: transparent; color: var(--amber); font-size: 11.5px; padding: 0; }
.after-input:focus { outline: none; box-shadow: none; }

/* Note libre documentant l'intérêt d'un déclencheur (champ description du when). */
.trig-desc {
    flex: 1 1 120px; min-width: 90px; border: none; border-bottom: 1px dashed var(--line);
    background: transparent; color: var(--muted); font-size: 11.5px; font-style: italic; padding: 2px 0;
}
.trig-desc:focus { outline: none; box-shadow: none; border-bottom-color: var(--accent); }
.trig-desc::placeholder { font-style: italic; opacity: 0.6; }

.add-trigger { position: relative; }
.add-menu {
    position: absolute; z-index: 20; margin-top: 6px; border: 1px solid var(--line);
    border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); overflow: hidden; width: 250px;
}
.add-menu button {
    display: flex; gap: 9px; align-items: center; width: 100%; text-align: left; background: none;
    border: none; padding: 9px 12px; font-size: 13px; cursor: pointer; color: var(--text);
}
.add-menu button:hover { background: var(--accent-soft); }
.add-menu .mi { width: 20px; text-align: center; }

.out-chips-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.timing-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.timing-row:last-of-type { border-bottom: none; }
.timing-row .tl { flex: 1; }
.timing-row .tl small { display: block; color: var(--muted); font-size: 11.5px; }
.timing-row input { width: 86px; text-align: right; font-variant-numeric: tabular-nums; }

.rule-summary {
    margin: 12px 0 0; border-left: 2px solid var(--mc-sketch-stroke-active); padding: 2px 0 2px 12px;
    color: var(--muted); font-size: 12.5px; line-height: 1.6; font-style: italic;
}
.json-view {
    margin: 6px 0 0; background: #1b2533; color: #cfe0f4; border-radius: var(--radius);
    padding: 12px 14px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 11.5px; line-height: 1.55; overflow-x: auto;
}
.json-toggle { font-size: 11px; padding: 2px 9px; margin-left: 6px; }

/* chips « ⚙ règle » sous les devices */
.rule-links { display: flex; gap: 5px; flex-wrap: wrap; margin: 4px 0 0 10px; }
.rule-link {
    font-size: 10.5px; border: 1px dashed var(--mc-sketch-stroke); border-radius: 12px;
    padding: 2px 8px; background: none; color: var(--mc-sketch-hover); cursor: pointer; transition: .15s;
}
.rule-link:hover { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); border-style: solid; }

/* ----------------------------------------------------------------- calendrier */
.cal-nav { display: flex; gap: 6px; align-items: center; margin-right: 10px; }
.cal-nav .btn { padding: 4px 10px; font-size: 13px; line-height: 1.2; }
.cal-key { display: flex; gap: 10px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }
.cal-key .key { display: inline-flex; align-items: center; gap: 4px; }
.cal-key .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.swatch.cron { background: hsla(218, 69%, 60%, .25); border: 1px solid var(--mc-sketch-stroke); }
.swatch.astro { background: rgba(217, 119, 6, .18); border: 1px solid rgba(217, 119, 6, .5); }
.swatch.cycle { background: hsla(96, 72%, 45%, .2); border: 1px solid var(--mc-sketch-stroke-active); }

.cal-scroll { overflow: auto; max-height: 480px; position: relative; }
/* le Calendrier prend TOUTE la page : plus de gouttière 1120px ; la grille remplit la hauteur
   (rangées en-têtes/all-day auto + colonnes 24 h en 1fr), positionnement des heures en %. */
.content:has(.cal-page) { max-width: none; }
.cal-page .cal-scroll { max-height: none; height: calc(100vh - 235px); min-height: 320px; }
.cal-grid { display: grid; grid-template-columns: 46px repeat(7, minmax(84px, 1fr)); min-width: 680px; }
.cal-page .cal-grid { grid-template-rows: auto auto 1fr; height: 100%; }
.cal-corner { position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 1px solid var(--line); }
.cal-day-head {
    position: sticky; top: 0; z-index: 3; background: var(--card);
    text-align: center; font-size: 12px; font-weight: 600; color: var(--muted);
    padding: 7px 4px; border-bottom: 1px solid var(--line);
}
.cal-day-head.today { color: var(--mc-sketch-stroke-active); }
.cal-day-head.today b {
    display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
    background: var(--mc-sketch-fill); color: #fff;
}
.cal-allday-label {
    position: sticky; top: 34px; z-index: 3; background: var(--card);
    font-size: 10px; color: var(--muted); text-align: right; padding: 5px 8px 0 0;
}
.cal-allday-cell {
    position: sticky; top: 34px; z-index: 3; grid-column: 2 / -1;
    background: var(--card); display: flex; flex-direction: column; gap: 3px; padding: 3px 2px;
}
.cal-allday-band {
    border-radius: 5px; padding: 3px 10px; font-size: 11.5px; text-align: left; cursor: pointer;
    background: hsl(96, 45%, 90%); border: 1px dashed var(--mc-sketch-stroke-active); color: hsl(96, 60%, 30%);
}
.cal-allday-none { font-size: 10.5px; color: var(--muted); font-style: italic; padding: 2px 4px; }
.cal-gutter { position: relative; border-right: 1px solid var(--line); }
.cal-gutter span {
    position: absolute; right: 6px; font-size: 10px; color: var(--muted);
    transform: translateY(-6px); font-variant-numeric: tabular-nums;
}
.cal-col {
    position: relative; border-right: 1px solid var(--line);
    /* lignes d'heures PROPORTIONNELLES : une ligne toutes les 1/24 de la hauteur de colonne */
    background-image: linear-gradient(to bottom, var(--line) 0 1px, transparent 1px);
    background-size: 100% calc(100% / 24);
    background-repeat: repeat-y;
}
.cal-col.today { background-color: hsla(96, 72%, 45%, .05); }
/* left / width sont posés inline (voie de collision) — les évènements simultanés se partagent
   la largeur de la colonne au lieu de se superposer. */
.cal-ev {
    position: absolute; border-radius: 4px; padding: 2px 6px; box-sizing: border-box;
    font-size: 10.5px; line-height: 1.3; cursor: pointer; white-space: nowrap; overflow: hidden;
    text-overflow: ellipsis; text-align: left; transition: filter .15s;
}
.cal-ev:hover { filter: brightness(.93); }
.cal-ev.cron { background: hsla(218, 69%, 60%, .16); border: 1px solid var(--mc-sketch-stroke); color: var(--mc-sketch-hover); }
.cal-ev.astro { background: rgba(217, 119, 6, .12); border: 1px solid rgba(217, 119, 6, .45); color: var(--amber); }
.cal-ev b { font-variant-numeric: tabular-nums; font-weight: 600; }
.cal-ev.remote { border-style: dashed; }

/* ----------------------------------------------------------------- configuration */
.loc-field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.loc-save { align-self: flex-end; }
.loc-map {
    height: 260px; border-radius: var(--radius); border: 1px solid var(--line);
    margin-bottom: 12px; background: #f2f6f1; cursor: crosshair; z-index: 0;
}
.cfg-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; max-width: 640px; }
.cfg-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cfg-form label.wide { grid-column: 1 / -1; }
.cfg-form input, .cfg-form select { width: 100%; }
.cfg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.chan-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.chan-row:last-of-type { border-bottom: none; }
.chan-row .ch-ic { width: 22px; text-align: center; }
.chan-row .ch-name { flex: 1; }
.chan-row .ch-name small { display: block; color: var(--muted); font-size: 11.5px; }
.ch-badge { font-size: 11px; border-radius: 12px; padding: 3px 10px; font-weight: 600; }
.ch-badge.on { background: rgba(22, 163, 74, .12); color: var(--green); }
.ch-badge.todo { background: #eef1f6; color: var(--muted); }
.ch-default { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 5px; }

/* ----------------------------------------------------------------- atelier de design */
/* Panneau de réglage du thème croquis : les curseurs pilotent les variables --mc-sketch-* */
.at-sliders { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px 26px; }
.at-slider { display: flex; flex-direction: column; gap: 4px; }
.at-lbl { font-size: 12.5px; color: var(--muted); }
.at-lbl b { color: var(--text); font-variant-numeric: tabular-nums; font-weight: 600; float: right; }
.at-slider input[type="range"] {
    width: 100%; height: 22px; appearance: none; background: transparent;
    border: none; box-shadow: none; padding: 0; cursor: pointer;
}
.at-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 6px; border-radius: 3px; background: var(--line);
}
.at-slider input[type="range"]::-webkit-slider-thumb {
    appearance: none; width: 16px; height: 16px; margin-top: -5px; border-radius: 50%;
    background: #fff; box-shadow: inset 0 0 0 var(--mc-sketch-width) var(--mc-sketch-stroke), 0 1px 3px rgba(0, 0, 0, .25);
}
.at-slider input.at-hue::-webkit-slider-runnable-track {
    background: linear-gradient(to right,
        hsl(0, 70%, 62%), hsl(60, 70%, 62%), hsl(120, 70%, 62%),
        hsl(180, 70%, 62%), hsl(240, 70%, 62%), hsl(300, 70%, 62%), hsl(360, 70%, 62%));
}
.at-slider input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line); }
.at-slider input[type="range"]::-moz-range-thumb {
    width: 16px; height: 16px; border: none; border-radius: 50%;
    background: #fff; box-shadow: inset 0 0 0 var(--mc-sketch-width) var(--mc-sketch-stroke), 0 1px 3px rgba(0, 0, 0, .25);
}
.at-slider input.at-hue::-moz-range-track {
    background: linear-gradient(to right,
        hsl(0, 70%, 62%), hsl(60, 70%, 62%), hsl(120, 70%, 62%),
        hsl(180, 70%, 62%), hsl(240, 70%, 62%), hsl(300, 70%, 62%), hsl(360, 70%, 62%));
}
.at-swatches { display: flex; gap: 8px; padding-top: 3px; }
.at-swatch {
    width: 26px; height: 26px; border-radius: 50%; cursor: pointer;
    border: 1px solid var(--line); transition: transform .12s;
}
.at-swatch:hover { transform: scale(1.15); }
.at-swatch.sel { box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--mc-sketch-stroke-active); }

/* Galerie d'icônes : SVG line-art du shell + emojis sémantiques (clic = copie) */
.at-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.at-icon {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 6px 9px; border: 1px solid var(--line); border-radius: var(--radius);
    background: none; font-size: 11px; color: var(--muted); text-align: center;
    transition: border-color var(--mc-sketch-transition), color var(--mc-sketch-transition);
}
.at-icon svg {
    width: 22px; height: 22px; fill: none; stroke: var(--mc-sketch-hover);
    stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.at-icon .glyph { font-size: 21px; line-height: 22px; }
button.at-icon { cursor: pointer; font-family: inherit; }
button.at-icon:hover { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); }
.at-emoji-row { display: flex; gap: 6px; align-items: flex-start; margin-top: 8px; }
.at-emoji-cat {
    flex: 0 0 150px; font-size: 11.5px; font-weight: 600; color: var(--muted);
    text-align: right; padding: 8px 6px 0 0;
}
.at-emoji-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.at-emoji-chip {
    border: 1px dashed var(--line); border-radius: var(--radius); background: none;
    font-size: 17px; padding: 5px 9px; cursor: pointer;
    transition: border-color var(--mc-sketch-transition), transform .12s;
}
.at-emoji-chip:hover { border-color: var(--mc-sketch-stroke-active); transform: scale(1.12); }

/* Catalogue : rangées de composants réels de la console */
.at-demo { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; }
.at-full { flex: 1 1 100%; }
.at-num { width: 90px; }
.at-cal-ev { position: static; width: auto; flex: 0 0 auto; }
.at-sidebar {
    background: var(--sidebar-bg); color: var(--sidebar-text);
    border-radius: var(--radius); padding: 12px; width: 248px;
    display: flex; flex-direction: column; gap: 10px;
}
.at-sidebar .tree-row svg { fill: none; stroke: currentColor; stroke-width: 1.8; }
a.btn { text-decoration: none; display: inline-block; }

/* ----------------------------------------------------------------- saisie avec suggestions (@) */
.suggest-wrap { position: relative; display: block; }
.ai-bar .suggest-wrap { flex: 1; }
.suggest-wrap input, .suggest-wrap textarea { width: 100%; }
.suggest-list {
    position: absolute; left: 0; right: 0; top: 100%; z-index: 40;
    margin: 4px 0 0; padding: 4px; list-style: none;
    background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow); max-height: 264px; overflow-y: auto;
}
.suggest-list li {
    display: flex; gap: 10px; align-items: center; padding: 6px 9px;
    border-radius: 5px; cursor: pointer; font-size: 12.5px;
}
.suggest-list li.sel { background: var(--accent-soft); }
.suggest-list .s-id { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-weight: 600; white-space: nowrap; }
.suggest-list .s-label { flex: 1; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-kind { font-size: 10.5px; border-radius: 10px; padding: 2px 8px; font-weight: 600; white-space: nowrap; }
.s-kind.capteur { background: hsla(218, 69%, 60%, .16); color: var(--mc-sketch-hover); }
.s-kind.actionneur { background: var(--mc-sketch-fill); color: #294a12; }
.s-kind.règle { background: rgba(217, 119, 6, .14); color: var(--amber); }

/* ----------------------------------------------------------------- page Capteurs & Commandes */
.sensors-table tbody tr { cursor: copy; }
.sensors-table tbody tr:hover { background: rgba(0, 0, 0, .03); }
.sensors-table .id { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.sensors-table .name { font-weight: 600; }
.sensors-table .detail { color: var(--muted); font-size: 12px; }
.ai-bar .count { font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* ----------------------------------------------------------------- timeseries (dialogue 📈) */
.chart-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.modal.metric { max-width: 820px; width: min(94vw, 820px); }
.modal.metric h3 svg { width: 16px; height: 16px; fill: none; stroke: var(--mc-sketch-stroke-active); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.rng-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 12px; font-size: 12px; color: var(--muted); }
.rng-pill {
    border: 1px solid var(--line); background: none; border-radius: 20px; cursor: pointer;
    padding: 3px 10px; font-size: 11.5px; color: var(--muted);
    transition: border-color var(--mc-sketch-transition), color var(--mc-sketch-transition);
}
.rng-pill:hover { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); }
.rng-pill.sel { border-color: var(--mc-sketch-stroke-active); color: var(--mc-sketch-stroke-active); background: rgba(0, 0, 0, .02); font-weight: 600; }
.rng-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rng-bar input[type="datetime-local"] { padding: 4px 6px; font-size: 12px; }
.mchart-box { position: relative; height: 300px; cursor: crosshair; }
.mchart-foot { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.mchart-foot .hint { font-size: 11px; }

/* ----------------------------------------------------------------- toast / modal */
.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: #1b2533; color: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 11px 18px; opacity: 0; transition: opacity .25s; pointer-events: none; max-width: 80vw;
    z-index: 90;
}
.toast.show { opacity: 1; }
.toast.err { background: var(--red); }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
    display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
    background: var(--card); border-radius: var(--radius); box-shadow: 0 10px 40px rgba(16, 24, 40, .25);
    padding: 22px 24px; width: 440px; max-width: 92vw;
}
.modal h3 { margin: 0 0 18px; font-size: 16px; }
.modal label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; color: var(--muted); font-size: 13px; }
.modal label input { width: 100%; }
.modal textarea {
    width: 100%; resize: vertical; background: #fff; color: var(--text);
    border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px;
    font-size: 13px; font-family: inherit; line-height: 1.5;
}
.modal textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* barre d'actions au-dessus d'une page utilisateur */
.userpage-bar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.modal-actions .left-action { margin-right: auto; }
.modal .modal-sep { border: none; border-top: 1px solid var(--border); margin: 14px 0 10px; }
.modal .folder-row { display: flex; gap: 8px; margin-top: 6px; }
.modal .folder-row input { flex: 1; }
.modal .folder-row .btn { white-space: nowrap; }
.modal-confirm { width: 380px; max-width: 92vw; }
.modal-confirm .confirm-msg { margin: 0 0 20px; color: var(--text); }
.modal .btn.confirm-danger { background: var(--red); border-color: var(--red); color: #fff; }
.modal .btn.confirm-danger:hover { filter: brightness(1.06); color: #fff; }

/* ---------------------------------------------------------------- page Alarmes */
table.alarms td { vertical-align: top; }
.alarm-state { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.alarm-state.cleared { background: rgba(60, 160, 90, .15); color: #2c8a4d; }
.alarm-state.acked { background: rgba(120, 120, 120, .18); color: #666; }
.alarm-state.active.info { background: rgba(60, 120, 200, .18); color: #2a67b3; }
.alarm-state.active.warning { background: rgba(230, 160, 20, .2); color: #a86d00; }
.alarm-state.active.alarm { background: rgba(220, 50, 50, .18); color: #b02020; font-weight: 600; }
tr.alarm-row.active.alarm td:first-child { border-left: 3px solid #b02020; }
tr.alarm-row.active.warning td:first-child { border-left: 3px solid #e0a020; }
button.link { background: none; border: none; padding: 0; color: inherit; text-decoration: underline dotted; cursor: pointer; font: inherit; }
code.alarm-cond { display: block; margin-top: 4px; font-size: 11px; opacity: .75; white-space: normal; word-break: break-word; }

/* Tableau des plateformes du cluster (cluster-table.js) — Configuration et Collecteurs. Dans la
   grille à deux colonnes de Configuration, les URL longues débordaient de la carte : le tableau
   prend la largeur de la carte, l'URL se coupe, et un défilement horizontal reste en dernier recours. */
.table-scroll { max-width: 100%; overflow-x: auto; }
.cluster-table { width: 100%; border-collapse: collapse; table-layout: auto; }
.cluster-table th, .cluster-table td { padding: 6px 8px; text-align: left; vertical-align: middle; }
.cluster-table .id { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.cluster-table .detail { color: var(--muted); font-size: 12px; }
.cluster-table .url { overflow-wrap: anywhere; word-break: break-word; min-width: 8em; }
.cluster-table .num { text-align: right; }
.cluster-table .act { width: 1%; white-space: nowrap; text-align: right; }
.cluster-table .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%;
    border: 1px solid var(--line, #cbd5e1); background: transparent; }
.cluster-table .dot.on { background: var(--mc-sketch-fill, #7bc96f); }

/* Sélecteur de nœud du cluster (node-switcher.js, B-2) + étiquettes taille/charge (B-4, B-5). */
.node-switcher { position: relative; }
.node-current.remote { border-color: var(--mc-sketch-stroke-active, #6a9f3e); font-weight: 600; }
.node-current .caret { opacity: .6; margin-left: 2px; }
.node-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 360px; max-width: 92vw;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 6px; max-height: 70vh; overflow-y: auto; }
.node-menu-hint { font-size: 11.5px; color: var(--muted); padding: 4px 8px 8px; }
.node-row { display: flex; align-items: center; gap: 4px; border-radius: 6px; }
.node-row.active, .node-item.active { background: rgba(0, 0, 0, .05); }
.node-item { flex: 1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; text-align: left;
    background: none; border: none; padding: 7px 8px; border-radius: 6px; cursor: pointer; color: inherit; font: inherit; }
.node-item:hover:not([disabled]) { background: rgba(0, 0, 0, .04); }
.node-item[disabled] { opacity: .5; cursor: default; }
.node-name { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }
.node-sub { flex-basis: 100%; padding-left: 18px; font-size: 11.5px; color: var(--muted); }
.node-sub:empty { display: none; }
.node-acts { display: flex; gap: 2px; padding-right: 4px; }
.btn.xs { padding: 2px 7px; font-size: 11.5px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--line, #cbd5e1); }
.dot.on { background: var(--mc-sketch-fill, #7bc96f); }
.size-tag { display: inline-block; min-width: 1.8em; text-align: center; font-size: 10.5px; font-weight: 700;
    border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); letter-spacing: .03em; }
.size-tag.size-xl { color: #7c3aed; border-color: #c4b5fd; }
.size-tag.size-l { color: #2563eb; border-color: #bfdbfe; }
.size-tag.size-m { color: #0d9488; border-color: #99f6e4; }
.size-tag.size-s { color: #b45309; border-color: #fcd34d; }
.load-bar { display: inline-block; width: 44px; height: 6px; border-radius: 3px; background: rgba(0, 0, 0, .08); overflow: hidden; vertical-align: middle; }
.load-bar > span { display: block; height: 100%; background: var(--mc-sketch-fill, #7bc96f); }
.load-bar.warm > span { background: #f59e0b; }
.load-bar.hot > span { background: var(--red, #dc2626); }
.view-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 8px 12px;
    border: 1px dashed var(--mc-sketch-stroke-active, #6a9f3e); border-radius: var(--radius); background: rgba(123, 201, 111, .10); font-size: 13px; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 10px; font-size: 12px; }
.tag-chip { border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; background: none; cursor: pointer; color: inherit; font: inherit; font-size: 12px; }
.tag-chip.on { background: var(--mc-sketch-fill, #7bc96f); border-color: transparent; }
.cluster-table .platform-meta { font-family: system-ui, sans-serif; white-space: normal; display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.tag-chip.static { cursor: default; font-size: 10.5px; padding: 0 7px; }
.cluster-table .services { font-size: 10.5px; color: var(--muted); }

/* « Pour le compte de » (B-2) : barre du haut rose vif quand on regarde un autre nœud. */
.topbar.on-behalf { background: #ff2d95; border-bottom-color: #d6177a; }
.topbar.on-behalf .page-title { color: #fff; }
.on-behalf-pill { display: inline-flex; align-items: center; gap: 6px; margin-left: 12px; padding: 3px 6px 3px 12px;
    border-radius: 999px; background: #fff; color: #c2136d; font-weight: 700; font-size: 13px; white-space: nowrap; }
.on-behalf-x { border: none; background: #ffe0f0; color: #c2136d; border-radius: 50%; width: 20px; height: 20px;
    line-height: 20px; padding: 0; cursor: pointer; font-size: 11px; }
.on-behalf-x:hover { background: #c2136d; color: #fff; }
.node-current { white-space: nowrap; }
.topbar.on-behalf .badge, .topbar.on-behalf .btn { background: #fff; }

/* Fiabilité des pairs (B-13) : attache réseau et disponibilité sur 24 h. */
.cluster-table td.reliability { white-space: nowrap; }
.link-tag { font-size: 12px; margin-right: 4px; }
.link-tag.wifi.weak { color: #c0392b; font-weight: 600; }
.avail { font-variant-numeric: tabular-nums; padding: 1px 6px; border-radius: 9px; font-size: 12px; }
.avail.good { background: #e6f4ea; color: #1e7e34; }
.avail.fair { background: #fff4d6; color: #8a6100; }
.avail.poor { background: #fde2e1; color: #b3261e; }
