/* začátek */
/* ZÁKLAD */
body { margin: 0; font-family: 'Segoe UI', Tahoma, sans-serif; background: #f4f6f8; height: 100vh; display: flex; flex-direction: column; -webkit-tap-highlight-color: transparent; }
.container { flex: 1; display: flex; justify-content: center; align-items: center; }

/* PŘIHLÁŠENÍ */
#login-screen { background: white; padding: 40px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); text-align: center; width: 300px; }
input:not([type="checkbox"]) { width: 100%; padding: 12px; margin: 10px 0; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-size: 16px; } 
button { padding: 12px 15px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; background: #0052cc; color: white; width: 100%; margin-bottom: 10px; touch-action: manipulation; }
.secondary-btn { background: #ebecf0; color: #333; width: auto; display: inline-block; }
.add-btn { width: auto; background: #00875a; display: inline-block; margin-bottom: 0; }

/* HLAVNÍ LAYOUT */
.app-layout { display: flex; width: 100%; height: 100vh; background: white; overflow: hidden; }

/* LEVÝ PANEL */
.sidebar { width: 250px; background: #fafbfc; border-right: 1px solid #dfe1e6; display: flex; flex-direction: column; }
.sidebar-header { padding: 20px; border-bottom: 1px solid #dfe1e6; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.sidebar-header h2 { margin: 0; color: #0052cc; font-size: 24px; }

#install-pwa-btn {
    background: #f9ab00;
    color: #172b4d;
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    display: none; 
    width: auto;
    margin: 0;
    align-items: center;
    gap: 5px;
    transition: transform 0.2s, background 0.2s;
}
#install-pwa-btn:hover { background: #e39a00; transform: scale(1.05); }

.sidebar h3 { font-size: 12px; color: #5e6c84; padding: 15px 20px 5px; text-transform: uppercase; font-weight: bold; }
.user-legend { padding: 10px 15px; overflow-y: auto; }
.legend-item { display: flex; align-items: center; padding: 8px 10px; margin-bottom: 6px; border-radius: 4px; background: white; border: 1px solid #dfe1e6; font-size: 13px; font-weight: 500; color: #172b4d; cursor: pointer; border-left-width: 6px; user-select: none; }

/* HORNÍ NAVIGACE */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.top-bar { padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #dfe1e6; background: white; z-index: 20; }
.nav-controls, .view-switchers { display: flex; align-items: center; gap: 15px; }
.date-range { font-size: 18px; font-weight: bold; color: #172b4d; }
.btn-group { display: flex; border: 1px solid #dfe1e6; border-radius: 4px; overflow: hidden; }
.btn-group button { border-radius: 0; margin: 0; background: white; color: #5e6c84; border-right: 1px solid #dfe1e6; width: auto; padding: 8px 12px; }
.btn-group button:last-child { border-right: none; }
.btn-group button.active { background: #0052cc; color: white; font-weight: bold; }

/* MINI KALENDÁŘ */
.mini-calendar-module { padding: 15px; border-bottom: 1px solid #dfe1e6; }
.mini-cal-header { font-weight: bold; color: #172b4d; margin-bottom: 10px; text-align: center; }
.mini-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 11px; color: #5e6c84; }
.mini-day { padding: 5px; cursor: pointer; border-radius: 4px; }
.mini-day.active { background: #0052cc; color: white; }

/* MŘÍŽKA - TÝDENNÍ POHLED */
.calendar-wrapper { flex: 1; overflow-y: auto; overflow-x: auto; background: white; -webkit-overflow-scrolling: touch; }
.weekly-grid { display: grid; border-top: none; min-width: 700px; } 

.time-col-header, .day-header { position: sticky; top: 0; background: white; z-index: 10; border-bottom: 1px solid #dfe1e6; border-right: 1px solid #dfe1e6; padding: 12px 5px; text-align: center; font-weight: bold; color: #5e6c84; font-size: 13px; }
.time-col-header { z-index: 11; left: 0; }
.all-day-label { background: #fafbfc; position: sticky; left: 0; z-index: 5; border-right: 1px solid #dfe1e6; border-bottom: 2px solid #dfe1e6; }
.all-day-cell { background: #fafbfc; border-right: 1px solid #dfe1e6; border-bottom: 2px solid #dfe1e6; min-height: 50px; padding: 4px; display: flex; flex-direction: column; gap: 2px; }
.time-label { position: sticky; left: 0; background: white; text-align: right; padding: 10px 8px; border-right: 1px solid #dfe1e6; border-bottom: 1px solid #f4f5f7; font-size: 12px; color: #5e6c84; z-index: 5; font-weight: 600; }
.grid-cell { border-right: 1px solid #dfe1e6; border-bottom: 1px solid #f4f5f7; min-height: 50px; position: relative; padding: 2px; }

/* MŘÍŽKA - MĚSÍČNÍ POHLED */
.week-number-cell { display: flex; align-items: flex-start; justify-content: center; padding-top: 10px; background: #fafbfc; border-right: 1px solid #dfe1e6; border-bottom: 1px solid #dfe1e6; font-size: 11px; font-weight: bold; color: #5e6c84; }
.month-day-cell { border-right: 1px solid #dfe1e6; border-bottom: 1px solid #dfe1e6; min-height: 130px; display: flex; flex-direction: column; background: white; }

/* UDÁLOSTI */
.event-block { font-size: 11px; color: white; padding: 5px; border-radius: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; box-shadow: 0 1px 2px rgba(0,0,0,0.1); user-select: none; }

/* MODAL */
.modal { position: fixed; z-index: 100; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 15px; box-sizing: border-box; }
.modal-content { background: white; padding: 20px; border-radius: 12px; width: 100%; max-width: 380px; text-align: center; max-height: 90vh; overflow-y: auto; }
.modal-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 15px; }

/* RESPONZIVITA - MOBILY (Ultra kompaktní hlavička) */
@media (max-width: 768px) {
    .app-layout { flex-direction: column; }
    
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid #dfe1e6; flex-direction: row; align-items: center; padding: 0; height: auto; }
    .sidebar-header { display: flex; padding: 5px 8px; border-bottom: none; border-right: 1px solid #dfe1e6; width: auto; flex-shrink: 0; gap: 5px; }
    .sidebar-header h2 { font-size: 14px; margin: 0; }
    #install-pwa-btn { padding: 4px 6px; font-size: 9px; margin-left: 2px; }
    
    .mini-calendar-module, .sidebar h3 { display: none; }
    
    .user-legend { display: flex; flex-direction: row; overflow-x: auto; padding: 4px 8px; gap: 5px; scrollbar-width: none; }
    .user-legend::-webkit-scrollbar { display: none; }
    .legend-item { margin-bottom: 0; white-space: nowrap; flex-shrink: 0; padding: 4px 8px; font-size: 11px; border-left-width: 4px; }

    .top-bar { flex-direction: column; padding: 5px 8px; gap: 5px; }
    .nav-controls { width: 100%; justify-content: space-between; align-items: center; }
    
    /* Změna velikosti oříznutého data */
    .date-range { font-size: 14px; font-weight: bold; letter-spacing: -0.3px; }
    
    .view-switchers { width: 100%; justify-content: space-between; align-items: center; flex-wrap: nowrap; gap: 4px; }
    
    #user-display-name { font-size: 12px; margin-right: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 60px; }
    
    /* Výrazné zmenšení tlačítek pro úsporu výšky */
    .btn-group button { padding: 5px 8px; font-size: 11px; }
    .icon-btn { padding: 5px 8px !important; font-size: 12px !important; }
    #today-btn { padding: 5px 8px !important; font-size: 11px !important; }
    .add-btn { padding: 5px 8px; font-size: 11px; }
    .secondary-btn { padding: 5px 8px; font-size: 11px; margin-left: 0 !important; }

    .weekly-grid { min-width: 850px; }
}

/* OVERVIEW POHLED - Kdo je kde */
.overview-grid {
    display: grid !important;
    min-width: unset !important;
    width: 100%;
    height: 100%;
    border-top: 1px solid #dfe1e6;
}

.overview-day-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px;
    border-right: 1px solid #dfe1e6;
    border-bottom: 2px solid #dfe1e6;
    background: white;
    position: sticky;
    top: 0;
    z-index: 10;
    cursor: pointer;
}

.overview-day-name {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: bold;
    color: #5e6c84;
    letter-spacing: 0.3px;
}

.overview-day-num-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.overview-day-num {
    font-size: 18px;
    font-weight: bold;
    color: #172b4d;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.overview-today .overview-day-num {
    background: #0052cc;
    color: white;
}

.overview-day-cell {
    border-right: 1px solid #dfe1e6;
    padding: 5px 3px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    background: white;
    min-height: 150px;
}

.overview-day-cell:hover {
    background: #f8f9ff;
}

.overview-pill {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 5px 5px;
    border-radius: 5px;
    font-size: 11px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: transform 0.1s;
}

.overview-pill:hover { transform: scale(1.03); }

.pill-emoji { font-size: 11px; flex-shrink: 0; }

.pill-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 400;
    letter-spacing: 0.2px;
    flex-shrink: 0;
}

/* Název akce — vždy viditelný, zkrácený ellipsou */
.pill-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 400;
    opacity: 0.92;
    display: inline;
    min-width: 0;
}

/* Portrait mobil: 5 dní viditelných, So+Ne scrollem doprava */
@media (max-width: 768px) and (orientation: portrait) {
    .overview-grid { min-width: calc(7 * (100vw / 5)) !important; }
}

/* Landscape + desktop: všechny 7 dní na šířku */
@media (orientation: landscape), (min-width: 769px) {
    .overview-grid { min-width: unset !important; width: 100%; }
}

/* Read-only modal pro cizí akce */
#view-event-modal .modal-content { text-align: left; }
#view-event-modal h3 { margin-bottom: 5px; }
.view-event-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f0f0f0; font-size: 14px; color: #172b4d; }
.view-event-row:last-of-type { border-bottom: none; }
.view-event-label { font-size: 11px; color: #5e6c84; min-width: 60px; }
/* VÍKENDY A SVÁTKY */
.weekend-cell { background: #f5f5f0 !important; }
.holiday-cell { background: #fffbea !important; }

/* Název svátku v měsíčním pohledu */
.holiday-label { font-size: 10px; color: #b06000; font-weight: 600; padding: 1px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Hlavičky dnů v týdenním pohledu */
.day-header.weekend-header { background: #f5f5f0; color: #5e6c84; }
.day-header.holiday-header { background: #fffbea; }
.header-holiday-name { display: block; font-size: 10px; font-weight: 600; color: #b06000; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Overview pohled */
.overview-day-header.overview-weekend { background: #f5f5f0; }
.overview-day-header.overview-holiday { background: #fffbea; }
.overview-weekend-cell { background: #f8f8f4; }
.overview-holiday-name { display: block; font-size: 9px; font-weight: 600; color: #b06000; margin-top: 2px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; }
/* DNEŠNÍ DEN */
.today-badge { display: inline-flex; align-items: center; justify-content: center; background: #0052cc; color: white; border-radius: 50%; width: 24px; height: 24px; font-size: 12px; font-weight: bold; }
.month-day-number { padding: 6px 8px; font-size: 13px; font-weight: 600; color: #172b4d; }
.day-header.today-header { background: #e8f0fe; color: #0052cc; font-weight: bold; }

/* PŘETÉKAJÍCÍ AKCE V MĚSÍCI */
.overflow-badge { position: absolute; bottom: 4px; right: 4px; font-size: 10px; font-weight: bold; color: #5e6c84; background: #f0f1f3; border-radius: 3px; padding: 1px 5px; pointer-events: none; }

/* DARK MODE */
body.dark { background: #111827; color: #f3f4f6; }
body.dark .container { background: #111827; }
body.dark .app-layout { background: #111827; }
body.dark .sidebar { background: #1f2937; border-color: #374151; }
body.dark .sidebar-header { border-color: #374151; }
body.dark .sidebar-header h2 { color: #60a5fa; }
body.dark .sidebar h3 { color: #9ca3af; }
body.dark .legend-item { background: #1f2937; border-color: #374151; color: #f3f4f6; }
body.dark .top-bar { background: #1f2937; border-color: #374151; }
body.dark .date-range { color: #f3f4f6; }
body.dark .btn-group { border-color: #374151; }
body.dark .btn-group button { background: #1f2937; color: #9ca3af; border-color: #374151; }
body.dark .btn-group button.active { background: #2563eb; color: white; }
body.dark .day-header, body.dark .time-col-header { background: #1f2937; color: #9ca3af; border-color: #374151; }
body.dark .day-header.today-header { background: #1e3a5f; color: #60a5fa; }
body.dark .day-header.weekend-header { background: #161b24; }
body.dark .day-header.holiday-header { background: #181812; }
body.dark .time-label { background: #111827; color: #6b7280; border-color: #1f2937; }
body.dark .grid-cell { background: #111827 !important; border-color: #1f2937; }
body.dark .grid-cell.weekend-cell { background: #14181f !important; }
body.dark .grid-cell.holiday-cell { background: #181812 !important; }
body.dark .all-day-label { background: #1f2937; border-color: #374151; }
body.dark .all-day-cell { background: #1a2332 !important; border-color: #374151; }
body.dark .all-day-cell.weekend-cell { background: #14181f !important; }
body.dark .all-day-cell.holiday-cell { background: #181812 !important; }
body.dark .calendar-wrapper { background: #111827; }
body.dark .month-day-cell { background: #1f2937; border-color: #374151; color: #f3f4f6; }
body.dark .month-day-number { color: #d1d5db; }
body.dark .month-day-cell.other-month-bg { background: #161e2b; }
body.dark .month-day-cell.weekend-cell { background: #161b24 !important; }
body.dark .month-day-cell.holiday-cell { background: #181812 !important; }
body.dark .week-number-cell { background: #161b24; color: #6b7280; border-color: #374151; }
body.dark .mini-cal-header { color: #f3f4f6; }
body.dark .mini-cal-grid { color: #9ca3af; }
body.dark .mini-day:hover { background: #374151; }
body.dark .mini-day.active { background: #2563eb; }
body.dark .overview-day-header { background: #1f2937; border-color: #374151; }
body.dark .overview-day-name { color: #9ca3af; }
body.dark .overview-day-num { color: #f3f4f6; }
body.dark .overview-today .overview-day-num { background: #2563eb; color: white; }
body.dark .overview-weekend { background: #161b24 !important; }
body.dark .overview-holiday { background: #181812 !important; }
body.dark .overview-day-cell { background: #111827 !important; border-color: #1f2937; }
body.dark .overview-day-cell:hover { background: #161b24 !important; }
body.dark .overview-day-cell.overview-weekend-cell { background: #14181f !important; }
body.dark .overview-day-cell.holiday-cell { background: #181812 !important; }
body.dark .modal-content { background: #1f2937; color: #f3f4f6; }
body.dark .modal-content h3 { color: #f3f4f6; }
body.dark input:not([type="checkbox"]), body.dark select { background: #374151; border-color: #4b5563; color: #f3f4f6; }
body.dark .secondary-btn { background: #374151; color: #d1d5db; }
body.dark .overflow-badge { background: #374151; color: #9ca3af; }
body.dark .holiday-label { color: #f59e0b; }
body.dark .header-holiday-name { color: #f59e0b; }
body.dark .overview-holiday-name { color: #f59e0b; }
body.dark #user-display-name { color: #60a5fa; }
body.dark .view-event-row { border-color: #374151; color: #f3f4f6; }
body.dark .view-event-label { color: #9ca3af; }

/* STŘÍDAVÁ PÉČE */
:root {
    --custody-mother-color: #d63384;   /* růžová */
    --custody-father-color: #1a73e8;   /* modrá */
}
.custody-legend { padding: 6px 15px 12px; font-size: 12px; color: #172b4d; }
.custody-legend-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.link-btn { background: transparent !important; border: none !important;