/* --- CORE VARIABLES & THEME --- */
:root {
    --bg-main: #0A0A0F; /* Темный фон для Лендинга */
    --text-white: #ffffff;
    --text-muted: #888899;
    /* Фирменные цвета */
    --p-start: #7B61FF;       
    --p-end: #A64BF4;         
    --lime: #CCFF00;
    /* Светлая тема (Кабинет) - High Contrast Update */
    --bg-light: #F2F5FA; /* Чуть более холодный и чистый фон */
    --card-light: #FFFFFF; /* Карточки: Чистый белый */
    --text-dark: #1B2559; /* Более глубокий темный цвет для текста */
    --text-grey: #707EAE; /* Более насыщенный серый для читаемости */
    
    --input-bg: #FFFFFF;      
    --input-border: #E0E5F2;  
    
    --sidebar-bg: #050B20; /* Сайдбар: Почти черный синий */
    --warning: #FFB547;
}

/* --- BASE & RESET --- */
body, html {
    height: 100%;
    margin: 0;
    padding: 0;
    background-color: var(--bg-main);
    color: var(--text-white);
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    overflow-x: hidden;
}

* { box-sizing: border-box; }
a { text-decoration: none; color: inherit; transition: 0.3s; }
ul { list-style: none; padding: 0; margin: 0; }
h1, h2, h3, h4, h5, h6 { font-family: 'Manrope', sans-serif; font-weight: 800; margin-top: 0; }
p { margin-top: 0; margin-bottom: 1.5rem; }

/* --- УТИЛИТЫ --- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; position: relative; z-index: 2; }
.text-center { text-align: center; }
.text-lime { color: var(--lime) !important; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.mb-40 { margin-bottom: 40px; }
.text-warning { color: var(--warning) !important; }

/* Текстовый градиент */
.text-gradient-main {
    background: linear-gradient(135deg, var(--p-start), var(--lime));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

/* --- СВЕТЛАЯ ТЕМА (КАБИНЕТ) --- */
body.light-theme {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

body.light-theme .main-content {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

/* САЙДБАР */
body.light-theme .sidebar {
    background: var(--sidebar-bg) !important;
    box-shadow: 10px 0 60px rgba(0,0,0,0.1);
    border-right: none;
}

body.light-theme .brand-logo {
    font-size: 28px;
    letter-spacing: 2px;
    font-weight: 900;
    text-transform: uppercase;
    background: linear-gradient(135deg, #9775FF 0%, #FFFFFF 40%, #CCFF00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 15px rgba(204, 255, 0, 0.6));
    margin-bottom: 40px;
    display: inline-block;
}

body.light-theme .nav-menu { gap: 4px; }

body.light-theme .nav-item {
    color: #ffffff !important;
    font-weight: 600;
    font-size: 14px;
    padding: 12px 18px;
    border-radius: 12px;
    transition: all 0.2s ease;
    border: none;
}

body.light-theme .nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateX(2px);
}

body.light-theme .nav-item.active {
    background: linear-gradient(90deg, var(--p-start), var(--p-end));
    color: #fff !important;
    font-weight: 700;
    box-shadow: 0 5px 20px rgba(123, 97, 255, 0.4);
}

/* КАРТОЧКИ (HIGH CONTRAST DESIGN) */
body.light-theme .card, 
body.light-theme .glass-panel {
    background: var(--card-light);
    border: 1px solid #E9EDF7;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(112, 144, 176, 0.08);
    color: var(--text-dark);
    padding: 30px;
    transition: transform 0.2s;
}

/* Заголовки в светлой теме */
body.light-theme h1 { font-size: 32px; color: var(--text-dark); letter-spacing: -0.5px; font-weight: 800; }
body.light-theme h2 { color: var(--text-dark); font-weight: 700; }
body.light-theme h3 { color: var(--text-dark); font-weight: 700; }
body.light-theme p { color: var(--text-grey); font-weight: 500; }
body.light-theme table th { color: var(--text-grey); font-weight: 600; opacity: 0.8; padding: 10px; text-align: left; }
body.light-theme table td { color: var(--text-dark); font-weight: 600; padding: 10px; border-bottom: 1px solid #F0F3FA; }

/* ПОЛЯ ВВОДА */
body.light-theme .form-group { margin-bottom: 24px; }

body.light-theme label {
    color: var(--text-dark);
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
}

body.light-theme .form-control {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-dark);
    font-weight: 600;
    padding: 14px 20px;
    border-radius: 16px;
    font-size: 15px;
    width: 100%;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.01);
}

body.light-theme .form-control::placeholder {
    color: var(--text-grey);
    font-weight: 400;
    opacity: 0.7;
}

body.light-theme .form-control:focus {
    background: #fff;
    border-color: var(--p-start);
    box-shadow: 0 0 0 3px rgba(123, 97, 255, 0.15);
    outline: none;
}

/* Стилизация Select */
body.light-theme select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232B3674' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px;
    background-color: #fff !important;
}

/* Checkbox */
body.light-theme input[type="checkbox"] {
    accent-color: var(--p-start);
    width: 18px;
    height: 18px;
    margin-right: 10px;
    cursor: pointer;
}

/* КНОПКИ */
.btn-primary {
    background: linear-gradient(90deg, var(--p-start), var(--p-end));
    color: #fff !important;
    border: none;
    box-shadow: 0 10px 25px rgba(123, 97, 255, 0.4);
    font-weight: 700;
    padding: 14px 32px;
    border-radius: 50px;
    font-size: 15px;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(123, 97, 255, 0.6);
}

.btn-secondary, .btn-outline {
    background: transparent;
    border: 2px solid var(--p-start);
    color: var(--p-start) !important;
    border-radius: 50px;
    padding: 12px 30px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}
body.light-theme .btn-secondary:hover, 
body.light-theme .btn-outline:hover {
    background: rgba(123, 97, 255, 0.08);
}
.btn-danger {
    background: #FFF5F5;
    color: #E53E3E !important;
    border: 1px solid #FC8181;
    border-radius: 50px;
    padding: 12px 30px;
    font-weight: 700;
    cursor: pointer;
    display: inline-block;
    text-align: center;
}
.btn-sm { padding: 8px 16px; font-size: 13px; }

/* MODALS */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: rgba(11, 20, 55, 0.6);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.modal.show { display: flex; }

.modal-content {
    background: #fff;
    color: var(--text-dark);
    box-shadow: 0 40px 80px rgba(0,0,0,0.2);
    border-radius: 24px;
    border: none;
    padding: 30px;
    width: 90%;
    max-width: 500px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes modalPop {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

body.light-theme .modal-content h2 { color: var(--text-dark); margin-top: 0; }
.close {
    position: absolute;
    top: 20px;
    right: 25px;
    color: var(--text-grey);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: 0.2s;
}
.close:hover {
    color: var(--text-dark);
    transform: scale(1.1);
}

/* --- AUTOCOMPLETE --- */
.autocomplete-dropdown {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 0 0 16px 16px;
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    max-height: 200px;
    overflow-y: auto;
}
.autocomplete-item {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: 0.1s;
    color: #2B3674;
}
.autocomplete-item:hover { background: #F4F7FE; }
.autocomplete-item small { color: #A3AED0; margin-left: 5px; }

/* === MOBILE NAV TOGGLE & SIDEBAR === */
.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px; 
    z-index: 1000;
    background: #fff; 
    color: var(--text-dark);
    width: 44px; 
    height: 44px; 
    border-radius: 12px;
    align-items: center; 
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    font-size: 24px;
    border: 1px solid #eee;
}

.mobile-nav-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background-color: var(--text-dark);
    position: relative;
    transition: 0.3s;
}

.mobile-nav-toggle span::before,
.mobile-nav-toggle span::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--text-dark);
    transition: 0.3s;
}

.mobile-nav-toggle span::before { top: -6px; }
.mobile-nav-toggle span::after { top: 6px; }

.mobile-nav-toggle.active span { background-color: transparent; }
.mobile-nav-toggle.active span::before { transform: rotate(45deg); top: 0; }
.mobile-nav-toggle.active span::after { transform: rotate(-45deg); top: 0; }

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active { display: block; opacity: 1; }

/* === MOBILE ADAPTATION FOR CABINET (Max-width: 1024px) === */
@media (max-width: 1024px) {
    .app-container { flexDirection: column; }
    
    .sidebar {
        transform: translateX(-100%);
        width: 85%;
        max-width: 320px;
        box-shadow: none;
        z-index: 1000;
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 10px 0 50px rgba(0,0,0,0.5);
    }

    .main-content {
        margin-left: 0 !important;
        padding: 20px !important;
        padding-top: 80px !important; /* Space for burger */
        width: 100%;
    }

    .mobile-nav-toggle { display: flex; }
    
    body.light-theme h1 { font-size: 28px; }
    
    .card[style*="max-width"] { max-width: 100% !important; }
    
    .form-group[style*="grid-template-columns"],
    div[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    
    .form-group[style*="display: flex"] {
        flex-direction: column;
        align-items: stretch !important;
    }
    
    .btn { width: 100%; margin-bottom: 10px; }
    .btn-secondary { margin-left: 0 !important; }
    .modal-content { width: 95%; padding: 20px; max-height: 85vh; }
}

/* --- TARIFFS TABLE REDESIGN --- */
.tariffs-wrapper {
    overflow-x: auto;
    position: relative;
    border-radius: 20px;
    background: #fff;
    border: 1px solid #E9EDF7;
    box-shadow: 0 8px 24px rgba(112, 144, 176, 0.08);
}

.tariffs-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 800px; /* Ensure scrolling triggers */
}

.tariffs-table th, .tariffs-table td {
    padding: 20px;
    border-bottom: 1px solid #F0F3FA;
    border-right: 1px solid #F0F3FA;
    background: #fff;
}

.tariffs-table th:last-child, .tariffs-table td:last-child {
    border-right: none;
}

/* Sticky First Column */
.tariffs-table th:first-child,
.tariffs-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff; /* Opaque background needed */
    border-right: 2px solid #E9EDF7; /* Stronger border to separate */
    font-weight: 700;
    color: #555;
    min-width: 150px;
}

.tariffs-table th {
    text-align: center;
    vertical-align: middle;
}

/* Header Cells styling */
.t-header-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.t-name {
    font-size: 18px;
    font-weight: 800;
    color: #2B3674;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.t-price {
    font-size: 14px;
    font-weight: 700;
    color: #707EAE;
    background: #F4F7FE;
    padding: 6px 12px;
    border-radius: 20px;
}

.price-nowrap {
    white-space: nowrap;
}