:root{
    --bg:#f5f7fb;
    --card:#ffffff;
    --text:#162033;
    --muted:#6b7280;
    --line:#e5e7eb;
    --blue:#20c98b;
    --nav:#0f172a;
    --green:#16a34a;
    --red:#dc2626;
    --orange:#d97706;
    --slate:#64748b;
}

*{box-sizing:border-box}

html,body{margin:0;min-height:100%}

body{
    font-family:Inter,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Arial,sans-serif;
    background:var(--bg);
    color:var(--text);
}

.topbar{
    height:66px;
    background:var(--nav);
    color:#fff;
    display:flex;
    align-items:center;
    gap:34px;
    padding:0 28px;
}

.brand{
    font-size:20px;
    font-weight:800;
    letter-spacing:.2px;
}

.brand span{color:#20c98b}

.nav{
    display:flex;
    align-items:center;
    gap:24px;
    flex:1;
}

.nav a,.nav span{
    color:#94a3b8;
    font-size:14px;
    text-decoration:none;
}

.nav .active{
    color:#fff;
    font-weight:700;
}

.logout-form{margin-left:auto}

button{
    border:0;
    border-radius:9px;
    font:inherit;
    font-weight:700;
    cursor:pointer;
}

.logout{
    color:#e2e8f0;
    background:transparent;
    border:1px solid #475569;
    padding:9px 13px;
}

main{
    max-width:1500px;
    margin:0 auto;
    padding:24px;
}

.card{
    background:var(--card);
    border:1px solid var(--line);
    border-radius:15px;
    box-shadow:0 3px 14px rgba(15,23,42,.05);
}

.login-card{
    max-width:430px;
    margin:9vh auto;
    padding:28px;
}

.login-card h1{margin:0 0 7px}

.muted{color:var(--muted)}

.small{font-size:12px}

label{
    display:block;
    font-size:13px;
    font-weight:700;
    margin:17px 0 6px;
}

input{
    width:100%;
    border:1px solid #cbd5e1;
    border-radius:9px;
    padding:12px 13px;
    font:inherit;
    outline:none;
}

input:focus{
    border-color:#94a3b8;
    box-shadow:0 0 0 3px rgba(32,201,139,.12);
}

.primary{
    width:100%;
    margin-top:20px;
    padding:11px 15px;
    background:var(--blue);
    color:#083b2c;
}

.code{
    text-align:center;
    font-size:22px;
    letter-spacing:.3em;
}

.error,.api-error{
    margin-top:15px;
    background:#fef2f2;
    border:1px solid #fecaca;
    color:#991b1b;
    padding:10px 12px;
    border-radius:9px;
    font-size:13px;
}

.security{
    margin-top:20px;
    padding-top:16px;
    border-top:1px solid var(--line);
    color:var(--muted);
    font-size:12px;
}

.page-head{
    display:flex;
    align-items:end;
    justify-content:space-between;
    margin-bottom:18px;
}

.page-head h1{
    margin:0;
    font-size:28px;
}

.page-head p{
    margin:4px 0 0;
    font-size:14px;
}

.live-state{
    color:var(--muted);
    font-size:13px;
}

.live-dot{
    display:inline-block;
    width:8px;
    height:8px;
    margin-right:7px;
    border-radius:50%;
    background:var(--green);
}

.stats{
    display:grid;
    grid-template-columns:repeat(4,1fr);
    gap:14px;
    margin-bottom:18px;
}

.stat{padding:18px}

.stat-label{
    color:var(--muted);
    font-size:13px;
}

.stat-number{
    margin-top:7px;
    font-size:27px;
    font-weight:800;
}

.stat-small{
    margin-top:2px;
    color:var(--muted);
    font-size:12px;
}

.dashboard-grid{
    display:grid;
    grid-template-columns:minmax(0,1.55fr) minmax(350px,.75fr);
    gap:18px;
}

.map-card{
    position:relative;
    overflow:hidden;
    min-height:620px;
}

#map{
    width:100%;
    height:620px;
    background:#e5e7eb;
}

.map-badge{
    position:absolute;
    z-index:500;
    top:15px;
    left:55px;
    display:flex;
    flex-direction:column;
    background:rgba(255,255,255,.96);
    border:1px solid var(--line);
    border-radius:10px;
    padding:9px 12px;
    box-shadow:0 2px 10px rgba(15,23,42,.1);
}

.map-badge span{
    color:var(--muted);
    font-size:11px;
    margin-top:2px;
}

.fleet-card{
    min-height:620px;
    overflow:hidden;
    display:flex;
    flex-direction:column;
}

.fleet-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:15px 16px;
    border-bottom:1px solid var(--line);
}

.search{
    max-width:180px;
    padding:8px 10px;
}

.vehicle-list{
    overflow:auto;
    max-height:558px;
}

.vehicle-row{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    gap:10px;
    padding:13px 16px;
    border-bottom:1px solid #eef2f7;
    cursor:pointer;
}

.vehicle-row:hover{
    background:#f8fafc;
}

.vehicle-name{
    display:flex;
    align-items:center;
    gap:8px;
    font-size:14px;
    font-weight:750;
}

.vehicle-meta{
    margin-top:4px;
    color:var(--muted);
    font-size:12px;
}

.vehicle-right{
    text-align:right;
    white-space:nowrap;
}

.speed{
    font-weight:750;
    font-size:13px;
}

.age{
    margin-top:4px;
    color:var(--muted);
    font-size:11px;
}

.status-dot{
    width:9px;
    height:9px;
    border-radius:50%;
    flex:0 0 auto;
}

.status-moving{background:var(--green)}
.status-stopped{background:var(--slate)}
.status-stale{background:var(--red)}
.status-missing{background:var(--orange)}

.loading{
    padding:30px 18px;
    text-align:center;
    color:var(--muted);
    font-size:13px;
}

.hidden{display:none}

.fleet-marker{
    width:30px;
    height:30px;
    border-radius:50%;
    border:3px solid #fff;
    box-shadow:0 2px 8px rgba(0,0,0,.28);
    display:flex;
    align-items:center;
    justify-content:center;
}

.fleet-marker::after{
    content:"";
    width:8px;
    height:8px;
    border-radius:50%;
    background:#fff;
}

.marker-moving{background:var(--green)}
.marker-stopped{background:var(--slate)}
.marker-stale{background:var(--red)}

.popup-title{
    font-weight:800;
    margin-bottom:5px;
}

.popup-grid{
    display:grid;
    grid-template-columns:auto auto;
    gap:3px 10px;
    font-size:12px;
}

.popup-grid span:nth-child(odd){
    color:var(--muted);
}

@media(max-width:1000px){
    .dashboard-grid{
        grid-template-columns:1fr;
    }

    .fleet-card{
        min-height:unset;
    }

    .vehicle-list{
        max-height:450px;
    }

    .nav{display:none}
}

@media(max-width:700px){
    main{padding:14px}

    .stats{
        grid-template-columns:repeat(2,1fr);
    }

    .page-head{
        align-items:flex-start;
        flex-direction:column;
        gap:10px;
    }

    .topbar{padding:0 15px}

    #map,.map-card{
        height:480px;
        min-height:480px;
    }

    .fleet-head{
        align-items:flex-start;
        flex-direction:column;
    }

    .search{max-width:none}
}


/* FleetView v0.15 */
.vehicle-main{
    min-width:0;
    display:flex;
    align-items:flex-start;
    gap:11px;
}

.vehicle-copy{
    min-width:0;
}

.vehicle-avatar{
    width:38px;
    height:38px;
    flex:0 0 38px;
    display:flex;
    align-items:center;
    justify-content:center;
    border-radius:50%;
    background:#e2e8f0;
    border:1px solid #cbd5e1;
    color:#334155;
    font-size:11px;
    font-weight:850;
    letter-spacing:.03em;
    box-shadow:0 1px 2px rgba(15,23,42,.05);
}

.vehicle-address{
    max-width:310px;
    margin-top:4px;
    overflow:hidden;
    color:#475569;
    font-size:11px;
    line-height:1.35;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.vehicle-row{
    grid-template-columns:minmax(0,1fr) auto;
    align-items:start;
}

@media(max-width:520px){
    .vehicle-address{
        max-width:210px;
    }
}

.brand-link{text-decoration:none;color:inherit}
.menu-toggle{display:none;width:42px;height:38px;border:1px solid rgba(255,255,255,.18);border-radius:9px;background:rgba(255,255,255,.06);padding:8px 9px;cursor:pointer;margin-left:auto}
.menu-toggle span{display:block;height:2px;background:#fff;border-radius:2px;margin:4px 0;transition:transform .18s ease,opacity .18s ease}
.menu-toggle.is-open span:nth-child(1){transform:translateY(6px) rotate(45deg)}.menu-toggle.is-open span:nth-child(2){opacity:0}.menu-toggle.is-open span:nth-child(3){transform:translateY(-6px) rotate(-45deg)}
@media(max-width:760px){
.topbar{position:relative;min-height:58px;height:auto;flex-wrap:wrap;padding:10px 14px;gap:0}
.menu-toggle{display:block}
.topbar .nav{display:none;width:100%;flex-direction:column;align-items:stretch;gap:4px;padding:10px 0 2px;order:10}
.topbar .nav.nav-open{display:flex}
.topbar .nav a{display:block;width:100%;padding:11px 12px;border-radius:8px}
.topbar .logout-form{order:11;width:100%;display:none;padding-top:4px}
.topbar .nav.nav-open~.logout-form{display:block}.topbar .logout-form .logout{width:100%}
}


/* =========================================================
   FlottenPortal v0.19.3 — Mobile menu polish
   ========================================================= */

.mobile-menu-divider {
    display: none;
}

@media (max-width:760px) {
    .topbar {
        min-height: 64px;
        padding: 11px 16px;
        flex-wrap: nowrap;
        align-items: center;
        overflow: visible;
        z-index: 1000;
    }

    .topbar .brand {
        font-size: 18px;
        white-space: nowrap;
        line-height: 1;
        flex: 0 1 auto;
        min-width: 0;
    }

    .menu-toggle {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        margin-left: auto;
        padding: 9px;
        border-radius: 11px;
        border: 1px solid rgba(255,255,255,.20);
        background: rgba(255,255,255,.07);
        position: relative;
        z-index: 1002;
    }

    .menu-toggle span {
        width: 22px;
        margin: 3px 0;
    }

    .menu-toggle.is-open {
        background: rgba(255,255,255,.13);
    }

    .menu-toggle.is-open span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .menu-toggle.is-open span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    .topbar .nav {
        display: none;
        position: absolute;
        top: calc(100% + 8px);
        right: 12px;
        width: min(310px, calc(100vw - 24px));
        padding: 9px;
        border: 1px solid rgba(148,163,184,.24);
        border-radius: 15px;
        background: #111a2d;
        box-shadow: 0 18px 45px rgba(15,23,42,.28);
        flex-direction: column;
        align-items: stretch;
        gap: 3px;
        z-index: 1001;
    }

    .topbar .nav.nav-open {
        display: flex;
    }

    .topbar .nav a {
        display: flex;
        align-items: center;
        width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border-radius: 9px;
        font-size: 15px;
        font-weight: 700;
        text-align: left;
    }

    .topbar .nav a:hover,
    .topbar .nav a.active {
        background: rgba(255,255,255,.08);
    }

    .topbar .nav .mobile-menu-divider {
        display: block;
        height: 1px;
        background: rgba(148,163,184,.22);
        margin: 6px 4px;
    }

    .topbar .nav .nav-logout {
        display: block;
        width: 100%;
        padding: 0;
        margin: 0;
    }

    .topbar .nav .nav-logout .logout {
        width: 100%;
        min-height: 44px;
        border-radius: 9px;
        margin: 0;
        text-align: left;
        padding: 10px 12px;
        border: 1px solid rgba(148,163,184,.24);
        background: rgba(255,255,255,.035);
    }

    .topbar .nav .nav-logout .logout:hover {
        background: rgba(255,255,255,.08);
    }

    /* Alte mobile Logout-Regel aus v0.19.2 neutralisieren */
    .topbar > .logout-form {
        display: none !important;
    }

    body.mobile-menu-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(15,23,42,.10);
        z-index: 900;
        pointer-events: none;
    }
}


/* v0.19.4 — Brand/link & desktop separator hotfix */
.topbar a.brand,
.topbar a.brand:link,
.topbar a.brand:visited,
.topbar a.brand:hover,
.topbar a.brand:active {
    color: #ffffff !important;
    text-decoration: none !important;
}

.topbar a.brand span,
.topbar a.brand:link span,
.topbar a.brand:visited span,
.topbar a.brand:hover span,
.topbar a.brand:active span {
    color: #20c98b !important;
    text-decoration: none !important;
}

.topbar .mobile-menu-divider {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
}

@media (max-width:760px) {
    .topbar .nav .mobile-menu-divider {
        display: block !important;
        width: auto !important;
        height: 1px !important;
        margin: 6px 4px !important;
        padding: 0 !important;
        background: rgba(148,163,184,.22) !important;
        border: 0 !important;
    }
}


/* =========================================================
   FlottenPortal v0.19.5 — definitive header cleanup
   ========================================================= */

/* Branding ist kein Link mehr. */
.topbar .brand {
    color: #ffffff !important;
    text-decoration: none !important;
}

.topbar .brand span {
    color: #20c98b !important;
    text-decoration: none !important;
}

/*
 * Desktop: Hamburger garantiert unsichtbar.
 * !important verhindert Wechselwirkungen mit älteren Button-Regeln.
 */
.topbar .menu-toggle {
    display: none !important;
}

.menu-icon-open,
.menu-icon-close {
    font-size: 26px;
    line-height: 1;
    font-weight: 400;
    color: #ffffff;
}

.menu-icon-close {
    display: none;
}

.menu-toggle.is-open .menu-icon-open {
    display: none;
}

.menu-toggle.is-open .menu-icon-close {
    display: block;
    font-size: 34px;
    line-height: .8;
}

@media (max-width:760px) {
    .topbar .menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
    }

    /* Alte Dreistrich-Regeln endgültig neutralisieren. */
    .topbar .menu-toggle > span {
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        background: transparent !important;
        transform: none !important;
        border-radius: 0 !important;
    }

    .topbar .menu-toggle .menu-icon-close {
        display: none !important;
    }

    .topbar .menu-toggle.is-open .menu-icon-open {
        display: none !important;
    }

    .topbar .menu-toggle.is-open .menu-icon-close {
        display: block !important;
    }
}


/* =========================================================
   FlottenPortal v0.19.6 — desktop hamburger hard-off
   ========================================================= */

/*
 * Auf Desktop existiert der Button zwar im DOM, ist aber vollständig
 * aus Layout und Rendering entfernt. Die doppelte Selektierung erhöht
 * die Spezifität gegenüber älteren allgemeinen Button-Regeln.
 */
.topbar button.menu-toggle.mobile-only-menu,
button.menu-toggle.mobile-only-menu {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

@media (max-width:760px) {
    .topbar button.menu-toggle.mobile-only-menu,
    button.menu-toggle.mobile-only-menu {
        display: flex !important;
        visibility: visible !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        margin-left: auto !important;
        padding: 9px !important;
        border: 1px solid rgba(255,255,255,.20) !important;
        position: relative !important;
        overflow: visible !important;
        pointer-events: auto !important;
    }
}


/* =========================================================
   FlottenPortal v0.19.7 — smartphone-only hamburger
   ========================================================= */

@media (min-width:641px) {
    .topbar button.menu-toggle.mobile-only-menu,
    button.menu-toggle.mobile-only-menu {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        min-width: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        pointer-events: none !important;
    }

    .topbar .nav {
        display: flex !important;
        position: static !important;
        width: auto !important;
        padding: 0 !important;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        flex-direction: row !important;
        align-items: center !important;
    }
}

@media (max-width:640px) {
    .topbar button.menu-toggle.mobile-only-menu,
    button.menu-toggle.mobile-only-menu {
        display: flex !important;
        visibility: visible !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        margin-left: auto !important;
        padding: 9px !important;
        border: 1px solid rgba(255,255,255,.20) !important;
        position: relative !important;
        overflow: visible !important;
        pointer-events: auto !important;
    }

    .topbar .nav {
        display: none !important;
    }

    .topbar .nav.nav-open {
        display: flex !important;
    }
}

/* v0.40 – Fahrzeugbild / Marken-Fallback in Live */
.vehicle-avatar-media{overflow:hidden;display:grid;place-items:center;background:#f3f6fb}.vehicle-avatar-media img{width:100%;height:100%;object-fit:cover;display:block}.vehicle-make-logo{font-size:8px;line-height:1;text-align:center;font-weight:900;letter-spacing:-.02em;color:#334155;max-width:90%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.vehicle-row:hover .vehicle-avatar-media{box-shadow:0 0 0 2px rgba(37,99,235,.12)}


/* Einheitliche Schweizer Kennzeichen */
.fp-plate{display:inline-flex;align-items:center;gap:5px;min-height:25px;padding:2px 6px;border:1px solid #cbd5e1;border-radius:5px;background:#fff;color:#0f172a;vertical-align:middle;white-space:nowrap;box-shadow:0 1px 1px rgba(15,23,42,.04)}
.fp-plate strong{font-size:12px;line-height:1;font-weight:900;letter-spacing:.035em}
.fp-plate-crest{display:inline-flex;width:17px;height:17px;align-items:center;justify-content:center;overflow:hidden}.fp-plate-crest img{display:block;max-width:17px;max-height:17px;object-fit:contain}
.fp-plate-empty{border-style:dashed;background:#f8fafc;color:#64748b;font-weight:700}

/* DEV 2026-08-30: kompakte Schweizer Kennzeichen */
.fp-plate{display:inline-flex;align-items:center;gap:3px;min-height:20px;padding:1px 4px;border:1px solid #cbd5e1;border-radius:4px;background:#fff;color:#0f172a;vertical-align:middle;white-space:nowrap}.fp-plate strong{font-size:11px;line-height:1;font-weight:900;letter-spacing:.025em}.fp-plate-crest{display:inline-flex!important;width:10px!important;height:10px!important;min-width:10px!important;align-items:center;justify-content:center;overflow:hidden}.fp-plate-crest img{display:block!important;width:10px!important;height:10px!important;max-width:10px!important;max-height:10px!important;object-fit:contain!important}

/* DEV Bugfix Runde 3 – Kennzeichen besser lesbar */
.fp-plate strong{font-size:12px!important;line-height:1.1!important;font-weight:600!important;letter-spacing:.01em!important}

/* Livekarte: Fahrzeugfoto im Marker immer vollständig und proportional anzeigen. */
.fleet-marker-photo{
    position:relative;
    width:48px;
    height:48px;
    box-sizing:border-box;
    padding:3px;
    border:2px solid #fff;
    border-radius:12px;
    background:#fff;
    box-shadow:0 2px 9px rgba(15,23,42,.28);
}
.fleet-marker-media{
    width:100%;
    height:100%;
    display:flex;
    align-items:center;
    justify-content:center;
    overflow:hidden;
    border-radius:8px;
    background:#f8fafc;
}
.fleet-marker-media img{
    display:block;
    width:100%;
    height:100%;
    max-width:100%;
    max-height:100%;
    object-fit:contain;
    object-position:center;
}
.fleet-marker-media > span{
    display:flex;
    width:100%;
    height:100%;
    align-items:center;
    justify-content:center;
    font-size:24px;
    line-height:1;
}
.fleet-marker-status{
    position:absolute;
    right:-3px;
    bottom:-3px;
    width:12px;
    height:12px;
    border:2px solid #fff;
    border-radius:50%;
    box-shadow:0 1px 4px rgba(15,23,42,.25);
}


/* Livekarte: eigene Bildklasse verhindert Cropping durch Leaflet/globales CSS. */
.fleet-marker-media .fleet-map-vehicle-image{
    display:block!important;
    width:100%!important;
    height:100%!important;
    max-width:100%!important;
    max-height:100%!important;
    object-fit:contain!important;
    object-position:center!important;
    margin:0!important;
    padding:0!important;
    transform:none!important;
}


/* Brand color normalization: Flotten = green, Portal = navy */
.fp-appbar.topbar .fp-brand-word,
.fp-appbar.topbar .fp-brand-word > span:first-child,
.topbar .brand .fp-brand-word,
.topbar .brand .fp-brand-word > span:first-child{
    color:#20c98b!important;
}
.fp-appbar.topbar .fp-brand-word .fp-brand-accent,
.topbar .brand .fp-brand-word .fp-brand-accent{
    color:#102a53!important;
}
