:root {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e3e6eb;
  --text: #14171c;
  --text-2: #4f5663;
  --text-3: #858c99;
  --accent: #1f5fae;
  --accent-soft: #e6eefa;
  --nav-bg: #13263f;
  --nav-text: #c9d4e3;
  --good: #1a7f37; --good-soft: #e3f4e8;
  --warn: #9a6400; --warn-soft: #fdf2d8;
  --bad: #b42318;  --bad-soft: #fde8e6;
  --rack: #2b2f36; --rack-rail: #1d2026; --panel: #3a3f48; --port-empty: #5b616c;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121314; --surface: #1a1a19; --surface-2: #222321; --border: #33342f;
    --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8e86;
    --accent: #6aa5ef; --accent-soft: #1e2b3d; --nav-bg: #0c0d0e; --nav-text: #b9b8b0;
    --good: #5cc27a; --good-soft: #17301f; --warn: #e3b04b; --warn-soft: #33290f; --bad: #f07a6e; --bad-soft: #3a1c19;
    --rack: #0f1013; --rack-rail: #08090a; --panel: #262a31; --port-empty: #444a54;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121314; --surface: #1a1a19; --surface-2: #222321; --border: #33342f;
  --text: #f0efec; --text-2: #c3c2b7; --text-3: #8f8e86;
  --accent: #6aa5ef; --accent-soft: #1e2b3d; --nav-bg: #0c0d0e; --nav-text: #b9b8b0;
  --good: #5cc27a; --good-soft: #17301f; --warn: #e3b04b; --warn-soft: #33290f; --bad: #f07a6e; --bad-soft: #3a1c19;
  --rack: #0f1013; --rack-rail: #08090a; --panel: #262a31; --port-empty: #444a54;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1rem; margin: 0 0 12px; }
h3 { font-size: .92rem; margin: 0; }
.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }

/* ── Layout ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.side-nav {
  width: 220px; flex-shrink: 0; background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 22px; color: #fff; font-weight: 700; font-size: 1.02rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #f0a500; color: #13263f; display: grid; place-items: center; font-weight: 800; }
.brand small { display: block; font-weight: 400; font-size: .72rem; color: var(--nav-text); }
.nav-links { list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px;
  color: var(--nav-text); font-weight: 500; margin-bottom: 2px;
}
.nav-links a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-links a.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; font-size: .85rem; }
.nav-foot a, .nav-foot button { color: var(--nav-text); background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 8px; cursor: pointer; font: inherit; }
.nav-foot a:hover, .nav-foot button:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-user { padding: 4px 10px 8px; color: var(--nav-text); opacity: .75; font-size: .8rem; }
.nav-user:empty { display: none; }

/* Compte en lecture seule : on ne garde que la consultation */
body.lecture .admin-only,
body.lecture .main .btn:not(.ro-ok),
body.lecture .modal .btn:not(.ro-ok):not([onclick^="App.closeModal"]),
body.lecture .move, body.lecture .dropzone { display: none !important; }
body.lecture input:disabled, body.lecture select:disabled, body.lecture textarea:disabled { opacity: 1; color: var(--text); cursor: default; }

/* Double authentification */
.otp-steps { padding-left: 20px; margin: 0 0 12px; display: grid; gap: 10px; font-size: .9rem; }
.otp-qr { background: #fff; border-radius: 8px; padding: 6px; width: 180px; margin: 8px 0; }
.otp-qr svg { display: block; width: 100%; height: auto; }
.otp-key { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; background: var(--accent-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.otp-input { font-family: ui-monospace, Consolas, monospace; font-size: 1.4rem; letter-spacing: .3em; text-align: center; }

/* Filtre par catégories (pastilles) */
.cat-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 12px; }
.cat-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: inherit; font-size: .82rem; cursor: pointer; }
.cat-chip .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-sizing: border-box; }
.cat-chip b { font-weight: 600; color: var(--text-3); }
.cat-chip:hover { border-color: var(--accent); }
.cat-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cat-chip.on b { color: var(--accent); }
.cat-chip.vide:not(.on) { opacity: .5; }
.cat-chip.reset { border-style: dashed; color: var(--text-3); }

/* Colonnes redimensionnables */
table.resizable { table-layout: fixed; min-width: 100%; }
table.resizable th { position: relative; overflow: hidden; text-overflow: ellipsis; }
table.resizable td { overflow: hidden; overflow-wrap: anywhere; }
table.resizable input, table.resizable select { width: 100%; min-width: 0; box-sizing: border-box; }
.col-resize { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: col-resize; touch-action: none; }
.col-resize::after { content: ''; position: absolute; top: 25%; bottom: 25%; right: 3px; width: 2px; border-radius: 2px; background: var(--border); }
.col-resize:hover::after, .col-resize:active::after { background: var(--accent); top: 0; bottom: 0; }
th[draggable="true"] { cursor: grab; }
th.th-drag { opacity: .4; }
th.th-avant { box-shadow: inset 3px 0 0 var(--accent); }
th.th-apres { box-shadow: inset -3px 0 0 var(--accent); }

/* Barre de défilement horizontal en haut des tableaux larges, collée en haut de l'écran */
.top-scroll { position: sticky; top: 0; z-index: 5; overflow-x: auto; overflow-y: hidden; height: 16px;
  background: var(--surface); border-bottom: 1px solid var(--border); margin-bottom: 2px; }
.top-scroll > div { height: 1px; }

/* Bouton œil (afficher / masquer un mot de passe) */
.eye-btn { padding: 4px 8px; display: inline-flex; align-items: center; justify-content: center; min-width: 34px; }
.eye-btn svg { display: block; }
.pwd-cell { display: inline-flex; align-items: center; gap: 4px; }
.pwd-cell [data-pwd-val] { min-width: 80px; }

/* Page Utilisateurs */
.role-badge.admin { background: var(--accent-soft); color: var(--accent); }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check-list label { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 500; }
.check-list input { width: auto; }
.check-list.scroll { max-height: 180px; overflow: auto; flex-direction: column; flex-wrap: nowrap; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.main { flex: 1; min-width: 0; padding: 26px 30px 60px; max-width: 1500px; }
/* Onglets en tableau : toute la largeur de l'écran pour limiter le défilement horizontal */
.main:has(#tab-brassage.active, #tab-equipements.active, #tab-ip.active) { max-width: none; padding-left: 22px; padding-right: 22px; }
.main:has(#tab-brassage.active, #tab-equipements.active, #tab-ip.active) .card:has(> .table-wrap) { padding-left: 12px; padding-right: 12px; }
table.resizable th { padding-left: 6px; padding-right: 9px; font-size: .7rem; letter-spacing: .02em; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .side-nav { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; flex-wrap: wrap; }
  .brand { padding: 0; }
  .nav-links { display: flex; gap: 4px; }
  .nav-foot { margin: 0 0 0 auto; flex-direction: row; }
  .main { padding: 18px 16px 50px; }
}

/* ── Cards, boutons, formulaires ─────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid transparent;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); filter: none; }
.btn.danger { background: var(--bad); }
.btn.ghost { background: none; color: var(--text-2); border-color: transparent; padding: 6px 8px; }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn:disabled { opacity: .5; cursor: default; }

label { display: block; font-size: .8rem; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  color: var(--text); font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type="color"] { padding: 2px; height: 36px; width: 48px; }
input[type="checkbox"] { width: auto; }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 14px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; } }
.field-row { display: flex; gap: 8px; align-items: center; }
.search { max-width: 320px; }

/* ── Tableaux ─────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); font-weight: 600; white-space: nowrap; cursor: default; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.tri-asc, th.tri-desc { color: var(--accent, var(--text)); }
th .tri-fleche { margin-left: 4px; font-size: .7em; }
@media print { th .tri-fleche { display: none; } }
tbody tr:hover { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
td.empty { text-align: center; color: var(--text-3); padding: 28px; }
td.num, th.num { text-align: right; }
table.edit td { padding: 4px 6px; }
table.edit input, table.edit select { padding: 5px 7px; font-size: .88rem; border-color: transparent; background: transparent; }
table.edit input:hover, table.edit select:hover { border-color: var(--border); }
#tBrassage select { min-width: 125px; }
#tBrassage select[data-f="switchId"], #tBrassage select[data-f="equipementId"] { min-width: 175px; }
#tBrassage input[data-f="priseMurale"], #tBrassage input[data-f="note"] { min-width: 120px; }
table.edit input:focus, table.edit select:focus { background: var(--surface); }
tr.saved td { animation: flash 1s; }
@keyframes flash { from { background: var(--good-soft); } }
tr.dup td { background: var(--bad-soft); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex-shrink: 0; }

/* ── Onglets ──────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600;
  color: var(--text-3); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Liste des clients ────────────────────────────────── */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.client-card { display: block; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.client-card:hover { border-color: var(--accent); }
.client-card h3 { font-size: 1.02rem; margin-bottom: 4px; }
.client-card .stats { display: flex; gap: 14px; margin-top: 10px; color: var(--text-2); font-size: .85rem; }
.client-card .stats b { color: var(--text); }
.results { list-style: none; margin: 0; padding: 0; }
.results li a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; color: inherit; }
.results li a:hover { background: var(--surface-2); }

/* ── Baie (rack) ──────────────────────────────────────── */
.baies-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 16px; align-items: start; }
@media (max-width: 1100px) { .baies-layout { grid-template-columns: 1fr; } }
.rack { background: var(--rack); border-radius: 10px; padding: 10px 26px; position: relative; margin-bottom: 18px; }
.rack::before, .rack::after { content: ""; position: absolute; top: 8px; bottom: 8px; width: 14px; background: repeating-linear-gradient(var(--rack-rail) 0 6px, #555b66 6px 8px, var(--rack-rail) 8px 14px); border-radius: 3px; }
.rack::before { left: 6px; } .rack::after { right: 6px; }
.rack-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: #fff; padding: 2px 0 10px; flex-wrap: wrap; }
.rack-head h2 { margin: 0; color: #fff; }
.rack-head .muted { color: #a9b0bc; }
.rack-head .btn.ghost { color: #c9d0db; }
.rack-head .btn.ghost:hover { background: rgba(255,255,255,.08); color: #fff; }
.rack-empty { color: #a9b0bc; text-align: center; padding: 18px; border: 1px dashed #555b66; border-radius: 8px; }

/* Bandeau de brassage */
.pp { background: var(--panel); border-radius: 6px; padding: 8px 10px 10px; margin-bottom: 8px; color: #e7eaf0; box-shadow: inset 0 1px 0 rgba(255,255,255,.06); }
.pp-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: .82rem; }
.pp-code { background: #f0a500; color: #13263f; font-weight: 800; border-radius: 4px; padding: 0 7px; min-width: 26px; text-align: center; }
.pp-name { font-weight: 600; }
.pp-fill { color: #a9b0bc; }
.move { display: inline-flex; gap: 0; flex-shrink: 0; }
.move .btn.ghost, .pp-head .move .btn.ghost { padding: 2px 6px; margin-left: 0; }
.pp-head .move { margin-left: auto; }
.pp-head .move + .btn.ghost { margin-left: 0; }
.rack-eq .move { margin-left: 4px; }
.pp-notes { color: #e8d9a8; font-style: italic; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-head .btn.ghost { color: #c9d0db; padding: 2px 6px; margin-left: auto; }
.pp-head .btn.ghost + .btn.ghost { margin-left: 0; }
.pp-head .btn.ghost:hover { background: rgba(255,255,255,.1); color: #fff; }
.pp-grid { display: grid; grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr)); gap: 6px 5px; }
@media (max-width: 700px) { .pp-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

.port {
  --c: var(--port-empty);
  appearance: none; border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: default;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; text-align: center;
}
.editable .port { cursor: pointer; }
.port .jack {
  width: 100%; max-width: 44px; aspect-ratio: 1.15; border-radius: 4px; background: #15171b; position: relative;
  border: 3px solid var(--c); display: grid; place-items: center; transition: transform .1s;
}
/* forme de prise RJ45 */
.port .jack::before { content: ""; width: 58%; height: 50%; background: var(--c); border-radius: 2px 2px 0 0; clip-path: polygon(0 25%, 25% 25%, 25% 0, 75% 0, 75% 25%, 100% 25%, 100% 100%, 0 100%); opacity: .9; }
.port.empty .jack { border-color: var(--port-empty); }
.port.empty .jack::before { background: #2a2e35; }
.port .num { font-size: .7rem; font-weight: 700; color: #c9d0db; line-height: 1; }
.port .lbl { font-size: .66rem; line-height: 1.15; color: #e7eaf0; width: 100%; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; min-height: 1.5em; word-break: break-word; }
.port.empty .lbl { color: #7d8490; }
.port.st-standby .jack { background: repeating-linear-gradient(45deg, #15171b 0 4px, #3a3f48 4px 8px); }
.port.st-standby .jack::before { opacity: .45; }
.port.st-defaut .jack { border-color: #ff4d4d; box-shadow: 0 0 0 2px rgba(255,77,77,.35); }
.port.st-defaut .jack::after { content: "!"; position: absolute; color: #fff; background: #e03131; border-radius: 50%; width: 14px; height: 14px; font-size: 10px; font-weight: 800; display: grid; place-items: center; top: -7px; right: -7px; }
.port.st-libre .jack { border-style: dashed; }
.port.hit .jack { outline: 3px solid #fff; outline-offset: 2px; }
.editable .port:hover .jack { transform: translateY(-2px); }
.port.drop .jack { outline: 3px dashed #f0a500; outline-offset: 2px; }
.port.dup .jack { box-shadow: 0 0 0 3px #f0a500; }
/* Matériel hors ligne (dernier état UniFi) : prise qui clignote en rouge */
@keyframes clignote-hl {
  0%, 100% { box-shadow: 0 0 0 3px #ff3b3b, 0 0 10px 2px rgba(255,59,59,.75); border-color: #ff3b3b; }
  50% { box-shadow: 0 0 0 3px rgba(255,59,59,.15), 0 0 0 0 rgba(255,59,59,0); border-color: transparent; }
}
.port.hors-ligne .jack { animation: clignote-hl 1.2s ease-in-out infinite; }
.port.hors-ligne .jack::before { animation: clignote-badge 1.2s ease-in-out infinite; }
.port.hors-ligne .lbl { color: #ff6b6b; }
.sw.sw-hors-ligne { box-shadow: inset 0 0 0 2px #ff3b3b; animation: clignote-sw 1.6s ease-in-out infinite; }
@keyframes clignote-sw { 50% { box-shadow: inset 0 0 0 2px rgba(255,59,59,.2); } }
.hl-badge { background: #e03131; color: #fff; border-radius: 99px; padding: 1px 8px; font-size: .72rem; font-weight: 700; animation: clignote-badge 1.2s ease-in-out infinite; }
@keyframes clignote-badge { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .port.hors-ligne .jack, .port.hors-ligne .jack::before, .sw.sw-hors-ligne, .hl-badge { animation: none; }
  .port.hors-ligne .jack { box-shadow: 0 0 0 3px #ff3b3b; }
}
@media print { .port.hors-ligne .jack, .port.hors-ligne .jack::before, .sw.sw-hors-ligne, .hl-badge { animation: none; } }

/* Équipement monté en baie */
.rack-eq { display: flex; align-items: center; gap: 10px; background: #4a505b; color: #fff; border-radius: 6px; padding: 8px 12px; margin-bottom: 8px; border-left: 5px solid var(--c, #858c99); }
.rack-eq .u { font-size: .72rem; color: #c9d0db; min-width: 28px; }
.rack-eq .meta { color: #c9d0db; font-size: .8rem; margin-left: auto; text-align: right; }
.rack-eq.clickable { cursor: pointer; }
.rack-eq.clickable:hover { filter: brightness(1.12); }

/* Liste latérale glissable */
.eq-list { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
.eq-list li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: .86rem; cursor: grab; border: 1px solid transparent; }
.eq-list li:hover { background: var(--surface-2); border-color: var(--border); }
.eq-list li small { color: var(--text-3); margin-left: auto; white-space: nowrap; }

/* Légende */
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; margin: 0 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { font-weight: 700; }
.legend .hatch { width: 12px; height: 12px; border-radius: 3px; background: repeating-linear-gradient(45deg, #15171b 0 3px, #8a909b 3px 6px); }

/* Switch */
.sw { background: var(--panel); border-radius: 8px; padding: 10px 12px 12px; margin-bottom: 14px; color: #e7eaf0; }
.sw-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; font-size: .85rem; }
.sw-head h3 { color: #fff; font-size: .95rem; }
.sw-head .pp-fill { margin-left: auto; }
/* Face avant d'un switch façon UniFi : impairs en haut, pairs en bas, blocs de ports, uplinks à part */
.sw-face { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 6px; }
.sw-grp { display: grid; grid-auto-flow: column; grid-template-rows: auto auto; grid-auto-columns: minmax(36px, 1fr); gap: 3px 4px; min-width: 0; }
.sw-grp.une-rangee { grid-template-rows: auto; grid-auto-columns: minmax(60px, 110px); flex: none !important; }
.port.fp .pnom { font-size: .64rem; font-weight: 700; color: #c9d0db; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sw-grp.lineaire { flex: 1 1 auto; grid-template-rows: auto; grid-template-columns: repeat(var(--n), minmax(20px, 1fr)); grid-auto-flow: row; align-items: center; gap: 0 3px; min-width: calc(var(--n) * 23px); }
.sw-face:has(> .lineaire) { padding: 2px 4px 4px; }
/* Aux deux extrémités, le libellé s'étend vers l'intérieur pour ne pas sortir du bandeau */
.sw-grp.lineaire .port.fp:first-child .lbl, .sw-grp.lineaire .port.fp:nth-child(2) .lbl { width: 150%; margin: 0 -50% 0 0; text-align: left; }
.sw-grp.lineaire .port.fp:last-child .lbl, .sw-grp.lineaire .port.fp:nth-last-child(2) .lbl { width: 150%; margin: 0 0 0 -50%; text-align: right; }
/* Libellé sur deux largeurs de port (les voisins ont le leur de l'autre côté) */
.sw-grp.lineaire .port.fp { overflow: visible; display: grid; grid-template-rows: 1.3em auto 1.3em; justify-items: center; align-items: center; }
.sw-grp.lineaire .port.fp .jack { grid-row: 2; width: 100%; }
.sw-grp.lineaire .port.fp.haut .lbl { grid-row: 1; }
.sw-grp.lineaire .port.fp.bas .lbl { grid-row: 3; }
.sw-grp.lineaire .port.fp .lbl { width: 200%; margin: 0 -50%; text-align: center; }
.sw-grp.uplink { padding-left: 12px; border-left: 1px dashed #5b616c; }
.port.fp { gap: 3px; }
.port.fp .jack { max-width: 40px; }
.port.fp .num { position: absolute; left: 3px; bottom: 1px; font-size: .62rem; color: #fff; text-shadow: 0 0 3px #000, 0 0 2px #000; z-index: 1; }
.port.fp.empty .num { color: #9aa1ad; }
.sw .port.fp .lbl, .pp .port.fp .lbl { display: block; -webkit-line-clamp: unset; min-height: 1.25em; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: .62rem; }
.sw-grp.une-rangee .port.fp .lbl { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; min-height: 2.3em; }
.sw-grp.uplink .port.fp .jack::before { clip-path: none; width: 70%; height: 32%; border-radius: 1px; }

/* Couleur propre à chaque switch : bande à gauche de sa vue + fond des lignes du tableau de brassage */
.sw-colore[style*="--swc:#"] { box-shadow: inset 6px 0 0 var(--swc); padding-left: 18px; }
.sw-pastille { width: 12px; height: 12px; border-radius: 50%; background: var(--swc); flex: none; }
tr.sw-row[style*="--swc"] > td { background: color-mix(in srgb, var(--swc) 14%, transparent); }
tr.sw-row[style*="--swc"] > td:first-child { box-shadow: inset 4px 0 0 var(--swc); }
tr.baie-debut > td { border-top: 3px solid var(--text-3); }
td.baie-cell { font-weight: 600; font-size: .82rem; white-space: nowrap; text-overflow: ellipsis; }
tr.sw-row[style*="--swc"]:hover > td { background: color-mix(in srgb, var(--swc) 22%, transparent); }
.sw-chip.on { background: color-mix(in srgb, var(--swc, var(--accent)) 20%, transparent); border-color: var(--swc, var(--accent)); color: var(--text); }
@media print { tr.sw-row[style*="--swc"] > td { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
.sw .port .lbl { -webkit-line-clamp: 3; min-height: 2.3em; }
.uplink { font-size: .8rem; color: #c9d0db; }

/* Infobulle */
.tip {
  position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: .82rem; box-shadow: 0 6px 24px rgba(0,0,0,.18); max-width: 300px; display: none;
}
.tip b { display: block; margin-bottom: 2px; }
.tip div { color: var(--text-2); }

/* ── Fenêtres ─────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgba(10,14,20,.45); display: none; align-items: flex-start; justify-content: center; z-index: 50; padding: 5vh 16px; overflow-y: auto; }
.modal-back.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 620px; padding: 20px 22px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-bottom: 16px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; align-items: center; }
.modal-foot .left { margin-right: auto; }
.section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 18px 0 8px; font-weight: 700; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--nav-bg); color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 200; display: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

/* Documents */
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.doc .thumb { height: 150px; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; color: var(--text-3); font-weight: 700; }
.doc .thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc .body { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.doc .body input { padding: 4px 6px; }
.doc .row { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: .8rem; color: var(--text-3); }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--text-3); margin-bottom: 14px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* Duplication de port */
.dup-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
@media (max-width: 640px) { .dup-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.dup-grid button { font: inherit; font-size: .78rem; font-weight: 600; padding: 4px 0; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.dup-grid button.used { border-color: var(--text-3); color: var(--text); }
.dup-grid button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.dup-grid button.on.used { background: var(--warn); border-color: var(--warn); }
.dup-grid button.self { background: var(--text); color: var(--surface); border-color: var(--text); cursor: default; }

/* Catégories */
.cat-row { display: grid; grid-template-columns: 48px 1fr auto; gap: 8px; align-items: center; margin-bottom: 6px; }
.share-box { display: flex; gap: 8px; align-items: center; }
.share-box input { font-family: ui-monospace, Consolas, monospace; font-size: .82rem; }

/* Connexion */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; }
.login .brand { color: var(--text); padding: 0 0 18px; }
.login .brand small { color: var(--text-3); }
.error { color: var(--bad); font-size: .88rem; min-height: 1.2em; margin: 8px 0 0; }

/* ── Impression ───────────────────────────────────────── */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; font-size: 11px; }
  .side-nav, .tabs, .no-print, .btn, .eq-side, .modal-back, .toast { display: none !important; }
  .main { padding: 0; max-width: none; }
  .print-only { display: block; }
  .tab-panel { display: none !important; }
  .tab-panel.active { display: block !important; }
  .baies-layout { grid-template-columns: 1fr; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .rack, .pp, .sw { -webkit-print-color-adjust: exact; print-color-adjust: exact; break-inside: avoid; }
  .pp-grid { grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr)) !important; }
  table.edit input, table.edit select { border: 0; appearance: none; padding: 0; }
}

/* VLAN déduit du sous-réseau (réseaux UniFi) */
.vlan-auto b { font-weight: 600; font-style: italic; }
.vlan-auto .muted { font-style: italic; }

