:root { 
    --bg: #0f1113; 
    --sidebar: #1a1c1e; 
    --text: #e0e6ed; 
    --accent: #3498db; 
    --card: #25282c; 
    --border: #33363a; 
    --danger: #e74c3c;
    --success: #2ecc71;
}

/* ===== ALAPOK ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
    margin: 0; font-family: 'Segoe UI', sans-serif;
    background: var(--bg); color: var(--text);
    height: 100dvh; width: 100vw; overflow: hidden;
}

#app-content { display: flex; width: 100%; height: 100%; }

/* ===== LOGIN SCREEN ===== */
#login-screen {
    position: fixed; inset: 0; background: var(--bg);
    display: flex; justify-content: center; align-items: center; z-index: 9999;
}
.login-box {
    background: var(--sidebar); padding: 30px; border-radius: 14px;
    border: 1px solid var(--accent); width: min(90%, 340px); text-align: center;
}

/* ===== SIDEBAR (ASZTALI) ===== */
#sidebar {
    width: 360px; min-width: 360px;
    background: var(--sidebar); display: flex;
    flex-direction: column; border-right: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-header { 
    padding: 10px; 
    background: #212427; 
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

/* STATISZTIKA (ASZTALI RÁCS) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 5px;
}

.stat-btn {
    background: var(--card); border-radius: 10px; text-align: center;
    cursor: pointer; border: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    height: 65px; transition: 0.2s;
}
.stat-btn b { display: block; font-size: 16px; color: var(--accent); margin-top: 2px; }

/* ===== LISTA ÉS VÁROSOK ===== */
#dueList { flex-grow: 1; overflow-y: auto; padding: 10px; }

.city-group {
    background: var(--card); padding: 12px 14px; margin-top: 6px;
    border-radius: 8px; display: flex; justify-content: space-between;
    font-size: 12px; color: var(--accent); border-left: 3px solid var(--accent);
    text-transform: uppercase; cursor: pointer;
}

.client-list-container {
    display: none; 
    padding-left: 5px;
}

.client-list-container.open {
    display: block !important; 
}

.list-item {
    padding: 10px; background: #1e2124; margin: 4px 0 4px 12px;
    border-radius: 8px; cursor: pointer; font-size: 13px;
}

/* ===== MODERNEBB ADATLAP ELEMEK ===== */
.action-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin: 20px 0;
}

.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px 5px;
    border-radius: 12px;
    text-decoration: none;
    color: white;
    font-weight: bold;
    font-size: 13px;
    transition: transform 0.1s;
}

.action-btn:active { transform: scale(0.95); }
.call-btn { background: var(--success); }
.mail-btn { background: var(--accent); }
.navi-btn { background: #e67e22; }

.action-btn i { font-size: 20px; margin-bottom: 5px; font-style: normal; }

.info-card {
    background: rgba(255,255,255,0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.info-card p { margin: 8px 0; font-size: 14px; color: #cbd5e0; }
.info-card strong { color: var(--accent); }

/* GOMBOK EGYMÁS MELLÉ RENDEZÉSE AZ ADATLAPON */
.button-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.button-row button {
    flex: 1;
    margin: 0 !important;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    white-space: nowrap;
}

/* ===== NAPTÁR RÁCS ===== */
.cal-grid {
    display: grid !important;
    grid-template-columns: repeat(7, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
    margin-top: 10px;
}

.cal-header {
    text-align: center; font-weight: bold; color: var(--accent);
    padding: 5px 0; font-size: 12px;
}

.cal-day {
    display: flex !important; aspect-ratio: 1 / 1 !important;
    justify-content: center; align-items: center;
    background: #1e2124; border-radius: 6px;
    font-size: 14px; cursor: pointer; min-width: 0;
}
.cal-day.has-task { border: 1.5px solid var(--accent); color: var(--accent); font-weight: bold; }
.cal-day.today { background: var(--accent); color: white; }

/* ===== TÉRKÉP ÉS GOMB ===== */
#map-container { flex-grow: 1; position: relative; }
#map { width: 100%; height: 100%; }
.add-btn {
    position: fixed; bottom: 24px; right: 24px; width: 56px; height: 56px;
    background: var(--accent); border-radius: 50%; font-size: 28px;
    color: white; border: none; z-index: 1500; cursor: pointer;
}

#clientDetails.open { right: 0 !important; }

/* ===== MOBIL NÉZET (768px ALATT) ===== */
@media (max-width: 768px) {
    #app-content { flex-direction: column; }
    #map-container { height: 35dvh; order: 1; flex-shrink: 0; }
    
    #sidebar { 
        width: 100%; min-width: 100%; height: 65dvh; 
        order: 2; border-top: 1px solid var(--border); border-right: none;
        display: flex !important; flex-direction: column !important;
    }

    #sidebar .stats-grid {
        display: none !important;
    }

    button[onclick="toggleMobileStats()"] {
        display: block;
    }

    .sidebar-header {
        width: 100% !important;
        padding: 10px !important;
        position: relative;
        z-index: 10;
    }

    #dueList {
        flex-grow: 1 !important;
        overflow-y: auto !important;
    }

    #clientDetails { width: 100%; right: -100%; }

    #sidebar > div[style*="grid-template-columns"] {
        background: var(--sidebar);
        padding-bottom: 25px !important; 
    }
    
    /* Munkalap modál mobilra igazítása */
    #logModal {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        inset: 0;
        transform: none;
        padding: 20px;
    }
    
    #logModal textarea {
        height: 150px; /* Nagyobb terület a mobil gépeléshez */
    }
}

@media (min-width: 769px) {
    button[onclick="toggleMobileStats()"] {
        display: none !important;
    }
}

/* ===== MODALOK ===== */
.modal {
    display: none; position: fixed; inset: 50% auto auto 50%;
    transform: translate(-50%, -50%); background: var(--card);
    padding: 20px; border-radius: 16px; z-index: 5001;
    width: min(95%, 550px); max-height: 90dvh; overflow-y: auto;
    border: 1px solid var(--accent);
}
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.8); z-index: 5000; }

input, select, textarea { 
    width: 100%; padding: 12px; margin-bottom: 10px; border-radius: 8px; 
    border: 1px solid var(--border); background: var(--card); color: white; 
    font-size: 16px; /* Megelőzi a mobil Safari automatikus zoomolását */
}
button { 
    width: 100%; padding: 12px; border-radius: 8px; border: none; 
    background: var(--accent); color: white; font-weight: bold; cursor: pointer; 
}

#clientDetails { 
    position: fixed; top: 0; right: -520px; width: 520px; max-width: 100%; 
    height: 100%; background: var(--sidebar); z-index: 2001; 
    transition: 0.4s ease; padding: 24px; overflow-y: auto; border-left: 1px solid var(--border); 
}

/* ===== MOBIL PANEL STÍLUSOK ===== */
#mobile-stats-panel {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    background: var(--sidebar);
    z-index: 5002;
    transition: bottom 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 20px;
    border-radius: 20px 20px 0 0;
    border-top: 2px solid var(--accent);
    box-shadow: 0 -10px 25px rgba(0,0,0,0.5);
}

#mobile-stats-panel.open { bottom: 0; }

#mobile-stats-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(3px);
    z-index: 5001;
}

#mobile-stats-overlay.active { display: block; }

#mobile-stats-container .stats-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
}

/* ============================================================
   ÚJ SZAKASZ: HIERARCHIA ÉS PIN PANEL (SAAS BŐVÍTÉS)
   ============================================================ */

#hierarchy-overlay {
    position: fixed; 
    inset: 0; 
    background: var(--bg);
    z-index: 9999; 
    display: none; 
    justify-content: center; 
    align-items: center; 
    flex-direction: column;
    backdrop-filter: blur(10px);
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 300px;
    margin: 20px auto;
}

.pin-pad button {
    height: 70px;
    font-size: 24px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    transition: background 0.2s, transform 0.1s;
    width: 100%;
}

.pin-pad button:active {
    transform: scale(0.95);
    background: var(--accent);
}

.role-btn {
    width: 100%;
    padding: 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: 0.2s;
    margin-bottom: 8px;
}

.role-btn:hover {
    border-color: var(--accent);
    background: #2c3136;
}

.role-btn i {
    color: var(--accent);
    font-style: normal;
}

#pin-display {
    text-align: center;
    min-height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0,0,0,0.2);
    border-radius: 8px;
    margin-bottom: 20px !important;
    font-size: 32px;
    letter-spacing: 10px;
}

.staff-item {
    background: #1e2124;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 3px solid var(--success);
}

.staff-info b {
    display: block;
    font-size: 14px;
    color: white;
}

.staff-info span {
    font-size: 12px;
    color: #888;
}

.remove-staff-btn {
    background: none;
    color: var(--danger);
    width: auto;
    padding: 5px;
    cursor: pointer;
    font-size: 18px;
    border: none;
}

@keyframes hierarchyFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.assigned-badge {
    font-size: 10px;
    background: var(--accent);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
    vertical-align: middle;
}

/* ===== LANDING INFO GOMB (HOZZÁADVA) ===== */
.floating-info {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--accent);
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    z-index: 9999;
    transition: all 0.3s ease;
    font-weight: bold;
}

.floating-info .icon {
    background: rgba(255,255,255,0.2);
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: serif;
    font-style: italic;
}

.floating-info:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

@media (max-width: 768px) {
    .floating-info span { display: none; }
    .floating-info { padding: 15px; border-radius: 50%; bottom: 20px; right: 20px; }
}

@media (max-width: 400px) {
    .pin-pad button {
        height: 60px;
        font-size: 20px;
    }
}