* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    height: 100vh;
    background-color: #0d131f;
    color: #f8fafc;
    overflow: hidden;
}

#app-container {
    --sidebar-width: 380px;
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Сайдбар */
#region-sidebar, #sidebar {
    width: 380px;
    min-width: 380px;
    height: 100vh;
    background-color: #111827;
    border-right: 1px solid #1f2937;
    display: flex;
    flex-direction: column;
    padding: 24px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
    z-index: 10;
    overflow-y: auto;
}

/* Карта */
#map-container {
    flex: 1;
    height: 100vh;
    position: relative;
    background-color: #0b0f19;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#russia-map {
    width: 100%;
    height: 100%;
    display: block;
}

/* Регионы: тонкие четкие границы, не меняющие толщину при зуме */
.region, .land, path, polygon {
    fill: #1e293b;
    stroke: #334155;
    stroke-width: 0.5px;
    vector-effect: non-scaling-stroke;
    transition: fill 0.3s ease, stroke 0.3s ease;
    cursor: pointer;
}

/* Простое наведение мыши на регион — глубокий синий оттенок */
.region:hover {
    fill: #1e40af;
    stroke: #3b82f6;
}

/* Активный масштабированный регион — яркий цвет */
.region.active-region {
    fill: #3b82f6 !important;
    stroke: #93c5fd !important;
}

.city-group {
    transition: opacity 0.3s ease;
    cursor: pointer;
}

/* Точки городов на карте */
.city-dot {
    fill: #38bdf8;
    stroke: #0f172a;
    stroke-width: 0.8px;
    paint-order: stroke fill;
    opacity: 0.8;
    cursor: pointer;
    transition: fill 0.2s ease, stroke 0.2s ease, opacity 0.2s ease;
}

.city-dot.is-top {
    fill: #60a5fa;
    stroke: #ffffff;
    stroke-width: 1px;
    opacity: 1;
}

.city-dot:hover {
    fill: #fbbf24 !important;
    stroke: #ffffff !important;
    stroke-width: 1.5px !important;
    opacity: 1 !important;
}

/* Подписи городов — на общей карте показываем только ключевые региональные центры */
.city-label {
    display: none;
    fill: #cbd5e1;
    font-size: 6.8px;
    font-family: system-ui, -apple-system, sans-serif;
    paint-order: stroke fill;
    stroke: #090e1a;
    stroke-width: 2px;
    stroke-linejoin: round;
    pointer-events: none;
    user-select: none;
}

.city-label.is-top {
    display: inline;
    fill: #ffffff;
    font-size: 7.5px;
    font-weight: 600;
    paint-order: stroke fill;
    stroke: #090e1a;
    stroke-width: 2.2px;
    stroke-linejoin: round;
    pointer-events: none;
    user-select: none;
}

/* В режиме приближения региона: подсвечиваем и показываем подписи всех городов активного региона */
.city-group.in-active-region .city-dot {
    opacity: 1 !important;
}

.city-group.in-active-region .city-label {
    display: inline !important;
    fill: #ffffff !important;
    font-weight: 600;
    paint-order: stroke fill;
    stroke: #090e1a;
    stroke-linejoin: round;
    pointer-events: none;
    user-select: none;
}

/* Тултип с названием региона / города при наведении */
#region-tooltip {
    position: fixed;
    pointer-events: none;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(59, 130, 246, 0.5);
    color: #f8fafc;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    transform: translate(-50%, -130%);
    transition: opacity 0.12s ease;
    white-space: nowrap;
    line-height: 1.2;
}

#region-tooltip.visible {
    opacity: 1;
}

#back-btn {
    position: absolute;
    top: 20px;
    left: calc(var(--sidebar-width) + 20px);
    padding: 12px 22px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transition: opacity 0.3s, transform 0.2s;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
    touch-action: manipulation;
}

#back-btn.visible {
    opacity: 1 !important;
    pointer-events: auto !important;
}

#back-btn:hover {
    background-color: #2563eb;
    transform: scale(1.03);
}



/* Стили формы сайдбара */
.auth-section, .ege-section, .unis-section, .sidebar-section {
    margin-bottom: 24px;
    border-bottom: 1px solid #1f2937;
    padding-bottom: 20px;
}

.auth-section:last-child, .ege-section:last-child, .unis-section:last-child, .sidebar-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.auth-section h3, .ege-section h3, .unis-section h3, .sidebar-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: #60a5fa;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group {
    margin-bottom: 12px;
}

.form-group label {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.form-input, .form-group input {
    width: 100%;
    padding: 10px 14px;
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus, .form-group input:focus {
    border-color: #3b82f6;
}

.user-card {
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 13px;
}

.btn-primary {
    width: 100%;
    padding: 10px;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-primary:hover {
    background-color: #2563eb;
}

.study-type-group, .radio-group {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.study-type-group label, .radio-group label {
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ege-field {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}

.ege-field select, .ege-select {
    flex: 1;
    padding: 8px 10px;
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    outline: none;
}

.ege-field input, .ege-input {
    width: 65px;
    padding: 8px 10px;
    background-color: #1f2937;
    border: 1px solid #374151;
    border-radius: 6px;
    color: white;
    font-size: 13px;
    text-align: center;
    outline: none;
}

.btn-remove-subject {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-remove-subject:hover {
    color: #dc2626;
}

.btn-add-subject {
    width: 100%;
    padding: 8px;
    background-color: transparent;
    border: 1px dashed #374151;
    color: #60a5fa;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    margin-bottom: 14px;
    transition: all 0.2s;
}

.btn-add-subject:hover {
    background-color: #1f2937;
    border-color: #60a5fa;
}

.ege-total, .total-score-box {
    font-size: 15px;
    font-weight: 600;
    color: #e2e8f0;
    margin-top: 10px;
}

.ege-total span, .total-score-box span {
    color: #38bdf8;
}

/* Список вузов */
.uni-list, #sidebar-unis-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.uni-item {
    background-color: #1f2937;
    border: 1px solid #374151;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.uni-item:hover {
    transform: translateY(-2px);
    border-color: #3b82f6;
}

.uni-item-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: #f8fafc;
}

.uni-item-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #94a3b8;
}

.badge-pass {
    color: #4ade80;
    font-weight: 600;
}

.badge-fail {
    color: #f87171;
    font-weight: 600;
}

.uni-item-details {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed #374151;
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.4;
}

.uni-item.is-expanded .uni-item-details {
    display: block;
}

.uni-detail-row {
    margin-bottom: 5px;
}

.uni-detail-row strong {
    color: #60a5fa;
}



/* ========================================================
   ОТЗЫВЧИВЫЙ ДИЗАЙН И АДАПТИВНОСТЬ ДЛЯ ВСЕХ УСТРОЙСТВ
   ======================================================== */

.sheet-drag-area {
    display: none;
}
.sidebar-scrollable-content {
    display: flex;
    flex-direction: column;
}

/* Планшеты и компактные ноутбуки (769px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    #region-sidebar, #sidebar {
        width: 310px;
        min-width: 310px;
        padding: 18px 14px;
    }

    #back-btn {
        top: 16px;
        left: calc(310px + 16px);
        padding: 10px 16px;
        font-size: 13px;
    }

    }

/* Смартфоны и узкие экраны (<= 768px): Нативная шторка (Bottom Sheet) */
@media (max-width: 768px) {
    html, body {
        height: 100dvh;
        height: -webkit-fill-available;
        overflow: hidden;
    }

    #app-container {
        position: relative;
        width: 100vw;
        height: 100dvh;
        height: -webkit-fill-available;
        overflow: hidden;
        display: block;
    }

    /* Карта занимает верхние 2/3 экрана (остается свободной и центрированной) */
    #map-container {
        width: 100vw;
        height: 67dvh;
        height: calc(-webkit-fill-available * 0.67);
        position: relative;
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #russia-map {
        width: 100%;
        height: 100%;
        display: block;
    }

    /* Кнопка сброса масштаба на мобилках */
    #back-btn {
        position: fixed;
        top: 14px;
        left: 14px;
        padding: 8px 14px;
        font-size: 12px;
        border-radius: 8px;
        z-index: 400;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    }

    /* Выдвижная панель (Bottom Sheet): занимает 1/3 экрана в свернутом виде */
    #region-sidebar, #sidebar {
        display: flex !important;
        flex-direction: column;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        min-width: 100vw;
        height: 88dvh;
        max-height: 88dvh;
        background: #111827;
        border-top: 2px solid #3b82f6;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
        z-index: 500;
        padding: 0 16px 20px 16px;
        transform: translateY(calc(100% - 33dvh));
        transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
        overflow: hidden;
    }

    #region-sidebar.sheet-expanded {
        transform: translateY(0) !important;
    }

    /* Зона свайпа / заголовка шторки */
    .sheet-drag-area {
        display: block;
        padding: 12px 0 12px 0;
        cursor: pointer;
        z-index: 10;
        border-bottom: 1px solid rgba(51, 65, 85, 0.5);
        user-select: none;
        -webkit-user-select: none;
        touch-action: none;
    }

    .sheet-handle {
        width: 48px;
        height: 5px;
        background-color: #64748b;
        border-radius: 3px;
        margin: 0 auto 10px auto;
        transition: background-color 0.2s;
    }

    .sheet-drag-area:active .sheet-handle {
        background-color: #94a3b8;
    }

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

    .sheet-header-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .sheet-icon {
        font-size: 24px;
        line-height: 1;
    }

    .sheet-title {
        font-size: 15px;
        font-weight: 700;
        color: #f8fafc;
        line-height: 1.2;
    }

    .sheet-subtitle {
        font-size: 12px;
        color: #94a3b8;
        margin-top: 2px;
    }

    .sheet-badge-wrap {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .sheet-count-badge {
        background: #2563eb;
        color: white;
        font-size: 11px;
        font-weight: 600;
        padding: 3px 8px;
        border-radius: 12px;
    }

    .sheet-toggle-arrow {
        color: #60a5fa;
        font-size: 14px;
        transition: transform 0.3s ease;
    }

    #region-sidebar.sheet-expanded .sheet-toggle-arrow {
        transform: rotate(180deg);
    }

    /* Скроллируемая область контента внутри шторки */
    .sidebar-scrollable-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-top: 14px;
        padding-bottom: 24px;
    }

    
    /* Поля ввода без авто-зума Safari */
    .form-input, .form-group input, .ege-field select, .ege-field input {
        font-size: 16px !important;
    }

    .btn-primary, .btn-add-subject {
        min-height: 42px;
    }
}
