/* Раздел /instrumenty/ — стили инструмента.
 *
 * Своей палитры нет намеренно: всё на токенах темы (--ground, --card, --ink,
 * --muted, --line, --accent, --shadow), поэтому тёмная тема, шрифты и радиусы
 * работают сами. Вторая палитра здесь означала бы вторую систему, которая
 * начнёт расходиться с первой на первой же правке style.css.
 */

.sb-tools-page { padding-bottom: 64px }

.sb-crumbs {
  margin: 18px 0 6px;
  font-size: 13px;
  color: var(--muted);
}
.sb-crumbs a { text-decoration: underline; text-underline-offset: 3px }
.sb-crumbs span { opacity: .6 }

.sb-lead {
  max-width: 62ch;
  color: var(--muted);
  font-size: 17px;
  margin: 10px 0 0;
}

/* ——— хаб ——— */
.sb-tools-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 28px;
}
.sb-tools-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.sb-tools-card h2 { margin: 0 0 8px; font-size: 19px }
.sb-tools-card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55 }
.sb-tools-card:hover { border-color: var(--accent) }

/* ——— оболочка инструмента ——— */
.sb-tool-slot { margin: 26px 0 40px }
.sb-tool-loading { color: var(--muted); font-size: 14px }

.sb-tool {
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
}

/* ——— вкладки площадок ——— */
.sb-tabs { display: flex; flex-wrap: wrap; gap: 8px }
.sb-tab {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 10px;
  padding: 8px 16px;
  font: 600 14px/1.2 'Golos Text', sans-serif;
  cursor: pointer;
}
.sb-tab.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink) }

/* ——— поля ——— */
.sb-field-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 14px }
.sb-field { display: flex; flex-direction: column; gap: 6px; min-width: 190px }
.sb-field--grow { flex: 1 1 240px }
.sb-field--narrow { min-width: 110px; max-width: 130px }
.sb-field__label { font-size: 12.5px; color: var(--muted) }

.sb-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--ground);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font: 400 14.5px/1.4 'Golos Text', sans-serif;
}
.sb-input:focus { border-color: var(--accent) }
.sb-input--area { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 13px }

/* ——— таблица товаров ——— */
.sb-grid { display: flex; flex-direction: column; gap: 8px }
.sb-grid__row {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 1fr .8fr .8fr .5fr 34px;
  gap: 8px;
  align-items: center;
}
.sb-grid__row--head { font-size: 12px; color: var(--muted); gap: 8px }
.sb-grid__row--head .sb-grid__cell { padding-left: 4px }

.sb-iconbtn {
  width: 30px; height: 30px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  font-size: 17px; line-height: 1;
  cursor: pointer;
}
.sb-iconbtn:hover { border-color: var(--accent); color: var(--ink) }

.sb-rowbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px }

.sb-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  font: 600 14px/1.2 'Golos Text', sans-serif;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
}
.sb-btn--ghost { background: transparent; border: 1px solid var(--line); color: var(--ink) }
.sb-btn--primary { padding: 12px 22px; font-size: 15px }
.sb-btn[disabled] { opacity: .45; cursor: not-allowed }

.sb-paste { display: flex; flex-direction: column; gap: 10px }
.sb-paste__hint { margin: 0; font-size: 13.5px; color: var(--muted) }

/* ——— предпросмотр ——— */
.sb-preview {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.sb-preview__cap { font-size: 12.5px; color: var(--muted) }

.sb-label {
  background: #fff;
  color: #000;
  border: 1px solid var(--line);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Golos Text', sans-serif;
  line-height: 1.15;
  /* Этикетка печатается на белом всегда — в тёмной теме тоже. */
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}
.sb-label__line { white-space: nowrap; overflow: hidden }
.sb-label__line--name { font-weight: 700 }
.sb-label__code { display: flex; align-items: flex-end; justify-content: center; color: #000 }
.sb-label__code svg { display: block; height: 100%; width: auto }
/* Предпросмотр идёт в натуральную величину, а модуль кода при этом равен
   примерно 1,7 экранного пикселя. С shape-rendering:crispEdges браузер
   прижимает каждый штрих к целому пикселю, и однородные штрихи получаются то
   в 1, то в 2 пикселя — один и тот же код выглядит по-разному при разном
   масштабе окна. На обычном экране честнее сглаживание: доли пикселя
   сохраняются в полутонах. На плотном экране модуля хватает, и там crispEdges
   даёт более резкую картинку. На печать это не влияет вовсе — PDF векторный. */
.sb-label__code svg { shape-rendering: auto }
@media (min-resolution: 2dppx) {
  .sb-label__code svg { shape-rendering: crispEdges }
}
.sb-label__digits { text-align: center; font-variant-numeric: tabular-nums }
.sb-label__attrs { white-space: nowrap; overflow: hidden }

.sb-empty { color: var(--muted); font-size: 14.5px; margin: 0 }

/* ——— вердикт ——— */
.sb-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 18px;
  width: 100%;
}
.sb-fact {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--ground);
}
.sb-fact__label { font-size: 12px; color: var(--muted) }
.sb-fact__value { font-size: 19px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums }
.sb-fact__hint { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.4 }

.sb-msgs { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; width: 100% }
.sb-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px;
  line-height: 1.5;
  background: var(--ground);
}
.sb-msg__mark {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
  margin-top: 1px;
}
.sb-msg--error { border-left-color: #C0342A }
.sb-msg--error .sb-msg__mark { background: #C0342A; color: #fff }
.sb-msg--warn { border-left-color: var(--amber) }
.sb-msg--warn .sb-msg__mark { background: var(--amber); color: var(--amber-ink) }
.sb-msg--note { border-left-color: var(--muted) }
.sb-msg--note .sb-msg__mark { background: var(--muted); color: var(--card) }

/* ——— печать ——— */
.sb-tool__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px }
.sb-status { font-size: 13.5px; color: var(--muted) }
.sb-actions__hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 70ch;
}

/* ——— правила площадки ——— */
.sb-rules {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.sb-rules__title { margin: 0 0 10px; font-size: 16px }
.sb-rules__list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px }
.sb-rules__list li { font-size: 14px; line-height: 1.5; color: var(--muted) }
.sb-rules__src { margin: 12px 0 0; font-size: 13px; color: var(--muted) }
.sb-rules__src a { text-decoration: underline; text-underline-offset: 3px }
.sb-rules__note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  border-left: 3px solid var(--amber);
  padding-left: 12px;
}

/* ——— текст под инструментом ——— */
.sb-tool-text { max-width: 72ch }
.sb-table-wrap { overflow-x: auto; margin: 18px 0 }
.sb-table-wrap table { border-collapse: collapse; width: 100%; min-width: 620px; font-size: 14.5px }
.sb-table-wrap th, .sb-table-wrap td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
.sb-table-wrap thead th { font-size: 12.5px; color: var(--muted); font-weight: 600 }
.sb-table-wrap tbody th { font-weight: 600; white-space: nowrap }
.sb-src { font-size: 13px; color: var(--muted) }

@media (max-width: 760px) {
  .sb-tool { padding: 16px; border-radius: 12px }
  .sb-grid__row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }
  /* На узком экране шапка таблицы бессмысленна: подписываем поля через
     aria-label, а визуально каждая строка становится карточкой. */
  .sb-grid__row--head { display: none }
  .sb-grid__cell--wide { grid-column: 1 / -1 }
}
