/* =====================================================
   Parts Search — Минималистичный дизайн в стиле 1С
   Серо-белая гамма, чистые линии, без иконок
   Мобильная адаптация от 320px
   ===================================================== */

/* ── Сброс ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Переменные ─────────────────────────────────────── */
:root {
    --c-white:      #ffffff;
    --c-bg:         #f4f5f7;
    --c-bg-2:       #eaecef;
    --c-panel:      #ffffff;
    --c-border:     #d0d3d9;
    --c-border-2:   #b8bcc4;
    --c-text:       #1f2328;
    --c-text-2:     #5a6070;
    --c-text-3:     #8a8f9d;
    --c-accent:     #1473b5;
    --c-accent-h:   #0f5a94;
    --c-accent-bg:  #e8f1f8;
    --c-success:    #2d7a2d;
    --c-success-bg: #e8f5e8;
    --c-warn:       #8a5a00;
    --c-warn-bg:    #fff8e0;
    --c-error:      #c0392b;
    --c-error-bg:   #fdf0ee;

    --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --font-mono:    'Consolas', 'Courier New', monospace;
    --radius:       3px;
    --radius-md:    4px;
    --shadow:       0 1px 3px rgba(0,0,0,0.12);
    --shadow-md:    0 2px 8px rgba(0,0,0,0.10);
}

/* ── База ───────────────────────────────────────────── */
html { font-size: 14px; }

body {
    font-family: var(--font);
    background:  var(--c-bg);
    color:       var(--c-text);
    line-height: 1.5;
    min-height:  100vh;
    display:     flex;
    flex-direction: column;
}

a { color: var(--c-accent); text-decoration: none; }
a:hover { text-decoration: underline; color: var(--c-accent-h); }

/* ── Контейнер ──────────────────────────────────────── */
.wrap { max-width: 1300px; margin: 0 auto; padding: 0 16px; }

/* ── Шапка в стиле 1С ───────────────────────────────── */
.topbar {
    background:   var(--c-accent);
    color:        #fff;
    border-bottom: 2px solid var(--c-accent-h);
}
.topbar-inner {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    height:      38px;
    gap:         16px;
}
.topbar-brand {
    font-size:   15px;
    font-weight: 700;
    color:       #fff;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.topbar-brand:hover { color: #fff; text-decoration: none; }

.topbar-nav {
    display:     flex;
    align-items: center;
    gap:         2px;
    flex:        1;
}
.topbar-nav a {
    color:       rgba(255,255,255,0.88);
    font-size:   13px;
    padding:     0 10px;
    height:      38px;
    display:     flex;
    align-items: center;
    border-right: 1px solid rgba(255,255,255,0.2);
    transition:  background 0.15s;
}
.topbar-nav a:hover {
    background: rgba(255,255,255,0.12);
    text-decoration: none;
    color: #fff;
}
.topbar-nav a.active {
    background: rgba(0,0,0,0.15);
    color: #fff;
    font-weight: 600;
}

.topbar-user {
    display:     flex;
    align-items: center;
    gap:         10px;
    font-size:   13px;
    white-space: nowrap;
}
.topbar-user span { color: rgba(255,255,255,0.9); }
.topbar-user a    { color: rgba(255,255,255,0.75); font-size: 12px; }
.topbar-user a:hover { color: #fff; text-decoration: underline; }

/* Мобильное меню */
.menu-toggle {
    display:     none;
    background:  transparent;
    border:      none;
    color:       #fff;
    font-size:   22px;
    cursor:      pointer;
    padding:     0 4px;
    line-height: 1;
}

/* ── Хлебные крошки / Подзаголовок ─────────────────── */
.subbar {
    background:   var(--c-panel);
    border-bottom: 1px solid var(--c-border);
    padding:      6px 0;
}
.subbar-inner {
    display:     flex;
    align-items: center;
    justify-content: space-between;
    gap:         12px;
    flex-wrap:   wrap;
}
.page-title {
    font-size:   15px;
    font-weight: 600;
    color:       var(--c-text);
}

/* ── Основной контент ───────────────────────────────── */
.main { flex: 1; padding: 16px 0; }

/* ── Подвал ─────────────────────────────────────────── */
.footer {
    background:   var(--c-panel);
    border-top:   1px solid var(--c-border);
    padding:      8px 0;
    font-size:    12px;
    color:        var(--c-text-3);
    text-align:   center;
}

/* ── Кнопки (1С стиль) ──────────────────────────────── */
.btn {
    display:       inline-block;
    padding:       5px 14px;
    font-size:     13px;
    font-family:   var(--font);
    border:        1px solid var(--c-border-2);
    border-radius: var(--radius);
    background:    linear-gradient(180deg, #f8f9fa 0%, #e9eaec 100%);
    color:         var(--c-text);
    cursor:        pointer;
    line-height:   1.5;
    white-space:   nowrap;
    user-select:   none;
    transition:    background 0.1s;
    text-decoration: none;
}
.btn:hover { background: linear-gradient(180deg, #eef0f2 0%, #dde0e3 100%); text-decoration: none; color: var(--c-text); }
.btn:active { background: #d8dce0; }

.btn-primary {
    background: linear-gradient(180deg, #1d86d5 0%, #1473b5 100%);
    border-color: #0f5a94;
    color: #fff;
}
.btn-primary:hover { background: linear-gradient(180deg, #1777c0 0%, #1060a0 100%); color: #fff; }

.btn-sm { padding: 3px 10px; font-size: 12px; }
.btn-danger { border-color: #c0392b; color: #c0392b; }
.btn-danger:hover { background: var(--c-error-bg); }

/* ── Формы ──────────────────────────────────────────── */
input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="email"],
select,
textarea {
    font-family:   var(--font);
    font-size:     13px;
    padding:       4px 8px;
    border:        1px solid var(--c-border-2);
    border-radius: var(--radius);
    background:    #fff;
    color:         var(--c-text);
    outline:       none;
    width:         100%;
    transition:    border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--c-accent);
    box-shadow:   0 0 0 2px rgba(20,115,181,0.15);
}
input::placeholder { color: var(--c-text-3); }

label {
    display:     block;
    font-size:   13px;
    color:       var(--c-text-2);
    margin-bottom: 3px;
}

.field { margin-bottom: 10px; }

.field-row {
    display:   flex;
    gap:       8px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.field-row .field { margin-bottom: 0; }

/* ── Панели / Карточки ──────────────────────────────── */
.panel {
    background:    var(--c-panel);
    border:        1px solid var(--c-border);
    border-radius: var(--radius-md);
    box-shadow:    var(--shadow);
}
.panel-head {
    padding:        8px 14px;
    border-bottom:  1px solid var(--c-border);
    background:     var(--c-bg);
    font-size:      13px;
    font-weight:    600;
    display:        flex;
    align-items:    center;
    justify-content: space-between;
    gap:            12px;
}
.panel-body { padding: 14px; }

/* ── Флеш-сообщения ─────────────────────────────────── */
.flash {
    padding:       8px 14px;
    margin-bottom: 12px;
    border:        1px solid;
    border-radius: var(--radius);
    font-size:     13px;
}
.flash-ok    { background: var(--c-success-bg); border-color: #a0d0a0; color: var(--c-success); }
.flash-error { background: var(--c-error-bg);   border-color: #e0a0a0; color: var(--c-error); }
.flash-warn  { background: var(--c-warn-bg);    border-color: #e0c060; color: var(--c-warn); }

/* ── Таблицы ────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table {
    width:           100%;
    border-collapse: collapse;
    font-size:       13px;
}
thead th {
    background:    var(--c-bg);
    border-bottom: 2px solid var(--c-border-2);
    padding:       6px 10px;
    text-align:    left;
    font-weight:   600;
    color:         var(--c-text-2);
    white-space:   nowrap;
}
thead th a {
    color:        var(--c-text-2);
    font-weight:  600;
    display:      inline-flex;
    align-items:  center;
    gap:          3px;
}
thead th a:hover { color: var(--c-accent); text-decoration: none; }
thead th a.sort-asc::after  { content: " ↑"; color: var(--c-accent); }
thead th a.sort-desc::after { content: " ↓"; color: var(--c-accent); }

tbody tr { border-bottom: 1px solid var(--c-border); }
tbody tr:hover { background: var(--c-accent-bg); }
tbody tr:last-child { border-bottom: none; }

td { padding: 6px 10px; vertical-align: middle; }

.td-name { max-width: 340px; word-break: break-word; }
.td-price { text-align: right; white-space: nowrap; width: 80px; }
.td-qty   { text-align: center; width: 80px; }
.td-src   { width: 120px; white-space: nowrap; }
.td-link  { text-align: center; width: 50px; }
.td-opt   { text-align: right; white-space: nowrap; width: 80px; color: var(--c-success); font-weight: 600; }

/* ── Бейджи магазинов ───────────────────────────────── */
/* Теги источников — единый стиль по ТЗ */
.shop-tag {
    display:        inline-block;
    padding:        2px 8px;
    border-radius:  4px;
    font-size:      11px;
    font-weight:    600;
    letter-spacing: 0.3px;
    border:         3px solid;
    white-space:    nowrap;
}

/* Liberty Project — красная обводка */
.src-liberti {
    color:            #000;
    background:       #fff;
    border-color:     #dc2626;
}

/* MEMS Technology — чёрная обводка */
.src-mems {
    color:            #000;
    background:       #fff;
    border-color:     #1a1a1a;
}

/* GreenSpark — зелёная обводка */
.src-gs {
    color:            #000;
    background:       #fff;
    border-color:     #16a34a;
}

/* Прочие источники */
.src-other {
    color:            #374151;
    background:       #fff;
    border-color:     #9ca3af;
}

/* Товары пользователей — фиолетовая обводка */
.src-user {
    color:            #000;
    background:       #fff;
    border-color:     #7c3aed;
}


/* ── Ссылка товара ──────────────────────────────────── */
.ext-link {
    font-size:   12px;
    padding:     2px 8px;
    border:      1px solid var(--c-border-2);
    border-radius: var(--radius);
    background:  var(--c-bg);
    color:       var(--c-accent);
    white-space: nowrap;
    cursor:      pointer;
    font-family: var(--font);
}
.ext-link:hover { background: var(--c-accent-bg); text-decoration: none; }

/* ── Пагинация ──────────────────────────────────────── */
.pager {
    display:     flex;
    align-items: center;
    gap:         3px;
    flex-wrap:   wrap;
    margin-top:  12px;
    font-size:   13px;
}
.pager a, .pager span {
    padding:      3px 9px;
    border:       1px solid var(--c-border-2);
    border-radius: var(--radius);
    background:   var(--c-panel);
    color:        var(--c-text);
    display:      inline-block;
}
.pager a:hover { background: var(--c-accent-bg); border-color: var(--c-accent); text-decoration: none; color: var(--c-accent); }
.pager .cur    { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }
.pager .dots   { border: none; background: none; color: var(--c-text-3); }

/* ── Сетка статистики ───────────────────────────────── */
.stat-grid {
    display:               grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap:                   12px;
    margin-bottom:         16px;
}
.stat-tile {
    background:    var(--c-panel);
    border:        1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding:       12px 16px;
    border-left:   3px solid var(--c-border-2);
}
.stat-tile--total   { border-left-color: var(--c-text-3); }

.stat-tile h4  { font-size: 12px; color: var(--c-text-2); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 4px; }
.stat-tile .n  { font-size: 24px; font-weight: 700; color: var(--c-text); line-height: 1; }
.stat-tile .sub { font-size: 11px; color: var(--c-text-3); margin-top: 3px; }

/* ── Рейтинг магазинов (столбцы) ───────────────────── */
.rating-list { display: flex; flex-direction: column; gap: 8px; }
.rating-item {
    display:     flex;
    align-items: center;
    gap:         10px;
    font-size:   13px;
}
.rating-label { width: 160px; flex-shrink: 0; font-weight: 600; }
.rating-bar-wrap {
    flex:          1;
    background:    var(--c-bg-2);
    border:        1px solid var(--c-border);
    border-radius: var(--radius);
    height:        18px;
    overflow:      hidden;
}
.rating-bar {
    height:     100%;
    background: var(--c-accent);
    border-radius: var(--radius);
    transition: width 0.4s ease;
}
.src-bar-src-liberti { background: #dc2626; }
.src-bar-src-mems    { background: #1a1a1a; }
.src-bar-src-gs      { background: #16a34a; }
.src-bar-src-other   { background: #9ca3af; }
.rating-val { width: 50px; text-align: right; color: var(--c-text-2); }

/* ── Поисковая форма ────────────────────────────────── */
.search-wrap {
    background:    var(--c-panel);
    border:        1px solid var(--c-border);
    border-radius: var(--radius-md);
    padding:       12px 14px;
    margin-bottom: 12px;
    box-shadow:    var(--shadow);
}
.search-main-row {
    display:   flex;
    gap:       8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.search-input {
    flex:    1;
    min-width: 200px;
    font-size: 14px;
    padding:   6px 10px;
}
.search-filters {
    display:   flex;
    gap:       10px;
    flex-wrap: wrap;
    align-items: flex-end;
    border-top: 1px solid var(--c-border);
    padding-top: 8px;
}
.filter-field { display: flex; flex-direction: column; gap: 2px; min-width: 100px; }
.filter-field label { font-size: 11px; color: var(--c-text-3); font-weight: 600; text-transform: uppercase; }

.sort-select { min-width: 180px; }

.search-info {
    font-size:   12px;
    color:       var(--c-text-3);
    margin-top:  6px;
}
.search-info .syn { color: var(--c-accent); }

/* ── Результаты ─────────────────────────────────────── */
.results-header {
    display:     flex;
    align-items: baseline;
    justify-content: space-between;
    gap:         12px;
    margin-bottom: 8px;
    flex-wrap:   wrap;
}
.results-count { font-size: 13px; color: var(--c-text-2); }
.results-count strong { color: var(--c-text); }

/* ── Логин ──────────────────────────────────────────── */
.login-page {
    min-height:  100vh;
    display:     flex;
    align-items: center;
    justify-content: center;
    background:  var(--c-bg-2);
}
.login-box {
    background:    var(--c-panel);
    border:        1px solid var(--c-border-2);
    border-radius: var(--radius-md);
    padding:       30px 32px;
    width:         100%;
    max-width:     360px;
    box-shadow:    var(--shadow-md);
}
.login-title {
    text-align:  center;
    font-size:   18px;
    font-weight: 700;
    color:       var(--c-accent);
    margin-bottom: 6px;
}
.login-sub {
    text-align:  center;
    font-size:   12px;
    color:       var(--c-text-3);
    margin-bottom: 20px;
}
.login-form { display: flex; flex-direction: column; gap: 10px; }

/* ── Страница ошибки ────────────────────────────────── */
.error-page {
    text-align: center; padding: 60px 20px;
}
.error-code  { font-size: 64px; font-weight: 700; color: var(--c-border-2); }
.error-msg   { font-size: 16px; color: var(--c-text-2); margin: 12px 0 20px; }

/* ── Таблица пользователей (Admin) ──────────────────── */
.role-tag {
    display:    inline-block; padding: 1px 7px;
    border:     1px solid; border-radius: var(--radius);
    font-size:  11px; font-weight: 600; text-transform: uppercase;
}
.role-tag--admin    { color: #8a3a00; border-color: #e0c0a0; background: #fff8f0; }
.role-tag--user     { color: var(--c-text-2); border-color: var(--c-border); background: var(--c-bg); }

.active-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-success); }
.inactive-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-border-2); }

/* ── Импорт ─────────────────────────────────────────── */
.upload-area {
    border:      2px dashed var(--c-border-2);
    border-radius: var(--radius-md);
    padding:     20px;
    text-align:  center;
    color:       var(--c-text-2);
    font-size:   13px;
    cursor:      pointer;
    transition:  border-color 0.2s;
}
.upload-area:hover { border-color: var(--c-accent); }
.upload-area input { display: none; }

/* Статус-значок импорта */
.status-ok  { color: var(--c-success); font-weight: 600; }
.status-err { color: var(--c-error);   font-weight: 600; }

/* ── Мобильная адаптация ────────────────────────────── */
@media (max-width: 768px) {
    html { font-size: 14px; }

    .topbar-nav { display: none; }
    .topbar-nav.open {
        display:        flex;
        flex-direction: column;
        position:       fixed;
        top:            50%;
        left:           50%;
        transform:      translate(-50%, -50%);
        background:     var(--c-accent);
        z-index:        200;
        border-radius:  8px;
        box-shadow:     0 8px 32px rgba(0,0,0,0.3);
        min-width:      220px;
        padding:        8px 0;
        overflow:       hidden;
    }
    .topbar-nav.open a {
        height:      auto;
        padding:     14px 20px;
        border-right: none;
        border-bottom: 1px solid rgba(255,255,255,0.12);
        font-size:   15px;
        font-weight: 500;
        color:       #fff;
        text-align:  center;
        white-space: nowrap;
        overflow:    hidden;
        text-overflow: ellipsis;
    }
    .topbar-nav.open a:last-child { border-bottom: none; }
    .topbar-nav.open a.active     { background: rgba(0,0,0,0.2); }

    /* Затемнение фона */
    .menu-overlay {
        display:    block;
        position:   fixed;
        inset:      0;
        background: rgba(0,0,0,0.4);
        z-index:    199;
    }

    .menu-toggle { display: block; }
    .topbar-inner { position: relative; }

    /* На мобильном таблица → горизонтальная прокрутка */
    .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    table { min-width: 600px; }

    /* На очень маленьких — карточки вместо таблицы */
    .search-main-row { flex-direction: column; }
    .search-input { min-width: 100%; }
    .search-filters { flex-direction: column; }
    .filter-field { min-width: 100%; }

    .stat-grid { grid-template-columns: 1fr 1fr; }

    .field-row { flex-direction: column; }

    /* Увеличенные зоны касания */
    .btn { padding: 8px 16px; font-size: 14px; min-height: 36px; }
    input[type="text"], input[type="password"],
    input[type="number"], select { padding: 8px 10px; font-size: 14px; min-height: 36px; }
    td { padding: 8px 10px; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr; }
    .login-box { padding: 20px 16px; }
    .panel-body { padding: 10px; }
    .results-header { flex-direction: column; gap: 6px; }

    /* Карточки вместо таблицы на 480px */
    .as-cards table, .as-cards thead, .as-cards tbody,
    .as-cards th, .as-cards td, .as-cards tr { display: block; }
    .as-cards thead { display: none; }
    .as-cards tbody tr {
        background:    var(--c-panel);
        border:        1px solid var(--c-border);
        border-radius: var(--radius-md);
        margin-bottom: 8px;
        padding:       8px 10px;
    }
    .as-cards td {
        padding:   4px 0;
        border:    none;
        max-width: 100%;
    }
    .as-cards td::before {
        content:     attr(data-label) ": ";
        font-weight: 600;
        color:       var(--c-text-2);
        font-size:   11px;
        text-transform: uppercase;
    }
    .as-cards .td-name { font-size: 13px; font-weight: 500; }
}

@media (max-width: 320px) {
    .wrap { padding: 0 10px; }
    .topbar-brand { font-size: 13px; }
}

/* ══════════════════════════════════════════════════════
   МОБИЛЬНЫЙ ПОИСК — Вариант 3
   Чёткий текст, крупные зоны касания, минимум UI
   ══════════════════════════════════════════════════════ */

/* ── Строка поиска ──────────────────────────────────── */
.search-bar {
    display:     flex;
    gap:         8px;
    align-items: stretch;
    margin-bottom: 8px;
}

.search-input {
    flex:         1;
    min-width:    0;    /* не вылезает за контейнер */
    font-size:    16px; /* ≥16px — iOS не зумит при фокусе */
    padding:      10px 14px;
    border:       1px solid var(--c-border-2);
    border-radius: var(--radius);
    background:   var(--c-panel);
    color:        var(--c-text);
    outline:      none;
    transition:   border-color .15s;
    -webkit-appearance: none;
}
.search-input:focus {
    border-color: var(--c-accent);
    box-shadow:   0 0 0 2px rgba(20,115,181,.15);
}
.search-input::placeholder { color: var(--c-text-3); }

.search-btn {
    flex-shrink: 0;
    background:  var(--c-accent);
    color:       #fff;
    border:      none;
    border-radius: var(--radius);
    padding:     10px 18px;
    font-size:   15px;
    font-weight: 600;
    cursor:      pointer;
    white-space: nowrap;
    min-width:   70px;
    transition:  background .15s;
}
.search-btn:active { background: var(--c-accent-h); }

.search-reset {
    display:      flex;
    align-items:  center;
    justify-content: center;
    width:        38px;
    height:       auto;
    flex-shrink:  0;
    background:   var(--c-bg);
    border:       1px solid var(--c-border);
    border-radius: var(--radius);
    color:        var(--c-text-3);
    font-size:    20px;
    text-decoration: none;
    transition:   all .15s;
}
.search-reset:hover { color: var(--c-error); border-color: var(--c-error); text-decoration: none; }

/* ── Подсказка синонимов ─────────────────────────────── */
.search-hint {
    font-size:     12px;
    color:         var(--c-text-3);
    margin-bottom: 8px;
    line-height:   1.4;
}
.search-hint-syn { color: var(--c-accent); }

/* ── Горизонтальные чипы сортировки ─────────────────── */
.chips-row {
    display:          flex;
    gap:              6px;
    overflow-x:       auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width:  none;
    padding-bottom:   2px;
    margin-bottom:    10px;
}
.chips-row::-webkit-scrollbar { display: none; }

.chip {
    flex-shrink:   0;
    display:       inline-flex;
    align-items:   center;
    padding:       5px 12px;
    border:        1px solid var(--c-border-2);
    border-radius: 20px;
    font-size:     13px;
    font-weight:   500;
    color:         var(--c-text-2);
    background:    var(--c-panel);
    cursor:        pointer;
    white-space:   nowrap;
    user-select:   none;
    transition:    all .15s;
    line-height:   1.4;
}
.chip:hover       { border-color: var(--c-accent); color: var(--c-accent); }
.chip-active,
.chip.chip-active { background: var(--c-accent); border-color: var(--c-accent); color: #fff; }

/* ── Панель фильтров ─────────────────────────────────── */
.filters-bar {
    display:     flex;
    gap:         10px;
    flex-wrap:   wrap;
    align-items: flex-end;
    margin-bottom: 10px;
}
.filter-group-inline { display: flex; flex-direction: column; gap: 3px; }
.filter-label { font-size: 11px; color: var(--c-text-3); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.filter-select,
.filter-input  { font-size: 13px; padding: 6px 8px; }
.filter-input  { width: 90px; }

/* Кнопка фильтров — только на мобильном */
.filters-toggle {
    display:   none;
    position:  relative;
    background: var(--c-panel);
    border:    1px solid var(--c-border-2);
    border-radius: var(--radius);
    padding:   6px 14px;
    font-size: 13px;
    color:     var(--c-text-2);
    cursor:    pointer;
    margin-bottom: 10px;
}
.filter-dot {
    display:       inline-block;
    width:         7px; height: 7px;
    background:    var(--c-accent);
    border-radius: 50%;
    margin-left:   5px;
    vertical-align: middle;
}

/* ── Заголовок результатов ───────────────────────────── */
.results-meta {
    display:       flex;
    align-items:   baseline;
    justify-content: space-between;
    gap:           12px;
    margin-bottom: 8px;
    flex-wrap:     wrap;
}
.results-count { font-size: 13px; color: var(--c-text-2); }
.results-count strong { color: var(--c-text); font-weight: 600; }
.results-pages { font-size: 12px; color: var(--c-text-3); white-space: nowrap; }

/* ── Пустой результат ────────────────────────────────── */
.search-empty {
    padding:    32px 16px;
    text-align: center;
    color:      var(--c-text-2);
    font-size:  15px;
}
.search-empty strong { color: var(--c-text); }
.search-empty-hint   { font-size: 13px; color: var(--c-text-3); margin-top: 8px; }

/* ── Мобильный 768px ─────────────────────────────────── */
@media (max-width: 768px) {

    /* Фильтры скрыты по умолчанию */
    .filters-bar         { display: none; }
    .filters-bar--open   { display: flex; flex-direction: column; }
    .filters-toggle      { display: inline-flex; align-items: center; }

    .filter-group-inline { flex-direction: row; align-items: center; gap: 8px; width: 100%; }
    .filter-label        { flex-shrink: 0; width: 64px; }
    .filter-select,
    .filter-input        { flex: 1; }

    /* Таблица → карточки */
    .as-cards table,
    .as-cards thead,
    .as-cards tbody,
    .as-cards th,
    .as-cards td,
    .as-cards tr { display: block; }

    .as-cards thead { display: none; }

    .as-cards tbody tr {
        background:    var(--c-panel);
        border:        1px solid var(--c-border);
        border-radius: var(--radius-md);
        margin-bottom: 10px;
        padding:       10px 12px;
        position:      relative;
    }

    /* Название — крупно и чётко */
    .as-cards .td-name {
        font-size:   15px;
        font-weight: 600;
        color:       var(--c-text);
        line-height: 1.4;
        margin-bottom: 6px;
        padding:     0;
    }
    .as-cards .td-name::before { display: none; }

    /* Магазин — бейдж вверху */
    .as-cards .td-src {
        margin-bottom: 6px;
        padding:       0;
        border:        none;
    }
    .as-cards .td-src::before { display: none; }

    /* Цена и наличие — в одну строку, опт всегда виден */
    .as-cards .td-price,
    .as-cards .td-opt,
    .as-cards .td-qty {
        display:     inline-block;
        padding:     0;
        border:      none;
        font-size:   14px;
        font-weight: 600;
        color:       var(--c-text);
    }
    .as-cards .td-price::before {
        content:        "Розн: ";
        font-size:      11px;
        font-weight:    400;
        color:          var(--c-text-2);
        text-transform: uppercase;
    }
    .as-cards .td-opt {
        color: var(--c-success);
    }
    .as-cards .td-opt::before {
        content:        "  Опт: ";
        font-size:      11px;
        font-weight:    400;
        color:          var(--c-text-2);
        text-transform: uppercase;
    }
    .as-cards .td-qty::before {
        content:     "  ";
        font-size:   11px;
        font-weight: 400;
        color:       var(--c-text-2);
    }



    /* Кнопка ссылки — внизу карточки */
    .as-cards .td-link {
        display:       block;
        padding:       8px 0 0;
        border:        none;
        border-top:    1px solid var(--c-border);
        margin-top:    8px;
    }
    .as-cards .td-link::before { display: none; }
    .as-cards .ext-link {
        width:       100%;
        text-align:  center;
        padding:     8px;
        font-size:   14px;
        display:     block;
        min-height:  40px;
        line-height: 24px;
    }

    /* Пагинация — крупные кнопки */
    .pager a, .pager span {
        padding:   8px 12px;
        font-size: 15px;
        min-height: 40px;
        display:   inline-flex;
        align-items: center;
    }
}

/* ── Мобильный 480px ─────────────────────────────────── */
@media (max-width: 480px) {
    .search-input { font-size: 16px; }
    .search-btn   { padding: 10px 14px; font-size: 14px; }

    .as-cards .td-name { font-size: 14px; }
    .as-cards .td-price,
    .as-cards .td-qty   { font-size: 13px; }
}

/* ── Чипы магазинов (мульти-выбор) ─────────────────── */
.store-chips {
    display:   flex;
    gap:       6px;
    flex-wrap: wrap;
}
.store-chip {
    display:       inline-flex;
    align-items:   center;
    padding:       5px 12px;
    border:        1px solid var(--c-border-2);
    border-radius: 20px;
    font-size:     13px;
    font-weight:   500;
    color:         var(--c-text-2);
    background:    var(--c-panel);
    cursor:        pointer;
    white-space:   nowrap;
    user-select:   none;
    transition:    all .15s;
    line-height:   1.4;
}
.store-chip:hover { border-color: var(--c-accent); color: var(--c-accent); }
.store-chip--on   { box-shadow: 0 0 0 2px currentColor; }
.store-chip--on .shop-tag { font-weight: 800; }

@media (max-width: 768px) {
    .store-chips { gap: 5px; }
    .store-chip  { padding: 7px 14px; font-size: 14px; min-height: 36px; }
}

/* ─── Колонка Фото ─────────────────────────────────────────── */
.td-photo { width: 48px; text-align: center; }

.photo-trigger {
    display: inline-block;
    cursor: default;
    color: var(--c-accent, #3b82f6);
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid color-mix(in srgb, var(--c-accent,#3b82f6) 30%, transparent);
    background: color-mix(in srgb, var(--c-accent,#3b82f6) 8%, transparent);
    user-select: none;
}

.photo-link {
    color: var(--c-accent, #3b82f6);
    font-size: .72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid color-mix(in srgb, var(--c-accent,#3b82f6) 30%, transparent);
    background: color-mix(in srgb, var(--c-accent,#3b82f6) 8%, transparent);
    text-decoration: none;
    white-space: nowrap;
}
.photo-link:hover {
    background: color-mix(in srgb, var(--c-accent,#3b82f6) 18%, transparent);
}

.photo-none { color: var(--c-text-3, #94a3b8); font-size: .82rem; }

@media (max-width: 640px) { .td-photo { display: none; } }

/* ═══════════════════════════════════════════════════════════════
   МОБИЛЬНАЯ ВЕРСИЯ — Parts Search
   Breakpoints: ≤640px = mobile, ≤960px = tablet
   ═══════════════════════════════════════════════════════════════ */

/* ── Bottom Navigation Bar (только мобильный) ───────────────── */
.bottom-nav {
    display: none;
}

@media (max-width: 640px) {

    /* Место для bottom-nav */
    body { padding-bottom: 64px; }

    .bottom-nav {
        display:         flex;
        position:        fixed;
        bottom:          0;
        left:            0;
        right:           0;
        z-index:         1000;
        background:      var(--c-panel);
        border-top:      1px solid var(--c-border);
        box-shadow:      0 -2px 12px rgba(0,0,0,.08);
        height:          60px;
        padding:         0;
        padding-bottom:  env(safe-area-inset-bottom, 0);
    }

    .bottom-nav a, .bottom-nav button {
        flex:            1;
        display:         flex;
        flex-direction:  column;
        align-items:     center;
        justify-content: center;
        gap:             2px;
        font-size:       10px;
        color:           var(--c-text-2);
        text-decoration: none;
        border:          none;
        background:      none;
        cursor:          pointer;
        padding:         6px 4px;
        transition:      color .15s;
        -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav a svg, .bottom-nav button svg {
        width: 22px; height: 22px;
    }
    .bottom-nav a.active, .bottom-nav a:hover,
    .bottom-nav button.active {
        color: var(--c-accent);
    }
    .bottom-nav a.active svg { stroke: var(--c-accent); }

    /* Скрываем обычный хедер-nav на мобиле */
    .topbar-nav { display: none !important; }
    .topbar-user { display: none !important; }
    .menu-toggle { display: none !important; }

    /* Хедер — только бренд */
    .topbar { height: 48px; }
    .topbar-inner {
        height: 48px;
        justify-content: center;
    }
    .topbar-brand { font-size: 16px; }

    /* ── Главная страница ───────────────────────────────────── */
    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        margin-top: 8px;
    }
    .stat-tile { padding: 12px; }
    .stat-tile .n { font-size: 22px; }
    .stat-tile h4 { font-size: 10px; }

    /* ── Поиск ──────────────────────────────────────────────── */
    .search-bar {
        position: sticky;
        top: 48px;
        z-index: 90;
        background: var(--c-bg);
        padding: 8px 0 4px;
        margin: 0 -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
    .search-input {
        font-size: 16px !important; /* предотвращает зум на iOS */
        height: 44px;
    }
    .search-btn {
        height: 44px;
        min-width: 70px;
    }
    .search-reset {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    /* Чипы сортировки */
    .chips-row {
        gap: 6px;
        padding: 4px 0;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    .chip {
        white-space: nowrap;
        min-height: 34px;
        padding: 6px 14px;
        font-size: 13px;
    }

    /* ── Фильтры — drawer снизу ─────────────────────────────── */
    .filters-toggle {
        display: flex;
        align-items: center;
        gap: 6px;
        min-height: 38px;
        font-size: 14px;
        padding: 6px 16px;
    }

    .filters-bar {
        /* На мобиле превращается в drawer снизу */
        position:   fixed;
        bottom:     60px;   /* над bottom-nav */
        left:       0;
        right:      0;
        z-index:    500;
        background: var(--c-panel);
        border-top: 2px solid var(--c-accent);
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,.15);
        padding:    16px 16px 20px;
        flex-direction: column !important;
        gap:        12px;
        max-height: 70vh;
        overflow-y: auto;

        /* Скрыт по умолчанию */
        transform: translateY(110%);
        transition: transform .25s cubic-bezier(.4,0,.2,1);
    }
    .filters-bar.filters-bar--open {
        transform: translateY(0);
        display: flex !important;
    }

    .filter-group-inline {
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100%;
    }
    .filter-input {
        width: 100% !important;
        height: 40px;
        font-size: 15px;
    }
    .filters-bar .btn { width: 100%; height: 44px; font-size: 15px; }

    /* ── Таблица результатов → карточки ─────────────────────── */
    .tbl-wrap table,
    .tbl-wrap thead,
    .tbl-wrap tbody,
    .tbl-wrap th,
    .tbl-wrap tfoot { display: block; }

    .tbl-wrap thead { display: none; } /* скрываем заголовок */

    .tbl-wrap tr {
        display:       block;
        background:    var(--c-panel);
        border:        1px solid var(--c-border);
        border-radius: 10px;
        margin-bottom: 10px;
        padding:       10px 12px 12px;
        box-shadow:    0 1px 4px rgba(0,0,0,.05);
        overflow:      hidden;
    }

    /* Скрываем все td по умолчанию, показываем по data-label */
    .tbl-wrap td { display: none; }

    /* Источник — бейдж вверху */
    .tbl-wrap td.td-src {
        display: block;
        padding: 0 0 6px;
        border-bottom: 1px solid var(--c-bg-2);
        margin-bottom: 8px;
    }

    /* Наименование — крупно */
    .tbl-wrap td.td-name {
        display:     block;
        font-size:   14px;
        font-weight: 600;
        color:       var(--c-text);
        line-height: 1.35;
        padding:     0 0 8px;
    }

    /* Строка цен */
    .tbl-wrap td.td-price,
    .tbl-wrap td.td-opt {
        display:      inline-block;
        font-size:    14px;
        padding:      0;
    }
    .tbl-wrap td.td-price::before { content: "Розн: "; font-size:11px; color:var(--c-text-2); }
    .tbl-wrap td.td-opt::before   { content: " / Опт: "; font-size:11px; color:var(--c-text-2); }

    /* Наличие */
    .tbl-wrap td.td-qty {
        display:    block;
        font-size:  12px;
        color:      var(--c-text-2);
        padding:    4px 0 0;
    }
    .tbl-wrap td.td-qty::before { content: "В наличии: "; }

    /* Ссылка — кнопка на всю ширину */
    .tbl-wrap td.td-link {
        display:    block;
        margin-top: 10px;
    }
    .tbl-wrap td.td-link .ext-link,
    .tbl-wrap td.td-link a.btn {
        display:    block;
        width:      100%;
        height:     40px;
        font-size:  14px;
        text-align: center;
        line-height: 40px;
        padding:    0;
    }

    /* Фото в карточке */
    .tbl-wrap td.td-photo {
        display:    inline-block;
        float:      right;
        margin-top: -28px; /* поднимаем к правому краю цены */
        padding:    0;
    }

    /* ── Пагинация ──────────────────────────────────────────── */
    .pager { gap: 4px; }
    .pager a, .pager span { min-width: 36px; height: 36px; font-size: 13px; }

    /* ── Результаты мета ────────────────────────────────────── */
    .results-meta {
        font-size: 12px;
        flex-wrap: wrap;
        gap: 2px;
    }

    /* ── Панели администратора ──────────────────────────────── */
    .panel-body { padding: 12px; }

    /* Admin таблицы — упрощённый вид */
    .tbl-wrap.admin-table tr {
        border-radius: 6px;
        margin-bottom: 6px;
        padding: 8px 10px;
    }

    /* ── Overlay для filters drawer ─────────────────────────── */
    .filters-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 499;
    }
    .filters-overlay.active { display: block; }
}

/* ── Планшет (641–960) ───────────────────────────────────────── */
@media (min-width: 641px) and (max-width: 960px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .tbl-wrap td.td-photo { display: none; }

    .tbl-wrap thead th:nth-child(6) { display: none; } /* скрыть Фото */
    .tbl-wrap td.td-qty { max-width: 70px; font-size: 12px; }
}

/* ── Touch targets — только padding, без fixed height ─────── */
@media (max-width: 960px) {
    .btn:not(.btn-sm), button:not(.btn-sm) {
        padding-top: 9px;
        padding-bottom: 9px;
    }
    input[type="text"],
    input[type="number"],
    input[type="password"],
    select { min-height: 38px; }
}
