:root {
      --bg-main: #0b0f19;
      --bg-sidebar: #0f172a;
      --bg-card: #131c31;
      --bg-card-inner: #0b1120;
      --border: #1e293b;
      --text: #f8fafc;
      --text-muted: #64748b;
      --accent: #2563eb;
      --accent-hover: #1d4ed8;
      --red: #dc2626;
      --red-hover: #b91c1c;
      --green: #22c55e;
      --amber: #f59e0b;
    }

    * { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
    body { background-color: var(--bg-main); color: var(--text); height: 100vh; overflow: hidden; }
    .hidden { display: none !important; }
    #appRoot { display: flex; height: 100vh; width: 100%; }

    /* LAYOUT GLOBAL */
    #sidebar { width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 20px 15px; flex-shrink: 0; justify-content: space-between; }
    #main-content { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 25px; }

    /* SIDEBAR CONTENT */
    .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
    .brand-icon { background: #b91c1c; color: white; padding: 6px 10px; border-radius: 6px; font-weight: 900; font-size: 14px; }
    .brand-title { font-weight: bold; font-size: 16px; line-height: 1.2; }
    .brand-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

    .sector-selector-box { margin-bottom: 20px; }
    .sector-label { font-size: 10px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; margin-bottom: 6px; display: block; }
    .sector-select { width: 100%; background: #090d16; border: 1px solid var(--border); color: white; padding: 8px 12px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }

    .btn-depart-top { width: 100%; background: var(--red); color: white; border: none; padding: 12px; border-radius: 8px; font-weight: bold; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 25px; transition: background 0.2s; }
    .btn-depart-top:hover { background: var(--red-hover); }

    .nav-section-title { font-size: 10px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; margin: 15px 0 8px 8px; letter-spacing: 0.5px; }
    .nav-list { display: flex; flex-direction: column; gap: 4px; }
    .nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; color: #94a3b8; font-size: 13px; font-weight: 500; cursor: pointer; border: none; background: transparent; width: 100%; text-align: left; transition: all 0.2s; }
    .nav-item:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
    .nav-item.active { background: var(--accent); color: white; font-weight: 600; }

    .user-profile { display: flex; align-items: center; gap: 10px; padding: 12px; border-top: 1px solid var(--border); margin-top: auto; }
    .avatar-badge { background: var(--accent); color: white; font-weight: bold; width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
    .user-name { font-size: 13px; font-weight: bold; line-height: 1.2; }
    .user-role { font-size: 11px; color: var(--text-muted); }

    /* HEADER MAIN */
    .top-bar { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
    .header-left { display: flex; flex-direction: column; gap: 4px; }
    .header-title-box { display: flex; align-items: center; gap: 12px; }
    .header-title { font-size: 22px; font-weight: bold; }
    .sector-toggle-group { display: flex; background: #090d16; border: 1px solid var(--border); border-radius: 6px; padding: 2px; }
    .sector-btn-toggle { background: transparent; border: none; color: var(--text-muted); padding: 4px 12px; border-radius: 4px; font-size: 12px; font-weight: 600; cursor: pointer; }
    .sector-btn-toggle.active { background: var(--accent); color: white; }
    .header-date { font-size: 12px; color: var(--text-muted); }

    .header-actions { display: flex; gap: 10px; }
    .btn-action { background: var(--bg-card); border: 1px solid var(--border); color: var(--text); padding: 8px 14px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; }
    .btn-action:hover { background: var(--border); }
    .btn-action-danger { color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
    .btn-action-danger:hover { background: rgba(239, 68, 68, 0.1); }

    /* PANELS & CARDS */
    .panel { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 20px; }
    .panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; gap: 12px; flex-wrap: wrap; }
    .panel-title { font-size: 15px; font-weight: bold; display: flex; align-items: center; gap: 8px; }
    .panel-header input[type="text"] { background: #090d16; border: 1px solid var(--border); color: white; padding: 8px 12px; border-radius: 6px; font-size: 12px; }

    /* GRID REMISE */
    .remise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
    .vehicle-card { background: var(--bg-card-inner); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

    .trombi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
    .trombi-card { background: var(--bg-card-inner); border: 1px solid var(--border); border-radius: 10px; padding: 18px; text-align: center; }
    .trombi-photo-box { position: relative; width: 90px; height: 90px; margin: 0 auto 12px; }
    .trombi-photo { width: 90px; height: 90px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border); }
    .trombi-photo-fallback { width: 90px; height: 90px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: white; border: 2px solid var(--border); }
    .trombi-name { font-weight: bold; font-size: 15px; margin-bottom: 2px; }
    .trombi-grade { color: var(--text-muted); font-size: 12px; margin-bottom: 10px; }
    .trombi-quals { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 12px; min-height: 22px; }
    .trombi-tel { font-family: monospace; font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
    .trombi-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
    .vehicle-img-box { position: relative; height: 160px; background: #1e293b; }
    .vehicle-img { width: 100%; height: 100%; object-fit: cover; }
    .vehicle-body { padding: 14px; }
    .vehicle-title { font-weight: bold; font-size: 15px; margin-bottom: 2px; }
    .vehicle-sub { color: var(--text-muted); font-size: 12px; margin-bottom: 12px; }
    .vehicle-footer { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 5px; }
    .vehicle-km { font-family: monospace; font-size: 13px; color: var(--text-muted); }
    .status-select { background: #090d16; border: 1px solid var(--border); color: white; padding: 4px 8px; border-radius: 6px; font-size: 12px; }

    /* TABLES & BADGES */
    table { width: 100%; border-collapse: collapse; text-align: left; }
    th, td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
    th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
    .mono { font-family: monospace; }

    .badge { padding: 4px 8px; border-radius: 6px; font-size: 11px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
    .badge-blue { background: rgba(37, 99, 235, 0.2); color: #60a5fa; }
    .badge-green { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
    .badge-red { background: rgba(239, 68, 68, 0.2); color: #f87171; }
    .badge-amber { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }

    /* MODALS & FORMS */
    .modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: flex; align-items: center; justify-content: center; z-index: 100; }
    .modal { background: var(--bg-card); border: 1px solid var(--border); padding: 24px; border-radius: 12px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
    input, select { background: #090d16; border: 1px solid var(--border); color: white; padding: 8px 12px; border-radius: 6px; width: 100%; }
    .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 15px; }
    .btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; cursor: pointer; }
    .btn-primary { background: var(--accent); color: white; border: none; font-weight: 600; }
    .btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }

    /* STAT CARDS */
    .stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
    .stat-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 18px; }
    .stat-label { font-size: 12px; color: var(--text-muted); }
    .stat-value { font-size: 28px; font-weight: bold; margin-top: 6px; }

    /* MAP */
    .map-box { position: relative; height: 420px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
      background: repeating-linear-gradient(0deg, #0f1626 0 38px, #131c31 38px 40px), repeating-linear-gradient(90deg, #0f1626 0 38px, #131c31 38px 40px); }
    .map-pin { position: absolute; transform: translate(-50%, -50%); text-align: center; }
    .map-pin-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid white; }
    .map-pin-label { font-size: 10px; font-weight: 700; color: white; margin-top: 3px; background: rgba(0,0,0,0.6); padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
    .map-legend { display: flex; gap: 16px; margin-top: 14px; flex-wrap: wrap; }
    .map-legend-item { font-size: 12px; display: flex; align-items: center; gap: 6px; }
    .map-legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

    /* TOASTS */
    #toastContainer { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
    .toast { color: white; padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,0.35); opacity: 0; transform: translateY(10px); transition: all .3s; max-width: 320px; }

    /* RESPONSIVE */
    @media (max-width: 900px) {
      #appRoot { flex-direction: column; height: auto; }
      body { height: auto; overflow: auto; }
      #sidebar { width: 100%; flex-direction: column; }
      .user-profile { margin-top: 10px; }
      .remise-grid { grid-template-columns: 1fr; }
      .top-bar { flex-direction: column; align-items: flex-start; gap: 10px; }
      .header-actions { width: 100%; }
      table { font-size: 12px; }
      #main-content { padding: 15px; }
    }

    /* AUTH SCREEN */
    .auth-screen { position: fixed; inset: 0; background: var(--bg-main); display: flex; align-items: center; justify-content: center; z-index: 500; padding: 20px; }
    .auth-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 30px; width: 100%; max-width: 380px; }
    .auth-error { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); padding: 10px 12px; border-radius: 8px; font-size: 12px; margin-bottom: 15px; }

    /* OFFLINE BANNER */
    .offline-banner { position: fixed; top: 0; left: 0; right: 0; background: #7f1d1d; color: white; text-align: center; padding: 8px; font-size: 13px; font-weight: 700; z-index: 400; letter-spacing: 0.3px; }

    /* ALERTE DEPART PLEIN ECRAN */
    .depart-alert-overlay { position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center; animation: alert-bg-pulse 1s infinite; }
    @keyframes alert-bg-pulse { 0%, 100% { background: rgba(127,29,29,0.97); } 50% { background: rgba(220,38,38,0.97); } }
    .depart-alert-box { text-align: center; color: white; padding: 20px; }
    .depart-alert-flash { font-size: 30px; font-weight: 900; letter-spacing: 2px; animation: alert-flash 0.6s infinite; margin-bottom: 22px; }
    @keyframes alert-flash { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
    .depart-alert-engin { font-size: 26px; font-weight: bold; margin-bottom: 6px; }
    .depart-alert-detail { font-size: 15px; opacity: 0.9; margin-bottom: 26px; }
    .depart-alert-chrono { font-family: monospace; font-size: 58px; font-weight: bold; margin-bottom: 4px; }
    .depart-alert-chrono-label { font-size: 12px; text-transform: uppercase; opacity: 0.85; margin-bottom: 30px; letter-spacing: 1px; }
    .depart-alert-btn { background: white; color: #7f1d1d; border: none; padding: 16px 34px; border-radius: 10px; font-size: 16px; font-weight: 800; cursor: pointer; display: block; margin: 0 auto 14px; }
    .depart-alert-dismiss { background: transparent; border: none; color: rgba(255,255,255,0.7); font-size: 12px; text-decoration: underline; cursor: pointer; }

    /* CHAT */
    .chat-wrapper { display: flex; flex-direction: column; height: 75vh; }
    .chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 6px 4px; }
    .chat-bubble { max-width: 70%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.4; }
    .chat-bubble.own { align-self: flex-end; background: var(--accent); color: white; border-bottom-right-radius: 2px; }
    .chat-bubble.other { align-self: flex-start; background: var(--bg-card-inner); border: 1px solid var(--border); border-bottom-left-radius: 2px; }
    .chat-bubble-meta { font-size: 10px; opacity: 0.7; margin-bottom: 3px; font-weight: 600; }
    .chat-input-row { display: flex; gap: 10px; margin-top: 14px; }
    .chat-input-row input { flex: 1; }
