html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* без общ скрол в iframe */
}

/* Модален прозорец за уреди на отбор (ансамбъл) в класирането */
.team-apparatus-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.team-apparatus-modal-content {
    background-color: #fefefe;
    margin: 4% auto;
    padding: 24px;
    border-radius: 10px;
    width: 90%;
    max-width: 960px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.team-apparatus-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.team-apparatus-modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.team-apparatus-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.team-apparatus-close:hover {
    color: #000;
}

.team-apparatus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.team-apparatus-item {
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: transform 0.2s, box-shadow 0.2s;
}

.team-apparatus-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-apparatus-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 8px;
}

.team-apparatus-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    word-break: break-word;
}

.team-apparatus-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.gymnasts-columns {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.gymnasts-columns .col {
    flex: 1;
    text-align: left;
}

.gymnasts-columns .col-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.team-apparatus-item ol {
    margin: 0 0 0 18px;
    padding: 0;
    text-align: left;
}

.ranking-container {
    padding: 15px 20px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.ranking-container h2 {
    margin-bottom: 12px;
}

.ranking-filters {
    background: #f9fafb;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 10px;
    flex: 0 0 auto;
    overflow: visible;
}

.ranking-filters .filter-row,
.ranking-filters .filter-group {
    overflow: visible;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 8px;
}

.filter-group {
    min-width: 180px;
}

.filter-group label,
.filter-group .filter-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

/* Падащи менюта във филтрите */
.filter-group select,
.filter-group .form-control {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #cbd3da;
    background-color: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.filter-group select:focus,
.filter-group .form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
}

.filter-group select:hover,
.filter-group .form-control:hover {
    background-color: #fdfdfd;
}

.filter-row .filter-buttons {
    display: flex;
    align-items: center;
}

/* Бутон "Изчисти" – ползва се и в двата файла */
.clear-filters-btn {
    display: inline-block;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.clear-filters-btn:hover {
    background-color: #ffe8a1;
    border-color: #ffdf7e;
    color: #7a5a00;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.clear-filters-btn:active {
    background-color: #ffd666;
    border-color: #ffc94a;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.ranking-table-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* хоризонтален скрол ще е в .ranking-table-body */
    --ranking-vscroll-gutter: 17px;
}

/* Резерв вдясно на заглавията = ширината на вертикалния скролбар в tbody */
.ranking-table-container > table.ranking-table thead tr::after {
    content: '';
    display: table-cell;
    width: var(--ranking-vscroll-gutter);
    min-width: var(--ranking-vscroll-gutter);
    max-width: var(--ranking-vscroll-gutter);
    padding: 0;
    border: 1px solid #ddd;
    border-left: none;
    background-color: #f5f5f5;
    box-sizing: border-box;
    vertical-align: middle;
}

.ranking-table-body {
    display: block;
    width: 100%;
    overflow-y: auto;   /* вертикален скрол за редовете */
    overflow-x: auto;   /* хоризонтален скрол под таблицата */
    max-height: 100%;
    scrollbar-gutter: stable;
}

.ranking-table {
    width: max-content; /* позволява таблицата да се разшири хоризонтално при много колони */
    min-width: 100%;    /* но да не става по-тясна от прозореца */
}

.ranking-table th,
.ranking-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #ddd;
    vertical-align: middle;
    white-space: nowrap; /* не позволява свиване на колоните, за да се появи хоризонтален скрол */
}

.ranking-table th:nth-child(1),
.ranking-table td:nth-child(1) {
    width: 30px;
    min-width: 28px;
    max-width: 34px;
    padding: 6px 4px;
    box-sizing: border-box;
}

.ranking-table th:nth-child(1) input[type="checkbox"],
.ranking-table td:nth-child(1) input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.ranking-table th:nth-child(2),
.ranking-table td:nth-child(2) {
    width: 42px;
    min-width: 38px;
    max-width: 50px;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    box-sizing: border-box;
}

.ranking-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ranking-table .photo-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.ranking-table .flag-icon {
    width: 24px;
    height: 16px;
    vertical-align: middle;
    margin-right: 5px;
}

.ranking-table th.apparatus-column .ranking-apparatus-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.ranking-table th.apparatus-column .ranking-apparatus-thumb-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    line-height: 0;
}

.ranking-table th.apparatus-column .ranking-apparatus-thumb,
.ranking-table th.apparatus-column .apparatus-thumbnail {
    display: block;
    height: 22px;
    width: auto;
    max-height: 22px;
    max-width: 100%;
    object-fit: contain;
    object-position: center center;
    margin: 0 auto;
}

.ranking-table th.apparatus-column .ranking-apparatus-label {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 1.15;
    white-space: normal;
}

.total-score-column {
    font-weight: bold;
}

.selection-controls {
    margin-left: 10px;
}

/* Модален прозорец за детайли на оценката - използва се в ranking_web.php */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.score-details {
    margin-top: 20px;
}

.score-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.score-item {
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.score-label {
    font-weight: bold;
    margin-bottom: 5px;
}

.score-value {
    font-size: 18px;
    color: #2c3e50;
}

.loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #6c757d;
}

/* Компактна мрежа за филтри (ranking_page.php, rec модал) */
.ranking-filters {
    padding: 10px 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.ranking-filter-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px 10px;
    align-items: end;
}

/* Скритите полета не трябва да заемат клетки в мрежата */
.ranking-filter-form > input[type="hidden"] {
    display: none;
}

.ranking-filter-form .filter-group {
    min-width: 0;
    margin: 0;
}

.ranking-filter-form .filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
    line-height: 1.2;
}

.ranking-filter-form .filter-group select,
.ranking-filter-form .years-checkbox-header {
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.3;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    box-sizing: border-box;
}

.ranking-filter-form .filter-group--years {
    position: relative;
}

.ranking-filter-form .years-checkbox-container {
    border: none;
    border-radius: 0;
    background: transparent;
}

.ranking-filter-form .years-checkbox-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    border-bottom: none;
}

.ranking-filter-form .years-checkbox-header .dropdown-arrow {
    font-size: 10px;
    color: #94a3b8;
}

.ranking-filter-form .years-checkbox-header .dropdown-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    text-transform: none;
    letter-spacing: normal;
}

.ranking-filter-form .years-checkbox-list {
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.ranking-filter-form .filter-group--actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
    grid-column: 5;
    grid-row: 1;
}

.ranking-filter-form .ranking-filter-obs-message {
    grid-column: 1 / -1;
    min-width: 0;
}

.ranking-filter-form .ranking-filter-obs-message .ranking-obs-message {
    display: block;
    margin-top: 0;
}

.ranking-filter-form .filter-actions-spacer {
    display: block;
    height: 15px;
    margin-bottom: 4px;
}

.ranking-filter-form .filter-actions-inner {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    width: 100%;
}

.ranking-filter-form .filter-group--actions .clear-filters-btn,
.ranking-filter-form .filter-group--actions .btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    position: static;
    float: none;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.3;
    border-radius: 6px;
    white-space: nowrap;
    margin: 0;
    box-sizing: border-box;
}

.ranking-filter-form .filter-group--actions .btn-sm {
    border: none;
    cursor: pointer;
}

.ranking-filter-form .filter-group--actions .ranking-obs-actions {
    display: inline-flex;
    align-items: stretch;
    flex-shrink: 0;
}

.ranking-filter-form .filter-group--actions .ranking-obs-actions .btn-sm + .btn-sm {
    margin-left: 0;
}

.ranking-filter-form .filter-group--actions .ranking-obs-send-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.ranking-filter-form .filter-group--actions .ranking-obs-clear-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-width: 34px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.ranking-filter-form .ranking-obs-message {
    font-size: 11px;
    color: #475569;
    line-height: 1.3;
    min-width: 0;
    max-height: 2.8em;
    overflow: hidden;
}

.ranking-obs-message a {
    color: #2563eb;
    word-break: break-all;
}

body.from-rec {
    margin: 0;
    overflow: hidden;
}

body.from-rec .ranking-container {
    padding: 8px 12px 10px;
    height: 100vh;
    max-height: 100vh;
}

body.from-rec .ranking-container > h2 {
    font-size: 1.05rem;
    margin: 0 0 8px;
    line-height: 1.3;
}

body.from-rec .ranking-filters {
    margin-bottom: 8px;
}

body.from-rec .ranking-table-container {
    flex: 1;
    min-height: 0;
}

@media (max-width: 1100px) {
    .ranking-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ranking-filter-form .filter-group--actions {
        grid-column: auto;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .ranking-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ranking-filter-form .filter-group--actions {
        grid-column: 1 / -1;
    }

    .ranking-filter-form .filter-actions-inner {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .ranking-filter-form {
        grid-template-columns: 1fr;
    }
}

/* Анимация „изкачване“ на маркиран ред (ranking_page.php) */
.ranking-table tbody tr.row-marked-moving {
    position: relative;
    z-index: 2;
    box-shadow:
        0 0 8px rgba(230, 168, 0, 0.65),
        0 0 16px rgba(230, 168, 0, 0.45),
        inset 3px 0 0 #e6a800;
}

.ranking-table tbody tr.row-marked-flash {
    animation: rankingRowMarkedFlash 0.65s ease-out;
}

@keyframes rankingRowMarkedFlash {
    0% {
        background-color: rgba(255, 193, 7, 0.85);
    }
    45% {
        background-color: rgba(255, 220, 120, 0.55);
    }
    100% {
        background-color: transparent;
    }
}
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; /* без общ скрол в iframe */
}

/* Модален прозорец за уреди на отбор (ансамбъл) в класирането */
.team-apparatus-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.team-apparatus-modal-content {
    background-color: #fefefe;
    margin: 4% auto;
    padding: 24px;
    border-radius: 10px;
    width: 90%;
    max-width: 960px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.team-apparatus-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.team-apparatus-modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.team-apparatus-close {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.team-apparatus-close:hover {
    color: #000;
}

.team-apparatus-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.team-apparatus-item {
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: transform 0.2s, box-shadow 0.2s;
}

.team-apparatus-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.team-apparatus-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    margin-bottom: 8px;
}

.team-apparatus-name {
    font-size: 12px;
    font-weight: 500;
    color: #333;
    word-break: break-word;
}

.team-apparatus-empty {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.gymnasts-columns {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
}

.gymnasts-columns .col {
    flex: 1;
    text-align: left;
}

.gymnasts-columns .col-title {
    font-weight: 600;
    margin-bottom: 6px;
}

.team-apparatus-item ol {
    margin: 0 0 0 18px;
    padding: 0;
    text-align: left;
}

.ranking-container {
    padding: 15px 20px;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.ranking-container h2 {
    margin-bottom: 12px;
}

.ranking-filters {
    background: #f9fafb;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px 15px;
    margin-bottom: 10px;
    flex: 0 0 auto;
    overflow: visible;
}

.ranking-filters .filter-row,
.ranking-filters .filter-group {
    overflow: visible;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    margin-bottom: 8px;
}

.filter-group {
    min-width: 180px;
}

.filter-group label,
.filter-group .filter-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

/* Падащи менюта във филтрите */
.filter-group select,
.filter-group .form-control {
    width: 100%;
    padding: 6px 10px;
    font-size: 13px;
    border-radius: 4px;
    border: 1px solid #cbd3da;
    background-color: #ffffff;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.filter-group select:focus,
.filter-group .form-control:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0,123,255,0.2);
}

.filter-group select:hover,
.filter-group .form-control:hover {
    background-color: #fdfdfd;
}

.filter-row .filter-buttons {
    display: flex;
    align-items: center;
}

/* Бутон "Изчисти" – ползва се и в двата файла */
.clear-filters-btn {
    display: inline-block;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: #856404;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.clear-filters-btn:hover {
    background-color: #ffe8a1;
    border-color: #ffdf7e;
    color: #7a5a00;
    text-decoration: none;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.clear-filters-btn:active {
    background-color: #ffd666;
    border-color: #ffc94a;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}

.ranking-table-container {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* хоризонтален скрол ще е в .ranking-table-body */
    --ranking-vscroll-gutter: 17px;
}

/* Резерв вдясно на заглавията = ширината на вертикалния скролбар в tbody */
.ranking-table-container > table.ranking-table thead tr::after {
    content: '';
    display: table-cell;
    width: var(--ranking-vscroll-gutter);
    min-width: var(--ranking-vscroll-gutter);
    max-width: var(--ranking-vscroll-gutter);
    padding: 0;
    border: 1px solid #ddd;
    border-left: none;
    background-color: #f5f5f5;
    box-sizing: border-box;
    vertical-align: middle;
}

.ranking-table-body {
    display: block;
    width: 100%;
    overflow-y: auto;   /* вертикален скрол за редовете */
    overflow-x: auto;   /* хоризонтален скрол под таблицата */
    max-height: 100%;
    scrollbar-gutter: stable;
}

.ranking-table {
    width: max-content; /* позволява таблицата да се разшири хоризонтално при много колони */
    min-width: 100%;    /* но да не става по-тясна от прозореца */
}

.ranking-table th,
.ranking-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #ddd;
    vertical-align: middle;
    white-space: nowrap; /* не позволява свиване на колоните, за да се появи хоризонтален скрол */
}

.ranking-table th:nth-child(1),
.ranking-table td:nth-child(1) {
    width: 30px;
    min-width: 28px;
    max-width: 34px;
    padding: 6px 4px;
    box-sizing: border-box;
}

.ranking-table th:nth-child(1) input[type="checkbox"],
.ranking-table td:nth-child(1) input[type="checkbox"] {
    margin: 0;
    width: 14px;
    height: 14px;
    vertical-align: middle;
}

.ranking-table th:nth-child(2),
.ranking-table td:nth-child(2) {
    width: 42px;
    min-width: 38px;
    max-width: 50px;
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    box-sizing: border-box;
}

.ranking-table th {
    background-color: #f5f5f5;
    font-weight: bold;
    position: sticky;
    top: 0;
    z-index: 10;
}

.ranking-table .photo-thumbnail {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

.ranking-table .flag-icon {
    width: 24px;
    height: 16px;
    vertical-align: middle;
    margin-right: 5px;
}

.ranking-table th.apparatus-column .ranking-apparatus-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    width: 100%;
}

.ranking-table th.apparatus-column .ranking-apparatus-thumb-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    line-height: 0;
}

.ranking-table th.apparatus-column .ranking-apparatus-thumb,
.ranking-table th.apparatus-column .apparatus-thumbnail {
    display: block;
    height: 22px;
    width: auto;
    max-height: 22px;
    max-width: 100%;
    object-fit: contain;
    object-position: center center;
    margin: 0 auto;
}

.ranking-table th.apparatus-column .ranking-apparatus-label {
    display: block;
    width: 100%;
    text-align: center;
    line-height: 1.15;
    white-space: normal;
}

.total-score-column {
    font-weight: bold;
}

.selection-controls {
    margin-left: 10px;
}

/* Модален прозорец за детайли на оценката - използва се в ranking_web.php */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

.score-details {
    margin-top: 20px;
}

.score-section {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 4px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}

.score-item {
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.score-label {
    font-weight: bold;
    margin-bottom: 5px;
}

.score-value {
    font-size: 18px;
    color: #2c3e50;
}

.loading {
    text-align: center;
    padding: 20px;
    font-style: italic;
    color: #6c757d;
}

/* Компактна мрежа за филтри (ranking_page.php, rec модал) */
.ranking-filters {
    padding: 10px 12px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.ranking-filter-form {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px 10px;
    align-items: end;
}

/* Скритите полета не трябва да заемат клетки в мрежата */
.ranking-filter-form > input[type="hidden"] {
    display: none;
}

.ranking-filter-form .filter-group {
    min-width: 0;
    margin: 0;
}

.ranking-filter-form .filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
    line-height: 1.2;
}

.ranking-filter-form .filter-group select,
.ranking-filter-form .years-checkbox-header {
    width: 100%;
    min-height: 34px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.3;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    background: #fff;
    box-sizing: border-box;
}

.ranking-filter-form .filter-group--years {
    position: relative;
}

.ranking-filter-form .years-checkbox-container {
    border: none;
    border-radius: 0;
    background: transparent;
}

.ranking-filter-form .years-checkbox-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    border-bottom: none;
}

.ranking-filter-form .years-checkbox-header .dropdown-arrow {
    font-size: 10px;
    color: #94a3b8;
}

.ranking-filter-form .years-checkbox-header .dropdown-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    color: #334155;
    text-transform: none;
    letter-spacing: normal;
}

.ranking-filter-form .years-checkbox-list {
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
}

.ranking-filter-form .filter-group--actions {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 0;
    grid-column: 5;
    grid-row: 1;
}

.ranking-filter-form .ranking-filter-obs-message {
    grid-column: 1 / -1;
    min-width: 0;
}

.ranking-filter-form .ranking-filter-obs-message .ranking-obs-message {
    display: block;
    margin-top: 0;
}

.ranking-filter-form .filter-actions-spacer {
    display: block;
    height: 15px;
    margin-bottom: 4px;
}

.ranking-filter-form .filter-actions-inner {
    display: flex;
    flex-flow: row nowrap;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    width: 100%;
}

.ranking-filter-form .filter-group--actions .clear-filters-btn,
.ranking-filter-form .filter-group--actions .btn-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: auto;
    max-width: none;
    position: static;
    float: none;
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.3;
    border-radius: 6px;
    white-space: nowrap;
    margin: 0;
    box-sizing: border-box;
}

.ranking-filter-form .filter-group--actions .btn-sm {
    border: none;
    cursor: pointer;
}

.ranking-filter-form .filter-group--actions .ranking-obs-actions {
    display: inline-flex;
    align-items: stretch;
    flex-shrink: 0;
}

.ranking-filter-form .filter-group--actions .ranking-obs-actions .btn-sm + .btn-sm {
    margin-left: 0;
}

.ranking-filter-form .filter-group--actions .ranking-obs-send-btn {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    border-right: 1px solid rgba(255, 255, 255, 0.35);
}

.ranking-filter-form .filter-group--actions .ranking-obs-clear-btn {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    min-width: 34px;
    padding-left: 10px;
    padding-right: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    line-height: 1;
}

.ranking-filter-form .ranking-obs-message {
    font-size: 11px;
    color: #475569;
    line-height: 1.3;
    min-width: 0;
    max-height: 2.8em;
    overflow: hidden;
}

.ranking-obs-message a {
    color: #2563eb;
    word-break: break-all;
}

body.from-rec {
    margin: 0;
    overflow: hidden;
}

body.from-rec .ranking-container {
    padding: 8px 12px 10px;
    height: 100vh;
    max-height: 100vh;
}

body.from-rec .ranking-container > h2 {
    font-size: 1.05rem;
    margin: 0 0 8px;
    line-height: 1.3;
}

body.from-rec .ranking-filters {
    margin-bottom: 8px;
}

body.from-rec .ranking-table-container {
    flex: 1;
    min-height: 0;
}

@media (max-width: 1100px) {
    .ranking-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .ranking-filter-form .filter-group--actions {
        grid-column: auto;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .ranking-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .ranking-filter-form .filter-group--actions {
        grid-column: 1 / -1;
    }

    .ranking-filter-form .filter-actions-inner {
        justify-content: flex-start;
    }
}

@media (max-width: 480px) {
    .ranking-filter-form {
        grid-template-columns: 1fr;
    }
}

/* Маркиран ред (отметка за OBS) — ranking_page.php */
.ranking-table tbody tr.ranking-row-marked {
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.22), rgba(255, 193, 7, 0.08)) !important;
    box-shadow: inset 3px 0 0 #e6a800;
}

.ranking-table tbody tr.ranking-row-marked:hover {
    background: linear-gradient(90deg, rgba(255, 193, 7, 0.3), rgba(255, 193, 7, 0.12)) !important;
}
