/* ==================================================
   1. БАЗОВЫЕ СТИЛИ И ПЕРЕОПРЕДЕЛЕНИЯ BOOTSTRAP
   ================================================== */
:root {
    --bs-blue: #0d6efd;
    --bs-indigo: #6610f2;
    --bs-purple: #6f42c1;
    --bs-pink: #d63384;
    --bs-red: #dc3545;
    --bs-orange: #fd7e14;
    --bs-yellow: #ffc107;
    --bs-green: #198754;
    --bs-teal: #20c997;
    --bs-cyan: #0dcaf0;
    --bs-black: #000;
    --bs-white: #fff;
    --bs-gray: #6c757d;
    --bs-gray-dark: #343a40;
    --bs-gray-100: #f8f9fa;
    --bs-gray-200: #e9ecef;
    --bs-gray-300: #dee2e6;
    --bs-gray-400: #ced4da;
    --bs-gray-500: #adb5bd;
    --bs-gray-600: #6c757d;
    --bs-gray-700: #495057;
    --bs-gray-800: #343a40;
    --bs-gray-900: #212529;
    --bs-primary: #007bff;
    --bs-secondary: #6c757d;
    --bs-success: #198754;
    --bs-info: #0dcaf0;
    --bs-warning: #ffc107;
    --bs-danger: #dc3545;
    --bs-light: #f8f9fa;
    --bs-dark: #212529;
    --bs-primary-rgb: 0, 123, 255;
    --bs-secondary-rgb: 108, 117, 125;
    --bs-success-rgb: 25, 135, 84;
    --bs-info-rgb: 13, 202, 240;
    --bs-warning-rgb: 255, 193, 7;
    --bs-danger-rgb: 220, 53, 69;
    --bs-light-rgb: 248, 249, 250;
    --bs-dark-rgb: 33, 37, 41;
    --bs-white-rgb: 255, 255, 255;
    --bs-black-rgb: 0, 0, 0;
    --bs-body-color-rgb: 33, 37, 41;
    --bs-body-bg-rgb: 248, 249, 250;
    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
    --bs-font-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    --bs-gradient: linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0));
    --bs-body-font-family: var(--bs-font-sans-serif);
    --bs-body-font-size: 1rem;
    --bs-body-font-weight: 400;
    --bs-body-line-height: 1.5;
    --bs-body-color: #212529;
    --bs-body-bg: #fff;
    --bs-border-width: 1px;
    --bs-border-style: solid;
    --bs-border-color: #dee2e6;
    --bs-border-color-translucent: rgba(0, 0, 0, 0.175);
    --bs-border-radius: 0.375rem;
    --bs-border-radius-sm: 0.25rem;
    --bs-border-radius-lg: 0.5rem;
    --bs-border-radius-xl: 1rem;
    --bs-border-radius-xxl: 2rem;
    --bs-border-radius-2xl: var(--bs-border-radius-xxl);
    --bs-border-radius-pill: 50rem;
    --bs-box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --bs-box-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --bs-box-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);
    --bs-box-shadow-inset: inset 0 1px 2px rgba(0, 0, 0, 0.075);
    --bs-focus-ring-width: 0.25rem;
    --bs-focus-ring-opacity: 0.25;
    --bs-focus-ring-color: rgba(13, 110, 253, 0.25);
    --bs-form-valid-color: #198754;
    --bs-form-valid-border-color: #198754;
    --bs-form-invalid-color: #dc3545;
    --bs-form-invalid-border-color: #dc3545;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f8f9fa;
    color: #333;
}
a {
    text-decoration: none;
}
/* ==================================================
   2. ПЕРВООЧЕРЕДНЫЕ ПРАВИЛА ДЛЯ НАВИГАЦИИ
   ================================================== */
.navbar {
    background-color: #007bff !important;
    padding: 1rem !important;
    display: flex;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: flex-start !important;
}
.navbar .container,
.navbar .container-fluid,
.navbar-collapse {
    flex-wrap: nowrap !important;
    display: flex !important;
    flex-basis: auto !important;
    flex-grow: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
}
.navbar-nav {
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
}
.navbar-nav li,
.navbar-nav .nav-item {
    list-style: none !important;
}
.navbar .nav-link,
.navbar a:not(.logo):not(.telegram-link) {
    color: white !important;
    padding: 0.5rem 1rem !important;
    border-radius: 4px !important;
    transition: background-color 0.2s !important;
}
.navbar .nav-link:hover,
.navbar a:not(.logo):not(.telegram-link):hover {
    background-color: #0056b3 !important;
}
.navbar-brand {
    margin-right: 2rem;
    padding: 0;
}
.navbar-brand img {
    height: 30px;
}
/* ---------------------- Логотип ------------------------ */
.navbar .logo {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    text-decoration: none !important;
    margin-right: 20px !important;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
}
.navbar .logo i {
    color: white !important;
    font-size: 1.2rem !important;
    background: transparent !important;
    padding: 0 !important;
}
.navbar .logo .logo-main {
    color: #ffffff !important;
    font-weight: bold !important;
    font-size: 1.2rem !important;
    background: transparent !important;
    padding: 0 !important;
}
.navbar .logo .logo-sep {
    color: rgba(255, 255, 255, 0.5) !important;
    font-weight: normal !important;
    font-size: 1.2rem !important;
    margin: 0 2px !important;
    background: transparent !important;
    padding: 0 !important;
}
.navbar .logo .logo-sub {
    color: rgba(255, 255, 255, 0.7) !important;
    font-weight: normal !important;
    font-size: 1.2rem !important;
    margin-left: 2px !important;
    background: transparent !important;
    padding: 0 !important;
}
.navbar .logo:hover,
.navbar .logo:hover * {
    background-color: transparent !important;
    color: inherit !important;
}
/* ---------------------- Telegram-блок ------------------------ */
.telegram-container {
    margin-left: auto !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 10px !important;
    align-items: center !important;
}
.telegram-invite {
    color: white !important;
    white-space: nowrap;
}
.navbar .telegram-link {
    background-color: white !important;
    color: #007bff !important;
    border: 1px solid #007bff !important;
    border-radius: 4px !important;
    padding: 0.5rem 1rem !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    transition: all 0.2s ease !important;
}
.navbar .telegram-link i {
    font-size: 1.2em !important;
    color: #007bff !important;
}
.navbar .telegram-link:hover {
    background-color: #e6f7ff !important;
    border-color: #0056b3 !important;
    color: #0056b3 !important;
}
.navbar .telegram-link:hover i {
    color: #0056b3 !important;
}
/* ==================================================
   3. СТИЛИ ДЛЯ ГЛАВНОЙ СТРАНИЦЫ
   ================================================== */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 20px;
}
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    padding: 2rem;
    margin-bottom: 2rem;
}
h1, h2, h3 {
    color: #007bff;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 0.5rem;
}
/* ---------------------- Hero-секция ------------------------ */
.hero-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 1.5rem;
    padding: 3rem 2rem;
    margin: 2rem auto;
    max-width: 1140px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.hero-section h1 {
    font-weight: 700;
    font-size: 2.4rem;
    margin-bottom: 1rem;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.hero-section .lead {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.25rem;
    margin-bottom: 2rem;
}
.hero-section .input-group {
    max-width: 800px;
    margin: 0 auto;
    border-radius: 50px;
    overflow: hidden;
    background: transparent;
}
.hero-section .form-control {
    border: none;
    border-radius: 50px 0 0 50px;
    padding: 0.8rem 1.5rem;
}
.hero-section .btn-primary {
    background-color: #ff7e5e;
    border: none;
    border-radius: 0 50px 50px 0;
    padding: 0.8rem 2rem;
}
.hero-section .btn-primary:hover {
    background-color: #feb47b;
}
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 1.8rem;
    }
    .hero-section .lead {
        font-size: 1rem;
    }
}
/* ---------------------- Карточки преимуществ ------------------------ */
.features-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}
.feature-card {
    flex: 1 1 300px;
    background: white;
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.05);
    transition: all 0.3s ease;
}
.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.1);
}
.feature-icon {
    background: transparent !important;
    width: auto !important;
    height: auto !important;
    text-align: center !important;
    margin-bottom: 1rem !important;
    transition: transform 0.2s !important;
}
.feature-icon i {
    font-size: 3rem !important;
    color: #007bff !important;
}
.feature-card:hover .feature-icon {
    transform: scale(1.05);
}
.feature-card h3 {
    font-weight: 700;
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: #2d3748;
    border-bottom: none;
    padding-bottom: 0;
}
.feature-card p {
    color: #4a5568;
    line-height: 1.5;
    margin-bottom: 0;
}
/* ---------------------- Блок "О проекте" ------------------------ */
.about-section {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9ff 100%);
    border-radius: 2rem;
    margin: 4rem auto;
    padding: 3rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.05);
}
.about-section h2 {
    font-weight: 700;
    color: #2d3748;
    border-bottom: none;
    padding-bottom: 0;
}
.about-section .lead {
    color: #4a5568;
}
.about-section img {
    max-width: 100%;
    height: auto;
}
.about-section svg {
    filter: drop-shadow(0 8px 15px rgba(0,0,0,0.1));
}
/* ---------------------- CTA-блок ------------------------ */
.cta-section {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 2rem;
    padding: 3rem;
    color: white;
    margin: 4rem auto;
}
.cta-section h2 {
    font-weight: 700;
    border-bottom: none;
    padding-bottom: 0;
    color: #ffffff;
}
.cta-section .btn-light {
    background-color: white;
    color: #f5576c;
    border: none;
    padding: 0.75rem 2rem;
    font-weight: 600;
    transition: all 0.2s;
}
.cta-section .btn-light:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    color: white !important;
}
.cta-section .btn-outline-light {
    border-color: white;
    color: white;
}
.cta-section .btn-outline-light:hover {
    background-color: white;
    color: #f5576c;
}

/* ---------------------- Дополнительные возможности ------------------------ */
.extra-card {
    background: white;
    border-radius: 1rem;
    transition: all 0.2s;
    border: 1px solid #edf2f7;
}
.extra-card:hover {
    border-color: #cbd5e0;
    box-shadow: 0 10px 15px -5px rgba(0,0,0,0.05);
}
.extra-card i {
    color: #667eea;
}
/* ==================================================
   4. СТИЛИ ДЛЯ ДРУГИХ СТРАНИЦ
   ================================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}
th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
th {
    background-color: #f8f9fa;
    font-weight: 600;
}
tr:hover {
    background-color: #f1f3f5;
}
.btn, .btn-apply, .btn-reset {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007bff;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.btn:hover, .btn-apply:hover, .btn-reset:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-secondary {
    background-color: #6c757d;
}
.btn-secondary:hover {
    background-color: #545b62;
}
.filters {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 25px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.filter-group {
    flex: 1 1 200px;
    min-width: 200px;
}
.filter-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.filter-group label i {
    margin-right: 5px;
    color: #007bff;
}
.filter-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background-color: white;
    font-size: 1rem;
    color: #495057;
    appearance: none;
    -webkit-appearance: none;
    -moz-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='%23495057' 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 10px center;
    background-size: 16px;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.filter-group select:hover {
    border-color: #adb5bd;
}
.filter-group select:focus {
    border-color: #007bff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,0.25);
}
.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 8px 12px;
    border-radius: 4px;
    text-decoration: none;
}
.pagination .current-page {
    background-color: #007bff;
    color: white;
}
.charts-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin: 30px 0;
}
.chart-card {
    background: white;
    border-radius: 8px;
    padding: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.chart-card h3 {
    margin-top: 0;
    color: #007bff;
    font-size: 18px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}
canvas {
    max-height: 300px;
    max-width: 100%;
}
.summary-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
}
.stat-card {
    background: linear-gradient(135deg, #007bff, #00bcd4);
    color: white;
    padding: 20px;
    border-radius: 10px;
    flex: 1;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.stat-card .value {
    font-size: 2em;
    font-weight: bold;
}
.stat-card .label {
    font-size: 1em;
    opacity: 0.9;
}
.financial-detail table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}
.financial-detail th, .financial-detail td {
    padding: 8px;
    text-align: left;
    border: 1px solid #dee2e6;
}
.financial-detail th {
    background-color: #f8f9fa;
    font-weight: 600;
}
.financial-detail h3 {
    margin-top: 25px;
    color: #007bff;
}
.pdf-link {
    margin: 10px 0 20px;
}
.summary-table {
    margin: 20px 0;
}
.alert {
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}
.alert-success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}
.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
    color: #856404;
}
.alert-error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}
.footer {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-size: 0.9rem;
}
html {
    scroll-behavior: smooth;
}
/* ==================================================
   5. АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ================================================== */
@media (max-width: 768px) {
    .hero-section {
        padding: 2rem 1rem;
        margin: 1rem;
        border-radius: 1.5rem;
    }
    .hero-section h1 {
        font-size: 2rem;
    }
    .hero-section .lead {
        font-size: 1rem;
    }
    .hero-section .form-control {
        width: 100% !important;
        border-radius: 50px;
        border-right: 1px solid #ced4da;
        margin-bottom: 0.5rem;
    }
    .hero-section .input-group {
        flex-wrap: wrap;
    }
    .hero-section .btn-primary {
        width: 100%;
        border-radius: 50px;
    }
    .btn-lg {
        padding: 0.5rem 1rem;
        font-size: 1rem;
    }
    .feature-card {
        margin-bottom: 1.5rem;
    }
    .about-section, .cta-section {
        padding: 2rem;
    }
    .feature-icon {
        width: 60px;
        height: 60px;
        line-height: 60px;
        font-size: 1.5rem;
    }
}

/* Адаптация главного меню для мобильных устройств */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap !important;
        justify-content: space-between !important;
        padding: 0.75rem 1rem !important;
    }
    /* Контейнер со ссылками – теперь вертикальный, занимает всю ширину */
    .navbar .navbar-nav {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
        margin-top: 15px !important;
        padding: 0 !important;
    }
    /* Каждая ссылка занимает всю ширину, текст по центру */
    .navbar .navbar-nav .nav-item,
    .navbar .navbar-nav a:not(.logo):not(.telegram-link) {
        display: block !important;
        width: 100% !important;
        text-align: center !important;
        padding: 10px !important;
        background-color: rgba(255,255,255,0.1) !important;
        border-radius: 8px !important;
    }
    /* Логотип и Telegram-блок остаются в одной строке */
    .logo {
        margin-right: auto !important;
    }
    .telegram-container {
        margin-left: 0 !important;
        flex-direction: row !important;
        gap: 5px !important;
    }
    /* Можно скрыть длинный текст-призыв, оставив только иконку и "Наш канал" */
    .telegram-invite {
        display: none;
    }
    /* Уменьшаем отступы у кнопки Telegram */
    .navbar .telegram-link {
        padding: 0.4rem 0.8rem !important;
        font-size: 0.9rem !important;
    }
}

/* Адаптация Hero Section для мобильных (ширина до 768px) */
@media (max-width: 768px) {
    .hero-section {
        padding: 1.5rem 1rem !important;
        margin: 1rem auto !important;
        border-radius: 1rem !important;
    }
    .hero-section h1 {
        font-size: 1.5rem !important;
        line-height: 1.2;
    }
    .hero-section .lead {
        font-size: 0.95rem !important;
        margin-bottom: 1.5rem !important;
    }
    /* Вертикальное расположение поля поиска и кнопки */
    .hero-section .input-group {
        flex-direction: column !important;
        gap: 10px !important;
        background: transparent !important;
        border-radius: 0 !important;
    }
    .hero-section .form-control {
        border-radius: 50px !important;
        border: 1px solid #ced4da !important;
        width: 100% !important;
        padding: 0.7rem 1rem !important;
    }
    .hero-section .btn-primary {
        border-radius: 50px !important;
        width: 100% !important;
        padding: 0.7rem 1rem !important;
    }
}

/* Для совсем маленьких экранов (480px и меньше) */
@media (max-width: 480px) {
    .hero-section h1 {
        font-size: 1.3rem !important;
    }
    .hero-section .lead {
        font-size: 0.85rem !important;
    }
}

/* ===== Адаптация страницы сводной статистики для мобильных ===== */

/* 1. Карточки summary-stats – горизонтальная прокрутка */
@media (max-width: 768px) {
    .summary-stats {
        flex-direction: column;  /* ставим карточки в столбец */
        gap: 15px;               /* отступы между карточками */
        align-items: stretch;    /* чтобы карточки были одинаковой ширины */
    }
    .stat-card {
        width: 100%;             /* каждая карточка на всю ширину */
        margin-bottom: 0;        /* убираем лишние отступы */
    }
}

/* 2. Графики – полная ширина на мобильных */
/* Адаптация графиков для мобильных устройств */
@media (max-width: 768px) {
    .charts-container {
        grid-template-columns: 1fr !important;   /* один столбец */
        gap: 20px;
    }
    .chart-card {
        width: 100%;
        padding: 10px;
    }
    .chart-card canvas {
        max-height: 250px !important;  /* уменьшаем высоту графика */
        width: 100% !important;
    }
    /* Дополнительно: подписи осей на графиках (если есть) */
    .chart-card h3 {
        font-size: 1.1rem;
        text-align: center;
    }
}

/* Ещё более мелкие экраны (ширина < 480px) */
@media (max-width: 480px) {
    .chart-card canvas {
        max-height: 200px !important;
    }
    .chart-card h3 {
        font-size: 1rem;
    }
}

/* 3. Таблица – горизонтальная прокрутка */
@media (max-width: 768px) {
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
    }
    .summary-table {
        min-width: 600px;
        width: 100%;
    }
}

/* Стили для адаптации таблицы на странице /companies на мобильных устройствах */
@media (max-width: 768px) {
    /* Оборачиваем таблицу в блок с прокруткой, если она не помещается */
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
        border-radius: 8px;
    }
    /* Задаём таблице минимальную ширину, чтобы она не сужалась */
    .companies-table {
        min-width: 700px;
        width: 100%;
    }
}