:root {
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --sidebar-bg: #f8fafc;
    --sidebar-border: #e2e8f0;
    --sidebar-text: #475569;
    --sidebar-active: #0284c7;
    --sidebar-active-bg: #e0f2fe;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --primary: #0284c7;
    --amber: #d97706;
    --emerald: #10b981;
    --modal-overlay: rgba(15, 23, 42, 0.5);
}

.dark {
    --bg-color: #0b0f19;
    --card-bg: #111827;
    --sidebar-bg: #030712;
    --sidebar-border: #1f2937;
    --sidebar-text: #9ca3af;
    --sidebar-active: #38bdf8;
    --sidebar-active-bg: rgba(56, 189, 248, 0.1);
    --text-color: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: #1f2937;
    --primary: #38bdf8;
    --amber: #f59e0b;
    --emerald: #10b981;
    --modal-overlay: rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }
body { background: var(--bg-color); color: var(--text-color); min-height: 100vh; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }

/* TOP LOADER */
.top-loader { position: fixed; top: 0; left: 0; height: 3px; background: var(--primary); width: 0%; transition: width 0.3s ease; z-index: 9999; }

/* LAYOUT */
.app-layout { display: flex; min-height: 100vh; }

/* SIDEBAR */
aside.sidebar { width: 230px; background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border); display: flex; flex-direction: column; transition: width 0.2s cubic-bezier(0.4, 0, 0.2, 1); shrink: 0; }
aside.sidebar.collapsed { width: 64px; }

.sidebar-brand { height: 60px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid var(--sidebar-border); }
.logo-area { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text-color); }
.logo-icon { width: 28px; height: 28px; color: var(--primary); }
.logo-text { font-weight: 800; font-size: 16px; letter-spacing: -0.5px; }
.logo-sub { color: var(--primary); }
.sidebar.collapsed .logo-text { display: none; }

.sidebar-menu { list-style: none; padding: 12px 8px; flex: 1; }
.sidebar-menu li { margin-bottom: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: var(--sidebar-text); text-decoration: none; border-radius: 8px; font-size: 13px; font-weight: 600; transition: all 0.15s; }
.nav-item:hover { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active); }
.nav-icon { width: 20px; height: 20px; }
.sidebar.collapsed .nav-item .text { display: none; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--sidebar-border); font-size: 10px; color: var(--text-muted); text-align: center; }
.sidebar.collapsed .sidebar-footer { display: none; }

/* MAIN CONTENT */
.main-wrapper { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.top-header { height: 60px; background: var(--card-bg); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; justify-content: space-between; padding: 0 20px; position: sticky; top: 0; z-index: 20; }
.header-left, .header-right { display: flex; align-items: center; gap: 12px; }
.page-title { font-size: 16px; font-weight: 700; }
.vehicle-selector { background: var(--bg-color); color: var(--text-color); border: 1px solid var(--border-color); padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700; }

/* BUTTONS & ICONS */
.btn { padding: 8px 14px; border-radius: 8px; border: none; font-weight: 600; font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-amber { background: var(--amber); color: #fff; }
.w-full { width: 100%; justify-content: center; }

.icon-btn { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-color); display: flex; align-items: center; justify-content: center; cursor: pointer; text-decoration: none; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

.user-btn { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--card-bg); color: var(--text-color); font-size: 12px; font-weight: 600; cursor: pointer; }
.btn-svg { width: 16px; height: 16px; }

/* THEME TOGGLE SWITCH */
.theme-switch { position: relative; width: 42px; height: 22px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background: #cbd5e1; border-radius: 22px; transition: .2s; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s; }
input:checked + .slider { background: var(--primary); }
input:checked + .slider:before { transform: translateX(20px); }

/* CONTENT & WIDGETS LAYOUT */
.content-body { display: flex; flex: 1; padding: 20px; gap: 20px; }
.module-container { flex: 1; min-width: 0; }
.widgets-sidebar { width: 300px; display: flex; flex-direction: column; gap: 16px; shrink: 0; }

.widget-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; padding: 14px; }
.widget-card h3 { font-size: 12px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 12px; }
.chart-box { height: 160px; position: relative; }

.monthly-list { display: flex; flex-direction: column; gap: 8px; }
.monthly-item { display: flex; justify-content: space-between; font-size: 11px; padding: 6px 0; border-bottom: 1px solid var(--border-color); }
.m-date { font-weight: 700; }
.m-cost { color: var(--emerald); font-weight: 700; }

/* TABLES */
.table-card { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; width: 100%; }
.table-card-title { padding: 14px 18px; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border-color); }

.desktop-table-wrapper { max-height: calc(100vh - 220px); overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
thead th { position: sticky; top: 0; background: var(--card-bg); color: var(--text-muted); font-size: 10px; text-transform: uppercase; padding: 12px 16px; border-bottom: 2px solid var(--border-color); text-align: left; }
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border-color); }
tbody tr:hover { background: var(--bg-color); }

/* MODALS A CHAMELEON SKLÁ TEMATIKY */
.modal { display: none; position: fixed; inset: 0; background: var(--modal-overlay); z-index: 100; align-items: center; justify-content: center; padding: 16px; backdrop-filter: blur(3px); }
.modal.open { display: flex; }

/* Farebné tónovanie overlayov pre tankovanie a jazdy */
.modal-amber { background: rgba(217, 119, 6, 0.35) !important; }
.modal-blue { background: rgba(2, 132, 199, 0.35) !important; }

.modal-content { background: var(--card-bg); border: 1px solid var(--border-color); border-radius: 16px; width: 100%; max-width: 500px; padding: 20px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.close-btn { background: transparent; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; }

.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.form-group input, .form-group select { width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-color); color: var(--text-color); font-size: 13px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.checkbox-group { display: flex; gap: 12px; font-size: 12px; margin-bottom: 12px; }

@media (max-width: 1024px) {
    .content-body { flex-direction: column; }
    .widgets-sidebar { width: 100%; }
}

.alert { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-radius: 8px; font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.alert-error { background: rgba(239, 68, 68, 0.12); border: 1px solid #ef4444; color: #ef4444; }
.alert-success { background: rgba(16, 185, 129, 0.12); border: 1px solid #10b981; color: #10b981; }
.alert-close { background: transparent; border: none; color: inherit; font-size: 16px; cursor: pointer; line-height: 1; }

/* SUB TABS PRE NASTAVENIA */
.sub-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 16px;
    padding-bottom: 4px;
}

.sub-tab-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.sub-tab-btn:hover {
    color: var(--primary);
    background: var(--sidebar-active-bg);
}

.sub-tab-btn.active {
    color: var(--primary);
    background: var(--sidebar-active-bg);
    border-bottom: 2px solid var(--primary);
}

.modal-table-wrap {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

/* TLAČIDLÁ AKCIÍ BEZ SIVÉHO PODFARBENIA (JEDNOFAREBNÉ) */
.btn-action-icon {
    background: transparent !important;
    border: none !important;
    color: var(--sidebar-text, #64748b);
    padding: 5px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-action-icon svg {
    width: 17px;
    height: 17px;
}
.btn-action-icon:hover {
    color: var(--primary, #0284c7);
    background: var(--sidebar-active-bg, rgba(2, 132, 199, 0.1)) !important;
}
.btn-action-delete:hover {
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.1) !important;
}

/* STRÁNKOVANIE & FILTRE AKTUÁLNY ŠTÝL */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 12px;
    font-size: 13px;
    background: var(--card-bg);
}
.pagination-info {
    color: var(--text-muted);
}
.pagination-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
}
.btn-pagination {
    padding: 5px 11px;
    border-radius: 6px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.btn-pagination:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.btn-pagination.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff !important;
}
.pagination-dots {
    color: var(--text-muted);
    padding: 0 4px;
}

.filter-input-sm {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 12px;
    outline: none;
}
.filter-input-sm:focus {
    border-color: var(--primary);
}
.btn-action-reset {
    padding: 6px 10px;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 6px;
    font-size: 12px;
}
.btn-action-reset:hover {
    color: var(--text-color);
    border-color: var(--text-muted);
}

/* WIDGETS TABS & GRID */
.widget-period-tabs {
    display: flex;
    gap: 4px;
    background: var(--bg-color);
    padding: 3px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.tab-period-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 5px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.tab-period-btn.active {
    background: var(--card-bg);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.stat-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.stat-box {
    background: var(--bg-color);
    padding: 8px 10px;
    border-radius: 8px;
}
.stat-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
}
.stat-val {
    font-size: 15px;
    font-weight: 800;
    margin-top: 2px;
}
.btn-share-sm {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    cursor: pointer;
}
.btn-share-sm:hover {
    color: var(--primary);
    border-color: var(--primary);
}


/* TOAST SPRÁVY (AUTO-FADING) */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: slideIn 0.3s forwards, fadeOut 0.5s 3.5s forwards;
}
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }

@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; pointer-events: none; } }

/* ZÚŽENÁ TABUĽKA TANKOVANIA */
.table-compact td { padding: 8px 12px; }
.cell-sub { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

/* JEDNOFAREBNÉ VEKTOROVÉ IKONY PRE REŽIM JÁZD */
.mode-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
}
.mode-icon svg { width: 16px; height: 16px; }
.mode-elec { background: rgba(217, 119, 6, 0.15); color: var(--amber); }
.mode-hybrid { background: rgba(16, 185, 129, 0.15); color: var(--emerald); }
.mode-gas { background: rgba(2, 132, 199, 0.15); color: var(--primary); }

/* AUTH STRÁNKY (LOGIN & REGISTER) */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-color);
    padding: 20px;
}
.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}
.auth-header { text-align: center; margin-bottom: 20px; }

/* ZVÄČŠENÉ MODÁLNE OKNO NASTAVENÍ */
.modal-lg { max-width: 780px !important; }

/* MOBILNÁ RESPONZIVITA */
@media (max-width: 768px) {
    .content-body { padding: 10px; }
    .top-header { padding: 0 10px; }
    .modal-content { padding: 16px; border-radius: 12px; }
    .desktop-table-wrapper { font-size: 11px; }
}


/* =========================================================
   MOBILNÝ DESIGN & BOTTOM NAVIGATION (< 768px)
   ========================================================= */
@media (max-width: 768px) {

    /* 1. Skrytie bočného sidebaru na mobile */
    aside.sidebar {
        display: none !important;
    }

    /* 2. ZOBRAZENIE A FIXOVANIE SPODNEJ MOBILNEJ LIŠTY */
    .mobile-bottom-nav {
        display: flex !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 60px !important;
        background: var(--card-bg) !important;
        border-top: 1px solid var(--border-color) !important;
        z-index: 1000 !important;
        justify-content: space-around !important;
        align-items: center !important;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15) !important;
    }

    .mobile-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        color: var(--text-muted) !important;
        text-decoration: none !important;
        font-size: 10px !important;
        font-weight: 600 !important;
        gap: 3px !important;
        flex: 1 !important;
        height: 100% !important;
    }

    .mobile-nav-item svg {
        width: 20px !important;
        height: 20px !important;
    }

    .mobile-nav-item.active {
        color: var(--primary) !important;
    }

    /* 3. Oprava pozadia hlavičky a prispôsobenie farieb */
    .top-header {
        height: auto !important;
        padding: 10px 12px !important;
        background: var(--card-bg) !important;
        border-bottom: 1px solid var(--border-color) !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
    }

    /* 4. Prvý riadok hlavičky: Titulok + Používateľ + Prepínač témy */
    .header-left {
        width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }

    .header-left .icon-btn[onclick="toggleSidebar()"] {
        display: none !important; /* Skrytie tlačidla menu, keďže je dole bottom nav */
    }

    .page-title {
        font-size: 15px !important;
        font-weight: 700 !important;
        color: var(--text-color) !important;
    }

    .header-right .user-btn {
        display: inline-flex !important;
        padding: 4px 8px !important;
        font-size: 11px !important;
        background: var(--bg-color) !important;
        color: var(--text-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 6px !important;
        max-width: 130px !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .header-right .theme-switch {
        display: inline-block !important;
        transform: scale(0.85);
    }

    /* 5. Druhý riadok hlavičky: Výber vozidla */
    .vehicle-selector {
        width: 100% !important;
        max-width: 100% !important;
        font-size: 12px !important;
        padding: 6px 8px !important;
        background: var(--bg-color) !important;
        color: var(--text-color) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: 8px !important;
    }

    /* 6. Tretí riadok hlavičky: Akčné tlačidlá (+ Jazda / + Tankovanie) */
    .header-right {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
        align-items: center !important;
    }

    .header-right .btn {
        width: 100% !important;
        justify-content: center !important;
        padding: 8px 6px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    /* 7. Odsadenie spodku obsahu, aby spodná lišta neprekrývala posledné riadky/tlačidlá */
    .content-body {
        padding: 10px 10px 75px 10px !important;
    }

    .table-card, .widget-card {
        background: var(--card-bg) !important;
        border: 1px solid var(--border-color) !important;
        color: var(--text-color) !important;
    }

    .table-card-title {
        background: var(--card-bg) !important;
        border-bottom: 1px solid var(--border-color) !important;
        color: var(--text-muted) !important;
    }
}

/* Skrytie spodnej lišty na desktopoch */
@media (min-width: 769px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* STYLY PRE PLÁVAJÚCE TLAČIDLO (FAB) A MENU "VIAC" */
.fab-container {
    display: none;
    position: fixed;
    bottom: 75px;
    right: 18px;
    z-index: 999;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.fab-main-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.fab-main-btn svg {
    width: 26px;
    height: 26px;
    transition: transform 0.2s ease;
}

.fab-container.open .fab-main-btn svg {
    transform: rotate(45deg);
}

.fab-options {
    display: none;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.fab-container.open .fab-options {
    display: flex;
}

.fab-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 24px;
    border: none;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    cursor: pointer;
    white-space: nowrap;
}

.fab-btn svg { width: 16px; height: 16px; }
.fab-btn-primary { background: var(--primary); }
.fab-btn-amber { background: var(--amber); }

/* PONUKA MENU "VIAC" */
.more-menu-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.more-menu-user {
    padding: 10px;
    background: var(--bg-color);
    border-radius: 10px;
    margin-bottom: 8px;
}

.more-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    text-align: left;
}

.more-menu-item:hover {
    background: var(--bg-color);
}

.more-menu-item svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .fab-container { display: flex !important; }
    .desktop-only-actions { display: none !important; }
    
    .top-header {
        padding: 8px 12px !important;
        height: auto !important;
    }
    
    .header-left {
        width: 100% !important;
        justify-content: space-between !important;
    }
    
    .vehicle-selector {
        width: 100% !important;
        margin-top: 4px;
    }
}