/* --- ENGINE CORE --- */
* { box-sizing: border-box; }

body {
    margin: 0; padding: 0;
    background-color: #0b0e11; color: #e0e6ed;
    font-family: 'Segoe UI', Tahoma, sans-serif;
    height: 100vh; 
    height: 100dvh; /* Для мобильных браузеров */
    width: 100vw; 
    overflow: hidden;
}

/* --- GRID LAYOUT (DESKTOP) --- */
.main-grid {
    display: grid; height: 100vh; width: 100vw; padding: 12px; gap: 12px;
    grid-template-columns: 320px 1fr 280px;
    grid-template-rows: 350px 1fr 300px;
    grid-template-areas: "info castles side" "summon castles side" "summon roster side";
}
.area-info { grid-area: info; } .area-summon { grid-area: summon; }
.area-castles { grid-area: castles; } .area-roster { grid-area: roster; } .area-side { grid-area: side; }

/* --- ОБЩИЕ КОНТЕЙНЕРЫ --- */
.grid-item { 
    background-color: #161d24; 
    border-radius: 10px; 
    border: 1px solid #28333e; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    position: relative !important; 
}
.scrollable { overflow-y: auto; scrollbar-width: thin; scrollbar-color: #34495e #161d24; }

.panel-header { background: #1f2933; padding: 10px 15px; border-bottom: 2px solid #28333e; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.panel-header h2 { font-size: 14px; color: #f1c40f; margin: 0; text-transform: uppercase; }

/* --- ПЛАВАЮЩИЕ КНОПКИ (FAB) --- */
.panel-floating-btn {
    position: absolute; bottom: 20px; right: 20px; z-index: 100;
    width: 50px; height: 50px; padding: 0;
    border-radius: 50%; font-size: 24px; font-weight: normal;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    background-color: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    border: 2px solid transparent; 
}
.panel-floating-btn.btn-blue { border-color: #3498db; color: #3498db; }
.panel-floating-btn.btn-gold { border-color: #f1c40f; color: #f1c40f; }
.panel-floating-btn.btn-gray { border-color: #bdc3c7; color: #bdc3c7; }
.panel-floating-btn:active { transform: scale(0.90); background-color: rgba(255,255,255,0.1); }

/* --- МОНСТРЫ --- */
.monster-card {
    background: #1c2630; margin: 10px 0; border-radius: 8px;
    border-left: 4px solid #e74c3c; transition: 0.2s;
    overflow: hidden; position: relative;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}
.monster-card.review-state { background: #1a252f; border-left-color: #3498db; border-style: dashed; }
.monster-card.pending-state { border-left-color: #f39c12; }

/* Подсветка дедлайнов */
.monster-card.deadline-warning {
    border-left-color: #f39c12; /* Оранжевая полоса */
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.2);
}

.monster-card.deadline-failed {
    border-left-color: #e74c3c; /* Красная полоса */
    background: #2a1111; /* Слегка красноватый фон самой карточки */
    box-shadow: 0 0 15px rgba(231, 76, 60, 0.4);
    border: 1px solid rgba(231, 76, 60, 0.5);
    border-left: 4px solid #e74c3c; /* Перебиваем предыдущий бордер */
}

.monster-card.spectator-mode { opacity: 0.85; border-left-color: #95a5a6; border-left-style: solid; background: #15191f; }
.monster-card.spectator-mode .monster-icon-box { filter: grayscale(1); opacity: 0.5; }
.monster-card.spectator-mode .custom-chk { cursor: not-allowed; background: rgba(255,255,255,0.01); border-color: #2c3e50; }
.monster-card.spectator-mode .chk-label { color: #555; text-decoration: none !important; }

.monster-top { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; cursor: pointer; background: rgba(0,0,0,0.1); }
.monster-icon-box { font-size: 16px; margin-right: 10px; }
.monster-controls { display: flex; align-items: center; gap: 8px; }
.btn-icon-only { background: rgba(255,255,255,0.05); border: 1px solid #444; color: #aaa; border-radius: 4px; width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; transition: 0.2s; padding: 0; }
.btn-icon-only:hover { background: #f1c40f; color: black; border-color: #f1c40f; }
.status-badge { font-size: 9px; padding: 2px 6px; border-radius: 3px; font-weight: bold; text-transform: uppercase; white-space: nowrap; color: white; letter-spacing: 0.5px; }
.status-work { background: #c0392b; } 
.status-review { background: #2980b9; } 
.status-pending { background: #d35400; animation: blink 1.5s infinite; }
.monster-title-row { padding: 4px 10px 8px 10px; font-weight: bold; font-size: 14px; color: white; cursor: pointer; }
.mini-bar-wrapper { display: flex; flex-direction: column; gap: 1px; background: #000; }
.mini-progress { width: 100%; height: 3px; background: #222; overflow: hidden; }
.mini-hp { height: 100%; background: #e74c3c; transition: width 0.3s ease-out; }
.mini-time { height: 100%; background: #f1c40f; transition: width 0.5s linear; }
.monster-body { padding: 10px; border-top: 1px solid #333; background: rgba(0,0,0,0.1); }

@keyframes blink { 50% { opacity: 0.6; } }

/* --- ЭЛЕМЕНТЫ УПРАВЛЕНИЯ --- */
.custom-chk { display: flex !important; align-items: center; padding: 8px; background: rgba(255,255,255,0.03); border: 1px solid #333; border-radius: 6px; margin-bottom: 5px; cursor: pointer; transition: 0.2s; user-select: none; width: 100%; }
.custom-chk:hover { background: rgba(255,255,255,0.07); border-color: #555; }
.custom-chk input { display: none !important; }
.checkmark { width: 18px; height: 18px; background: #0d1117; border: 2px solid #555; border-radius: 4px; margin-right: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.custom-chk input:checked + .checkmark { background: #27ae60; border-color: #2eff79; }
.checkmark:after { content: "✔"; color: white; font-size: 12px; display: none; }
.custom-chk input:checked + .checkmark:after { display: block; }
.chk-label { font-size: 13px; color: #ccc; flex-grow: 1; }
.custom-chk input:checked ~ .chk-label { color: #fff; font-weight: bold; text-decoration: line-through; }

.filter-switch-container { display: flex; align-items: center; gap: 10px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; display: none !important; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #34495e; transition: .4s; border-radius: 34px; border: 1px solid #555; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background-color: white; transition: .4s; border-radius: 50%; }
.switch input:checked + .slider { background-color: #27ae60; border-color: #27ae60; }
.switch input:checked + .slider:before { transform: translateX(18px); }
.switch-label { font-size: 11px; color: #f1c40f; font-weight: bold; text-transform: uppercase; }

/* --- ПРОФИЛЬ И ЗАМКИ --- */
.user-profile-container { display: flex; flex-direction: column; height: 100%; position: relative; }
.user-header-mini { padding: 10px; background: rgba(0,0,0,0.3); display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #2c3e50; }
.full-body-display { flex-grow: 1; display: flex; justify-content: center; align-items: flex-end; overflow: hidden; background: radial-gradient(circle at bottom, #2c3e50 0%, #0b0e11 70%); padding-bottom: 5px; }
.full-body-display img { height: 95%; width: auto; object-fit: contain; filter: drop-shadow(0 0 10px rgba(0,0,0,0.5)); }
.gear-btn { position: absolute; background: transparent; border: none; font-size: 18px; cursor: pointer; color: #7f8c8d; transition: 0.3s; padding: 0; }
.gear-btn:hover { color: #f1c40f; transform: rotate(90deg); }

.castles-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); 
    gap: 20px; padding: 20px; overflow-y: auto; align-content: start; padding-bottom: 70px !important; 
}
.castle-card { 
    background: #2c3e50; border: 3px solid #7f8c8d; padding: 15px; 
    border-radius: 8px; box-shadow: 0 4px 10px rgba(0,0,0,0.3); position: relative; height: fit-content; transition: 0.3s; 
}
.castle-card.is-mine { border: 2px solid #f1c40f; box-shadow: 0 0 15px rgba(241, 196, 15, 0.2); }

/* --- СОСТАВ ГИЛЬДИИ --- */
.knights-horizontal { 
    display: grid !important; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); 
    gap: 15px; padding: 15px; overflow-y: auto !important; height: 100%; 
    align-content: start; padding-bottom: 70px !important; 
}
.knight-card { 
    width: 100%; height: 140px; background: linear-gradient(145deg, #1f2933, #161d24); 
    border: 1px solid #3e4c5a; border-radius: 12px; padding: 10px; 
    display: grid; grid-template-columns: 100px 1fr; gap: 10px; 
    position: relative !important; flex-shrink: 0; overflow: hidden; 
}
.knight-card.is-me { border: 2px solid #f1c40f; box-shadow: 0 0 15px rgba(241, 196, 15, 0.2); }
.knight-list-avatar { width: 100px; height: 100px; background: #000; border: 2px solid #555; border-radius: 8px; overflow: hidden; align-self: center; }
.knight-list-avatar img { width: 100%; height: 100%; object-fit: cover; }
.knight-info-box { display: flex; flex-direction: column; justify-content: space-between; height: 100px; align-self: center; }
.knight-title-text { font-size: 10px; color: #f1c40f; text-transform: uppercase; font-weight: bold; }
.knight-name { font-size: 15px; font-weight: bold; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.knight-stats-mini { display: flex; justify-content: space-between; background: rgba(0,0,0,0.3); padding: 5px; border-radius: 4px; font-size: 11px; }

/* --- ФОРМЫ --- */
input, select, textarea { background: #0d1117 !important; border: 1px solid #30363d; color: #c9d1d9 !important; padding: 8px; border-radius: 4px; width: 100%; outline: none; }
.field-label { font-size: 10px; color: #f1c40f; font-weight: bold; text-transform: uppercase; margin-top: 10px; display: block;}
button { cursor: pointer; border: none; border-radius: 4px; font-weight: bold; color: #ffffff; background-color: #8e44ad; transition: 0.1s; border-bottom: 3px solid rgba(0,0,0,0.3); }
button:active { transform: translateY(2px); border-bottom: none; }
.btn-green { background-color: #27ae60; } .btn-blue { background-color: #2980b9; } .btn-purple { background-color: #8e44ad; } .btn-gold { background-color: #d4ac0d; color: #000; } .btn-red { background-color: #c0392b; }
#btnGlobalSummon { width: 100%; margin-top: 15px; height: 50px; }
.targets-container {
    max-height: 150px; /* Жестко ограничиваем высоту на компе */
    overflow-y: auto;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 10px;
}

/* --- МОДАЛЬНЫЕ ОКНА (ОБЩИЕ) --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 10000; justify-content: center; align-items: center; }
.modal-content { width: 450px; padding: 30px; background-color: #161d24; border: 1px solid #f1c40f; border-radius: 12px; position: relative; box-shadow: 0 0 50px rgba(0,0,0,0.8); display: flex; flex-direction: column; }
.modal-close { position: absolute; top: 0; right: 0; width: 40px; height: 40px; background-color: #c0392b; color: white; display: flex; align-items: center; justify-content: center; font-size: 24px; cursor: pointer; border-top-right-radius: 10px; border-bottom-left-radius: 10px; z-index: 200; }
.quest-large-view { width: 900px !important; max-height: 90vh; overflow-y: auto; }

/* --- СТИЛЬ ПАНЕЛИ СОЗДАТЕЛЯ (DESKTOP) --- */
.admin-theme {
    width: 900px !important; 
    border-color: #e74c3c !important;
    box-shadow: 0 0 50px rgba(192, 57, 43, 0.4) !important;
}
.admin-theme .modal-close { background-color: #c0392b !important; }
.admin-theme .shop-sidebar { background: rgba(192,57,43,0.1) !important; border-right-color: #e74c3c !important; }

.bar-container { width: 100%; background-color: #0d1117; border: 1px solid #333; border-radius: 4px; overflow: hidden; margin-bottom: 5px; position: relative; }
.hp-fill { height: 100%; background-color: #c0392b; width: 0%; transition: width 0.4s ease-out; box-shadow: 0 0 10px rgba(192, 57, 43, 0.5); }
.timer-fill { height: 100%; background-color: #f39c12; width: 0%; transition: width 1s linear; }
.quest-meta-row { display: flex; gap: 20px; align-items: center; margin: 15px 0; }
.admin-edit-row { display: flex; gap: 10px; flex-grow: 1; }

/* --- SHOP --- */
.shop-modal { width: 700px !important; height: 500px; padding: 0 !important; overflow: hidden; display: flex; flex-direction: column; }
.shop-modal h2 { margin: 15px 0; text-align: center; flex-shrink: 0; }
.shop-layout { display: flex; flex-direction: row; flex-grow: 1; border-top: 1px solid #333; overflow: hidden; height: 100%; }
.shop-sidebar { width: 220px; background: rgba(0,0,0,0.3); border-right: 1px solid #333; padding: 15px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; }
.shop-tab { background: transparent !important; color: #7f8c8d !important; text-align: left; padding: 12px 15px !important; border: 1px solid #333 !important; border-radius: 6px !important; width: 100%; cursor: pointer; font-size: 13px; font-weight: bold; }
.shop-tab:hover { background: rgba(255,255,255,0.05) !important; color: white !important; }
.shop-tab.active { background: #f1c40f !important; color: black !important; border-color: #f1c40f !important; }
.shop-content { flex-grow: 1; padding: 20px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; align-content: start; background: #0d1117; }
.shop-item { background: #1c2630; border: 1px solid #333; border-radius: 8px; padding: 15px; text-align: center; cursor: pointer; transition: 0.2s; display: flex; flex-direction: column; align-items: center; justify-content: space-between; height: 150px; }
.shop-item:hover { border-color: #f1c40f; transform: translateY(-5px); }
.shop-item-icon { font-size: 35px; }
.shop-item-name { font-size: 13px; font-weight: bold; margin: 10px 0; }
.shop-item-price { font-size: 12px; color: #27ae60; font-weight: bold; background: rgba(0,0,0,0.5); padding: 2px 8px; border-radius: 4px; }

/* --- ДОСЬЕ РЫЦАРЯ --- */
.profile-left { width: 250px; background: radial-gradient(circle at bottom, #2c3e50 0%, #0b0e11 70%); display: flex; justify-content: center; align-items: flex-end; border-right: 1px solid #333; }
.profile-left img { height: 95%; max-height: 450px; object-fit: contain; filter: drop-shadow(0 0 10px rgba(0,0,0,0.5)); }
.profile-right { flex: 1; padding: 30px; display: flex; flex-direction: column; gap: 20px; }
.medal-box { background: rgba(255,255,255,0.05); border: 1px solid #444; border-radius: 8px; padding: 10px 20px; min-width: 80px; }
.castle-tag { background: #2980b9; color: white; padding: 3px 8px; border-radius: 4px; font-size: 11px; white-space: nowrap; }

/* --- КАРТОЧКИ МЕДАЛЕЙ --- */
.medals-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 15px; padding-top: 15px; padding-bottom: 15px; }
.medal-detail-card { background: #1c2630; border: 1px solid #34495e; border-radius: 8px; padding: 12px; text-align: center; display: flex; flex-direction: column; justify-content: flex-start; align-items: center; transition: transform 0.2s, border-color 0.2s; }
.medal-detail-card:hover { transform: translateY(-3px); border-color: #f1c40f; box-shadow: 0 4px 15px rgba(241, 196, 15, 0.15); }
.medal-detail-icon { font-size: 32px; margin-bottom: 8px; filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.1)); }
.medal-detail-name { font-size: 11px; font-weight: bold; color: #e0e6ed; margin-bottom: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.medal-detail-date { font-size: 9px; color: #7f8c8d; margin-top: auto; }

/* --- ЛЕТОПИСЬ И ЛОГИ --- */
.chronicle-card { height: 230px !important; min-height: 230px !important; display: flex !important; flex-direction: column !important; justify-content: space-between !important; padding: 15px !important; box-sizing: border-box !important; border: 1px solid #7f8c8d !important; background: #1c2630 !important; }
.chronicle-card .chronicle-action-btn { align-self: flex-end; width: 100%; margin-top: 10px; padding: 8px; border-radius: 6px; font-weight: bold; font-size: 11px; border: none; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.btn-restore { background-color: #27ae60; color: white; }
.btn-destroy { background-color: #c0392b; color: white; }

.joke-bubble { background: rgba(46, 20, 55, 0.6) !important; border: 1px solid #8e44ad !important; border-left: 4px solid #9b59b6 !important; border-radius: 8px; padding: 12px !important; margin: 10px 0 !important; box-shadow: 0 4px 10px rgba(0,0,0,0.4); display: flex; flex-direction: column; gap: 8px; }
.joke-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(142, 68, 173, 0.3); padding-bottom: 5px; font-size: 11px; }
.joke-sponsor { color: #f1c40f; font-weight: bold; text-transform: uppercase; letter-spacing: 1px; }
.joke-text { color: #d2b4de; font-style: italic; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }

.admin-only { display: none; }
.auth-center { width: 380px; padding: 30px; background: #161d24; border: 1px solid #f1c40f; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); }

/* --- MOBILE ADAPTATION & BOTTOM NAV --- */
#mobile-nav { display: none; position: fixed; bottom: 0; left: 0; width: 100%; height: 60px; background: #1f2933; border-top: 2px solid #f1c40f; z-index: 20000; justify-content: space-around; align-items: center; }
#mobile-nav button { flex: 1; height: 100%; background: transparent; border: none; font-size: 24px; color: white; }
#mobile-nav button.active { background: rgba(241, 196, 15, 0.1); border-bottom: 4px solid #f1c40f; }

/* ==========================================
   📊 ТАКТИЧЕСКАЯ КАРТА (GANTT CHART)
   ========================================== */
.timeline-grid {
    display: grid;
    grid-auto-columns: 40px; 
    gap: 2px;
    position: relative;
    padding-bottom: 15px;
    min-width: max-content;
}

/* 1. ЛЕВЫЙ ВЕРХНИЙ УГОЛ (Прибит намертво: top + left) */
.tl-corner {
    position: sticky;
    top: 0;
    left: 0;
    z-index: 40 !important; 
    background: #1f2933; /* Непрозрачный фон обязателен! */
    border-bottom: 2px solid #f1c40f;
    border-right: 1px solid #333;
    color: #f1c40f;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* 2. ШАПКА ДАТ (Прибита к потолку: top) */
.tl-date-header {
    position: sticky;
    top: 0;
    z-index: 30 !important;
    background: #1f2933; /* Непрозрачный фон */
    color: #bdc3c7;
    font-size: 10px;
    text-align: center;
    padding: 5px 0;
    border-bottom: 2px solid #f1c40f;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.tl-date-header.today { background: #f39c12; color: black; font-weight: bold; }

/* 3. ЛЕВАЯ КОЛОНКА (Названия квестов и замков - Прибиты к левому краю: left) */
.tl-task-name {
    position: sticky;
    left: 0;
    z-index: 20 !important; 
    background: #161d24; /* Непрозрачный фон */
    border-right: 1px solid #333;
    padding: 5px;
    font-size: 11px;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5); /* Тень, чтобы отделить от графика */
}

/* Разделитель замка (Тоже в левой колонке) */
.tl-castle-divider {
    position: sticky;
    left: 0;
    z-index: 25 !important; 
    background: #2c3e50; /* Плотный цвет вместо градиента */
    color: #f1c40f;
    font-weight: bold;
    font-size: 12px;
    padding: 5px 10px;
    border-right: 1px solid #333;
    border-left: 3px solid #3498db;
    display: flex;
    align-items: center;
    box-shadow: 2px 0 5px rgba(0,0,0,0.5);
}

/* 4. ГРАФИК (Линии и капсулы) */
.tl-grid-line {
    background: rgba(255,255,255,0.02);
    border-right: 1px solid rgba(255,255,255,0.05);
}
.tl-grid-line.weekend { background: rgba(231,76,60,0.05); }

.tl-capsule {
    height: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 10px;
    font-weight: bold;
    color: white;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    transition: transform 0.1s, filter 0.1s;
    margin-top: 2px;
    overflow: hidden;
    white-space: nowrap;
    z-index: 10; /* Обычные капсулы лежат на самом дне (ниже шапок) */
}
.tl-capsule:hover { filter: brightness(1.2); transform: scale(1.02); z-index: 15; }

.tl-cap-active { background: linear-gradient(90deg, #8e44ad, #2980b9); border: 1px solid #9b59b6; }
.tl-cap-warning { background: linear-gradient(90deg, #d35400, #f39c12); border: 1px solid #e67e22; }
.tl-cap-danger { background: linear-gradient(90deg, #c0392b, #e74c3c); border: 1px solid #e74c3c; animation: pulse 2s infinite; }
.tl-cap-archive { background: #7f8c8d; opacity: 0.6; border: 1px solid #95a5a6; }
.tl-cap-noline { background: linear-gradient(90deg, #27ae60, transparent); border-left: 2px solid #2ecc71; }

@media (max-width: 768px) {
    
    #mobile-nav { display: flex; }
    .main-grid { display: block; padding: 0; margin: 0; height: 100vh; height: 100dvh; }
    
    .grid-item { 
        display: none !important; 
        width: 100%; 
        height: calc(100vh - 60px); height: calc(100dvh - 60px); 
        border-radius: 0; border: none;
    }
    .grid-item.mobile-active { display: flex !important; }
    
    .knights-horizontal { grid-template-columns: 1fr !important; padding-bottom: 20px !important; }
    .castles-grid { padding-bottom: 20px !important; }
    .summon-panel { flex-grow: 1; overflow-y: auto; padding: 15px; display: flex; flex-direction: column; padding-bottom: 20px !important; }
    
    .knight-card { width: 100% !important; min-width: unset !important; }
    .panel-floating-btn { bottom: 20px !important; right: 20px !important; }

    .admin-edit-row { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 10px; }
    .admin-edit-row > div { flex: 1; min-width: 45%; }

    .profile-modal { flex-direction: column !important; }
    .profile-left { width: 100% !important; height: 250px; border-right: none !important; border-bottom: 1px solid #333; }
    .profile-right { padding: 15px !important; }

    /* ============================================== */
    /* 🔥 ИДЕАЛЬНЫЙ ФИКС МОДАЛОК ДЛЯ МОБИЛОК (v4.0) 🔥 */
    /* ============================================== */
    
    /* 1. ПОДЛОЖКА (Оверлей) - Строго фиксирована, оставляет место для меню */
    .modal-overlay {
       
        flex-direction: column !important;
        justify-content: center !important; 
        align-items: center !important;
        
        padding: 20px 10px 80px 10px !important; /* 80px снизу для меню! */
        box-sizing: border-box !important;
        
        /* Оверлей НЕ СКРОЛЛИТСЯ, это жесткая рамка для модалки */
        overflow: hidden !important; 
    }

    /* 2. БАЗОВОЕ ОКНО (Простые модалки типа квестов) */
    .modal-content, 
    .quest-large-view, 
    .profile-modal {
        position: relative !important;
        top: auto !important; left: auto !important; transform: none !important; margin: 0 !important;
        
        width: 100% !important;
        max-height: 100% !important; /* Растет до границ оверлея, но не больше */
        
        /* ВЕСЬ контент скроллится внутри окна */
        overflow-y: auto !important; 
        border-radius: 12px !important;
    }

    /* 3. СЛОЖНЫЕ ОКНА С ВКЛАДКАМИ (Магазин, Админка, Летопись) */
    .shop-modal, .admin-theme {
        width: 100% !important;
        max-height: 100% !important;
        
        /* ГЛАВНАЯ МАГИЯ: Само окно НЕ скроллится! */
        overflow: hidden !important; 
        display: flex !important;
        flex-direction: column !important;
        box-shadow: none !important;
    }

    /* Шапка "Летопись/Админка" прибита гвоздями */
    .shop-modal h2 {
        flex-shrink: 0 !important; 
        margin-top: 0 !important;
    }

    /* Контейнер вкладок и контента */
    .shop-layout {
        display: flex !important;
        flex-direction: column !important;
        flex-grow: 1 !important;
        min-height: 0 !important; /* Обязательно для скролла внутри флекса */
        overflow: hidden !important; /* Не скроллим всё вместе */
    }

    /* Вкладки: прибиты гвоздями, можно листать только влево-вправо */
    .shop-sidebar {
        flex-direction: row !important;
        width: 100% !important;
        flex-shrink: 0 !important; /* НЕ СЖИМАТЬСЯ! */
        overflow-x: auto !important; /* Скролл вкладок по горизонтали */
        border-bottom: 1px solid #333 !important;
        border-right: none !important;
        padding: 5px !important;
    }
    .shop-tab { width: auto; white-space: nowrap; flex-shrink: 0; }

    /* КОНТЕНТ (Сетки карточек) - ВОТ ОН ДОЛЖЕН СКРОЛЛИТЬСЯ ВНИЗ */
    .shop-content {
        flex-grow: 1 !important;
        width: 100% !important;
        
        /* Скроллится ТОЛЬКО этот блок! */
        overflow-y: auto !important; 
        min-height: 0 !important; /* Обязательно для флекса */
        height: auto !important;
    }
    /* Фикс сплющенной шапки в модалке квеста */
    .quest-meta-row { 
        flex-direction: column !important; 
        align-items: stretch !important; 
        gap: 12px !important; 
    }
    .admin-edit-row {
        width: 100% !important;
    }
}