:root {
  font-size: 16px; /* 1rem = 16px baseline */ --bg:#f8fafc; --card:#ffffff; --muted:#64748b; --accent:#0ea5e9; --text:#0f172a; --border:#cbd5e1; }
* { box-sizing: border-box; }
body { margin:0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Inter, Arial, sans-serif; background: var(--bg); color: var(--text); }
.wrap { width:100%; margin: 0; padding: 0; }
.card { width:100%; background: var(--card); border:0.0625rem solid var(--border); border-radius: 0; box-shadow: 0 0.375rem 1rem rgba(0,0,0,.08); overflow: hidden; }
.head { display:flex; align-items:center; justify-content:space-between; padding: 0.3125rem 1.5rem; border-bottom:0.0625rem solid var(--border); background: #f1f5f9;}
.head h1 { font-size: 1.375rem; letter-spacing:0.0125rem; color:#303030; hyphens: auto;}
@media (max-width: 50rem) {
  .head {
    flex-direction: column;
    align-items: flex-start;  /* выравнивание по левому краю */
    text-align: left;
  }
}
.badge { font-size:0.75rem; color:#0369a1; background: #bae6fd; padding:0.25rem 0.625rem; border-radius: 62.4375rem; font-weight: 700; }
.grid { display:grid; grid-template-columns: 1fr 1fr; gap:1rem; padding: 1rem 1.5rem; }
.field { display:flex; flex-direction:column; gap:0.5rem; }
.label { font-size: 1.125rem; color: var(--muted); }
.input { border:0.0625rem solid var(--border); background:#ffffff; color:var(--text); border-radius: 0.625rem; padding: 0.625rem 0.75rem; outline:none; font-size:1rem; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 0.1875rem rgba(14,165,233,.15); }

/* десктоп и планшеты */
.table-wrap {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 70vh;
  margin-left: 1.5rem;
  margin-right: 1.5rem;
  border: 0.0625rem solid var(--border);
  border-bottom-left-radius: 0.75rem;
}

/* мобильные устройства */
@media (max-width: 40rem) {
  .table-wrap {
    max-height: 90vh;        /* до 90% экрана на телефонах */
    border: 0;
  }
}

.table-wrap table {
  width: 100%;
  border-collapse: separate; /* было: collapse */
  border-spacing: 0;         /* важен ноль, чтобы не было зазоров */
}
.table-wrap tbody td {
  padding: 0.1875rem 0.5rem;
  border-bottom: 0.0625rem dashed #e2e8f0;
  font-size: 1rem;
  line-height: 1.3;
}
.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #ffffff;
  text-align: center;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
  padding: 0.625rem 0.75rem;
  border-bottom: 0.0625rem solid var(--border);
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.08);
}

/* Белая подложка под каждым th, перекрывает щели между ячейками */
.table-wrap thead th::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -0.0625rem;
  height: 0.375rem;                /* можно 4–0.5rem по вкусу */
  background: #ffffff;
  pointer-events: none;
}
.table-wrap tbody tr:hover { background: #e1f2fd; }
.number { width: 6.875rem; }

button { appearance:none; border:none; cursor:pointer; border-radius: 0.75rem; font-weight:700; letter-spacing:0.0187rem; }
.actions {
  display: flex;
  justify-content: center;
}
.btn-primary {
  position: fixed;
  display: flex;
  bottom: 0.25rem;
  gap: 0.5rem;
  align-items: center;
  background: linear-gradient(135deg, #22c55e, #16a34a); /* зелёный градиент */
  color: #fff;
  font-weight: 600;
  font-size: 1.125rem;
  padding: 0.875rem 1.75rem;
  border: none;
  border-radius: 0.875rem;
  cursor: pointer;
  box-shadow: 0 0.25rem 0.75rem rgba(22, 163, 74, 0.4);
  transition: transform 120ms ease, box-shadow 120ms ease, background 200ms ease;
  margin-bottom: 0.625rem;
  text-align: center;
}

.btn-primary:hover {
  transform: translateY(-0.125rem);
  box-shadow: 0 0.375rem 0.875rem rgba(22, 163, 74, 0.55);
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 0.1875rem 0.5rem rgba(22, 163, 74, 0.5);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.note { color: var(--muted); font-size: 0.75rem; padding: 0 1.5rem 1.25rem; }
.center { text-align:center; padding: 3.75rem 1.5rem; }
.pill { display:inline-flex; gap:0.5rem; align-items:center; padding: 0.625rem 0.875rem; border:0.0625rem solid var(--border); border-radius: 62.4375rem; background:#f8fafc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tabs {
  display: flex; gap: 0.5rem; list-style: none; margin: 0; padding: 0 1.5rem;
}
.tab {
  padding: 0.5rem 0.75rem; cursor: pointer; border: 0.0625rem solid transparent;
  border-radius: 0.625rem 0.625rem 0 0; user-select: none; color: var(--muted);
  font-weight: 500; background: #ebeef2;
}
.tab.active {
  color: var(--text); background: #eaf2fb; border-color: var(--border) var(--border) #eaf2fb var(--border);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.input.invalid {
  border-color: #dc2626;
  background-color: #fef2f2;
}

/* общая сетка для полей */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13.75rem, 1fr));
  gap: 1rem;
}

/* мобильный режим — в одну колонку */
@media (max-width: 40rem) {
  .grid {
    grid-template-columns: 1fr;  /* все поля в один столбик */
  }
}

.totals { display: grid; row-gap: 0.5rem; padding: 0.75rem 1rem; font-size: 1.125rem;}

.total-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  column-gap: 0.625rem;
}
.total-line strong {
  font-size: 1.125rem;
}

#selection-summary {
  margin-left: 1rem;
  font-size: 0.9rem;
}

.summary-table {
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: #fff;
  width: auto;          /* ширина под содержимое */
  max-width: 100%;      /* не вылезет за контейнер */
  table-layout: auto;   /* колонки подстраиваются */
}

.summary-table th,
.summary-table td {
  border: 0.0625rem solid #e5e7eb;
  padding: 0.375rem 0.625rem;
  text-align: left;
  white-space: nowrap;   /* строки не ломаются, пока хватает ширины */
}

.summary-table td {
  white-space: normal;   /* но если текст очень длинный — переносим */
}

.summary-table th {
  background: #f9fafb;
  font-weight: 600;
}

.photo-modal {
  display: none;               /* по умолчанию скрыто */
  position: fixed;
  z-index: 1000;
  left: 0; top: 0;
  width: 100%; height: 100%;
  background-color: rgba(0,0,0,0.7);
  align-items: center;
  justify-content: center;
}

.photo-modal-content {
  max-width: 90%;
  max-height: 90%;
  border-radius: 0.5rem;
  box-shadow: 0 0.25rem 1.25rem rgba(0,0,0,0.5);
  animation: zoomIn 0.2s ease;
}

@keyframes zoomIn {
  from { transform: scale(0.8); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.photo-modal-close {
  position: absolute;
  top: 0.75rem; right: 1.25rem;
  color: white;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
}

.form-hint {
  margin: 1rem 1rem 7rem 1rem;
  padding: 0.75rem 1rem;
  font-size: 1.125rem;
  color: #444;
  background: #f9f9f9;
  border-left: 0.25rem solid #4caf50;
  border-radius: 0.375rem;
}

.form-hint a {
  color: #2e7d32;
  font-weight: 500;
  text-decoration: none;
}

.form-hint a:hover {
  text-decoration: underline;
}

/* значение + бейдж как единый блок (не ломаем сетку) */
.value-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;     /* не переносим бейдж */
}

.total-line .currency { white-space: nowrap; }


.submit-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.vpn-badge {
  padding: 0.375rem 0.625rem;
  border-radius: 0.5rem;
  background: #fef2f2;
  border: 0.0625rem solid #fecaca;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

td.price {
  white-space: nowrap;
  text-align: center;
}

.table-search { margin: 0rem 1.5rem 1rem 1.5rem; display: flex; justify-content: flex-start; }

.searchbar {
  position: relative;
  width: min(26.25rem, 100%);
}

#table-search {
  width: 100%;
  padding: 0.625rem 2.375rem 0.625rem 2.375rem;   /* место под иконки слева/справа */
  border: 0.0625rem solid #d1d5db;
  border-radius: 624.9375rem;          /* «пилюля» */
  font-size: 1rem;
  outline: none;
  transition: box-shadow .15s, border-color .15s;
  background: #fff;
}

#table-search:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 0.1875rem rgba(96,165,250,.25);
}

.search-icon {
  position: absolute;
  left: 0.8125rem; top: 50%; transform: translateY(-50%);
  width: 1.125rem; height: 1.125rem; fill: #9ca3af;
  pointer-events: none;
}
@media (max-width: 50rem) {
  .table-search {
    flex-direction: column;
    align-items: flex-start;  /* выравнивание по левому краю */
    text-align: left;
  }
  #table-search {
    margin-left: 1.25rem;
  }
  .search-icon {
    margin-left: 1.25rem;
    transform: translateY(-50%);
  }
}

.filter-bar {
  display: flex; 
  align-items: center; 
  gap: 0.5rem;
  margin-left: 1rem;
}

.clear-btn {
  position: absolute;
  right: 0.5rem; top: 50%; transform: translateY(-50%);
  width: 1.625rem; height: 1.625rem;
  border: 0; border-radius: 50%;
  background: #e5e7eb; color: #374151;
  font-size: 1rem; line-height: 1;
  cursor: pointer;
}
.clear-btn:hover { background: #d1d5db; }

#table-search::-webkit-search-cancel-button,
#table-search::-webkit-search-decoration {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

#table-search::-ms-clear { /* старый Edge/IE */
  display: none;
  width: 0;
  height: 0;
}

mark.highlight {
  background: #fef08a; /* мягко-жёлтый */
  color: inherit;      /* сохраняем цвет текста */
  padding: 0;
}

/* Контейнер: 2/3 слева, 1/3 справа */
.summary-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem 1.5rem;
  align-items: start;
  margin-top: 1rem;
}

/* Левая колонка — всё по левому краю */
.summary-left {
  text-align: left;
  max-width: 100vw;
}

/* Правая колонка — всё по правому краю */
.summary-right {
  text-align: right;
}

/* Таблица "Вы выбрали" — авто ширина, но не шире контейнера */
.summary-table {
  width: auto;
  max-width: 100%;
  border-collapse: collapse;
  background: #fff;
}
.summary-table th, .summary-table td {
  border: 0.0625rem solid #e5e7eb;
  padding: 0.375rem 0.625rem;
  text-align: left;
  white-space: nowrap;
}
.summary-table td { white-space: normal; }

.clear-selection-btn {
  margin-top: 1rem;
  padding: 0.375rem 0.875rem;
  background: #636568; color: #fff; border: none; border-radius: 0.375rem;
  cursor: pointer; font-size: 1rem; transition: background .2s;
}
.clear-selection-btn:hover { background: #dc2626; }

/* Блок totals: трёхколоночная мини-сетка для выравнивания */
.totals { display: grid; row-gap: 0.375rem; padding: 0.75rem 1rem; }
.total-line {
  display: grid;
  grid-template-columns: 1fr auto auto; /* текст | значение | ₽ */
  align-items: center;
  column-gap: 0.625rem;
}
.value-badge {
  display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap;
}
.total-line .currency { white-space: nowrap; }

/* Адаптив: на узких экранах в одну колонку */
@media (max-width: 56.25rem) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
  .summary-right { text-align: left; } /* на мобиле выравниваем как слева */
  .clear-wrap { text-align: left; }
}


.total-line {
  display: grid;
  grid-template-columns: 1fr auto auto; /* текст+бейдж | число | ₽ */
  align-items: center;
  column-gap: 0.625rem;
}

.label-with-badge {
  align-items: center;
  white-space: nowrap;
}

.saving-badge {
  padding: 0.4rem 0.7rem;
  border-radius: 624.9375rem;
  background: #16a34a;
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
  box-shadow: 0 0.125rem 0.375rem rgba(22,163,74,.25);
  vertical-align: middle;
  justify-self: end;
}

.photo-cell {
  text-align: center;
}
.clickable-photo {
  user-select: none;
  -webkit-user-select: none; /* Safari/Chrome */
  -moz-user-select: none;
  -ms-user-select: none;

  -webkit-user-drag: none;   /* запрет «перетаскивания» картинки */
  -webkit-tap-highlight-color: transparent; /* мобильные "подсветки" */
  max-width:21.875rem; max-height:21.875rem; object-fit:cover; cursor: zoom-in;
}

.cell-feature {
  min-width: 13.75rem;
}



/* Lightbox */
.lightbox{position:fixed;inset:0;display:none;z-index:1000}
.lightbox.is-open{display:block}
.lb-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.6)}
/* контейнер оставляем гридом с 3 колонками */
.lb-frame{
  position: absolute;
  inset: 4vh 6vw;              /* стабильно на любых экранах */
  background:#111;
  border-radius:0.625rem;
  display:flex;                /* вместо grid – проще центрировать */
  align-items:center;
  justify-content:center;
  overflow:hidden;             /* важное: не позволяем картинке вылезать */
  box-sizing: border-box;
}

/* 👉 кладём картинку в центральную колонку и центрируем */
#lb-img{
  display:block;
  max-width: 100%;
  max-height: 100%;
  width:auto;
  height:auto;
  object-fit: contain;         /* вписываем с сохранением пропорций */
  pointer-events:none;         /* чтобы клики доходили до стрелок поверх */
}
.lb-nav,.lb-close{
  position:absolute;z-index:2;background:rgba(255,255,255,.4);color:#fff;
  border:0;border-radius:0.5rem;width:2.75rem;height:2.75rem;cursor:pointer;
  font-size: 1.875rem;
}
.lb-nav {
  padding-bottom: 0.1875rem;
}
.lb-prev{ left:0.75rem; top:50%; transform:translateY(-50%); }
.lb-next{ right:0.75rem; top:50%; transform:translateY(-50%); }
.lb-close{ right:0.75rem; top:0.75rem; }
.lb-counter{position:absolute;left:1rem;bottom:0.75rem;color:#fff;font-size:0.875rem;opacity:.9}
@media (max-width: 40rem){
  .lb-frame{ inset: 0; border-radius:0; }
  .lb-prev{ left:0.375rem; }
  .lb-next{ right:0.375rem; }
}

.switch {
  position: relative;
  display: inline-block;
  width: 2.875rem;
  height: 1.5rem;
}
.switch input { display: none; }

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: .3s;
  border-radius: 1.5rem;
}
.slider:before {
  position: absolute;
  content: "";
  height: 1.125rem;
  width: 1.125rem;
  left: 0.1875rem;
  bottom: 0.1875rem;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: #28a745;
}
input:checked + .slider:before {
  transform: translateX(1.375rem);
}
/* зебра по группам */
.zebra-odd tr:not(.highlight)  { background: #ffffff; }
.zebra-even tr:not(.highlight) { background: #f3f4f5; }


/* подсветка выбранной */
.table.striped tbody.group tr.highlight {
  background: #ffeab5;
}

/* границы между строками */
.table.striped tbody.group tr {
  border-bottom: 0.0625rem solid #e0e0e0;
}

/* лёгкая граница между группами */
.table.striped tbody.group:last-child tr:last-child {
  border-bottom: 0.0625rem solid #ccc;
}

/* скрытое содержимое первой строки — ничего не занимает */
td.ghost-cell {
  visibility: hidden;          /* не видно, но колонка остается */
  pointer-events: none;
}

/* делаем «плоской» первую строку, если она не в наличии */
tr.ghost-row td:not(.photo-cell) {
  padding: 0 !important;       /* было 0.5rem — убираем и по бокам */
  height: 0 !important;
  line-height: 0 !important;
  font-size: 0 !important;     /* чтобы текст/inline не давали высоту */
  border: 0 !important;
  background: transparent !important;
}

/* на всякий случай полностью прячем вложенные элементы */
tr.ghost-row td:not(.photo-cell) > * {
  display: none !important;
}

/* ====== Мобильная версия: строка делится на фото и остальное ====== */
@media (max-width: 800px) {
  thead {
    display: none;
  }
  table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
  }

  /* отключаем поведение таблицы */
  table, tbody, tr, td, th {
    display: block;
  }

  /* добавляем отступы между "строками" */
  tbody tr {
    border: 0.0625rem solid #ddd;           /* 1px → 0.0625rem */
    border-radius: 0.625rem;                /* 10px → 0.625rem */
    margin-bottom: 0.75rem;                 /* 12px → 0.75rem */
    overflow: hidden;
    background: #fff;
  }

  /* первая ячейка с фото идёт первой отдельной строкой */
  td.photo-cell {
    display: block;
    text-align: center;
    padding: 0.5rem;                        /* 8px → 0.5rem */
    border-bottom: 0.0625rem solid #eee;
  }

  td.photo-cell img {
    width: 100%;
    height: auto;
    max-height: 28vh;                       /* 220px → ~28vh (зависит от высоты экрана) */
    object-fit: contain;
  }

  /* остальные ячейки — внизу карточки */
  tr td:not(.photo-cell) {
    display: inline-flex;
    padding: 0.375rem 0.5rem;               /* 6px 8px → rem */
    box-sizing: border-box;
    align-items: center;
  }

  /* чтобы номенклатура и характеристика занимали всю ширину */
  td.cell-nomenclature,
  td.cell-feature {
    width: 100%;
    font-weight: 600;
  }

  /* небольшие подписи */
  td.cell-availability::before {
    content: "Наличие: ";
    font-weight: 500;
    color: #555;
    margin-right: 0.5rem;
  }
  td.cell-price-dealer::before {
    content: "Цена дилер: ";
    font-weight: 500;
    color: #555;
    margin-right: 0.5rem;
  }
  td.cell-price-rrc::before {
    content: "РРЦ: ";
    font-weight: 500;
    color: #555;
    margin-right: 0.5rem;
  }
  td.cell-order::before {
    content: "Заказ: ";
    font-weight: 500;
    color: #555;
    margin-right: 0.5rem;
  }

  /* поле ввода заказа на всю ширину */
  td.cell-order input {
    box-sizing: border-box;
    min-width: fit-content;
  }
  .table-search{ display: flex; justify-content: stretch; }
  .searchbar{ width: 100%; }
  .filter-bar {  margin-left: 0rem; margin-top: 1rem; margin-bottom: 0.5rem;}
  #table-search{ font-size: 1rem; padding: .625rem 2.25rem; margin-left: 0; }
  .search-icon{ left: 14px; margin-left: 0; }

    .tabs {
    display: flex;
    flex-wrap: nowrap;           /* не переносить элементы */
    gap: 8px;
    overflow-x: auto;            /* горизонтальный скролл */
    overflow-y: hidden;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;  /* инерция iOS */
    touch-action: pan-x;         /* жест по оси X */
    padding: 6px 8px;
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }
  .tabs::-webkit-scrollbar { display: none; } /* скрыть полоску в WebKit */

  .tabs .tab {
    flex: 0 0 auto;              /* не растягивать */
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
  }
  .tabs .tab.active {
    background: #e6f6ff;
    border-color: #7cc7ff;
  }

  .summary-table {
    margin-right: 1.5rem;
  }
  .summary-table td {
    border: 0;
  }
}