@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@500;600&display=swap');

:root {
    --bg: #0B0E14;
    --panel: #12161F;
    --panel-2: #171C27;
    --panel-3: #1D2330;
    --border: #232838;
    --border-light: #2E3448;
    --text: #EDEFF3;
    --text-dim: #8891A3;
    --text-mute: #565F73;

    --ice: #38BDF8;
    --ice-dim: #1E5A75;
    --ice-glow: rgba(56, 189, 248, .35);
    --amber: #F5A623;
    --amber-glow: rgba(245, 166, 35, .3);
    --red: #EF4444;
    --red-glow: rgba(239, 68, 68, .3);
    --green: #34D399;
    --green-glow: rgba(52, 211, 153, .3);

    --radius-s: 8px;
    --radius-m: 14px;
    --radius-l: 20px;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    background: var(--bg);
    background-image:
        radial-gradient(ellipse 900px 500px at 15% -10%, rgba(56,189,248,.08), transparent 60%),
        radial-gradient(ellipse 700px 500px at 100% 0%, rgba(245,166,35,.06), transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.01em; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 2px; }

/* ================= LOGIN ================= */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border-light);
    border-radius: var(--radius-l);
    padding: 40px 36px;
    box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04);
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: '';
    position: absolute; top: -60%; left: -20%;
    width: 260px; height: 260px;
    background: radial-gradient(circle, var(--ice-glow), transparent 70%);
    filter: blur(10px);
    pointer-events: none;
}
.login-badge {
    width: 52px; height: 52px; border-radius: var(--radius-m);
    background: linear-gradient(135deg, var(--ice), #1a7fa3);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 22px; color: #051018;
    box-shadow: 0 8px 24px var(--ice-glow);
    margin-bottom: 22px;
}
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 4px; }
.login-card p.sub { color: var(--text-dim); font-size: 13.5px; margin-bottom: 28px; }

/* ================= FORM ELEMENTS ================= */
.field { margin-bottom: 16px; }
.field label {
    display: block; font-size: 12px; font-weight: 600; color: var(--text-dim);
    text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px;
}
.field input, .field select, .field textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-s);
    padding: 11px 13px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--ice); box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}
.field input[type="file"] { padding: 8px; font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    border: none; border-radius: var(--radius-s);
    padding: 11px 20px; font-family: var(--font-body); font-weight: 600; font-size: 13.5px;
    cursor: pointer; transition: transform .12s, box-shadow .12s, opacity .12s;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: linear-gradient(135deg, var(--ice), #1a94c4); color: #04141c; box-shadow: 0 6px 18px var(--ice-glow); }
.btn-primary:hover { box-shadow: 0 8px 24px var(--ice-glow); }
.btn-full { width: 100%; padding: 13px; }
.btn-ghost { background: var(--panel-3); color: var(--text); border: 1px solid var(--border-light); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }

.error-banner {
    background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3);
    color: #fca5a5; padding: 11px 14px; border-radius: var(--radius-s);
    font-size: 13px; margin-bottom: 16px; display: none;
}

/* ================= APP SHELL ================= */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 232px; flex-shrink: 0;
    background: var(--panel);
    border-right: 1px solid var(--border);
    padding: 22px 16px;
    display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; margin-bottom: 30px; }
.sidebar-brand .badge-mark {
    width: 36px; height: 36px; border-radius: 10px;
    background: linear-gradient(135deg, var(--ice), #1a7fa3);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; color: #04141c; font-size: 16px;
    box-shadow: 0 6px 16px var(--ice-glow);
}
.sidebar-brand .name { font-family: var(--font-display); font-weight: 700; font-size: 15px; }
.sidebar-brand .sub { font-size: 10.5px; color: var(--text-mute); letter-spacing: .04em; text-transform: uppercase; }

.nav-link {
    display: flex; align-items: center; gap: 11px;
    padding: 10px 12px; border-radius: var(--radius-s);
    color: var(--text-dim); text-decoration: none; font-size: 13.5px; font-weight: 500;
    margin-bottom: 3px; transition: background .15s, color .15s;
}
.nav-link .ic { font-size: 16px; width: 18px; text-align: center; }
.nav-link:hover { background: var(--panel-2); color: var(--text); }
.nav-link.active {
    background: linear-gradient(90deg, rgba(56,189,248,.14), rgba(56,189,248,.03));
    color: var(--ice); font-weight: 600;
    box-shadow: inset 2px 0 0 var(--ice);
}

.sidebar-footer {
    margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px;
}
.avatar-mini {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--panel-3); border: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 13px; color: var(--ice);
    flex-shrink: 0; overflow: hidden;
}
.avatar-mini img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-footer .who { flex: 1; min-width: 0; }
.sidebar-footer .who .n { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who .r { font-size: 10.5px; color: var(--text-mute); }
.sidebar-footer .logout { background: none; border: none; color: var(--text-mute); cursor: pointer; font-size: 15px; padding: 4px; }
.sidebar-footer .logout:hover { color: var(--red); }

.main { flex: 1; padding: 30px 36px; max-width: 1400px; }

.page-top { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 26px; flex-wrap: wrap; gap: 14px; }
.page-top h1 { font-size: 24px; font-weight: 700; }
.page-top p { color: var(--text-dim); font-size: 13.5px; margin-top: 3px; }

/* ================= GAUGE CLUSTER ================= */
.gauge-cluster {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px; margin-bottom: 30px;
}
.gauge-card {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border); border-radius: var(--radius-l);
    padding: 18px; display: flex; align-items: center; gap: 16px;
    position: relative; overflow: hidden;
}
.gauge-card::after {
    content: ''; position: absolute; inset: 0; border-radius: inherit;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.03); pointer-events: none;
}
.gauge-svg { flex-shrink: 0; }
.gauge-track { fill: none; stroke: var(--border); stroke-width: 8; }
.gauge-arc { fill: none; stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 1.1s cubic-bezier(.3,.8,.3,1); }
.gauge-tick { stroke: var(--border-light); stroke-width: 1.5; }
.gauge-center-num { font-family: var(--font-mono); font-weight: 600; font-size: 17px; fill: var(--text); }
.gauge-info .g-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.gauge-info .g-value { font-family: var(--font-mono); font-size: 22px; font-weight: 600; margin-top: 2px; }
.gauge-info .g-value.ice { color: var(--ice); }
.gauge-info .g-value.amber { color: var(--amber); }
.gauge-info .g-value.red { color: var(--red); }
.gauge-info .g-value.green { color: var(--green); }
.gauge-info .g-sub { font-size: 11px; color: var(--text-mute); margin-top: 3px; }

/* ================= TOOLBAR ================= */
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }
.search-input { position: relative; flex: 1; min-width: 220px; max-width: 340px; }
.search-input input {
    width: 100%; background: var(--panel); border: 1px solid var(--border-light);
    border-radius: var(--radius-s); padding: 10px 14px 10px 36px; color: var(--text); font-size: 13.5px;
}
.search-input .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-mute); font-size: 14px; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill {
    padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
    border: 1px solid var(--border-light); background: var(--panel); color: var(--text-dim); cursor: pointer;
    transition: all .15s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active { background: rgba(56,189,248,.14); border-color: var(--ice); color: var(--ice); }

/* ================= VEHICLE CARD (carte grise) ================= */
.vehicle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.vcard {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-l);
    overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.vcard:hover { transform: translateY(-3px); border-color: var(--border-light); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.vcard-photo {
    height: 140px; background: var(--panel-3); position: relative;
    display: flex; align-items: center; justify-content: center; color: var(--text-mute); font-size: 34px;
    background-size: cover; background-position: center;
}
.vcard-status {
    position: absolute; top: 10px; right: 10px; padding: 4px 10px; border-radius: 20px;
    font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
    backdrop-filter: blur(6px);
}
.vcard-status.disponible { background: rgba(52,211,153,.18); color: var(--green); border: 1px solid rgba(52,211,153,.4); }
.vcard-status.loue { background: rgba(56,189,248,.18); color: var(--ice); border: 1px solid rgba(56,189,248,.4); }
.vcard-status.maintenance { background: rgba(245,166,35,.18); color: var(--amber); border: 1px solid rgba(245,166,35,.4); }
.vcard-status.hors_service { background: rgba(239,68,68,.18); color: var(--red); border: 1px solid rgba(239,68,68,.4); }

.vcard-body { padding: 16px; }
.vcard-name { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; }
.vcard-sub { font-size: 12px; color: var(--text-dim); margin-top: 1px; }

.plate-chip {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 10px;
    background: #05070B; border: 1.5px solid var(--border-light); border-radius: 5px;
    padding: 5px 10px; font-family: var(--font-mono); font-weight: 600; font-size: 13px;
    letter-spacing: .08em; color: #E8F4FA;
}
.plate-chip .flag { width: 6px; height: 14px; background: var(--ice); border-radius: 1px; }

.vcard-specs { display: flex; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.vcard-specs .spec { font-size: 11.5px; color: var(--text-dim); }
.vcard-specs .spec b { display: block; font-family: var(--font-mono); color: var(--text); font-size: 13px; font-weight: 600; }
.vcard-alert { margin-top: 10px; font-size: 11.5px; color: var(--amber); display: flex; align-items: center; gap: 5px; }

/* ================= COLLABORATOR BADGE ================= */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.staff-card {
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius-l);
    padding: 18px; text-align: center; cursor: pointer; transition: transform .15s, border-color .15s;
    position: relative;
}
.staff-card:hover { transform: translateY(-3px); border-color: var(--border-light); }
.staff-card.inactive { opacity: .5; }
.staff-avatar {
    width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--panel-3), var(--panel-2));
    border: 2px solid var(--border-light);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--ice);
    overflow: hidden;
}
.staff-avatar img { width: 100%; height: 100%; object-fit: cover; }
.staff-name { font-family: var(--font-display); font-weight: 700; font-size: 14.5px; }
.staff-email { font-size: 11.5px; color: var(--text-mute); margin-top: 2px; }
.role-pill {
    display: inline-block; margin-top: 10px; padding: 4px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.role-pill.admin { background: rgba(245,166,35,.16); color: var(--amber); border: 1px solid rgba(245,166,35,.35); }
.role-pill.standard { background: rgba(56,189,248,.14); color: var(--ice); border: 1px solid rgba(56,189,248,.3); }
.staff-badge-inactive { position: absolute; top: 12px; right: 12px; font-size: 10px; color: var(--red); font-weight: 700; text-transform: uppercase; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-mute); font-size: 13.5px; }
.loading-state { text-align: center; padding: 60px; color: var(--text-mute); font-size: 13.5px; }

/* ================= MODAL ================= */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(4,6,10,.7); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-panel {
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--border-light); border-radius: var(--radius-l);
    padding: 30px; width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto;
    position: relative; box-shadow: 0 40px 100px rgba(0,0,0,.6);
}
.modal-panel h2 { font-size: 18px; font-weight: 700; margin-bottom: 22px; }
.modal-close {
    position: absolute; top: 18px; right: 18px; background: var(--panel-3);
    border: 1px solid var(--border-light); border-radius: 50%; width: 30px; height: 30px;
    color: var(--text-dim); cursor: pointer; font-size: 14px;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

.detail-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.detail-row .k { color: var(--text-dim); }
.detail-row .v { font-family: var(--font-mono); font-weight: 600; }

@media (max-width: 860px) {
    .sidebar { width: 76px; padding: 20px 10px; }
    .sidebar-brand .name, .sidebar-brand .sub, .nav-link span.lbl, .sidebar-footer .who { display: none; }
    .sidebar-brand { justify-content: center; }
    .nav-link { justify-content: center; }
    .main { padding: 22px 16px; }
    .grid-2 { grid-template-columns: 1fr; }
}
