@font-face {
  font-family: 'MoskvichSans';
  src: url('/static/fonts/MoskvichSans-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
}

html, body { overflow-x: hidden; max-width: 100vw; overscroll-behavior-x: none; }
body { background: linear-gradient(180deg, #f6f8fb 0%, #eef2f7 100%); }
.card { border-radius: 12px; }
.form-label { font-weight: 600; }
.nav-tabs .nav-link { font-weight: 600; }
.rating-value { width: 24px; display: inline-block; text-align: center; }
@media (max-width: 576px) {
  .btn-group .btn { padding: .4rem .6rem; font-size: .9rem; }
}

/* Visual sections */
.section { background: rgba(255,255,255,.8); backdrop-filter: blur(4px); border: 1px solid #e9ecef; border-radius: 12px; padding: 12px; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.section + .section { margin-top: 8px; }
.section-title { font-weight: 700; margin-bottom: 8px; color: #0d6efd; letter-spacing: .2px; }

/* Инфраструктура: полное выделение блоков со всех сторон */
#tab-infra .section {
  border: 2px solid rgba(13,110,253,.3);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(16,24,40,.08);
}

/* Bigger checkboxes and clearer rows */
.check-row { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border: 1px dashed rgba(13,110,253,.25); border-radius: 10px; margin: 6px 0; background: rgba(13,110,253,.04); }
.big-check { transform: scale(1.3); accent-color: #0d6efd; }
.form-range { accent-color: #0d6efd; }
.range-wrap { padding: 10px 12px; border: 2px solid rgba(13,110,253,.25); border-radius: 10px; background: rgba(255,255,255,.7); }
.range-scale { display: flex; justify-content: space-between; font-size: 12px; color: #6c757d; margin-top: 4px; }
.range-scale span { width: 16%; text-align: center; }
.form-check-label { font-weight: 600; }
.check-row:hover { background: rgba(13,110,253,.07); }

/* Rating buttons */
.rating-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.rating-btn { 
  flex: 1; 
  min-width: 60px; 
  font-size: 14px; 
  padding: 8px 12px; 
  border-radius: 8px; 
  transition: all 0.2s ease;
  border: 2px solid transparent;
}
.rating-btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.rating-btn.active { 
  border-color: #0d6efd; 
  box-shadow: 0 0 0 2px rgba(13,110,253,0.25); 
  font-weight: 600;
}
.rating-btn[data-rating="1"]:not(.active) { background-color: #f8d7da; color: #721c24; }
.rating-btn[data-rating="2"]:not(.active) { background-color: #fff3cd; color: #856404; }
.rating-btn[data-rating="3"]:not(.active) { background-color: #d4edda; color: #155724; }

/* Loading overlay - полноэкранный, размывает страницу, блокирует все действия */
/* iOS Safari PWA: transform для stacking context, touch-action для блокировки жестов */
.loading-overlay {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: -webkit-fill-available;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2147483647;
  pointer-events: auto;
  touch-action: none;
  -webkit-touch-callout: none;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
body.loading-overlay-active {
  overflow: hidden;
  position: fixed;
  width: 100%;
  touch-action: none;
  pointer-events: none;
}
body.loading-overlay-active #loadingOverlay:not(.d-none) {
  pointer-events: auto;
}
.loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px;
}
.loading-overlay-text {
  font-weight: 600;
  color: #0d6efd;
  font-size: 1.2rem;
}

/* Sticky actions */
.sticky-actions { position: sticky; top: 0; z-index: 100; border-bottom: 1px solid #e9ecef; }
.actions { gap: 8px; }
.actions .btn { padding: .25rem .5rem; font-size: .85rem; }
@media (max-width: 575.98px) {
  .actions { gap: 12px; }
  .actions .btn { padding: .5rem .85rem; font-size: 1rem; min-height: 44px; }
}

/* Ачивки проверяющего — справа на десктопе, снизу по центру на мобильных/планшетах */
.inspector-rating-layout {
  flex-wrap: wrap;
}
/* До 768px — вертикальная раскладка (текст сверху, ачивка снизу), включая iOS PWA */
@media (max-width: 767.98px) {
  .inspector-rating-layout {
    flex-direction: column;
    align-items: center;
  }
  .inspector-rating-layout .flex-grow-1 {
    width: 100%;
  }
  .inspector-achievement {
    height: 56px;
    max-height: 56px;
    order: 2;
  }
}
.inspector-achievement {
  height: 150px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .inspector-achievement { height: 150px; }
}

/* Footer */
.app-footer { color: #6c757d; font-size: .75rem; }

/* Export link sizing */
.export-link { font-size: .9rem; }
@media (max-width: 575.98px) { .export-link { font-size: .72rem; white-space: normal; } }

/* Brand header */
.brand { display: inline-flex; align-items: center; gap: 12px; }
/* Cross‑browser (incl. IE) – fixed heights with overrides */
.brand img { height: 90px !important; max-height: 90px !important; width: auto; display: block; }
@media (max-width: 575.98px) { .brand img { height: 72px !important; max-height: 72px !important; } }
@media (min-width: 576px) and (max-width: 991.98px) { .brand img { height: 84px !important; max-height: 84px !important; } }
@media (min-width: 992px) { .brand img { height: 96px !important; max-height: 96px !important; } }
/* IE10/IE11 specific target */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
  .brand img { height: 90px !important; max-height: 90px !important; }
}

/* Tweak title size and spacing for better mobile fit */
.brand .h5, .brand .h4 { font-size: 1.00rem; }
@media (max-width: 575.98px) {
  .brand { gap: 8px; }
  .brand .h5, .brand .h4 { font-size: .95rem; }
}

/* Disable browser autofill UI overlap */
input, textarea, select { -webkit-appearance: none; }
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
select:-webkit-autofill { box-shadow: 0 0 0px 1000px #fff inset; -webkit-text-fill-color: #212529; }

/* Program dropdown for mobile compatibility */
.program-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 9999;
  max-height: 200px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* Плавная прокрутка на iOS Safari */
  overscroll-behavior: contain; /* Уменьшает «подёргивание» при скролле на iOS */
  border: 1px solid #ced4da;
  border-radius: 0.375rem;
  background-color: #fff;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  margin-top: 4px;
  pointer-events: auto;
}
.program-dropdown.show {
  display: block;
}
.program-dropdown:not([size]) {
  /* Для select без size (на мобильных) устанавливаем фиксированную высоту */
  height: auto;
  min-height: 120px;
}
@media (max-width: 767.98px) {
  .program-dropdown {
    max-height: 150px;
    font-size: 16px;
  }
  .program-dropdown.show {
    position: fixed !important;
    top: 100px !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    max-height: min(220px, 50vh) !important;
    z-index: 10600 !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  }
}
@media (max-width: 575.98px) {
  .program-dropdown {
    max-height: 120px;
    font-size: 16px;
  }
  .program-dropdown.show {
    top: 80px !important;
    left: 12px !important;
    right: 12px !important;
    max-height: min(200px, 45vh) !important;
  }
}

/* Attendance flags row: stack on mobile */
@media (max-width: 575.98px) {
  .att-flags-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .att-flags-row .form-check { margin: 0; }
}

/* Новогодний прелоадер */
.newyear-preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s ease-out;
}

.newyear-preloader.hidden {
    opacity: 0;
    pointer-events: none;
}

.tree-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    min-height: 300px;
    margin-bottom: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tree-layers {
    position: relative;
    width: 100%;
    max-width: 350px;
    height: 450px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.tree-layer {
    position: absolute;
    width: 100%;
    max-width: 350px;
    height: auto;
    max-height: 450px;
    object-fit: contain;
    transform-origin: 50% 100%;
    visibility: visible;
    opacity: 1;
    filter: drop-shadow(0 0 15px rgba(135, 206, 250, 0.3));
}

/* Верхний ярус (layer-1) - мягкое движение */
.layer-1 {
    animation: layerSway1 3.5s ease-in-out infinite,
               ballTwinkle 2.8s ease-in-out infinite;
    z-index: 5;
}

/* Второй ярус (layer-2) - быстрое движение с небольшой задержкой */
.layer-2 {
    animation: layerSway2 3.2s ease-in-out infinite 0.1s,
               ballTwinkle 3.2s ease-in-out infinite 0.2s;
    z-index: 4;
}

/* Третий ярус (layer-3) - средняя скорость */
.layer-3 {
    animation: layerSway3 3.5s ease-in-out infinite 0.2s,
               ballTwinkle 3.6s ease-in-out infinite 0.4s;
    z-index: 3;
}

/* Четвертый ярус (layer-4) - медленное движение */
.layer-4 {
    animation: layerSway4 4s ease-in-out infinite 0.3s,
               ballTwinkle 4.1s ease-in-out infinite 0.6s;
    z-index: 2;
}

/* Нижний ярус (layer-5) - самое медленное движение, минимальная амплитуда */
.layer-5 {
    animation: layerSway5 4.4s ease-in-out infinite 0.4s,
               ballTwinkle 4.5s ease-in-out infinite 0.8s;
    z-index: 1;
}

/* Анимация для верхнего яруса - мягкое движение с меньшей амплитудой */
@keyframes layerSway1 {
    0%, 100% {
        transform: rotate(-1deg) translateX(-0.5px) translateY(0);
    }
    25% {
        transform: rotate(1.2deg) translateX(0.5px) translateY(-1px);
    }
    50% {
        transform: rotate(-0.8deg) translateX(-0.3px) translateY(0);
    }
    75% {
        transform: rotate(1deg) translateX(0.3px) translateY(-0.5px);
    }
}

/* Анимация для второго яруса - большая амплитуда */
@keyframes layerSway2 {
    0%, 100% {
        transform: rotate(-2deg) translateX(-1.5px) translateY(0);
    }
    25% {
        transform: rotate(2.5deg) translateX(1.5px) translateY(-3px);
    }
    50% {
        transform: rotate(-1.5deg) translateX(-1px) translateY(-1px);
    }
    75% {
        transform: rotate(2deg) translateX(1px) translateY(-2px);
    }
}

/* Анимация для третьего яруса - средняя амплитуда */
@keyframes layerSway3 {
    0%, 100% {
        transform: rotate(-1.5deg) translateX(-1px) translateY(0);
    }
    25% {
        transform: rotate(2deg) translateX(1px) translateY(-2px);
    }
    50% {
        transform: rotate(-1deg) translateX(-0.5px) translateY(0);
    }
    75% {
        transform: rotate(1.5deg) translateX(0.5px) translateY(-1px);
    }
}

/* Анимация для четвертого яруса - меньшая амплитуда */
@keyframes layerSway4 {
    0%, 100% {
        transform: rotate(-1deg) translateX(-0.5px) translateY(0);
    }
    25% {
        transform: rotate(1.5deg) translateX(0.5px) translateY(-1px);
    }
    50% {
        transform: rotate(-0.5deg) translateX(-0.3px) translateY(0);
    }
    75% {
        transform: rotate(1deg) translateX(0.3px) translateY(-0.5px);
    }
}

/* Анимация для нижнего яруса - минимальная амплитуда, самое плавное движение */
@keyframes layerSway5 {
    0%, 100% {
        transform: rotate(-0.5deg) translateX(-0.3px) translateY(0);
    }
    25% {
        transform: rotate(1deg) translateX(0.3px) translateY(-0.5px);
    }
    50% {
        transform: rotate(-0.3deg) translateX(-0.2px) translateY(0);
    }
    75% {
        transform: rotate(0.8deg) translateX(0.2px) translateY(-0.3px);
    }
}

/* Мигание шаров через яркость и свечение */
@keyframes ballTwinkle {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 8px rgba(135, 206, 250, 0.4)) drop-shadow(0 0 15px rgba(173, 216, 230, 0.3));
    }
    25% {
        filter: brightness(1.2) drop-shadow(0 0 12px rgba(135, 206, 250, 0.5)) drop-shadow(0 0 20px rgba(173, 216, 230, 0.4));
    }
    50% {
        filter: brightness(1.3) drop-shadow(0 0 15px rgba(135, 206, 250, 0.6)) drop-shadow(0 0 25px rgba(173, 216, 230, 0.5));
    }
    75% {
        filter: brightness(1.15) drop-shadow(0 0 14px rgba(135, 206, 250, 0.55)) drop-shadow(0 0 22px rgba(173, 216, 230, 0.45));
    }
}

.loading-text {
    color: #0d6efd;
    font-size: 22px;
    margin-top: 20px;
    font-weight: 700;
    text-transform: uppercase;
    text-shadow: none;
    letter-spacing: 1px;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'MoskvichSans', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.loading-line {
    display: inline-block;
    line-height: 1.2;
}

.wave-char {
    display: inline-block;
    animation: waveAnimation 2s ease-in-out infinite;
}

@keyframes waveAnimation {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

/* Адаптивность для мобильных устройств */
@media (max-width: 575.98px) {
    .tree-container {
        max-width: 280px;
        max-height: 350px;
    }
    
    .tree-layers {
        max-width: 250px;
        max-height: 320px;
    }
    
    .tree-layer {
        max-width: 250px;
        max-height: 320px;
    }
    
    .loading-text {
        font-size: 18px;
        margin-top: 15px;
        letter-spacing: 0.5px;
    }
}

