/* ===========================================
   СВОЙЛОТ — Мобильная адаптация v5.0 Final
   =========================================== */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===========================================
   БАЗА — только body и html
   =========================================== */
@media (max-width: 768px) {
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
    }

    body {
        padding-bottom: 72px !important;
    }

    .main {
        padding: 12px 8px !important;
        max-width: 100% !important;
    }

    img, video {
        max-width: 100% !important;
        height: auto !important;
    }

    /* Длинные слова */
    p, span, div, h1, h2, h3, h4, h5, h6, li, td, th, a {
        word-break: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Заголовки */
    h1 { font-size: 20px !important; }
    h2 { font-size: 17px !important; }
    h3 { font-size: 15px !important; }

    /* Хлебные крошки */
    .mb-24[style*="font-size:14px"] {
        font-size: 11px !important;
        margin-bottom: 10px !important;
        white-space: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Карточки */
    .card {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }

    /* Сетки */
    .grid-3, .grid-4 {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }

    /* Кнопки */
    .btn {
        padding: 8px 14px !important;
        font-size: 12px !important;
    }
}

/* ===========================================
   ШАПКА
   =========================================== */
@media (max-width: 768px) {
    .header-inner {
        padding: 0 8px !important;
        height: 48px !important;
    }

    .logo img { height: 22px !important; }
    .logo span { font-size: 14px !important; }

    .header-inner .nav-link { display: none !important; }
    .notify-bell { display: flex !important; }

    .user-avatar { width: 26px !important; height: 26px !important; font-size: 10px !important; }
    .btn-outline { font-size: 10px !important; padding: 4px 8px !important; }
    .btn-primary { font-size: 11px !important; padding: 5px 10px !important; }
    .user-menu { gap: 6px !important; }
}

/* ===========================================
   НИЖНЕЕ МЕНЮ
   =========================================== */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    background: rgba(10, 14, 20, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    padding: 4px 0 calc(4px + var(--safe-bottom));
    display: flex;
    justify-content: space-around;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 9px;
    font-weight: 500;
    padding: 3px 6px;
    border-radius: 8px;
}
.mobile-nav-item.active { color: var(--accent); }
.mobile-nav-item svg { width: 20px; height: 20px; }

@media (max-width: 768px) { .mobile-nav { display: flex; } }
@media (min-width: 769px) { .mobile-nav { display: none !important; } }

/* ===========================================
   КАТАЛОГ
   =========================================== */
@media (max-width: 768px) {
    .catalog-wrap, .catalog-layout {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }

    .catalog-side {
        position: static !important;
        padding: 8px !important;
        border-radius: 10px !important;
    }

    .catalog-side-list {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 3px !important;
    }

    .catalog-side-list a {
        flex-shrink: 0;
        padding: 5px 8px !important;
        font-size: 10px !important;
        border-radius: 14px !important;
        border: 1px solid var(--border);
        white-space: nowrap !important;
    }

    .catalog-side-list a.active {
        background: var(--accent);
        color: #fff;
        border-color: var(--accent);
    }

    .catalog-side-head, .cat-count, .badge-count { display: none !important; }

    .subcat-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 5px !important;
    }
    .subcat-card { padding: 10px !important; }
    .subcat-name { font-size: 11px !important; }
    .subcat-cnt { font-size: 10px !important; }

    .listing-row {
        flex-direction: column !important;
        padding: 10px !important;
        gap: 6px !important;
    }

    .lr-seller {
        width: 100% !important;
        flex-direction: row !important;
        border: none !important;
        padding: 0 0 6px !important;
        gap: 6px !important;
    }

    .lr-avatar { width: 28px !important; height: 28px !important; }
    .lr-seller-name { font-size: 11px !important; }
    .lr-info { width: 100% !important; padding: 0 !important; }
    .lr-title { font-size: 12px !important; }

    .lr-price {
        width: 100% !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        padding: 6px 0 0 !important;
        border-top: 1px solid var(--border);
    }

    .lr-price-current { font-size: 15px !important; }
    .sort-bar { gap: 3px !important; flex-wrap: wrap !important; }
    .sort-pill { font-size: 10px !important; padding: 4px 8px !important; }

    /* ФИКС ДЛИННОГО ОПИСАНИЯ */
    .desc-preview {
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    word-break: break-all !important;    /* Режет 33333 */
    overflow-wrap: break-word !important;
    white-space: normal !important;
}


/* ===========================================
   СТРАНИЦА ТОВАРА
   =========================================== */
@media (max-width: 768px) {
    [style*="grid-template-columns:1fr 380px"] {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    [style*="position:sticky"] {
        position: static !important;
    }

    [style*="font-size:32px"] {
        font-size: 22px !important;
    }
}

/* ===========================================
   СДЕЛКИ
   =========================================== */
@media (max-width: 768px) {
    .transactions-table th,
    .transactions-table .col-category,
    .transactions-table .col-date,
    .transactions-table .col-id {
        display: none;
    }

    .transactions-table tbody td {
        padding: 10px 6px !important;
        font-size: 11px !important;
    }

    .tab-link {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }

    h1[style*="font-size:28px"] {
        font-size: 20px !important;
    }
}

/* ===========================================
   ПРОФИЛЬ
   =========================================== */
@media (max-width: 650px) {
    .profile-cover { height: 90px !important; border-radius: 8px !important; margin-bottom: -22px !important; }
    .profile-header { flex-direction: column !important; align-items: center !important; text-align: center !important; gap: 8px !important; padding: 0 6px !important; }
    .profile-avatar { width: 56px !important; height: 56px !important; font-size: 20px !important; }
    .profile-name { font-size: 15px !important; }
    .profile-counters { justify-content: center !important; gap: 10px !important; font-size: 10px !important; }
    .profile-tabs { overflow-x: auto !important; padding: 0 !important; }
    .profile-tabs a { padding: 7px 9px !important; font-size: 10px !important; white-space: nowrap !important; }
    .profile-content { padding: 0 2px 20px !important; }

    .stats-grid-sm, .stats-grid-profile {
        grid-template-columns: 1fr 1fr !important;
        gap: 5px !important;
    }
}

/* ===========================================
   ФОРМЫ
   =========================================== */
@media (max-width: 600px) {
    .form-line, .edit-media-row, .edit-form-grid, .sec-grid-2 {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
}

/* ===========================================
   ВИДЖЕТ ПОДДЕРЖКИ
   =========================================== */
@media (max-width: 440px) {
    #supportWidget {
        bottom: 78px !important;
        right: 6px !important;
    }

    #supportPanel {
        width: calc(100vw - 8px) !important;
        right: 0 !important;
        bottom: 68px !important;
        border-radius: 14px 14px 0 0 !important;
        height: 50vh !important;
    }

    #supportToggle {
        width: 44px !important;
        height: 44px !important;
    }
}

/* ===========================================
   ФУТЕР
   =========================================== */
@media (max-width: 600px) {
    .footer {
        padding: 20px 10px 85px 10px !important;
    }

    .footer-grid {
        flex-direction: column !important;
        gap: 14px !important;
    }

    .footer-brand {
        flex: 0 0 100% !important;
        text-align: left !important;
        max-width: 100% !important;
    }

    .footer-logo-text { font-size: 16px !important; }
    .footer-logo-img { height: 28px !important; }
    .footer-logo-wrapper { gap: 8px !important; margin-bottom: 10px !important; }

    .footer-links {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .footer-heading { font-size: 9px !important; margin-bottom: 8px !important; }
    .footer-group a { font-size: 11px !important; padding: 3px 0 !important; }

    .contact-column {
        max-width: 100% !important;
        margin-left: 0 !important;
    }

    .social-links { justify-content: flex-start !important; gap: 8px !important; }
    .social-btn { width: 36px !important; height: 36px !important; }

    .footer-bottom {
        flex-direction: column !important;
        text-align: left !important;
        gap: 4px !important;
        font-size: 10px !important;
    }
}

/* ===========================================
   ГЛАВНАЯ
   =========================================== */
@media (max-width: 800px) {
    .hero-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
    .hero-content h1 { font-size: 22px !important; }
    .hero-stats-col { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
    .hero-stat-card { padding: 10px !important; }
    .hero-stat-card .hsc-value { font-size: 18px !important; }
    .trust-bar { grid-template-columns: 1fr !important; gap: 6px !important; }
    .featured-grid { grid-template-columns: 1fr 1fr !important; gap: 6px !important; }
    .categories-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 5px !important; }
    .cat-card { padding: 12px 8px !important; }
}

/* ===========================================
   АДМИНКА
   =========================================== */
@media (max-width: 768px) {
    .sidebar {
        width: 100% !important;
        position: static !important;
        height: auto !important;
        padding: 6px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 2px;
    }

    .sidebar-nav a {
        padding: 4px 7px !important;
        font-size: 9px !important;
        border-radius: 5px !important;
        border: 1px solid var(--border);
    }

    .sidebar-logo { display: none; }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 10px 6px !important;
    }
}
/* ===========================================
   DASHBOARD — карточки как в приложении
   =========================================== */
@media (max-width: 768px) {
    .transactions-table,
    .transactions-table tbody,
    .transactions-table tr,
    .transactions-table td,
    .transactions-table th {
        display: block !important;
        width: 100% !important;
    }

    .transactions-table thead { display: none !important; }

    .transactions-table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    .transactions-table tr {
        background: var(--bg-card) !important;
        border: 1px solid var(--border) !important;
        border-radius: 14px !important;
        padding: 14px !important;
        display: flex !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        gap: 4px 12px !important;
    }

    .transactions-table td { border: none !important; padding: 0 !important; }

    .col-id { display: none !important; }
    .col-date { display: none !important; }
    .col-category { display: none !important; }
    .col-user { order: 3; font-size: 11px !important; color: var(--text-muted) !important; width: auto !important; }

    .col-title {
        order: 1;
        width: 100% !important;
        font-weight: 600 !important;
        font-size: 14px !important;
        margin-bottom: 2px !important;
    }
    .col-title a { color: var(--text-primary) !important; text-decoration: none !important; }

    .col-amount {
        order: 2;
        font-weight: 700 !important;
        font-size: 16px !important;
        color: var(--accent-green) !important;
        width: auto !important;
    }

    .col-status {
        order: 4;
        margin-left: auto !important;
        width: auto !important;
    }

    .col-action {
        order: 5;
        width: 100% !important;
        margin-top: 10px !important;
    }

    .col-action .btn {
        width: 100% !important;
        text-align: center !important;
        justify-content: center !important;
    }
}
body {
    padding-bottom: 50px !important;
}