* {
    box-sizing: border-box;
}
body {
    background-color: #b9e7f9;
    color: #000000;
    font-family: Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0 0 30px 0;
}

/* Veřejná hlavička a navigace */
.public-header {
    background: #0d3b66;
    color: #ffffff;
    margin: 0 0 25px 0;
    padding: 12px 25px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
}
.public-header-inner {
    max-width: 824px;
    max-width: calc(210mm + 30px);
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
}
.public-brand {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: #ffffff;
    text-align: left;
    min-width: 0;
}
.public-brand-title {
    font-size: 1.25em;
    font-weight: bold;
    letter-spacing: 0.5px;
    line-height: 1.2;
}
.public-brand-sub {
    font-size: 0.85em;
    opacity: 0.85;
    color: #ffd166;
    line-height: 1.2;
}
.public-nav {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
.public-nav .nav-item {
    color: #ffffff;
    background: transparent;
    border: none;
    text-decoration: none;
    font-family: inherit;
    font-weight: bold;
    font-size: 0.9em;
    padding: 7px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}
.public-nav .nav-icon {
    font-size: 1.15em;
    line-height: 1;
    display: inline-block;
}
.public-nav .nav-text {
    line-height: 1;
    display: inline;
}
.public-nav .nav-item:hover, .public-nav .nav-item.active {
    background: rgba(255, 255, 255, 0.2);
}
.public-nav .nav-admin-link {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.35);
}
.public-nav .nav-admin-link:hover {
    background: #ffffff;
    color: #0d3b66;
}
.btn-public-print {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffd166;
    color: #0d3b66;
    border: none;
    padding: 7px 14px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.9em;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s;
}
.btn-public-print:hover {
    background: #ffbe3b;
}

.container {
    max-width: 824px;
    max-width: calc(210mm + 30px);
    margin: 0 auto;
    padding: 0 15px;
}

/* Jednotný styl karet pro vstupy i výstupy (pro PC šířka A4: 210mm) */
.card {
    max-width: 794px;
    max-width: 210mm;
    width: 100%;
    margin: 20px auto;
    background: #52aed2;
    border: 3px solid #d4a359;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    padding: 25px;
    color: #000;
}
.form-card {
    max-width: 500px;
}

.card-title {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    color: #0d3b66;
    margin-bottom: 20px;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.6);
}

.year-title,
.search-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    max-width: 794px;
    max-width: 210mm;
    margin: 30px auto 15px auto;
    color: #0d3b66;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
}
.year-title-text,
.search-title-text {
    flex: 1;
    text-align: center;
    word-break: break-word;
}
.search-title-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.btn-print-year,
.btn-title-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #0d3b66;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    font-size: 14px;
    line-height: 1.4;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    transition: all 0.2s;
    text-shadow: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.btn-print-year:hover,
.btn-title-action:hover {
    background: #165b9c;
}
.btn-print-year .btn-print-icon,
.btn-title-action .btn-title-icon {
    font-size: 1.15em;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-svg {
    display: inline-block;
    width: 1em;
    height: 1em;
    vertical-align: -0.15em;
    fill: currentColor;
    flex-shrink: 0;
}

.form-section {
    margin-bottom: 15px;
}
.form-section label {
    font-size: 14px;
    cursor: pointer;
    display: inline-block;
    margin-top: 3px;
}
input[type="text"], input[type="search"], input[type="email"], select, textarea {
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-family: inherit;
    box-sizing: border-box;
}
input[type="submit"] {
    padding: 7px 16px;
    background-color: #0d3b66;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    font-family: inherit;
}
input[type="submit"]:hover {
    background-color: #165b9c;
}

/* Responzivní vyhledávací a výběrové skupiny */
.search-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-top: 8px;
    margin-bottom: 10px;
}
.search-input-group input[type="search"] {
    flex: 1;
    min-width: 0;
    width: 100%;
}
.search-input-group input[type="submit"] {
    flex-shrink: 0;
}
.year-select-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
    margin-bottom: 8px;
}
.year-select-group select {
    flex: 1 1 140px;
    min-width: 0;
}
.year-select-group #tridaContainer {
    flex: 1 1 140px;
    display: inline-block;
}
.year-select-group #tridaContainer select {
    width: 100%;
}
.form-checkbox-group {
    margin: 10px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    cursor: pointer;
    padding: 3px 0;
    user-select: none;
}
.form-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #0d3b66;
    flex-shrink: 0;
}
.btn-submit-block {
    width: 100%;
    padding: 10px 16px !important;
    font-size: 1.05em !important;
    min-height: 42px;
    cursor: pointer;
}

hr.divider {
    border: 0;
    border-top: 1px solid rgba(0,0,0,0.2);
    margin: 20px 0;
}

/* Styl pro debugovací výstupy */
.debug-box {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    padding: 8px 12px;
    margin: 6px 0;
    font-family: monospace;
    font-size: 0.85em;
    border-radius: 4px;
    word-break: break-all;
}

/* Informace o třídě (záhlaví uvnitř karty) */
.class-info-header {
    background: rgba(255, 255, 255, 0.25);
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.95em;
    line-height: 1.5;
}
.class-name {
    font-size: 1.2em;
    font-weight: bold;
    color: #0d3b66;
    margin-bottom: 5px;
}

/* Responzivní grid pro seznam žáků uvnitř jedné třídy */
.students-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px 15px;
    padding-top: 5px;
}

.student-item {
    font-size: 0.95em;
    line-height: 1.35;
}

/* Styl pro vyhledávací výsledky */
.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.search-item {
    background: rgba(255, 255, 255, 0.25);
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.95em;
}

.back-link {
    display: block;
    text-align: center;
    margin-top: 30px;
    color: #0d3b66;
    font-weight: bold;
    text-decoration: none;
}
.back-link:hover {
    text-decoration: underline;
}

/* Tlačítka pro nahlášení nepřesnosti v záznamech */
.item-report-link {
    font-size: 0.85em;
    color: #0d3b66;
    text-decoration: none;
    opacity: 0.8;
    margin-left: 6px;
    cursor: pointer;
    background: rgba(13, 59, 102, 0.08);
    border: 1px solid rgba(13, 59, 102, 0.2);
    border-radius: 4px;
    padding: 2px 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    font-family: inherit;
    line-height: 1.2;
    transition: all 0.2s;
    min-height: auto;
    height: auto;
    flex-shrink: 0;
    box-sizing: border-box;
}
.item-report-link:hover {
    opacity: 1;
    background: #0d3b66;
    color: #fff;
}
.section-report-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85em;
    color: #0d3b66;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #0d3b66;
    padding: 5px 12px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.section-report-btn:hover {
    background: #0d3b66;
    color: #fff;
}

/* Kontaktní modal dialog */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.active {
    display: flex;
}
.modal-content,
.modal-box {
    background: #52aed2;
    border: 3px solid #d4a359;
    border-radius: 15px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px;
    position: relative;
    box-shadow: 0 5px 25px rgba(0,0,0,0.4);
    color: #000;
    box-sizing: border-box;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    padding-right: 32px;
}
.modal-title {
    font-size: 20px;
    font-weight: bold;
    color: #0d3b66;
    text-shadow: 1px 1px 1px rgba(255,255,255,0.6);
}
.modal-close {
    position: absolute;
    top: 12px;
    right: 15px;
    font-size: 26px;
    font-weight: bold;
    color: #0d3b66;
    cursor: pointer;
    background: none;
    border: none;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}
.modal-close:hover {
    color: #000;
    background: rgba(0, 0, 0, 0.08);
}

/* ==============================================================================
    RESPONZIVNÍ STYLY PRO MOBILNÍ TELEFONY A TABLETY
    ============================================================================== */
@media (max-width: 768px) {
    .public-header {
        padding: 10px 14px;
        margin-bottom: 16px;
    }
    .public-header-inner {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
        gap: 8px;
    }
    .public-nav {
        gap: 6px;
        flex-shrink: 0;
    }
    .public-nav .nav-item,
    .public-nav .btn-public-print,
    .public-nav .nav-admin-link {
        padding: 7px 10px;
        font-size: 0.85em;
    }

    /* Prevence auto-zoomu na iOS při zaměření formulářového pole */
    input[type="text"],
    input[type="search"],
    input[type="email"],
    input[type="number"],
    select,
    textarea {
        font-size: 16px !important;
    }
    input[type="submit"],
    button:not(.item-report-link):not(.modal-close) {
        min-height: 40px;
    }
    .item-report-link {
        min-height: auto !important;
        height: auto !important;
        padding: 2px 7px;
        line-height: 1.2;
        flex-shrink: 0;
        align-self: center;
    }
}

/* Skrytí textových popisků ikon na úzkých mobilních displejích */
@media (max-width: 640px) {
    .public-header {
        padding: 8px 12px;
    }
    .public-nav .nav-text {
        display: none;
    }
    .public-nav .nav-item {
        padding: 6px 9px;
        gap: 0;
        font-size: 1.05em;
        min-width: 36px;
        min-height: 36px;
    }
    .public-brand-title {
        font-size: 1.05em;
    }
    .public-brand-sub {
        font-size: 0.85em;
    }
    .btn-print-year .btn-print-text,
    .btn-title-action .btn-title-text {
        display: none;
    }
    .btn-print-year,
    .btn-title-action {
        padding: 6px 10px;
        min-width: 36px;
        min-height: 36px;
        justify-content: center;
    }
}

@media (max-width: 440px) {
    .public-header {
        padding: 8px 10px;
    }
    .public-brand-title {
        font-size: 1em;
    }
    .public-brand-sub {
        font-size: 0.75em;
    }
    .public-nav .nav-item {
        padding: 5px 7px;
        font-size: 1em;
        min-width: 32px;
        min-height: 32px;
    }
    .year-title,
    .search-title {
        font-size: 1.15em;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 0 10px;
    }
    .card {
        padding: 18px 14px;
        margin: 14px auto;
        border-radius: 10px;
    }
    .card-title {
        font-size: 1.2em;
        margin-bottom: 15px;
    }
    .year-title,
    .search-title {
        font-size: 1.3em;
        margin: 22px auto 10px auto;
        gap: 8px;
    }
    .class-name {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 8px;
    }
    .class-name .no-print {
        width: 100%;
        display: flex;
        gap: 6px;
    }
    .class-name .no-print .section-report-btn {
        flex: 1 1 auto;
        text-align: center;
        padding: 6px 10px;
    }
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }
    .modal-content,
    .modal-box {
        padding: 18px 14px;
        max-height: 92vh;
        border-radius: 15px 15px 0 0;
    }
    .modal-close {
        top: 8px;
        right: 10px;
        font-size: 28px;
    }
}

@media (max-width: 520px) {
    .students-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .student-item {
        padding: 6px 0;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 8px;
    }
    .student-item .student-text {
        min-width: 0;
        word-break: break-word;
    }
    .student-item .item-report-link {
        min-height: auto !important;
        height: auto !important;
        padding: 2px 7px;
        flex-shrink: 0;
        align-self: center;
    }
    .student-item:last-child {
        border-bottom: none;
    }
}

/* Tisková hlavička pro tisk */
.print-header {
    display: none;
}

/* TISKOVÉ STYLY (@media print) */
@media print {
    .no-print,
    .public-header,
    .form-card,
    .divider,
    .back-link,
    .debug-box,
    .modal-overlay,
    .section-report-btn,
    .item-report-link,
    form,
    #kontakt {
        display: none !important;
    }

    /* Režim tisku pouze vybrané třídy */
    body.print-single-class-mode .card:not(.print-only-this-card),
    body.print-single-class-mode .year-title:not(.print-only-this-year) {
        display: none !important;
    }

    body {
        background: #ffffff !important;
        background-color: #ffffff !important;
        color: #000000 !important;
        font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
        font-size: 11pt;
        padding: 0 !important;
        margin: 0 !important;
    }

    .container {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .print-header {
        display: block !important;
        border-bottom: 2px solid #000000;
        padding-bottom: 8px;
        margin-bottom: 20px;
    }
    .print-header-school {
        font-size: 12pt;
        font-weight: bold;
        text-transform: uppercase;
        color: #000000;
    }
    .print-header-title {
        font-size: 16pt;
        font-weight: bold;
        margin-top: 2px;
        color: #000000;
    }
    .print-header-info {
        font-size: 11pt;
        color: #222222;
        margin-top: 4px;
    }
    .print-header-meta {
        font-size: 9pt;
        color: #666666;
        margin-top: 4px;
    }

    .year-title,
    .search-title {
        display: block !important;
        color: #000000 !important;
        font-size: 15pt !important;
        text-shadow: none !important;
        text-align: left !important;
        border-bottom: 1.5px solid #000000 !important;
        padding-bottom: 4px !important;
        margin: 25px 0 12px 0 !important;
        page-break-after: avoid;
        break-after: avoid;
    }

    .card {
        background: #ffffff !important;
        border: 1px solid #777777 !important;
        border-radius: 4px !important;
        box-shadow: none !important;
        max-width: 100% !important;
        margin: 15px 0 !important;
        padding: 12px 15px !important;
        color: #000000 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .card-title {
        color: #000000 !important;
        text-shadow: none !important;
        font-size: 13pt !important;
        text-align: left !important;
        border-bottom: 1px solid #999999;
        padding-bottom: 5px;
        margin-bottom: 10px !important;
    }

    .class-info-header {
        background: #f5f5f5 !important;
        border: 1px solid #cccccc !important;
        color: #000000 !important;
        padding: 8px 10px !important;
        margin-bottom: 10px !important;
    }

    .class-name {
        color: #000000 !important;
        font-size: 12pt !important;
        margin-bottom: 4px !important;
    }

    .students-grid {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px 15px !important;
    }

    .student-item {
        font-size: 9.5pt !important;
        color: #000000 !important;
        line-height: 1.25 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    .search-results-list {
        gap: 6px !important;
    }

    .search-item {
        background: #ffffff !important;
        border-bottom: 1px solid #e0e0e0 !important;
        padding: 5px 0 !important;
        color: #000000 !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}