:root {
    --navy: #12335e;
    --navy-dark: #0c2444;
    --orange: #f28c1e;
    --orange-dark: #d97a10;
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #22303f;
    --muted: #6b7a8c;
    --border: #dde3ea;
    --danger: #c0392b;
    --success: #1e8449;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

a { color: var(--navy); }

.container {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 16px;
}

/* Шапка */
.site-header {
    background: var(--card);
    border-bottom: 3px solid var(--orange);
}

.header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    flex-wrap: wrap;
}

.logo img { display: block; height: 52px; }

.header-contacts { text-align: right; font-size: 14px; color: var(--muted); }
.header-contacts .phone { font-size: 17px; font-weight: bold; color: var(--navy); display: block; }

.header-actions { display: flex; align-items: center; gap: 14px; }

.btn {
    display: inline-block;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}
.btn:hover { background: var(--navy-dark); }
.btn-orange { background: var(--orange); }
.btn-orange:hover { background: var(--orange-dark); }
.btn-outline { background: transparent; color: var(--navy); border: 1px solid var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

.cart-link { position: relative; font-weight: bold; text-decoration: none; }
.cart-badge {
    background: var(--orange);
    color: #fff;
    border-radius: 10px;
    font-size: 12px;
    padding: 1px 7px;
    margin-left: 4px;
}

/* Меню */
.main-nav { background: var(--navy); }
.main-nav ul {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}
.main-nav a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 11px 15px;
    color: #e8eef7;
    text-decoration: none;
    font-size: 14px;
}
.main-nav a:hover, .main-nav a.active { background: var(--navy-dark); color: var(--orange); }
.nav-badge {
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--orange);
    color: #fff;
    font-size: 12px;
    line-height: 18px;
    text-align: center;
}

/* Контент */
main { padding: 24px 0 40px; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
}

h1 { color: var(--navy); font-size: 26px; margin-top: 0; }
h2 { color: var(--navy); font-size: 20px; }

.flash {
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #e7f6ec; color: var(--success); border: 1px solid #bfe6cc; }
.flash-error { background: #fbeae7; color: var(--danger); border: 1px solid #f0c3bc; }
.flash-info { background: #eaf1fb; color: var(--navy); border: 1px solid #c9daf0; }

/* Таблица каталога */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    font-size: 14px;
}
.table th, .table td {
    border: 1px solid var(--border);
    padding: 8px 10px;
    text-align: left;
    vertical-align: middle;
}
.table th { background: var(--navy); color: #fff; font-weight: 600; }
/* Сортируемые заголовки — ссылки; в тёмной шапке они должны быть белыми, не navy */
.table th a { color: #fff; text-decoration: none; }
.table th a:hover { color: var(--orange); text-decoration: underline; }
.table tr:nth-child(even) { background: #f8fafc; }
.table img.part-photo { width: 48px; height: 48px; object-fit: contain; display: block; }
.table-actions-cell {
    width: 200px;
}
/* Действия по поставщику — одной колонкой, кнопки одной ширины */
.table-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    width: 200px;
}
.table-actions > a.btn,
.table-actions > form {
    display: flex;
    flex-direction: column;
    margin: 0;
    width: 100%;
    text-align: center;
}
.table-actions .btn {
    white-space: nowrap;
    width: 100%;
}
/* Загрузка прайса из файла: выбор файла и отправка — единый связанный блок */
.import-file-native {
    /* Скрываем нативный «Choose File», диалог открывается по <label> «Выбрать прайс» */
    display: none;
}
.import-group {
    display: flex;
    flex-direction: column;
    width: 100%;
    border: 1px solid var(--navy);
    border-radius: 4px;
    overflow: hidden;
}
.import-choose,
.import-submit {
    display: block;
    width: 100%;
    padding: 5px 10px;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    border: none;
    box-sizing: border-box;
}
.import-choose {
    background: #fff;
    color: var(--navy);
    border-bottom: 1px solid var(--navy);
}
.import-choose:hover { background: #eef2f7; }
.import-submit {
    background: var(--navy);
    color: #fff;
}
.import-submit:hover { background: var(--navy-dark); }
.price { white-space: nowrap; font-weight: bold; color: var(--navy); }
.stock-ok { color: var(--success); }
.stock-low { color: var(--orange-dark); }

.qty-input { width: 64px; padding: 5px; border: 1px solid var(--border); border-radius: 4px; }

/* Строка «в корзину»: количество слева, кнопка-иконка справа */
.cart-add-form {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
    margin: 0;
}
.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 9px;
}
.btn-icon svg { display: block; }

/* Модальное окно (отчёт об импорте прайса и т.п.) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 51, 94, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}
.modal {
    background: var(--card);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
    max-width: 460px;
    width: 100%;
    padding: 24px 26px;
}
.modal h2 { margin: 0 0 14px; color: var(--navy); font-size: 20px; }
.modal .modal-file { color: var(--muted); font-size: 14px; margin-bottom: 16px; word-break: break-all; }
.modal .modal-stats { display: flex; gap: 12px; margin-bottom: 20px; }
.modal .stat {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    text-align: center;
}
.modal .stat .num { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.modal .stat .label { font-size: 12px; color: var(--muted); }
.modal .stat.ok .num { color: var(--success); }
.modal .stat.err .num { color: var(--orange-dark); }
.modal .modal-actions { text-align: right; }

/* Поиск и фильтры */
.search-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.search-bar input[type="text"], .search-bar select, .search-bar input[type="date"] {
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background: var(--card);
    color: inherit;
    height: 38px;
}
.search-bar input[type="text"] { flex: 1; min-width: 220px; }
.search-bar select { cursor: pointer; }
.search-bar input[type="text"]:focus, .search-bar select:focus,
.search-bar input[type="date"]:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px rgba(240, 140, 0, 0.15);
}
/* Диапазон дат: подпись «с»/«по» и поле как единый блок */
.date-field {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--muted);
    white-space: nowrap;
}
.date-field input[type="date"] { color-scheme: light; }

/* Пагинация */
.pagination { display: flex; gap: 6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    background: var(--card);
    font-size: 14px;
}
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .gap { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 4px; }

/* Формы */
.form-narrow { max-width: 520px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 14px; margin-bottom: 4px; color: var(--muted); }
.form-group input[type="text"], .form-group input[type="email"],
.form-group input[type="password"], .form-group input[type="tel"],
.form-group select, .form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
}
.form-check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin-bottom: 10px; }
.form-check input { margin-top: 3px; }
.field-error { color: var(--danger); font-size: 13px; margin-top: 3px; }

/* Главная: реклама и новости */
.home-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
@media (max-width: 800px) { .home-grid { grid-template-columns: 1fr; } }
.ad-placeholder {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 34px 20px;
    text-align: center;
    color: var(--muted);
    background: repeating-linear-gradient(45deg, #fafbfc, #fafbfc 12px, #f2f4f7 12px, #f2f4f7 24px);
}
.news-item { border-bottom: 1px solid var(--border); padding: 10px 0; font-size: 14px; }
.news-item:last-child { border-bottom: none; }
.news-date { color: var(--muted); font-size: 12px; }

.hero {
    background: linear-gradient(120deg, var(--navy), var(--navy-dark));
    color: #e8eef7;
    border-radius: 6px;
    padding: 36px 28px;
    margin-bottom: 20px;
}
.hero h1 { color: #fff; }
.hero .accent { color: var(--orange); }

/* Бренды */
.brand-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.brand-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    text-decoration: none;
    display: flex;
    justify-content: space-between;
}
.brand-card:hover { border-color: var(--orange); }
.brand-count { color: var(--muted); }

/* Футер */
.site-footer {
    background: var(--navy-dark);
    color: #b9c6d8;
    padding: 28px 0;
    font-size: 14px;
}
.site-footer a { color: #e8eef7; }
.footer-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
.site-footer h3 { color: #fff; font-size: 15px; margin-top: 0; }
.footer-bottom { margin-top: 20px; padding-top: 14px; border-top: 1px solid #22406b; font-size: 12px; }

/* Баннер cookies */
.cookie-banner {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--navy-dark);
    color: #e8eef7;
    padding: 14px 0;
    z-index: 1000;
    display: none;
}
.cookie-banner.visible { display: block; }
.cookie-banner .container { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.cookie-banner p { margin: 0; flex: 1; font-size: 13px; }
.cookie-banner a { color: var(--orange); }

/* Прочее */
.total-row td { font-weight: bold; background: #f0f4f9; }
.order-summary { font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.center { text-align: center; }
.mock-note {
    background: #fff8ec;
    border: 1px solid #f2d2a2;
    border-radius: 4px;
    padding: 10px 14px;
    font-size: 13px;
    color: #8a5a12;
    margin-bottom: 14px;
}


/* Подсказки города и адреса ПВЗ при оформлении заказа */
.suggest { position: relative; }
.suggest-list {
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(18, 51, 94, 0.12);
    max-height: 260px;
    overflow-y: auto;
}
.suggest-item {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
}
.suggest-item:hover { background: var(--bg); }
.suggest-item.own { background: #fff8ec; font-weight: bold; }
.suggest-item.own:hover { background: #fdefd7; }
.suggest-badge {
    margin-left: 8px;
    font-size: 11px;
    font-weight: normal;
    color: var(--orange-dark);
    white-space: nowrap;
}

/* Карта выбора пункта выдачи */
.pickup-map {
    height: 400px;
    margin-top: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
}

/* Раздел «Управление» */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.tool-form .form-group { margin-bottom: 12px; }
.tool-form input[type=number] { width: 120px; }
.tool-progress { margin-top: 16px; }
.progress-bar {
    height: 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0;
    background: var(--orange);
    transition: width 0.4s ease;
}

/* Ссылка на товар в каталоге */
.part-link { font-weight: bold; text-decoration: none; }
.part-link:hover { text-decoration: underline; }

/* Карточка товара */
.product-detail {
    display: grid;
    grid-template-columns: minmax(220px, 360px) 1fr;
    gap: 24px;
    align-items: start;
}
.product-photo { text-align: center; }
.product-photo img {
    max-width: 100%;
    max-height: 360px;
    object-fit: contain;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
}
.product-props { width: 100%; }
.product-props th {
    text-align: left;
    color: var(--muted);
    font-weight: normal;
    padding: 6px 12px 6px 0;
    white-space: nowrap;
    vertical-align: top;
}
.product-props td { padding: 6px 0; }
@media (max-width: 720px) {
    .product-detail { grid-template-columns: 1fr; }
}

/* Увеличение фото товара */
.product-photo img.zoomable { cursor: zoom-in; }
body.no-scroll { overflow: hidden; }
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: rgba(12, 36, 68, 0.85);
}
.lightbox[hidden] { display: none; }
.lightbox-image {
    max-width: 92vw;
    max-height: 88vh;
    object-fit: contain;
    background: var(--card);
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}
.lightbox-close {
    position: absolute;
    top: 18px;
    right: 24px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--card);
    color: var(--navy);
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
}
.lightbox-close:hover { background: var(--orange); color: #fff; }
