/* ============================================================
   SAGT / Trafixys — Feuille de style
   Palette : bleu Trafixys #2E86C1 · sidebar slate #1e293b
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #2E86C1;
    --primary-hover:  #2471A3;
    --primary-light:  #EBF5FB;
    --accent:         #7CB342;
    --accent-hover:   #689F38;
    --danger:         #dc2626;
    --danger-hover:   #b91c1c;
    --danger-light:   #fef2f2;
    --warning:        #d97706;
    --warning-light:  #fffbeb;
    --success:        #16a34a;
    --success-light:  #f0fdf4;

    --sidebar-w:  250px;
    --topbar-h:   56px;
    --bg:         #ffffff;
    --surface:    #f8fafc;
    --border:     #e2e8f0;
    --shadow:     0 1px 4px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:  0 4px 16px rgba(0,0,0,.09), 0 2px 6px rgba(0,0,0,.05);

    --text:    #0f172a;
    --muted:   #64748b;
    --radius:  10px;

    /* Sidebar dark */
    --sb-bg:           #1e293b;
    --sb-border:       rgba(255,255,255,.07);
    --sb-text:         #94a3b8;
    --sb-text-hover:   #e2e8f0;
    --sb-hover-bg:     rgba(255,255,255,.05);
    --sb-active-bg:    rgba(46,134,193,.18);
    --sb-active-text:  #bfdbfe;
    --sb-active-border:#2E86C1;
    --sb-sub-bg:       rgba(0,0,0,.15);
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* Pas d'inversion sur la carte login (fond blanc) */
.login-header img { filter: none; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sb-bg);
    border-right: none;
    display: flex; flex-direction: column;
    z-index: 200; overflow-y: auto; overflow-x: hidden;
    transition: transform .25s ease;
    box-shadow: 2px 0 8px rgba(0,0,0,.18);
}

.sidebar-brand {
    display: flex; align-items: center; justify-content: center;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--sb-border);
    flex-shrink: 0; text-decoration: none;
}
.sidebar-brand-logo {
    max-width: 180px; width: 100%; height: auto;
    filter: brightness(0) invert(1);
}

.sidebar-nav { flex: 1; padding: .5rem 0; overflow-y: auto; }

.nav-section-label {
    font-size: .6rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: rgba(148,163,184,.5);
    padding: 1rem 1.25rem .35rem; user-select: none;
}

.nav-link {
    display: flex; align-items: center; gap: .65rem;
    padding: .6rem 1.25rem; color: var(--sb-text);
    text-decoration: none; font-size: .84rem; font-weight: 500;
    border-left: 3px solid transparent;
    transition: all .15s ease;
    cursor: pointer; user-select: none;
}
.nav-link:hover        { background: var(--sb-hover-bg); color: var(--sb-text-hover); }
.nav-link.active       { background: var(--sb-active-bg); color: var(--sb-active-text);
                         border-left-color: var(--sb-active-border); font-weight: 600; }
.nav-link.group-active { color: var(--sb-text-hover); font-weight: 600; }

.nav-icon    { flex-shrink: 0; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { display: block; width: 18px; height: 18px; }
.nav-label   { flex: 1; }
.nav-chevron { font-size: .75rem; color: var(--sb-text); transition: transform .2s; }
.nav-chevron.open { transform: rotate(90deg); }

.nav-sub {
    display: none; background: var(--sb-sub-bg);
    border-left: 2px solid rgba(46,134,193,.3);
    margin: 0 0 .2rem 2.8rem; border-radius: 0 0 6px 6px;
}
.nav-sub.open { display: block; }

.nav-sub-link {
    display: block; padding: .45rem 1rem; font-size: .8rem;
    color: var(--sb-text); text-decoration: none;
    border-left: 2px solid transparent;
    transition: all .12s ease;
}
.nav-sub-link:hover  { color: var(--sb-text-hover); background: rgba(255,255,255,.04); }
.nav-sub-link.active { color: var(--sb-active-text); font-weight: 600; border-left-color: var(--sb-active-border); }

.nav-sep { height: 1px; background: var(--sb-border); margin: .6rem 1.25rem; }

.sidebar-footer {
    border-top: 1px solid var(--sb-border); padding: 1rem 1.25rem; flex-shrink: 0;
}
.sidebar-user { margin-bottom: .75rem; }
.sidebar-user strong { display: block; font-size: .84rem; color: #f1f5f9; }
.sidebar-user small  { font-size: .73rem; color: var(--sb-text); }

.sidebar .btn-secondary {
    background: rgba(255,255,255,.07); color: var(--sb-text-hover);
    border-color: rgba(255,255,255,.12);
}
.sidebar .btn-secondary:hover {
    background: rgba(255,255,255,.13); color: #fff; border-color: rgba(255,255,255,.2);
}

.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.45); z-index: 190;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ═══════════════════════════════════════════════════════════
   TOPBAR MOBILE
   ═══════════════════════════════════════════════════════════ */
.topbar {
    display: none; position: fixed; top: 0; left: 0; right: 0;
    height: var(--topbar-h); background: var(--sb-bg);
    border-bottom: 1px solid var(--sb-border);
    align-items: center; padding: 0 1.25rem; gap: .75rem;
    z-index: 180; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.topbar-toggle {
    background: none; border: none; cursor: pointer;
    font-size: 1.4rem; color: #e2e8f0; padding: .25rem; line-height: 1;
}

/* ═══════════════════════════════════════════════════════════
   PAGE WRAPPER
   ═══════════════════════════════════════════════════════════ */
.page-wrapper { margin-left: var(--sidebar-w); min-height: 100vh; }
.container { width: 100%; max-width: 1440px; margin: 0 auto; padding: 2rem 2rem; }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-title    { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.page-subtitle { font-size: .82rem; color: var(--muted); margin-top: .15rem; }

/* ═══════════════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════════════ */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 1.5rem;
}
.card-header {
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.card-title {
    font-size: .88rem; font-weight: 600; color: var(--text);
    display: flex; align-items: center; gap: .45rem;
}
.card-body { padding: 1.25rem; }

/* ── Stats ── */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.25rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.5rem 1.25rem; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: .35rem;
    transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-label {
    font-size: .7rem; color: var(--muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
}
.stat-value { font-size: 2.2rem; font-weight: 700; line-height: 1; }
.stat-value.green { color: var(--success); }
.stat-value.red   { color: var(--danger); }
.stat-value.blue  { color: var(--primary); }
.stat-value.amber { color: var(--warning); }
.stat-value.muted { color: var(--muted); }

/* ── Carrefour card ── */
.carrefour-card { border-left: 4px solid var(--primary); }
.carrefour-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 1rem;
}
.info-block { display: flex; flex-direction: column; min-width: 0; }
.info-label {
    font-size: .65rem; color: var(--muted); text-transform: uppercase;
    letter-spacing: .06em; font-weight: 600; margin-bottom: .2rem;
}
.info-value { font-size: .95rem; font-weight: 600; overflow: hidden; }
.info-value .badge { white-space: normal; word-break: break-word; display: inline; }

/* ═══════════════════════════════════════════════════════════
   TABLEAU
   ═══════════════════════════════════════════════════════════ */
.table-wrap {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
thead tr { background: #f1f5f9; }
th {
    padding: .75rem 1rem; text-align: left; font-size: .67rem;
    letter-spacing: .08em; text-transform: uppercase;
    color: var(--muted); font-weight: 600; white-space: nowrap;
}
td { padding: .8rem 1rem; border-top: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f1f5f9; }
.row-error td { background: var(--danger-light); }

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
    display: inline-block; padding: .2rem .6rem; border-radius: 6px;
    font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.badge-blue   { background: #DCEEFB; color: #1A5276; }
.badge-green  { background: #D5F5E3; color: #186A3B; }
.badge-red    { background: #FADBD8; color: #922B21; }
.badge-amber  { background: #FEF9E7; color: #7D6608; }
.badge-gray   { background: #EAECEE; color: #5D6D7E; }
.badge-purple { background: #E8DAEF; color: #6C3483; }

/* Badges rôle — fond clair (contenu principal) */
.role-admin    { background: #dbeafe; color: #1e40af; }
.role-operator { background: #dcfce7; color: #166534; }
.role-viewer   { background: #f1f5f9; color: #475569; }

/* Badges rôle — fond sombre (sidebar) */
.sidebar .role-admin    { background: rgba(46,134,193,.25); color: #bfdbfe; }
.sidebar .role-operator { background: rgba(22,163,74,.2);   color: #86efac; }
.sidebar .role-viewer   { background: rgba(255,255,255,.1);  color: #94a3b8; }

.status-dot { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; font-size: .84rem; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.online  { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.dot.alert   { background: var(--warning); box-shadow: 0 0 0 3px rgba(217,119,6,.18); }
.dot.offline { background: var(--danger);  box-shadow: 0 0 0 3px rgba(220,38,38,.18); }

/* ═══════════════════════════════════════════════════════════
   BOUTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.1rem;
    border-radius: 8px; font-size: .84rem; font-weight: 500; cursor: pointer;
    text-decoration: none; border: 1px solid transparent;
    transition: all .15s ease; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); box-shadow: var(--shadow); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-hover); }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-warning:hover  { background: #b45309; }
.btn-success   { background: var(--success); color: #fff; }
.btn-success:hover  { background: #15803d; }
.btn-secondary { background: #f1f5f9; color: #334155; border-color: #cbd5e1; }
.btn-secondary:hover { background: #e2e8f0; border-color: #94a3b8; color: #1e293b; }
.btn-sm   { padding: .32rem .7rem; font-size: .78rem; border-radius: 6px; }
.btn-group { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ═══════════════════════════════════════════════════════════
   FORMULAIRES
   ═══════════════════════════════════════════════════════════ */
.form-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); max-width: 800px;
}
.form-header { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); }
.form-body { padding: 1.5rem; display: flex; flex-direction: column; gap: 1.1rem; }
.form-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--border);
    display: flex; gap: .75rem; justify-content: flex-end;
}
.form-section { margin-bottom: 1.5rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
.form-section h2 { font-size: .95rem; font-weight: 600; margin-bottom: .75rem; color: var(--primary); }
.form-section h3 { font-size: .85rem; font-weight: 600; margin-bottom: .75rem; }
.form-row     { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-group   { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .85rem; }
.form-label   { font-size: .8rem; font-weight: 600; color: var(--text); }
.form-label .req { color: var(--danger); margin-left: .15rem; }
.form-control, input[type="text"], input[type="number"], input[type="password"],
input[type="email"], select, textarea {
    padding: .6rem .85rem; border: 1px solid var(--border); border-radius: 8px;
    font-size: .875rem; color: var(--text); background: var(--surface);
    transition: border-color .15s, box-shadow .15s; width: 100%;
    font-family: inherit;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(46,134,193,.12);
}
.form-hint  { font-size: .73rem; color: var(--muted); }
.form-actions { margin-top: 1.25rem; display: flex; gap: .75rem; }

/* ═══════════════════════════════════════════════════════════
   ALERTES
   ═══════════════════════════════════════════════════════════ */
.alert {
    padding: .85rem 1.15rem; border-radius: 8px; font-size: .84rem;
    display: flex; align-items: flex-start; gap: .6rem; margin-bottom: 1.25rem;
}
.alert-error   { background: var(--danger-light);  color: #991b1b; border: 1px solid rgba(220,38,38,.2); }
.alert-success { background: var(--success-light); color: #14532d; border: 1px solid rgba(22,163,74,.2); }
.alert-warning { background: var(--warning-light); color: #78350f; border: 1px solid rgba(217,119,6,.2); }
.alert-info    { background: var(--primary-light); color: #1A5276; border: 1px solid rgba(46,134,193,.2); }

/* ═══════════════════════════════════════════════════════════
   PAGE LOGIN
   ═══════════════════════════════════════════════════════════ */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        linear-gradient(135deg, rgba(15,23,42,.92) 0%, rgba(30,41,59,.86) 55%, rgba(14,56,86,.82) 100%),
        url('/assets/background.png');
    padding: 1.5rem;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.08);
    width: 100%; max-width: 420px;
    overflow: hidden;
}
.login-header {
    padding: 2.25rem 2rem 1.5rem; text-align: center;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}
.login-header img { max-width: 190px; height: auto; margin-bottom: .5rem; }
.login-subtitle { font-size: .8rem; color: var(--muted); margin-top: .35rem; }
.login-body { padding: 1.75rem 2rem; display: flex; flex-direction: column; gap: 1.1rem; }
.login-footer {
    padding: .9rem 2rem; border-top: 1px solid #e2e8f0;
    text-align: center; background: #f8fafc;
}
.login-footer small { font-size: .72rem; color: #94a3b8; }

/* ═══════════════════════════════════════════════════════════
   DIVERS
   ═══════════════════════════════════════════════════════════ */
.filter-bar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-bar select, .filter-bar input { max-width: 280px; }
.pagination { display: flex; gap: .5rem; justify-content: center; margin-top: 1.5rem; }
.inline-form { display: inline-flex; gap: .5rem; align-items: center; }
.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', monospace;
    font-size: .82rem; background: #f1f5f9; padding: .15rem .45rem; border-radius: 5px;
    border: 1px solid #cbd5e1; color: #334155;
}
.monospace { font-family: 'SFMono-Regular', Consolas, monospace; font-size: .82rem; }
.serveur-status { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }

/* ── Applications DIASER ── */
.app-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .75rem; }
.app-toggle {
    display: flex; flex-direction: column; align-items: center; gap: .3rem;
    padding: 1rem .75rem; background: #f8fafc; border: 2px solid #e2e8f0;
    border-radius: var(--radius); cursor: pointer; transition: all .2s;
    text-align: center; user-select: none;
}
.app-toggle:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.app-toggle.app-active, .app-toggle:has(input:checked) {
    border-color: var(--primary); background: var(--primary-light);
}
.app-toggle input[type="checkbox"] { display: none; }
.app-icon { font-size: 1.6rem; line-height: 1; }
.app-name { font-size: .82rem; font-weight: 600; color: var(--text); }
.app-code { font-size: .65rem; color: var(--muted); font-family: monospace; }
.app-badge { font-size: .65rem; color: var(--primary); font-weight: 600; margin-top: .15rem; }

/* ── Badges applications synoptique ── */
.app-badges { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.app-badge-item {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .7rem; border-radius: 6px; font-size: .78rem; font-weight: 500;
}
.app-badge-item.active { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(46,134,193,.2); }
.app-badge-item.inactive { background: #f1f5f9; color: var(--muted); border: 1px solid #e2e8f0; opacity: .5; }
.app-badge-item small { font-size: .65rem; font-weight: 700; }

/* ── Carte standard (sous-page) ── */
#map-full { height: calc(100vh - 130px); border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* ── Carte plein écran (Accueil) ── */
body.map-fullscreen { overflow: hidden; }
body.map-fullscreen .page-wrapper { display: flex; height: 100vh; overflow: hidden; margin-top: 0; }
body.map-fullscreen .container { flex: 1; padding: 0; max-width: none; min-height: 0; }
body.map-fullscreen #map-full { width: 100%; height: 100%; border-radius: 0; border: none; box-shadow: none; background: #fff; }

/* Mobile : la sidebar se masque, la topbar prend la place, la map remplit le reste */
@media (max-width: 900px) {
    body.map-fullscreen .page-wrapper { height: calc(100vh - var(--topbar-h)); margin-top: var(--topbar-h); }
}
#map-picker { height: 320px; border-radius: var(--radius); border: 1px solid var(--border); margin-top: .75rem; box-shadow: var(--shadow); }
.leaflet-container { font-family: inherit; }
.leaflet-popup-content { min-width: 200px; font-size: .85rem; }

/* ═══════════════════════════════════════════════════════════
   LIGNES DE FEUX
   ═══════════════════════════════════════════════════════════ */
.feux-section { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.feux-title { font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .75rem; display: flex; align-items: center; gap: .5rem; }
.feux-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.feu-item {
    display: flex; align-items: center; gap: .6rem;
    padding: .5rem .65rem; background: #f8fafc; border-radius: 8px;
    border: 1px solid #e2e8f0; transition: box-shadow .15s;
}
.feu-item:hover { box-shadow: var(--shadow); }
.feu-pastille {
    width: 22px; height: 22px; border-radius: 50%;
    flex-shrink: 0; border: 2px solid rgba(0,0,0,.15);
}
.feu-off         { background: #4a5568; }
.feu-red         { background: #dc2626; box-shadow: 0 0 8px rgba(220,38,38,.5); }
.feu-red-blink   { background: #dc2626; animation: feu-blink 1s infinite; }
.feu-amber       { background: #d97706; box-shadow: 0 0 8px rgba(217,119,6,.5); }
.feu-amber-blink { background: #d97706; animation: feu-blink 1s infinite; }
.feu-green       { background: #16a34a; box-shadow: 0 0 8px rgba(22,163,74,.5); }
.feu-green-blink { background: #16a34a; animation: feu-blink 1s infinite; }
.feu-red-amber   { background: linear-gradient(135deg, #dc2626 50%, #d97706 50%); }
.feu-open        { background: #cbd5e1; box-shadow: 0 0 5px rgba(148,163,184,.6); } /* OUVERT — couleur non configurée */
.feu-none        { background: #e5e7eb; border-style: dashed; }
.feu-unknown     { background: #9ca3af; }
@keyframes feu-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: .2; }
}
.feu-info { display: flex; flex-direction: column; min-width: 0; }
.feu-num { font-size: .75rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.feu-label { font-size: .65rem; color: var(--muted); }

/* ── Config lignes de feux (formulaire) ── */
.lignes-config { margin-top: .75rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.lignes-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .5rem;
}
.lignes-toggle {
    display: flex; align-items: center; gap: .5rem;
    font-size: .82rem; font-weight: 600; color: var(--muted);
    cursor: pointer; user-select: none;
}
.lignes-toggle:hover { color: var(--text); }
.lignes-body { margin-top: .5rem; }
/* En-têtes de colonnes */
.lignes-cols-header {
    display: flex; align-items: center; gap: .5rem;
    padding: .2rem .5rem; margin-bottom: .15rem;
    font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em;
}
.lignes-cols-header .col-num  { width: 58px; flex-shrink: 0; text-align: center; }
.lignes-cols-header .col-desc { flex: 1; min-width: 120px; }
.lignes-cols-header .col-type { width: 320px; flex-shrink: 0; }
.lignes-cols-header .col-del  { width: 32px; flex-shrink: 0; }
.ligne-row {
    display: flex; align-items: center; gap: .5rem;
    padding: .3rem .5rem; margin-bottom: .25rem;
    background: var(--bg); border-radius: 6px; border: 1px solid var(--border);
}
/* Override du padding global (input/select héritent de .6rem .85rem) pour les champs compacts */
.ligne-row input, .ligne-row select { padding: .3rem .5rem; }
/* Numéro de ligne — spécificité (0,2,0) > input[type="number"] (0,1,1) qui impose width:100% */
.ligne-row .ligne-input-num {
    width: 58px; flex-shrink: 0; text-align: center;
    font-weight: 700; color: var(--primary);
}
/* Masquer les flèches spinner (visuellement trop lourd dans un tableau compact) */
.ligne-row .ligne-input-num::-webkit-inner-spin-button,
.ligne-row .ligne-input-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ligne-row .ligne-input-num { -moz-appearance: textfield; }
/* Description — flex:1 l'emporte sur width:100% via flex-basis:0 de flex:1 */
.ligne-row .ligne-input-desc { flex: 1; min-width: 120px; width: auto; }
/* Type — spécificité (0,2,0) > select (0,0,1), pas de problème mais cohérence */
.ligne-row .ligne-input-type { width: 320px; flex-shrink: 0; }
.ligne-row .btn-danger { padding: .25rem .5rem; font-size: .85rem; line-height: 1; flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   REFRESH INDICATOR & ANIMATIONS
   ═══════════════════════════════════════════════════════════ */
.refresh-indicator {
    display: flex; align-items: center; gap: .5rem;
    font-size: .78rem; color: var(--muted); font-weight: 500;
}
.pulse-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--success); display: inline-block;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(22,163,74,.4); }
    50% { opacity: .7; box-shadow: 0 0 0 6px rgba(22,163,74,0); }
}
.stat-flash {
    animation: flash .4s ease;
}
@keyframes flash {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}
.dashboard-grid {
    display: grid; grid-template-columns: 1fr; gap: 1.25rem;
    margin-bottom: 1.5rem;
}

/* ═══════════════════════════════════════════════════════════
   CHRONOGRAMME
   ═══════════════════════════════════════════════════════════ */
.chronogramme-container {
    margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.chrono-title {
    font-size: .78rem; font-weight: 600; color: var(--muted);
    margin-bottom: .5rem; display: flex; align-items: center; gap: .5rem;
}
.chrono-axis {
    display: flex; justify-content: space-between;
    padding-left: 85px; margin-bottom: .25rem;
    font-size: .6rem; color: var(--muted); font-family: monospace;
}
.chrono-row {
    display: flex; align-items: center; gap: 0;
    margin-bottom: 2px; height: 22px;
}
.chrono-row-ligne {
    height: 10px; margin-bottom: 1px;
}
.chrono-row-ligne .chrono-label {
    font-size: .6rem; font-weight: 500; color: var(--muted);
}
.chrono-seg {
    position: absolute; top: 0; height: 100%;
}
.chrono-label {
    width: 85px; flex-shrink: 0; padding-right: .5rem;
    font-size: .7rem; font-weight: 600; color: var(--text);
    text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chrono-bar {
    flex: 1; height: 100%; position: relative;
    background: var(--bg); border-radius: 3px; overflow: hidden;
    border: 1px solid var(--border);
}
/* Quadrillage : uniquement les grandes graduations (toutes les 30 s = 4 traits) */
.chrono-bar::after {
    content: '';
    position: absolute; inset: 0;
    pointer-events: none;
    z-index: 3;
    background-image:
        linear-gradient(90deg,
            rgba(255,255,255,0.30) 0px, rgba(255,255,255,0.30) 1px,
            transparent 1px);
    background-size: calc(100% / 4) 100%;
}
.chrono-segment {
    position: absolute; top: 0; height: 100%;
    z-index: 1;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
    /* pas de transition : redraw à 1 s, l'animation width est contre-productive */
}
.chrono-segment[title]:hover { opacity: .8; }
/* Segments tronqués par les bords de la fenêtre temporelle :
 * hachures blanches semi-transparentes sur le bord concerné pour signaler
 * que la durée réelle du segment est inconnue (> durée affichée). */
.chrono-seg-trunc-l {
    border-left: 2px dashed rgba(255,255,255,0.55);
}
.chrono-seg-trunc-r {
    border-right: 2px dashed rgba(255,255,255,0.55);
}
.chrono-seg-dur {
    position: relative; z-index: 2;
    font-family: monospace; font-size: .6rem; font-weight: 700;
    color: rgba(255,255,255,0.90);
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    pointer-events: none; white-space: nowrap;
    line-height: 1;
}
.chrono-seg-off         { background: #4a5568; }
.chrono-seg-red         { background: #dc2626; }
.chrono-seg-red-blink   { background: repeating-linear-gradient(90deg, #dc2626 0px, #dc2626 6px, #8b1a1a 6px, #8b1a1a 12px); }
.chrono-seg-amber       { background: #d97706; }
.chrono-seg-amber-blink { background: repeating-linear-gradient(90deg, #d97706 0px, #d97706 6px, #92400e 6px, #92400e 12px); }
.chrono-seg-green       { background: #16a34a; }
.chrono-seg-green-blink { background: repeating-linear-gradient(90deg, #16a34a 0px, #16a34a 4px, #14532d 4px, #14532d 8px); }
.chrono-seg-red-amber   { background: linear-gradient(135deg, #dc2626 50%, #d97706 50%); }
.chrono-seg-open        { background: #cbd5e1; }   /* OUVERT — couleur lampe non configurée */
.chrono-seg-none        { background: #e5e7eb; }
.chrono-seg-unknown     { background: #9ca3af; }
.chrono-seg-dj-0        { background: #1f2937; }   /* DJ bit=0 : FERMÉ (lampe éteinte) */
.chrono-seg-dj-1        { background: #bbf7d0; }   /* DJ bit=1 : OUVERT (lampe allumée) */

/* ── Rangées debug DJ ────────────────────────────────────────────── */
.chrono-row-dj { height: 8px; margin-bottom: 1px; }
.chrono-row-dj .chrono-label { font-size: .55rem; }
.chrono-label-dj { font-size: .55rem; font-style: italic; color: #94a3b8; }

/* ── Affichage binaire brut 0/1 ──────────────────────────────────── */
.chrono-bar-bits {
    display: flex;
    align-items: stretch;
    overflow: hidden;
}
.chrono-bit {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6px;
    font-family: monospace;
    font-weight: 700;
    line-height: 1;
    border-right: 1px solid rgba(0,0,0,0.08);
    box-sizing: border-box;
    overflow: hidden;
}
.chrono-bit-0         { background: #1f2937; color: #6b7280; }   /* tricolore fermé (rouge/jaune) */
.chrono-bit-1         { background: #bbf7d0; color: #14532d; }   /* tricolore ouvert (vert) */
.chrono-bit-ped-go    { background: #bbf7d0; color: #14532d; }   /* piéton bit=0 = vert (passe) */
.chrono-bit-ped-stop  { background: #fca5a5; color: #7f1d1d; }   /* piéton bit=1 = rouge (stop) */
.chrono-bit-antic     { background: #fde68a; color: #78350f; }   /* anticipation bit=1 = actif */
.chrono-bit-na        { background: #374151; color: #6b7280; font-size: 8px; }
.chrono-bit-future    { background: #111827; }

/* ── Séparateur entre section couleur et section ROUV ─────────── */
.chrono-section-sep {
    padding: 2px 6px;
    font-size: .6rem;
    font-family: monospace;
    font-weight: 700;
    letter-spacing: .08em;
    color: #94a3b8;
    background: #1e293b;
    border-top: 1px solid #334155;
    border-bottom: 1px solid #334155;
    margin: 2px 0;
}
.chrono-label-rouv {
    font-size: .6rem;
    color: #94a3b8;
}
/* Rangées ROUV plus compactes que les rangées couleur */
.chrono-row:has(.chrono-label-rouv) {
    height: 14px;
    margin-bottom: 1px;
}

/* ── Interphase (rouge de dégagement) ────────────────────────────── */
/* Marqueur vertical fin à chaque changement de phase */
.chrono-phase-marker {
    position: absolute;
    top: 0; bottom: 0;
    width: 1px;
    transform: translateX(-50%);
    background: repeating-linear-gradient(
        to bottom,
        rgba(251,191,36,0.9) 0px, rgba(251,191,36,0.9) 3px,
        transparent 3px, transparent 5px
    );
    z-index: 4;
    pointer-events: none;
}
/* Bande hachurée couvrant la durée de l'interphase */
.chrono-interphase {
    position: absolute;
    top: 0; bottom: 0;
    background: repeating-linear-gradient(
        135deg,
        rgba(251, 191, 36, 0.30)  0px,
        rgba(251, 191, 36, 0.30)  4px,
        rgba(17,  24,  39, 0.20)  4px,
        rgba(17,  24,  39, 0.20)  8px
    );
    border-right: 2px solid rgba(251, 191, 36, 0.85);
    z-index: 3;
    pointer-events: none;
}

/* Rangées Plan/Phase : texte par seconde */
.chrono-bar-text {
    background: #f1f5f9;   /* fond légèrement différent des rangées couleur */
}
.chrono-bar-text::after {
    /* Même quadrillage que les rangées couleur, mais moins contrasté */
    background-image:
        linear-gradient(90deg,
            rgba(0,0,0,0.10) 0px, rgba(0,0,0,0.10) 1px,
            transparent 1px),
        linear-gradient(90deg,
            rgba(0,0,0,0.25) 0px, rgba(0,0,0,0.25) 1px,
            transparent 1px);
    background-size:
        calc(100% / 120) 100%,
        calc(100% / 12)  100%;
}
.chrono-text-seg {
    position: absolute; top: 0; height: 100%;
    z-index: 1;
    overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    font-family: monospace; font-size: .55rem; font-weight: 700;
    color: #334155; white-space: nowrap;
    border-right: 1px solid rgba(0,0,0,0.08);
}
.chrono-empty {
    padding: .75rem; text-align: center; color: var(--muted);
    font-size: .78rem; font-style: italic;
}
/* ── Grille état lignes de feux (supervision) ── */
.lignes-feux-grid {
    display: flex; flex-wrap: wrap; gap: 6px;
    padding: .65rem 0 .75rem;
    border-top: 1px solid var(--border);
    margin-top: .5rem;
}
.ligne-dot-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    cursor: default;
}
.ligne-dot {
    width: 18px; height: 18px; border-radius: 50%;
    display: block; flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0,0,0,.08);
}
.ligne-dot-num {
    font-size: .6rem; font-family: monospace; color: var(--muted); line-height: 1;
}

.chrono-offline {
    display: flex; align-items: center; gap: .6rem;
    padding: .65rem 1rem; margin: .25rem 0;
    background: #fff7ed; border: 1px solid #fed7aa; border-radius: 6px;
    font-size: .78rem; font-weight: 600; color: #c2410c;
}
.chrono-offline svg { flex-shrink: 0; }
.sartre-banner {
    display: flex; align-items: center; gap: .75rem;
    padding: .75rem 1.25rem; margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff7ed, #fff);
    border: 1.5px solid #fb923c; border-radius: 10px;
    font-size: .83rem; color: #9a3412;
}
.sartre-banner svg { flex-shrink: 0; }
.sartre-banner strong { font-weight: 700; }
.refresh-indicator.offline .pulse-dot {
    background: #f97316 !important;
    box-shadow: 0 0 0 0 rgba(249,115,22,.6) !important;
    animation: none !important;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
    .sidebar.open { transform: translateX(0); }
    .topbar { display: flex; }
    .page-wrapper { margin-left: 0; padding-top: var(--topbar-h); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 1.25rem 1rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
    table { font-size: .8rem; }
    th, td { padding: .6rem .75rem; }
    .form-card { max-width: 100%; }
    .carrefour-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .carrefour-grid { grid-template-columns: 1fr; }
    .login-card { border-radius: 12px; }
    .login-header { padding: 1.75rem 1.25rem 1.25rem; }
    .login-body { padding: 1.5rem 1.25rem; }
}
