/* ===== МОБИЛЬНАЯ АДАПТАЦИЯ (максимум 768px) ===== */
@media (max-width: 768px) {
    /* Запрещаем всей странице горизонтальную прокрутку */
    html, body {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-container {
        max-width: 100%;
        padding: 0.5rem;
    }

    button, .btn, select, input, textarea {
        min-height: 38px;
        font-size: 14px;
    }

    /* ----- ШАПКА ----- */
    .header { padding: 0 0.5rem; }
    .header-inner {
    max-width: 100%;
    margin: 0;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;      /* поднимаем кнопку и дату наверх */
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.4rem 0;
}
.header-logo {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.8rem;
    white-space: normal;          /* разрешаем перенос */
    flex: 1 1 auto;
    line-height: 1.2;
    max-width: 200px;             /* ограничиваем ширину, чтобы текст разбился */
}
.header-logo .icon {
    width: 28px;
    height: 28px;
    font-size: 1rem;
    flex-shrink: 0;
}
.header-date {
    font-size: 0.65rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.header-auth {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    flex-shrink: 0;
}
#btnLoginLogout {
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    flex-shrink: 0;
}

    /* ----- СТАТИСТИКА ----- */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
    .stat-card { padding: 0.5rem 0.7rem; }
    .stat-card .stat-value { font-size: 1.1rem; }
    .stat-card .stat-icon { font-size: 1.1rem; right: 0.3rem; top: 0.3rem; }
    .stat-card .stat-label { font-size: 0.65rem; }
    .stat-card .stat-sub { font-size: 0.6rem; }

    /* ----- ТУЛБАР ----- */
    .toolbar { flex-direction: column; align-items: stretch; gap: 0.4rem; }
    .search-wrapper, .filter-select { width: 100%; }

    /* ----- ТАБЛИЦЫ (общие) ----- */
    .table-wrapper {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
    .table-wrapper table {
        min-width: 850px;
        width: max-content;
        font-size: 0.75rem;
    }
    thead th, tbody td {
        padding: 0.4rem 0.3rem;
        white-space: nowrap;
    }
    thead th { font-size: 0.65rem; }
    tbody td { font-size: 0.7rem; }
    .type-badge { font-size: 0.65rem; }
    .qty-badge { font-size: 0.7rem; }

    /* ----- МОДАЛЬНЫЕ ОКНА ----- */
    .modal { max-width: 95vw; margin: 0.5rem; padding: 1rem; }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }

    /* ----- ФИЛЬТРЫ (админ‑панель) ----- */
    .filters { flex-direction: column; gap: 0.5rem; }
    .filters select,
    .filters input,
    .filters button {
        width: 100%;
        font-size: 15px;
        padding: 0.6rem;
    }
   
    #inventoryTable {
    min-width: auto;           /* отменяем принудительные 850px */
    width: auto;
    font-size: 0.75rem;
}

    #requestsTable {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
#requestsTable table {
    min-width: 800px;
    font-size: 0.8rem;
}
    #inventoryTable th:nth-child(3),
#inventoryTable td:nth-child(3) {
    max-width: 140px;
    word-wrap: break-word;
    white-space: normal;
    overflow-wrap: break-word;
}
#inventoryTable th:nth-child(4),
#inventoryTable td:nth-child(4) {
    max-width: 110px;
    white-space: normal;
    word-wrap: break-word;
}
#inventoryTable th:nth-child(5),
#inventoryTable td:nth-child(5) {
    max-width: 100px;
    white-space: normal;
    word-wrap: break-word;
}

/* ===== ДОПОЛНИТЕЛЬНО ДЛЯ ОЧЕНЬ УЗКИХ ЭКРАНОВ (480px) ===== */
@media (max-width: 480px) {
    .header-logo { font-size: 0.7rem; }
    .header-date { display: none; }
    .table-wrapper table, #requestsTable table {
        min-width: 800px;
        font-size: 0.7rem;
    }
    thead th { font-size: 0.6rem; }
    tbody td { font-size: 0.65rem; }

 #inventoryTable {
        font-size: 0.65rem;
    }
}

@media (min-width: 769px) {
    #statsAccordion {
        display: none;
    }
}
