/* --- ZMIENNE KOLORYSTYCZNE & MOTYWY --- */
:root {
    /* Podstawowe - Jasny Motyw */
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #d1fae5;
    
    --bg-body: #f8fafc;
    --bg-gradient: radial-gradient(circle at 50% 0%, #e2e8f0 0%, transparent 70%);
    
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --surface-glass: rgba(255, 255, 255, 0.85);
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-inverse: #ffffff;
    
    --border-subtle: rgba(148, 163, 184, 0.2);
    --border-focus: #10b981;
    
    --active-surface: #ecfdf5;
    --active-border: #10b981;
    
    /* Cienie */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-float: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Promienie */
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;

    /* Zastępstwa */
    --sub-bg: #fff7ed;
    --sub-border: #f97316;
    --sub-text: #9a3412;
    --sub-cancel-bg: #fef2f2;
    --sub-cancel-border: #ef4444;
    --sub-cancel-text: #991b1b;
}

/* Ciemny Motyw */
[data-theme="dark"] {
    --primary: #10b981;
    --primary-dark: #059669; /* Ciemniejsza zieleń w dark mode */
    --primary-light: #064e3b;

    --bg-body: #0f172a;
    --bg-gradient: radial-gradient(circle at 50% 0%, #1e293b 0%, transparent 70%);

    --surface: #1e293b;
    --surface-hover: #334155;
    --surface-glass: rgba(30, 41, 59, 0.85);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    
    --border-subtle: rgba(255, 255, 255, 0.1);
    
    --active-surface: rgba(5, 150, 105, 0.2);
    --active-border: #34d399;

    --sub-bg: rgba(67, 20, 7, 0.3); 
    --sub-border: #fb923c;
    --sub-text: #fdba74;
    --sub-cancel-bg: rgba(69, 10, 10, 0.3);
    --sub-cancel-border: #f87171;
    --sub-cancel-text: #fca5a5;
}

/* --- ANIMACJE --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95) translateY(-5px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- GLOBALNE --- */
html { 
    background-color: var(--bg-body); 
    overscroll-behavior-y: none; 
    transition: background-color 0.3s ease;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0; 
    padding: 0; 
    min-height: 100dvh;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
    transition: color 0.3s ease;
}

.container { 
    max-width: 1400px; 
    margin: 0 auto; 
    padding: 0 1rem; 
}

/* --- NAGŁÓWEK --- */
header {
    background: var(--surface-glass);
    backdrop-filter: blur(9px) saturate(180%);
    -webkit-backdrop-filter: blur(9px) saturate(180%);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-content { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

h1 { 
    margin: 0; 
    font-size: 1.25rem; 
    font-weight: 800; 
    display: flex; 
    align-items: center; 
    gap: 0.75rem;
    letter-spacing: -0.02em;
}

.badge { 
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--text-inverse);
    padding: 0.25rem 0.6rem;
    border-radius: 99px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-actions { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem; 
}

/* --- WIDOKI I PRZEŁĄCZANIE --- */
.view-section {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

.view-section.hidden {
    display: none !important;
}

/* --- STYLE DLA LISTY ZASTĘPSTW (PRZENIESIONE Z ZASTEPSTWA.PHP) --- */
.sub-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 2rem;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.sub-grid-layout {
    display: grid;
    grid-template-columns: 110px 80px 1.5fr 2fr 1.5fr;
    gap: 1rem;
    align-items: center;
}

.sub-row {
    display: flex;
    gap: 12px;
    align-items: stretch;
    width: 100%;
}

.sub-period {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 60px;
    min-width: 60px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-main);
}

.sub-period.header-variant {
    background: transparent;
    border-color: transparent;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sub-period-num {
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    padding: 2px;
    text-align: center;
}

.sub-card {
    flex-grow: 1;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: 0 1rem;
    min-height: 64px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sub-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.sub-card.header-variant {
    background: transparent;
    border-color: transparent;
    border-left-color: transparent;
    box-shadow: none;
    min-height: auto;
    padding-top: 5px;
    padding-bottom: 5px;
    pointer-events: none;
}

.sub-header-cell {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.col-group, .col-room { display: flex; justify-content: flex-start; }
.col-subject { font-weight: 700; font-size: 1rem; color: var(--text-main); }
.col-teacher-change { display: flex; flex-direction: column; justify-content: center; font-size: 0.9rem; line-height: 1.3; }
.teacher-old { color: var(--text-muted); text-decoration: line-through; font-size: 0.8em; }
.teacher-new { color: var(--primary-dark); font-weight: 600; }
[data-theme="dark"] .teacher-new { color: var(--primary); }
.col-notes { font-size: 0.85rem; color: var(--text-muted); font-style: italic; text-align: right; }

.sub-error-box {
    background: var(--sub-cancel-bg);
    border: 1px solid var(--sub-cancel-border);
    color: var(--sub-cancel-text);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    text-align: center;
}
.sub-empty-box {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* --- KONTROLKI I FILTRY (ISTNIEJĄCE) --- */
.controls { 
    padding: 1rem 0; 
    margin-bottom: 0.5rem; 
}

.controls-inner { 
    display: flex; 
    gap: 1rem; 
    align-items: center; 
    flex-wrap: wrap; 
    background: var(--surface); 
    padding: 0.5rem; 
    border-radius: var(--radius-lg); 
    border: 1px solid var(--border-subtle); 
    box-shadow: var(--shadow-md);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* --- ZAKŁADKI (Sliding Glider) --- */
.tabs { 
    background: var(--bg-body); 
    padding: 0.25rem; 
    border-radius: var(--radius-md); 
    display: flex; 
    gap: 0.2rem;
    border: 1px solid var(--border-subtle);
    position: relative;
    z-index: 1;
}

.tab-glider {
    position: absolute;
    top: 0.25rem;
    left: 0;
    height: calc(100% - 0.5rem);
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1), width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 0;
    pointer-events: none;
}

.tab-btn { 
    background: transparent !important;
    border: none; 
    padding: 0.5rem 1rem; 
    border-radius: var(--radius-sm); 
    cursor: pointer; 
    font-size: 0.85rem; 
    font-weight: 600; 
    color: var(--text-muted); 
    transition: color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative; 
    z-index: 1;
    box-shadow: none !important;
}

.tab-btn:hover { color: var(--text-main); }
.tab-btn:active { transform: scale(0.96); }
.tab-btn.active { color: var(--primary); }

.selector-group { 
    display: flex; 
    gap: 0.75rem; 
    align-items: center; 
    flex-grow: 1;
    position: relative; 
}

select#item-selector { display: none; }

/* --- CUSTOM SELECT (Istniejący) --- */
.custom-select-wrapper {
    position: relative;
    min-width: 220px;
    max-width: 300px;
    flex-grow: 1;
    font-family: 'Inter', sans-serif;
}

.custom-select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    height: 42px;
    background: var(--bg-body);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
    transition: all 0.2s;
    user-select: none;
}
.custom-select-trigger:hover { background: var(--surface-hover); border-color: var(--border-subtle); }
.custom-select-wrapper.open .custom-select-trigger { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1); }
.custom-select-arrow {
    width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent;
    border-top: 5px solid var(--text-muted); margin-left: 10px; transition: transform 0.2s;
}
.custom-select-wrapper.open .custom-select-arrow { transform: rotate(180deg); }

.custom-options {
    position: absolute; top: calc(100% + 8px); left: 0; right: 0;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(9px) saturate(180%); -webkit-backdrop-filter: blur(9px) saturate(180%);
    border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-float);
    z-index: 150; opacity: 0; visibility: hidden; transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); max-height: 300px; overflow-y: auto; overscroll-behavior: contain;
}
.custom-options::-webkit-scrollbar { width: 6px; }
.custom-options::-webkit-scrollbar-track { background: transparent; margin: 4px 0; }
.custom-options::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.5); border-radius: 10px; }
.custom-options::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.8); }
[data-theme="dark"] .custom-options::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); }
[data-theme="dark"] .custom-options { background: rgba(30, 41, 59, 0.75); border-color: rgba(255,255,255,0.1); }
.custom-select-wrapper.open .custom-options { opacity: 1; visibility: visible; transform: translateY(0); }

.custom-option {
    padding: 0.6rem 1rem; font-size: 0.9rem; font-weight: 500; color: var(--text-main);
    cursor: pointer; transition: background 0.1s; border-bottom: 1px solid rgba(0,0,0,0.03);
}
[data-theme="dark"] .custom-option { border-bottom: 1px solid rgba(255,255,255,0.03); }
.custom-option:last-child { border-bottom: none; }
.custom-option:hover { background: var(--primary-light); color: var(--primary-dark); }
[data-theme="dark"] .custom-option:hover { background: rgba(16, 185, 129, 0.2); color: var(--primary); }
.custom-option.selected { background: var(--primary); color: white; }

/* Przyciski ikonowe */
.btn-icon { 
    background: transparent; 
    border: 1px solid var(--border-subtle); 
    border-radius: var(--radius-md); 
    cursor: pointer; 
    color: var(--text-muted); 
    height: 42px; width: 42px; 
    display: flex; justify-content: center; align-items: center; 
    transition: all 0.2s; 
}
header .btn-icon { border-color: transparent; background: rgba(0,0,0,0.03); height: 36px; width: 36px; }
header .btn-icon:hover { background: var(--surface-hover); border-color: var(--border-subtle); color: var(--primary); }
[data-theme="dark"] header .btn-icon { background: rgba(255,255,255,0.05); }
.btn-icon:hover { background: var(--surface-hover); color: var(--primary); border-color: var(--primary); }
.btn-icon.active { background: var(--surface); border-color: #fecaca; } 
.btn-icon.active svg { fill: #ef4444; stroke: #ef4444; }

.btn-old-plan {
    text-decoration: none; color: var(--text-muted); font-size: 0.75rem; font-weight: 600;
    border: 1px solid var(--border-subtle); padding: 0.4rem 0.8rem; border-radius: var(--radius-md);
    transition: all 0.2s; background: transparent; display: inline-flex; align-items: center; white-space: nowrap;
    cursor: pointer;
}
.btn-old-plan:hover { color: var(--primary); border-color: var(--primary); background: var(--surface); }

/* --- GRID PLANU LEKCJI --- */
.grid-container { 
    background: var(--surface); 
    border-radius: var(--radius-lg); 
    box-shadow: var(--shadow-float); 
    border: 1px solid var(--border-subtle); 
    transition: background-color 0.3s, border-color 0.3s;
    position: relative;
    z-index: 0;
}

.timetable-header { 
    display: grid; 
    grid-template-columns: 60px repeat(5, 1fr); 
    background: var(--bg-body); 
    border-bottom: 1px solid var(--border-subtle); 
    position: sticky; top: var(--header-offset, 60px); z-index: 80;
    border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.header-cell { 
    padding: 1rem 0.5rem; text-align: center; font-weight: 700; color: var(--text-muted); 
    font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; border-right: 1px solid var(--border-subtle); 
}
.header-cell:last-child { border-right: none; }

.timetable-row { 
    display: grid; grid-template-columns: 60px repeat(5, 1fr); border-bottom: 1px dashed var(--border-subtle); 
    padding-bottom: 0; transition: background-color 0.2s; opacity: 0; 
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.timetable-row:nth-child(1) { animation-delay: 0.02s; }
.timetable-row:nth-child(2) { animation-delay: 0.04s; }
.timetable-row:nth-child(3) { animation-delay: 0.06s; }
.timetable-row:nth-child(4) { animation-delay: 0.08s; }
.timetable-row:nth-child(5) { animation-delay: 0.10s; }
.timetable-row:nth-child(6) { animation-delay: 0.12s; }
.timetable-row:nth-child(7) { animation-delay: 0.14s; }
.timetable-row:nth-child(8) { animation-delay: 0.16s; }
.timetable-row:nth-child(9) { animation-delay: 0.18s; }
.timetable-row:nth-child(10) { animation-delay: 0.20s; }
.timetable-row:nth-child(n+11) { animation-delay: 0.22s; }

.timetable-row:last-child { border-bottom: none; border-bottom-left-radius: var(--radius-lg); border-bottom-right-radius: var(--radius-lg); }
.timetable-row:hover { background-color: var(--surface-hover); }

.period-cell { 
    padding: 0.5rem; border-right: 1px solid var(--border-subtle); display: flex; 
    flex-direction: column; align-items: center; justify-content: center; text-align: center; 
    color: var(--text-muted); background: rgba(0,0,0,0.02); 
}

.period-num { font-weight: 800; font-size: 1.25rem; color: var(--text-main); line-height: 1; margin-bottom: 4px; }
.period-time { font-size: 0.7rem; font-weight: 600; font-family: 'Monaco', monospace; opacity: 0.8; }
.day-cell { border-right: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 6px; padding: 6px; height: auto; min-height: 60px; }
.day-cell:last-child { border-right: none; }

/* --- KARTA LEKCJI --- */
.lesson-card {
    background: var(--surface); border-radius: var(--radius-sm); padding: 6px 8px; 
    display: flex; align-items: center; text-align: left; border: 1px solid var(--border-subtle); 
    border-left: 3px solid var(--primary); box-shadow: var(--shadow-sm); overflow: hidden; 
    min-height: 48px; flex: 1; width: 100%; box-sizing: border-box; 
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.lesson-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: rgba(148, 163, 184, 0.4); }
.lesson-card.has-sub { background-color: var(--sub-bg) !important; border-left-color: var(--sub-border) !important; border-color: var(--sub-border) !important; }
.lesson-card.has-sub .subj-name { color: var(--sub-text); }
.lesson-card.has-sub-cancel { 
    background-color: var(--sub-cancel-bg) !important; border-left-color: var(--sub-cancel-border) !important; 
    border-color: var(--sub-cancel-border) !important; opacity: 0.8;
}
.lesson-card.has-sub-cancel .subj-name { color: var(--sub-cancel-text); text-decoration: line-through; }
.lesson-card.full-fill { flex-grow: 1; height: 100%; }
.lesson-placeholder { flex: 1; min-height: 44px; visibility: hidden; }

.card-content { display: flex; align-items: center; flex-grow: 1; gap: 8px; min-width: 0; padding-right: 4px; }
.groups-stack { display: flex; flex-direction: column; gap: 3px; margin-right: 6px; justify-content: center; }
.group-marker { 
    font-size: 0.7rem; color: var(--primary); background: var(--primary-light);
    padding: 1px 4px; border-radius: 4px; font-weight: 700; flex-shrink: 0; white-space: nowrap; text-align: center;
}
[data-theme="dark"] .group-marker { color: var(--primary-dark); background: rgba(16, 185, 129, 0.2); }
.subj-name { 
    flex-grow: 1; font-weight: 700; font-size: 0.85rem; line-height: 1.2; color: var(--text-main); 
    min-width: 0; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; 
    white-space: normal; word-break: break-word; 
}

.details { display: flex; flex-direction: row; align-items: center; height: 100%; gap: 4px; flex-shrink: 0; }
.detail-tag { 
    display: flex; align-items: center; justify-content: center; height:-webkit-fill-available; max-height: 35px;
    padding: 0 8px; font-weight: 600; font-size: 0.7rem; width: 23px; text-align: center; white-space: nowrap; 
    border-radius: 4px; margin: 0; cursor: pointer; transition: opacity 0.2s, background-color 0.2s; 
}
.detail-tag:hover { opacity: 0.8; }
.tag-room { background: var(--active-surface); color: var(--primary-dark); border: 1px solid rgba(0,0,0,0.05); }
.tag-teacher { background: var(--bg-body); color: var(--text-muted); border: 1px solid var(--border-subtle); padding-left: 6px; }
.tag-class { background: #eff6ff; color: #1d4ed8; border: 1px solid transparent;}
[data-theme="dark"] .tag-class { background: rgba(30, 64, 175, 0.3); color: #93c5fd; }

.active-day-header { background: var(--active-surface); color: var(--primary); border-bottom: 2px solid var(--active-border); }
.active-period-row .period-cell { color: var(--primary); font-weight: bold; background: var(--active-surface); }
.active-lesson-cell { position: relative; }
.active-lesson-cell::after { 
    content: ''; position: absolute; inset: 2px; border: 2px solid var(--active-border); border-radius: var(--radius-sm); 
    pointer-events: none; opacity: 0.6; box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

/* --- MOBILE & RESPONSIVE --- */
.mobile-nav { 
    display: none; justify-content: space-between; align-items: center; background: var(--surface-glass); 
    backdrop-filter: blur(6px) saturate(180%); padding: 0.4rem 0.5rem; border: 1px solid var(--border-subtle); 
    border-radius: 99px; position: sticky; top: 75px; z-index: 90; max-width: 320px; margin: 0 auto 1rem auto; 
    box-shadow: var(--shadow-float); 
}
.mobile-btn { background: var(--surface); border: 1px solid var(--border-subtle); color: var(--text-main); width: 36px; height: 36px; border-radius: 50%; font-weight: bold; cursor: pointer; }
.mobile-day-label { font-weight: 700; color: var(--text-main); }

.status-screen { position: fixed; inset: 0; background: var(--bg-body); z-index: 200; display: flex; justify-content: center; align-items: center; }
.status-box { background: var(--surface); padding: 2rem; border-radius: var(--radius-lg); text-align: center; box-shadow: var(--shadow-float); border: 1px solid var(--border-subtle); }
.hidden { display: none !important; }
.print-only { display: none; }

/* TABLET MODE */
@media (min-width: 769px) and (max-width: 1500px) {
    .details { flex-direction: column; justify-content: center; width: 34px; gap: 2px; margin-left: 2px; height: 50%; }
    .detail-tag { width: 100%; min-height: 18px; padding: 0; font-size: 0.65rem; line-height: 1.3; max-height: 30px; }
    .groups-stack { margin-right: 2px; }
    .group-marker { padding: 0 1px; font-size: 0.6rem; min-width: 14px; }
    .card-content { gap: 4px; }
    .subj-name { font-size: 0.8rem; -webkit-line-clamp: 3; }
}

@media (max-width: 900px) {
    /* RESPONSYWNOŚĆ ZASTĘPSTW */
    .sub-header-row { display: none; }
    .sub-grid-layout { grid-template-columns: 1fr !important; gap: 0.5rem; }
    .sub-card { padding: 1rem; height: auto; text-align: center; }
    .col-group, .col-room { justify-content: center; }
    .col-teacher-change { flex-direction: row; gap: 8px; align-items: center; justify-content: center; }
    .col-notes { text-align: center; border-top: 1px dashed var(--border-subtle); padding-top: 0.5rem; margin-top: 0.2rem; }
}

@media (max-width: 768px) and (orientation: portrait) {
    .timetable-header { position: static !important; box-shadow: none !important; }
    .timetable-header, .timetable-row { grid-template-columns: 50px 1fr !important; }
    .mobile-nav { display: flex !important; }
    .controls-inner { flex-direction: column; align-items: stretch; gap: 0.5rem; }
    .selector-group, select { width: 100%; }
    h1 { font-size: 1rem; }
    .container { padding: 0 0.5rem; }
    .header-actions { gap: 0.5rem; }
    .btn-old-plan { padding: 0.3rem 0.5rem; font-size: 0.7rem; }
    #clock { font-size: 0.8rem; }
    .tabs { justify-content: center; }
}

/* DRUKOWANIE */
@media print {
    @page { margin: 5mm; size: landscape; }
    html, body { background: white !important; height: auto !important; overflow: visible !important; font-family: Arial, sans-serif !important; color: #000 !important; font-size: 9pt !important; line-height: 1.2 !important; zoom: 84%; }
    header, .controls, .mobile-nav, .status-screen, footer, #btn-favorite, #btn-print { display: none !important; }
    .print-only { display: block !important; text-align: center; margin-bottom: 5px; }
    #print-title { font-size: 14pt; font-weight: bold; text-transform: uppercase; padding-bottom: 3px; border-bottom: 1px solid #000; }
    .container { max-width: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
    .grid-container { box-shadow: none !important; border: 1px solid #000 !important; border-radius: 0 !important; display: block !important; overflow: visible !important; position: static !important; }
    .timetable-header, .timetable-row { display: grid !important; grid-template-columns: 30px repeat(5, 1fr) !important; background: transparent !important; border-bottom: 1px solid #000 !important; page-break-inside: avoid; padding: 0 !important; min-height: 50px !important; }
    .timetable-header { background-color: #f0f0f0 !important; border-bottom: 2px solid #000 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; min-height: auto !important; position: static !important; }
    .header-cell { border-right: 1px solid #000 !important; color: #000 !important; font-weight: bold; padding: 2px !important; font-size: 10pt; }
    .header-cell:last-child { border-right: none !important; }
    .header-cell:first-child { color: transparent !important; }
    .period-cell { border-right: 2px solid #000 !important; background: transparent !important; color: #000 !important; justify-content: flex-start; padding-top: 2px; padding-bottom: 2px; }
    .period-num { font-size: 11pt !important; font-weight: bold; }
    .period-time { font-size: 7pt !important; display: none; }
    .day-cell { border-right: 1px solid #000 !important; display: block !important; padding: 1px !important; height: 100% !important; min-height: 50px !important; overflow: visible !important; box-sizing: border-box !important; }
    .day-cell:last-child { border-right: none !important; }
    .lesson-card { background: transparent !important; border: none !important; box-shadow: none !important; border-left: none !important; border-radius: 0 !important; padding: 1px 0 2px 0 !important; display: block !important; min-height: auto !important; margin-bottom: 2px; overflow: visible !important; }
    .lesson-card + .lesson-card { border-top: 1px dashed #bbb !important; padding-top: 2px !important; }
    .card-content { display: block !important; }
    .group-marker { color: #000 !important; font-size: 7pt; text-decoration: underline; margin-right: 2px; }
    .subj-name { color: #000 !important; font-size: 9pt; font-weight: bold; display: inline; }
    .details { display: flex !important; flex-wrap: wrap; gap: 2px; margin-top: 0px; }
    .detail-tag { background: transparent !important; border: none !important; color: #000 !important; padding: 0 !important; height: auto !important; font-size: 8pt; font-weight: normal; }
    .tag-room::before { content: "s. "; font-size: 0.8em; }
    .tag-teacher { font-style: italic; }
    .active-day-header, .active-period-row, .active-lesson-cell::after { border: none !important; background: transparent !important; }
    .hidden-mobile { display: block !important; }
}
@media (max-height: 600px) and (orientation: landscape) {
    header { position: static !important; }
    .timetable-header { top: 0 !important; z-index: 100; border-top-left-radius: 0; border-top-right-radius: 0; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
}