* { margin: 0; padding: 0; box-sizing: border-box; }

body, html {
    width: 100%; height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0f172a;
    color: #f8fafc;
}

.screen { display: none; width: 100%; height: 100%; }
.screen.active { display: flex; }

/* LOGOWANIE */
#login-screen {
    justify-content: center; align-items: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 20px;
}
.login-box {
    background: #1e293b; padding: 32px; border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    border: 1px solid #334155; width: 100%; max-width: 400px; text-align: center;
}
.login-box h2 { margin-bottom: 8px; font-size: 24px; }
.login-box p { color: #94a3b8; font-size: 14px; margin-bottom: 24px; }
.login-box input {
    width: 100%; padding: 12px 16px; border-radius: 8px;
    border: 1px solid #334155; background: #0f172a; color: #fff;
    font-size: 16px; margin-bottom: 16px; outline: none;
}
.login-box button {
    width: 100%; padding: 12px; border-radius: 8px; border: none;
    background: #2563eb; color: white; font-weight: bold; font-size: 16px; cursor: pointer;
}
.error { color: #ef4444 !important; font-size: 13px !important; margin-top: 12px; }

/* MAPA I PASEK KONTROLNY */
#map-screen { position: relative; }
#map { width: 100%; height: 100vh; }

.map-controls { position: absolute; top: 16px; right: 16px; z-index: 1000; display: flex; gap: 10px; align-items: center; }
.control-btn {
    height: 40px; border-radius: 8px; border: 1px solid #334155; background: #1e293b;
    color: #f8fafc; font-weight: bold; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    display: flex; align-items: center; justify-content: center; transition: all 0.2s ease;
}
.control-btn:hover { background: #334155; border-color: #38bdf8; }
.square-btn { width: 40px; padding: 0; }
.square-btn img { width: 22px; height: 22px; object-fit: contain; }
.square-btn.light-mode { background: #ffffff !important; border-color: #cbd5e1 !important; box-shadow: 0 4px 10px rgba(0,0,0,0.15) !important; }
.logout-btn { padding: 0 16px; background: #ef4444; border-color: #dc2626; }
.logout-btn:hover { background: #dc2626; }

/* IKONA APARTAMENTOWCA Z LICZNIKIEM */
.building-hub-container { background: none; border: none; }
.building-wrapper { position: relative; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.building-img { width: 38px; height: 38px; object-fit: contain; filter: drop-shadow(0px 4px 6px rgba(0,0,0,0.5)); transition: transform 0.2s ease; }
.building-wrapper:hover .building-img { transform: scale(1.15); }
.building-badge {
    display: none; position: absolute; bottom: -3px; right: -3px; background: #f59e0b;
    color: #0f172a; font-weight: bold; font-size: 11px; padding: 1px 6px; border-radius: 10px;
    border: 1px solid #0f172a; box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}
#map-screen.zoom-close .building-badge { display: flex; }

/* STYLIZACJA POPUP I CHMUREK */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.96) !important; backdrop-filter: blur(10px);
    color: #f8fafc !important; border-radius: 14px !important; border: 1px solid #334155 !important;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6) !important; padding: 8px !important; max-width: 92vw !important;
}
.leaflet-popup-tip { background: rgba(15, 23, 42, 0.96) !important; border: 1px solid #334155 !important; }
.popup-title { font-size: 14px; font-weight: 700; color: #38bdf8; margin-bottom: 10px; border-bottom: 1px solid #334155; padding-bottom: 6px; }

.chmurki-container { display: flex; gap: 12px; flex-wrap: wrap; max-height: 450px; overflow-y: auto; }
.chmurka-box {
    background: #1e293b; border: 1px solid #3b82f6; border-radius: 10px;
    padding: 12px; min-width: 260px; flex: 1; box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.package-card { background: #0f172a; border: 1px solid #334155; border-radius: 8px; padding: 10px; margin-top: 8px; }
.package-order-num { font-size: 13px; font-weight: bold; color: #38bdf8; }
.package-sub-meta { font-size: 10px; color: #94a3b8; margin-bottom: 8px; border-bottom: 1px solid #1e293b; padding-bottom: 4px; }

.field-vertical { display: flex; flex-direction: column; margin-bottom: 8px; }
.field-label-small { font-size: 10px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }

/* PODKREŚLENIE IMIENIA I NAZWISKA W POPUPIE */
.client-name {
    font-weight: 600;
    font-size: 1.15rem;
    color: #f1f5f9; /* Zmieniono na jasny, aby było widać na ciemnym tle */
    border-bottom: 2px solid #002699; /* Ciemnoniebieskie podkreślenie (Twoje wytyczne) */
    padding-bottom: 2px;
    display: inline-block;
    margin-top: 2px;
}

.phone-container {
    display: flex; align-items: center; justify-content: space-between;
    background: #0f172a; padding: 6px 8px; border-radius: 6px; border: 1px solid #334155; margin-top: 6px; margin-bottom: 8px;
}
.products-dropdown { margin-top: 8px; border-top: 1px dashed #334155; padding-top: 6px; }
.toggle-products-btn {
    width: 100%; background: #1e293b; border: 1px solid #334155; color: #38bdf8; font-size: 11px;
    padding: 5px; border-radius: 4px; cursor: pointer; text-align: left; display: flex; justify-content: space-between;
}
.toggle-products-btn:hover { background: #334155; }
.products-list-content {
    display: none; background: #090d16; border: 1px solid #1e293b; border-radius: 4px;
    padding: 6px; margin-top: 6px; max-height: 120px; overflow-y: auto; font-size: 11px; color: #cbd5e1;
}
.products-list-content ul { list-style: none; padding-left: 0; }
.products-list-content li { padding: 2px 0; border-bottom: 1px solid #111827; }
.reveal-btn { background: none; border: none; cursor: pointer; font-size: 13px; }
/* WYSZUKIWARKA I FILTRY - ZAKTUALIZOWANE */
.search-container {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-panel {
    display: flex;
    gap: 8px;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(8px);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #334155;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    align-items: center;
}

.search-panel input, .search-panel select {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid #334155;
    background: #0f172a;
    color: #f8fafc;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-panel input { width: 220px; }
.search-panel input:focus, .search-panel select:focus { border-color: #38bdf8; }

.search-panel button {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    background: #2563eb;
    color: white;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    transition: background 0.2s;
}

.search-panel button:hover { background: #1d4ed8; }

/* ROZWIJANA LISTA WYNIKÓW */
.search-results {
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(8px);
    border: 1px solid #334155;
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    max-height: 350px;
    overflow-y: auto;
    display: none; /* Domyślnie ukryte */
}

.search-results.active {
    display: block;
}

.results-header {
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #334155;
}

.results-header span {
    font-weight: bold;
    color: #38bdf8;
    font-size: 14px;
}

#results-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.result-item {
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    border-bottom: 1px solid #1e293b;
    transition: background 0.2s;
}

.result-item:last-child { border-bottom: none; }
.result-item:hover { background: #334155; }

.result-name {
    font-size: 14px;
    font-weight: bold;
    color: #f8fafc;
    margin-bottom: 4px;
}

.result-meta {
    font-size: 12px;
    color: #cbd5e1;
    margin-bottom: 2px;
}

/* Responsywność */
@media (max-width: 768px) {
    .search-container {
        top: 70px;
        width: 90%;
    }
    .search-panel {
        flex-direction: column;
        width: 100%;
    }
    .search-panel input, .search-panel select, .search-panel button { width: 100%; }
}
/* Nowoczesna Karta Logowania */
.login-card {
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 35px 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.5);
    margin: 0 auto;
}

.login-card h2 {
    color: #ffffff;
    font-size: 24px;
    margin-bottom: 8px;
}

.login-card .subtitle {
    color: #94a3b8;
    font-size: 14px;
    margin-bottom: 20px;
}

.turnstile-container {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

/* Nowoczesny Przycisk */
.btn-login {
    width: 100%;
    padding: 14px;
    background: #2563eb;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-login:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    background: #475569;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-msg {
    color: #f87171;
    font-size: 13px;
    margin-top: 15px;
    min-height: 18px;
}
/* Nagłówek wyników z przyciskiem zwijania */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1e293b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    font-size: 13px;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
}

.toggle-search-btn {
    background: transparent;
    border: none;
    color: #3b82f6;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 2px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.toggle-search-btn:hover {
    color: #60a5fa;
    background: rgba(255, 255, 255, 0.08);
}

/* Stan zwinięty panelu wyników */
.search-results-panel.collapsed #results-content {
    display: none;
}

.search-results-panel.collapsed .search-results-header {
    border-bottom: none;
    border-radius: 10px;
}
/* --- PANEL WYNIKÓW WYSZUKIWANIA --- */
.search-results-panel {
    display: none; /* Domyślnie CAŁKOWICIE UKRYTY po zalogowaniu */
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    width: 100%;
    margin-top: 8px;
    overflow: hidden;
}

/* Pokazuje się TYLKO gdy szukamy */
.search-results-panel.active {
    display: block;
}

/* Nagłówek zwijania */
.search-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #1e293b;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s ease;
}

.search-results-header:hover {
    background: #283548;
    color: #ffffff;
}

.toggle-arrows {
    color: #3b82f6;
    font-size: 11px;
    letter-spacing: 2px;
    font-weight: bold;
}

/* ZABLOKOWANIE WYSOKOŚCI LISTY (max 4-5 wyników) + SCROLL */
#results-content {
    max-height: 250px;
    overflow-y: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Ładny wygląd paska przewijania (Scrollbara) */
#results-content::-webkit-scrollbar {
    width: 6px;
}
#results-content::-webkit-scrollbar-thumb {
    background: #3b82f6;
    border-radius: 3px;
}

/* Stan ZWINIĘTY (ukrywa tylko listę pod nagłówkiem) */
.search-results-panel.collapsed #results-content {
    display: none;
}
/* Styling dla kart w popupie */
.multi-pkg-badge {
    display: inline-block;
    background-color: #2563eb;
    color: #ffffff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 12px;
    margin-top: 4px;
    font-weight: 600;
}

.card-border-top {
    border-top: 2px dashed #334155;
    margin-top: 12px;
    padding-top: 12px;
}

.products-list-ul {
    list-style: none;
    padding-left: 5px;
    margin: 5px 0 0 0;
    max-height: 120px;
    overflow-y: auto;
}

.products-list-ul li {
    font-size: 12px;
    color: #cbd5e1;
    padding: 2px 0;
}
/* ==========================================
   STYLOWANIE SUWAKA (SCROLLBAR) W POPUPACH
   ========================================== */
.chmurki-container {
    max-height: 400px; /* Zabezpieczenie wysokości */
    overflow-y: auto;
    padding-right: 5px;
}

.chmurki-container::-webkit-scrollbar {
    width: 8px;
}

.chmurki-container::-webkit-scrollbar-track {
    background: #1e2430; /* Ciemne tło, pasujące do tła popupu */
    border-radius: 4px;
}

.chmurki-container::-webkit-scrollbar-thumb {
    background: #3a475e; /* Kolor samego suwaka */
    border-radius: 4px;
}

.chmurki-container::-webkit-scrollbar-thumb:hover {
    background: #4a5975; /* Jaśniejszy kolor przy najechaniu */
}
/* ==========================================
   STYLOWANIE SUWAKA W LISTACH PRODUKTÓW
   ========================================== */
.products-list-content,
.products-list-content ul {
    scrollbar-width: thin; /* Dla Firefoxa */
    scrollbar-color: #2c3648 #121721;
}

/* Chrome, Edge, Safari, Opera */
.products-list-content::-webkit-scrollbar,
.products-list-content ul::-webkit-scrollbar {
    width: 6px;
}

.products-list-content::-webkit-scrollbar-track,
.products-list-content ul::-webkit-scrollbar-track {
    background: #121721; /* Ciemne tło pod suwakiem */
    border-radius: 3px;
}

.products-list-content::-webkit-scrollbar-thumb,
.products-list-content ul::-webkit-scrollbar-thumb {
    background: #2c3648; /* Kolor uchwytu suwaka */
    border-radius: 3px;
}

.products-list-content::-webkit-scrollbar-thumb:hover,
.products-list-content ul::-webkit-scrollbar-thumb:hover {
    background: #3e4c66; /* Kolor po najechaniu myszką */
}
/* ==========================================
   IDENTYFIKATOR SESJI UŻYTKOWNIKA
   ========================================== */
.session-badge {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(18, 23, 33, 0.65);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8ba3c7;
    font-size: 11px;
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none; /* Żeby nie blokował klikania w mapę pod nim */
    user-select: all; /* Łatwe zaznaczanie do skopiowania */
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.session-badge:hover {
    opacity: 1;
}
.session-badge {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(18, 23, 33, 0.65);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8ba3c7;
    font-size: 11px;
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    user-select: all;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}
.session-badge:hover {
    opacity: 1;
}
/* ==========================================
   IDENTYFIKATOR SESJI UŻYTKOWNIKA
   ========================================== */
.session-badge {
    position: fixed;
    bottom: 12px;
    left: 12px;
    z-index: 1000;
    background: rgba(18, 23, 33, 0.65);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #8ba3c7;
    font-size: 11px;
    font-family: monospace;
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    user-select: all;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.session-badge:hover {
    opacity: 1;
}
/* Uniwersalny badge sesji - czytelny w obu motywach */
/* Domyślny (ciemny) motyw: ciemne tło, biały/jasny czytelny napis */
/* Podłużny badge sesji - elegancki, poziomy pasek w lewym dolnym rogu */
.session-badge {
    position: absolute;
    bottom: 24px;
    left: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: rgba(18, 23, 33, 0.85);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 12px;
    font-family: monospace;
    padding: 8px 14px;
    border-radius: 8px;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    transition: background 0.3s ease, border-color 0.3s ease;
}

/* --- TRYB CIEMNY (DOMYŚLNY) --- */
.session-label {
    color: #ffffff; /* Biały napis "Sesja:" */
    font-weight: 500;
}

.session-id-value {
    color: #38bdf8; /* Wyrazisty błękit dla samego ID sesji */
    font-weight: bold;
}

/* --- TRYB JASNY --- */
body.light-mode .session-badge,
.light-mode .session-badge {
    background: rgba(255, 255, 255, 0.90);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

body.light-mode .session-label,
.light-mode .session-label {
    color: #000000; /* Czarny napis "Sesja:" w jasnym motywie */
}

body.light-mode .session-id-value,
.light-mode .session-id-value {
    color: #2563eb; /* Ciemnoniebieski / wyróżniający się kolor dla ID sesji w jasnym motywie */
}

/* Jasny motyw (gdy body ma klasę light-mode): jasne tło, czarny napis */
body.light-mode .session-badge,
.light-mode .session-badge {
    background: rgba(255, 255, 255, 0.90);
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: #000000; /* Mocny, czytelny czarny napis w jasnym motywie */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Automatyczne dostosowanie do jasnego motywu (gdy body ma klasę light-mode / light) */
body.light-mode .session-badge,
.light-mode .session-badge {
    background: rgba(255, 255, 255, 0.90);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #0369a1; /* Ciemniejszy, elegancki niebieski na jasnym tle */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
/* Jasny motyw dla badge'a sesji */
body.light-mode .session-badge {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.15);
    color: #333333;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}