:root {
    --bg: #f4f6f9;
    --panel: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --accent: #4f6ef7;
    --accent-rgb: 79, 110, 247;
    --green: #16a34a;
    --green-rgb: 22, 163, 74;
    --red: #dc2626;
    --red-rgb: 220, 38, 38;
    --warning: #d97706;
    --warning-rgb: 217, 119, 6;
}
* { box-sizing: border-box; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
    margin: 0;
}
h1, h2 { font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }

/* ---------- Layout : sidebar + contenu ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px; padding: 20px 18px; font-weight: 700;
    font-family: -apple-system, "Segoe UI", Roboto, sans-serif; border-bottom: 1px solid var(--border);
    color: var(--text);
}
.sidebar-brand img { height: 22px; display: block; }
.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: block; padding: 9px 12px; margin-bottom: 2px; border-radius: 8px; color: var(--muted);
    text-decoration: none; font-size: 0.88em; border-left: 3px solid transparent;
}
.sidebar-nav a:hover { color: var(--text); background: rgba(var(--accent-rgb), 0.06); }
.sidebar-nav a.active { color: var(--accent); background: rgba(var(--accent-rgb), 0.1); border-left-color: var(--accent); font-weight: 600; }
/* Sections toujours visibles (plus de menu "Config" à déplier) - un simple libellé de section
   suivi de ses liens, comme demandé le 2026-07-17 pour "y voir plus clair" d'un coup d'œil plutôt
   que de devoir ouvrir un accordéon unique regroupant tout. */
.sidebar-section-label {
    font-size: 0.7em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted);
    opacity: 0.75; padding: 16px 12px 6px; font-weight: 700; margin-top: 4px; border-top: 1px solid var(--border);
}
.sidebar-section-label:first-child { border-top: none; margin-top: 0; }
.sidebar-user {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 16px; border-top: 1px solid var(--border);
}
.sidebar-user-name { font-size: 0.85em; color: var(--text); font-weight: 600; }
.sidebar-user-role { font-size: 0.75em; color: var(--muted); }
.sidebar-toggle {
    display: none; margin-left: auto; background: none; border: 1px solid var(--border);
    color: var(--text); font-size: 1.2em; line-height: 1; padding: 6px 10px; border-radius: 8px; cursor: pointer;
}
.content { flex: 1; min-width: 0; }
.container { max-width: 1200px; margin: 0 auto; padding: 28px 32px; }

.page-header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.live-indicator { font-size: 0.8em; color: var(--muted); white-space: nowrap; }
.live-indicator .dot {
    display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green);
    margin-right: 6px; box-shadow: 0 0 6px rgba(var(--green-rgb), 0.5);
}

.site-link-form { display: flex; gap: 6px; align-items: center; }
.site-link-form select { font-size: 0.85em; padding: 4px 6px; }

.omada-template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 12px 0 8px; align-items: start; }
.omada-diagram {
    background: var(--panel); border: 1px dashed var(--border); border-radius: 12px; padding: 16px;
}
.omada-diagram-section {
    border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 12px; background: #fafbfc;
}
.omada-diagram-section strong { display: block; font-size: 0.85em; margin-bottom: 6px; }
.omada-diagram-field {
    display: flex; justify-content: space-between; padding: 5px 8px; margin: 4px 0; font-size: 0.85em;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--muted);
}
.omada-diagram-field span { color: var(--accent); font-weight: 600; }
.omada-fields { display: flex; flex-direction: column; gap: 8px; }
.field-row {
    display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 10px;
}
.field-num {
    background: var(--accent); color: #ffffff; font-size: 0.75em; font-weight: 700; border-radius: 50%;
    width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.field-label { font-size: 0.85em; color: var(--muted); min-width: 110px; flex-shrink: 0; }
.field-row code {
    flex: 1; font-size: 0.82em; background: #f1f3f6; padding: 4px 8px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    border-radius: 6px; overflow-x: auto; white-space: nowrap; color: var(--text);
}
h1 { margin-top: 0; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); }
.hint { color: var(--muted); font-size: 0.9em; }
table { width: 100%; border-collapse: collapse; margin: 16px 0 32px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 0.85em; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbfc; }
th { color: var(--muted); font-weight: 600; text-transform: uppercase; font-size: 0.72em; letter-spacing: 0.04em; background: #fafbfc; }
a { color: var(--accent); }
.badge { padding: 3px 10px; border-radius: 20px; font-size: 0.8em; font-weight: 600; }
.badge.online { background: rgba(var(--green-rgb), 0.12); color: var(--green); }
.badge.offline { background: rgba(var(--red-rgb), 0.1); color: var(--red); }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.status-dot.online { background: var(--green); box-shadow: 0 0 5px rgba(var(--green-rgb), 0.5); }
.status-dot.offline { background: #cbd2d9; }
.cards { display: flex; gap: 16px; margin-bottom: 24px; }
.card {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px;
    min-width: 200px; flex: 1; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.card-value { font-size: 1.8em; font-weight: 700; color: var(--text); }
.card-label { color: var(--muted); font-size: 0.72em; text-transform: uppercase; letter-spacing: 0.04em; margin-top: 4px; }
.usage-card { min-width: 130px; }
.usage-card .card-value { font-size: 1.1em; font-weight: 600; line-height: 1.4; }

.bw-chart-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; margin: 12px 0 28px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.bw-window-buttons { display: flex; gap: 6px; margin-bottom: 14px; }
.bw-window-btn.active { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.08); }
.bw-chart-wrap { position: relative; }
#bw-chart { width: 100%; height: 240px; display: block; }
.bw-tooltip {
    position: absolute; pointer-events: none; background: #1f2937; color: #f3f4f6; border: 1px solid #374151;
    border-radius: 8px; padding: 6px 10px; font-size: 0.78em; z-index: 5; white-space: nowrap;
}
.bw-tooltip .bw-tooltip-row { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
.bw-tooltip .bw-swatch { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.bw-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.bw-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.82em; }
.bw-legend-item .bw-swatch { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bw-legend-name { color: var(--text); }
.bw-legend-stat { color: var(--muted); }

.meter-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px 22px; min-width: 220px; flex: 1; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.meter-label { color: var(--text); font-size: 0.85em; margin-bottom: 2px; font-family: -apple-system, "Segoe UI", Roboto, sans-serif; }
.meter-value { font-size: 1.7em; font-weight: 700; margin-bottom: 10px; color: var(--text); }
.meter-track { background: #eef0f3; border-radius: 6px; height: 8px; overflow: hidden; }
.meter-fill { height: 100%; border-radius: 6px; transition: width 0.4s ease; }
.meter-fill.good { background: var(--green); }
.meter-fill.warning { background: var(--warning); }
.meter-fill.critical { background: var(--red); }
.meter-detail { margin-top: 8px; font-size: 0.78em; color: var(--muted); }
form.inline-form, form.grid-form {
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
    padding: 16px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
form.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
form.grid-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
form.grid-form label { display: block; font-size: 0.8em; color: var(--muted); margin-bottom: 4px; }
input, select, button {
    background: #ffffff; color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px; font-size: 0.9em; font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12); }
button { background: var(--accent); color: #ffffff; border: none; cursor: pointer; font-weight: 600; }
button:hover { filter: brightness(1.08); }
button.danger { background: var(--red); color: white; }
form.inline { display: inline; }
td.actions form, td.actions a { margin-right: 8px; }

.btn {
    display: inline-block; padding: 5px 12px; font-size: 0.8em; font-weight: 600;
    border-radius: 8px; border: 1px solid var(--border); background: var(--panel);
    color: var(--muted); text-decoration: none; cursor: pointer; line-height: 1.5;
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(var(--accent-rgb), 0.06); }
.btn.btn-red:hover { border-color: var(--red); color: var(--red); background: rgba(var(--red-rgb), 0.06); }
td.actions .btn, .tunnel-mode-box .btn { margin-right: 6px; }
.login-box { max-width: 340px; margin: 80px auto; background: var(--panel); padding: 28px; border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 8px 30px rgba(16, 24, 40, 0.08); text-align: center; }
.login-box--inline { margin: 40px auto; }
.login-box img { height: 44px; margin-bottom: 12px; }
.login-box h1 { font-size: 1.3em; }
.login-box form { text-align: left; }
.login-box form { display: flex; flex-direction: column; gap: 10px; }
/* Page Paramètres : barre d'onglets (ancres vers les sections plus bas) plutôt que des pages
   séparées à parcourir une par une depuis la sidebar - inspiré du Syslog Server (2026-07-17). */
.settings-tabs {
    display: flex; gap: 4px; flex-wrap: wrap; background: var(--panel); border: 1px solid var(--border);
    border-radius: 12px; padding: 6px; margin: 16px 0 28px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.settings-tabs a {
    padding: 8px 16px; border-radius: 8px; color: var(--muted); text-decoration: none;
    font-size: 0.88em; font-weight: 600;
}
.settings-tabs a:hover { color: var(--text); background: #f4f6f9; }
.settings-section { scroll-margin-top: 20px; padding-top: 6px; margin-bottom: 8px; }
.settings-section:not(:first-of-type) { border-top: 1px solid var(--border); padding-top: 28px; margin-top: 8px; }
.settings-section h2 { margin-bottom: 4px; }
.settings-section h3 { font-size: 1em; color: var(--text); margin-bottom: 8px; }
.error { color: var(--red); }
.qr-block { display: flex; align-items: center; gap: 20px; margin: 16px 0; }
.conf-block { background: #f7f8fa; padding: 16px; border-radius: 10px; overflow-x: auto; border: 1px solid var(--border); color: var(--text); font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace; }
.bulk-create { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.bulk-create h2 { margin-top: 0; font-size: 1.1em; }
.bulk-create form.grid-form { margin-top: 12px; box-shadow: none; border: none; padding: 0; }
.checkbox-field { display: flex; align-items: center; }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 8px 20px; padding: 8px 0; }
.checkbox-grid label { display: flex; align-items: center; gap: 6px; font-size: 0.85em; color: var(--text); }
.checkbox-field label { display: flex !important; align-items: center; gap: 6px; font-size: 0.85em; color: var(--text); margin-bottom: 0 !important; }
.checkbox-field input[type="checkbox"] { width: auto; }
.cancel-link { margin-left: 12px; color: var(--muted); }
.tunnel-mode-box { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin: 16px 0; max-width: 720px; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); }
.tunnel-mode-box form { margin-top: 8px; }
.tunnel-mode-box p { margin: 6px 0; }
.full-width { grid-column: 1 / -1; }
.edit-link { font-size: 0.5em; margin-left: 12px; color: var(--accent); vertical-align: middle; }

.list-controls {
    display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap;
}
.list-controls input[type="search"] { min-width: 220px; }
.list-controls .spacer { flex: 1; }
.list-controls label { font-size: 0.85em; color: var(--muted); }
.pagination { display: flex; align-items: center; gap: 10px; margin: 12px 0 28px; font-size: 0.88em; }
.pagination a.btn.disabled { pointer-events: none; opacity: 0.4; }
.pagination .page-info { color: var(--muted); }

img { max-width: 100%; }

/* ---------- Extensions api.link-b.fr : statuts de synchro (4 états, pas juste online/offline) ----------
   Même schéma de couleurs que .badge.online/.offline de LinkGate (variables --green-rgb/--red-rgb/
   --accent-rgb/muted), étendu pour les états propres à la synchro Vilogi. */
/* Fieldsets de champs par type de connecteur (voir _connector_fields.html) : transparents pour
   la grille .grid-form du parent (display:contents), mais [hidden] doit rester prioritaire pour
   les types non sélectionnés - deux sélecteurs d'attribut battent le seul display:contents. */
.grid-form fieldset[data-connector-fields] { border: none; padding: 0; margin: 0; display: contents; }
.grid-form fieldset[data-connector-fields][hidden] { display: none; }

.badge.ok { background: rgba(var(--green-rgb), 0.12); color: var(--green); }
.badge.error { background: rgba(var(--red-rgb), 0.1); color: var(--red); }
.badge.running { background: rgba(var(--accent-rgb), 0.1); color: var(--accent); }
.badge.never { background: #eef0f3; color: var(--muted); }

@media (max-width: 900px) {
    /* Sidebar repliée en barre + bouton menu (hamburger) plutôt qu'un empilement de liens en
       flex-wrap : sur un écran de téléphone étroit, le flex-wrap forçait chaque lien dans une
       colonne trop étroite et coupait le texte des libellés sur 2 lignes (illisible - constaté
       le 2026-07-16). Ouvert/fermé via .sidebar.mobile-open (bouton dans .sidebar-brand). */
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar-brand { border-bottom: none; padding: 14px; }
    .sidebar-toggle { display: block; }
    .sidebar-nav, .sidebar-user { display: none; }
    .sidebar.mobile-open .sidebar-nav { display: block; }
    .sidebar.mobile-open .sidebar-user { display: flex; border-top: 1px solid var(--border); }
}

@media (max-width: 760px) {
    .container { padding: 16px; }
    .cards { flex-wrap: wrap; }
    .card { flex: 1 1 45%; min-width: 140px; }
    .meter-card { flex: 1 1 100%; min-width: 0; }
    form.grid-form { grid-template-columns: 1fr; }
    form.inline-form { flex-direction: column; align-items: stretch; }
    form.inline-form input, form.inline-form select, form.inline-form button { width: 100%; }
    table { display: block; overflow-x: auto; white-space: nowrap; }
    .login-box { max-width: none; margin: 32px 16px; }
    .qr-block { flex-direction: column; align-items: flex-start; }
    .list-controls { flex-direction: column; align-items: stretch; }
    .list-controls input[type="search"] { min-width: 0; width: 100%; }
    .omada-template-grid { grid-template-columns: 1fr; }
    .field-row { flex-wrap: wrap; }
    .field-row code { width: 100%; order: 3; }
}
