/* ==========================================================================
   «ПОИСК ТЕХНИКИ» — оформление

   Замысел: не нарядное приложение, а монохромный терминал грузового
   диспетчера. Чистая темнота вместо серого, цвет кости вместо белого,
   рубленые рамки без единого скругления и движение «ступеньками» —
   так, как двигалась картинка на старых экранах.

   Правила, которые соблюдаются везде:
     • ни одного скругления — только прямые углы;
     • тени не размытые, а сдвинутые на целые пиксели;
     • движение идёт скачками (steps), а не плавно;
     • цвет один — кость на чёрном; янтарный только там, где нужно
       привлечь внимание.
   ========================================================================== */

:root {
  /* Темнота и кость */
  --bg:        #000000;
  --panel:     #060605;
  --panel-2:   #0d0d0b;

  --ink:       #ece3d0;   /* кость — вместо белого */
  --ink-dim:   #9c9482;
  --ink-far:   #5c564a;

  --line:      #2b2820;
  --line-hi:   #6d6656;

  /* Единственный цветной акцент — янтарь старого монитора */
  --amber:     #f2b33d;
  --amber-dim: #7a5c22;

  /* Вердикты различаются больше формой метки, чем цветом */
  --match:     #ece3d0;
  --better:    #9ec7d8;
  --near:      #c9a86a;

  --tap:       48px;
  --edge:      2px;

  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);

  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
          "Liberation Mono", monospace;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  border-radius: 0 !important;   /* пиксельная сетка не терпит скруглений */
}

html {
  background: var(--bg);
  overscroll-behavior-y: none;   /* при оттягивании списка не проглядывает серое */
}

body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

/* Развёртка старого экрана ложится только на заголовки страниц.
   На числах и ценах полосы читались как зачёркивание, а мелкий текст
   и фотографии техники она портит — поэтому там её нет. */
.topbar h1, .login-card h1 { position: relative; display: inline-block; }
.topbar h1::after, .login-card h1::after {
  content: ''; position: absolute; inset: -2px -1px;
  pointer-events: none;
  background: repeating-linear-gradient(
      180deg, rgba(0,0,0,.45) 0 1px, transparent 1px 3px);
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--ink); color: var(--bg); }

/* --------------------------------------------------------------------------
   Движение: всё скачками
   -------------------------------------------------------------------------- */

@keyframes blink     { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes boot      { from { opacity: 0; transform: translateY(6px); }
                       to   { opacity: 1; transform: none; } }
@keyframes scan      { from { transform: translateY(-100%); }
                       to   { transform: translateY(1400%); } }
@keyframes marchB    { to { background-position: 24px 0; } }
@keyframes spinBlock { to { transform: rotate(360deg); } }
@keyframes nudge     { 0%, 100% { transform: translateY(0); }
                       50%      { transform: translateY(3px); } }

.anim {
  animation: boot .28s steps(4, end) both;
  animation-delay: var(--d, 0ms);
}

/* Мигающий знак ввода — как в терминале */
.caret {
  display: inline-block; width: .48em; height: .95em;
  background: var(--amber); vertical-align: -.1em; margin-left: .28em;
  animation: blink 1.06s steps(1, end) infinite;
}

/* --------------------------------------------------------------------------
   Каркас
   -------------------------------------------------------------------------- */

.app {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(66px + var(--safe-bottom));
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(16px + var(--safe-top)) calc(18px + var(--safe-right))
           16px calc(18px + var(--safe-left));
  background: var(--bg);
  border-bottom: var(--edge) solid var(--line-hi);
}
.topbar .row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.topbar h1 {
  margin: 0; font-size: 17px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; line-height: 1.2;
  min-width: 0;
}
.topbar .sub {
  color: var(--ink-dim); font-size: 11.5px; margin-top: 4px; letter-spacing: .02em;
}

.wrap {
  padding: 20px calc(18px + var(--safe-right)) 24px calc(18px + var(--safe-left));
  max-width: 820px; margin: 0 auto;
  transition: opacity .12s steps(3, end), transform .12s steps(3, end);
}
body.leaving .wrap { opacity: 0; transform: translateY(-4px); }

/* --------------------------------------------------------------------------
   Состояние бота в шапке
   -------------------------------------------------------------------------- */

.state {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 10px; color: var(--ink-dim); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .08em;
  border: var(--edge) solid var(--line); padding: 4px 8px; flex: none;
}
.dot { width: 7px; height: 7px; display: inline-block; flex: none; background: var(--ink-far); }
.dot.on   { background: var(--amber); animation: blink 1.8s steps(1, end) infinite; }
.dot.warn { background: var(--near); }
.dot.off  { background: var(--ink-far); }

/* --------------------------------------------------------------------------
   Крупные счётчики
   -------------------------------------------------------------------------- */

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin-bottom: 20px; }
.stat {
  background: var(--panel); border: var(--edge) solid var(--line);
  padding: 14px 12px 12px; position: relative; min-width: 0;
}
.stat .num {
  font-size: 26px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.stat .lbl {
  margin-top: 4px; font-size: 9px; text-transform: uppercase;
  letter-spacing: .1em; color: var(--ink-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat.match  .num { color: var(--match); }
.stat.better .num { color: var(--better); }
.stat.near   .num { color: var(--near); }

/* Уголки, как рамка на экране терминала */
.stat::before, .stat::after {
  content: ''; position: absolute; width: 5px; height: 5px;
  border: var(--edge) solid var(--line-hi); pointer-events: none;
}
.stat::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.stat::after  { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

/* --------------------------------------------------------------------------
   Кнопки
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px; width: 100%;
  background: var(--panel-2); border: var(--edge) solid var(--line-hi);
  color: var(--ink);
  font-size: 12.5px; font-weight: 700; cursor: pointer;
  text-transform: uppercase; letter-spacing: .08em;
  box-shadow: 3px 3px 0 var(--line);
  transition: transform .06s steps(1, end), box-shadow .06s steps(1, end),
              background .1s steps(2, end);
  text-align: center; line-height: 1.2;
  font-family: var(--mono);
}
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 var(--line);
  background: var(--line);
}
.btn:disabled { color: var(--ink-far); border-color: var(--line); cursor: default; }
.btn:disabled:active { transform: none; box-shadow: 3px 3px 0 var(--line); }

.btn.primary {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
  box-shadow: 3px 3px 0 var(--amber-dim);
}
.btn.primary:active { background: var(--amber); border-color: var(--amber); }
.btn.ghost  { background: transparent; box-shadow: none; border-color: var(--line); }
.btn.ghost:active { box-shadow: none; transform: translate(2px, 2px); }
.btn.danger { color: var(--amber); border-color: var(--amber-dim); }

.btn-row { display: grid; gap: 9px; grid-template-columns: 1fr; margin-bottom: 20px; }
.btn-row.two { grid-template-columns: 1fr 1fr; }

/* --------------------------------------------------------------------------
   Разделы
   -------------------------------------------------------------------------- */

.section { margin-bottom: 30px; }
.section > h2 {
  margin: 0; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; color: var(--ink-dim);
  display: flex; align-items: center; gap: 9px;
  border-bottom: var(--edge) solid var(--line); padding-bottom: 9px;
  margin-bottom: 14px;
}
.section > h2::before { content: '\25AE'; color: var(--amber); }
.section > h2 .count {
  margin-left: auto; color: var(--ink-far);
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}

.group-title {
  margin: 30px 0 14px; font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .14em; color: var(--ink-dim);
  border-bottom: var(--edge) solid var(--line); padding-bottom: 9px;
}

/* --------------------------------------------------------------------------
   Карточка объявления
   -------------------------------------------------------------------------- */

.item {
  display: flex; gap: 14px; padding: 14px;
  background: var(--panel); border: var(--edge) solid var(--line);
  margin-bottom: 10px;
  content-visibility: auto; contain-intrinsic-size: auto 122px;
  transition: border-color .1s steps(2, end), background .1s steps(2, end);
}
.item:active { border-color: var(--line-hi); background: var(--panel-2); }

.item .thumb-box {
  position: relative; overflow: hidden; flex: none;
  width: 88px; height: 66px;
  background: var(--panel-2); border: var(--edge) solid var(--line);
}
.item .thumb-box img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; filter: grayscale(.4) contrast(1.1);
  transition: opacity .2s steps(4, end);
}
.item .thumb-box img.ready { opacity: 1; }
.item .thumb-box .none {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  font-size: 8.5px; color: var(--ink-far); text-align: center;
  text-transform: uppercase; letter-spacing: .06em;
}
/* Пока фото грузится — бегущая сыпь из пикселей */
.item .thumb-box.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(90deg, rgba(236,227,208,.08) 0 4px, transparent 4px 8px),
    repeating-linear-gradient(0deg,  rgba(236,227,208,.05) 0 4px, transparent 4px 8px);
  background-size: 24px 24px, 24px 24px;
  animation: marchB .5s steps(3, end) infinite;
}

.item .body { min-width: 0; flex: 1; }
.item .name {
  font-weight: 700; font-size: 13.5px; line-height: 1.3;
  text-transform: uppercase; letter-spacing: .02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item .price {
  margin-top: 6px; font-size: 18px; font-weight: 700;
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  display: inline-block;
}
.item .facts {
  margin-top: 6px; font-size: 11.5px; color: var(--ink-dim);
  display: flex; flex-wrap: wrap; gap: 2px 12px;
}
.item .why  { margin-top: 8px; font-size: 11.5px; color: var(--near); line-height: 1.5; }
.item .plus { margin-top: 8px; font-size: 11.5px; color: var(--better); line-height: 1.5; }

/* Приписка площадки — не больше одной строки, иначе карточка пухнет */
.item .note {
  margin-top: 8px; font-size: 10.5px; color: var(--ink-far);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.item .meta {
  margin-top: 10px; font-size: 9.5px; color: var(--ink-far);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}

/* Метки различаются формой: подходит — залитая, дешевле — в рамке,
   почти — пунктиром. Так видно даже краем глаза. */
.chip {
  display: inline-flex; align-items: center; padding: 3px 7px;
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .09em; white-space: nowrap;
  border: var(--edge) solid transparent;
}
.chip.match  { background: var(--ink); color: var(--bg); }
.chip.better { border-color: var(--better); color: var(--better); }
.chip.near   { border-style: dashed; border-color: var(--near); color: var(--near); }
.chip.new    { background: var(--amber); color: var(--bg); }
.chip.src    { border-color: var(--line-hi); color: var(--ink-dim); letter-spacing: .03em; }

/* --------------------------------------------------------------------------
   Вкладки-фильтры
   -------------------------------------------------------------------------- */

.tabs {
  display: flex; gap: 7px; margin-bottom: 18px; padding-bottom: 3px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 9px 12px; min-height: 38px;
  display: inline-flex; align-items: center;
  background: transparent; border: var(--edge) solid var(--line);
  font-size: 10.5px; font-weight: 700; color: var(--ink-dim); cursor: pointer;
  white-space: nowrap; text-transform: uppercase; letter-spacing: .07em;
  transition: color .1s steps(2, end), border-color .1s steps(2, end);
}
.tab:active { border-color: var(--line-hi); }
.tab.active {
  background: var(--ink); border-color: var(--ink); color: var(--bg);
  box-shadow: 2px 2px 0 var(--amber-dim);
}

/* --------------------------------------------------------------------------
   Карточки и формы
   -------------------------------------------------------------------------- */

.card {
  background: var(--panel); border: var(--edge) solid var(--line);
  padding: 18px; margin-bottom: 14px; position: relative;
}
.card::before, .card::after {
  content: ''; position: absolute; width: 6px; height: 6px;
  border: var(--edge) solid var(--line-hi); pointer-events: none;
}
.card::before { top: -2px; left: -2px; border-right: 0; border-bottom: 0; }
.card::after  { bottom: -2px; right: -2px; border-left: 0; border-top: 0; }

/* Заголовок карточки — и когда он лежит прямо в ней, и когда
   стоит в строке с переключателем */
.card h3 {
  margin: 0 0 10px; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
}
.card .hint { color: var(--ink-dim); font-size: 11.5px; margin: 0 0 16px; line-height: 1.65; }

.field { margin-bottom: 16px; }
.field > label {
  display: block; font-size: 9px; text-transform: uppercase;
  letter-spacing: .12em; color: var(--ink-dim); margin-bottom: 7px;
}
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

input[type=text], input[type=password], input[type=number] {
  width: 100%; min-height: var(--tap); padding: 0 11px;
  background: var(--bg); border: var(--edge) solid var(--line);
  font-size: 16px;                     /* меньше 16 — айфон зумит страницу */
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
input::placeholder { color: var(--ink-far); }
input:focus {
  outline: none; border-color: var(--amber);
  box-shadow: 2px 2px 0 var(--amber-dim);
}

/* --------------------------------------------------------------------------
   Нижнее меню
   -------------------------------------------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  background: var(--bg);
  border-top: var(--edge) solid var(--line-hi);
}
.tabbar.five { grid-template-columns: repeat(5, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; height: 62px; font-size: 8.5px; color: var(--ink-far);
  letter-spacing: .06em; text-transform: uppercase; font-weight: 700;
  position: relative; min-width: 0; padding: 0 2px; text-align: center;
}
.tabbar a span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.tabbar a.active { color: var(--ink); }
/* Отметка выбранного — брусок сверху, как курсор */
.tabbar a.active::before {
  content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 3px; background: var(--amber);
}
.tabbar svg { width: 20px; height: 20px; stroke-width: 2; }
.tabbar.five a { font-size: 7.5px; letter-spacing: .03em; }
.tabbar.five svg { width: 19px; height: 19px; }

/* --------------------------------------------------------------------------
   Сообщения
   -------------------------------------------------------------------------- */

.toast {
  position: fixed;
  left: calc(10px + var(--safe-left)); right: calc(10px + var(--safe-right));
  bottom: calc(74px + var(--safe-bottom));
  z-index: 60; padding: 14px 15px;
  background: var(--bg); border: var(--edge) solid var(--ink);
  font-size: 12px; box-shadow: 4px 4px 0 var(--line); line-height: 1.6;
  opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .12s steps(3, end), transform .12s steps(3, end);
}
.toast::before { content: '\25B8 '; color: var(--amber); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err  { border-color: var(--amber); }

.notice {
  padding: 15px 16px; margin-bottom: 16px;
  background: var(--panel); border: var(--edge) dashed var(--amber-dim);
  color: var(--near); font-size: 11.5px; line-height: 1.65;
}
.empty {
  padding: 34px 20px; text-align: center; color: var(--ink-far); font-size: 11px;
  border: var(--edge) dashed var(--line-hi); text-transform: uppercase;
  letter-spacing: .07em; line-height: 2;
}

/* Плашка «фильтр изменён» */
.banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 15px; margin-bottom: 16px;
  background: var(--panel); border: var(--edge) solid var(--amber);
  box-shadow: 3px 3px 0 var(--amber-dim);
  font-size: 11.5px; color: var(--ink); line-height: 1.45;
}
.banner .grow { flex: 1; min-width: 150px; }
.banner button {
  min-height: 40px; padding: 0 14px; flex: none;
  background: var(--amber); border: var(--edge) solid var(--amber); color: var(--bg);
  font-size: 10.5px; font-weight: 700; cursor: pointer;
  text-transform: uppercase; letter-spacing: .08em; font-family: var(--mono);
}
.banner button:active { background: var(--bg); color: var(--amber); }
.banner button:disabled { opacity: .6; }

/* --------------------------------------------------------------------------
   Список отчётов
   -------------------------------------------------------------------------- */

.file {
  display: flex; align-items: center; gap: 12px; padding: 15px;
  background: var(--panel); border: var(--edge) solid var(--line);
  margin-bottom: 9px; min-height: var(--tap);
  transition: border-color .1s steps(2, end);
}
.file:active { border-color: var(--line-hi); }
.file .body { min-width: 0; flex: 1; }
.file .name {
  font-size: 12px; font-weight: 700; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  text-transform: uppercase; letter-spacing: .03em;
}
.file .when { font-size: 10px; color: var(--ink-dim); margin-top: 3px; }
.file .arrow { color: var(--ink-far); flex: none; }

/* --------------------------------------------------------------------------
   Выбор варианта
   -------------------------------------------------------------------------- */

.choices { display: grid; gap: 9px; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px;
  padding: 14px 15px; text-align: left; cursor: pointer;
  background: var(--bg); border: var(--edge) solid var(--line);
  font-family: var(--mono); min-height: var(--tap);
  transition: border-color .1s steps(2, end), box-shadow .1s steps(2, end);
}
.choice .t {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
}
.choice .d { font-size: 10.5px; color: var(--ink-dim); }
.choice.active { border-color: var(--ink); box-shadow: 3px 3px 0 var(--amber-dim); }
.choice.active .t::before { content: '\25B8 '; color: var(--amber); }

/* --------------------------------------------------------------------------
   Сворачиваемая карточка площадки
   -------------------------------------------------------------------------- */

.card.fold { padding: 0; overflow: hidden; }
.fold-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 16px 18px; background: none; border: 0; cursor: pointer;
  text-align: left; color: inherit; font-family: var(--mono); min-height: var(--tap);
}
.fold-title {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
}
.fold-sub {
  font-size: 10px; font-weight: 400; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: .04em;
}
.fold .chev {
  color: var(--ink-dim); flex: none;
  transition: transform .16s steps(3, end), color .1s steps(2, end);
}
.fold.open { border-color: var(--line-hi); }
.fold.open .chev { transform: rotate(180deg); color: var(--amber); }

.fold-body { max-height: 0; overflow: hidden; transition: max-height .22s steps(6, end); }
.fold-inner {
  padding: 18px; border-top: var(--edge) solid var(--line);
  opacity: 0; transition: opacity .16s steps(3, end) .04s;
}
.fold.open .fold-inner { opacity: 1; }
.fold .chev.nudge { animation: nudge .8s steps(3, end) 2; color: var(--amber); }

/* --------------------------------------------------------------------------
   Загрузка
   -------------------------------------------------------------------------- */

/* Полоса вверху — не заливка, а бегущие бруски */
#progress {
  position: fixed; top: var(--safe-top); left: 0; z-index: 100;
  height: 4px; width: 0;
  background-color: var(--amber);
  background-image: repeating-linear-gradient(
      90deg, transparent 0 4px, rgba(0,0,0,.6) 4px 6px);
  opacity: 0; pointer-events: none;
  transition: width .22s steps(6, end), opacity .2s steps(3, end);
}
#progress.on { opacity: 1; }

/* Колесо квадратное и вращается рывками — по восьми положениям */
.spin {
  width: 12px; height: 12px; flex: none; display: inline-block;
  border: 3px solid currentColor; border-right-color: transparent;
  animation: spinBlock .64s steps(8, end) infinite;
}
.spin.sm { width: 10px; height: 10px; border-width: 2px; }

.btn.loading { cursor: default; }
.btn.loading:disabled { color: var(--ink); border-color: var(--line-hi); }
.btn.primary.loading:disabled { color: var(--bg); }

/* Строка «бот сейчас работает»: по ней бежит полоса развёртки */
.working {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 15px; margin-bottom: 16px;
  background: var(--panel); border: var(--edge) solid var(--line-hi);
  font-size: 11.5px; color: var(--ink-dim); line-height: 1.6;
  overflow: hidden; position: relative;
}
.working .spin { color: var(--amber); }
.working b {
  color: var(--ink); font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; font-size: 10.5px;
}
.working::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--amber-dim); animation: scan 2.4s steps(16, end) infinite;
}

.notice.progress { position: relative; overflow: hidden; }
.notice.progress::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--amber-dim); animation: scan 2.4s steps(16, end) infinite;
}
.notice .head { display: flex; align-items: center; gap: 9px; margin-bottom: 5px; }
.notice .head .spin { color: var(--amber); }
.notice .head b {
  color: var(--ink); text-transform: uppercase; letter-spacing: .1em; font-size: 10.5px;
}

/* Заглушки списка */
.skel {
  background-color: var(--panel-2);
  background-image: repeating-linear-gradient(
      90deg, rgba(236,227,208,.07) 0 4px, transparent 4px 8px);
  background-size: 24px 24px;
  animation: marchB .5s steps(3, end) infinite;
}
.skel-row {
  display: flex; gap: 10px; padding: 9px; margin-bottom: 7px;
  background: var(--panel); border: var(--edge) solid var(--line);
}
.skel-row .skel.pic { width: 82px; height: 62px; flex: none; }
.skel-row .lines { flex: 1; display: flex; flex-direction: column; gap: 8px; padding-top: 3px; }
.skel-row .skel.l1 { height: 12px; width: 62%; }
.skel-row .skel.l2 { height: 16px; width: 42%; }
.skel-row .skel.l3 { height: 10px; width: 78%; }

/* --------------------------------------------------------------------------
   Смена вкладки в списке
   -------------------------------------------------------------------------- */

#list { transition: opacity .1s steps(2, end), transform .1s steps(2, end); }
#list.swap { opacity: 0; transform: translateY(4px); }

[hidden] { display: none !important; }

/* --------------------------------------------------------------------------
   Кабинет: показатели, графики, таблицы
   -------------------------------------------------------------------------- */

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.fact {
  background: var(--bg); border: var(--edge) solid var(--line);
  padding: 12px 13px; min-width: 0;
}
.fact .k {
  font-size: 8.5px; text-transform: uppercase; letter-spacing: .11em;
  color: var(--ink-dim); margin-bottom: 6px;
}
.fact .v { font-size: 13.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.fact .v.good { color: var(--amber); }
.fact .v.warn { color: var(--near); }
.fact .v.off  { color: var(--ink-far); }

.head-row {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 8px; margin-bottom: 6px;
}
.head-row h3 { margin: 0; white-space: nowrap; }

.switch { display: inline-flex; flex: none; border: var(--edge) solid var(--line); }
.switch button {
  border: 0; background: none; color: var(--ink-dim); cursor: pointer;
  padding: 7px 12px; font-size: 9.5px; white-space: nowrap; min-height: 34px;
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em;
  font-weight: 700;
  transition: background .1s steps(2, end), color .1s steps(2, end);
}
.switch button + button { border-left: var(--edge) solid var(--line); }
.switch button.on { background: var(--ink); color: var(--bg); }

/* График: столбики из целых блоков */
.chart {
  display: flex; align-items: flex-end; justify-content: flex-start; gap: 3px;
  height: 156px; padding: 0 8px; margin: 4px -8px 10px;
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chart::-webkit-scrollbar { display: none; }

.chart .bar {
  flex: 1 1 0; min-width: 10px; max-width: 48px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end;
  align-items: center; gap: 4px; cursor: pointer; padding: 2px 1px;
  transition: background .1s steps(2, end);
}
.chart .bar:active { background: var(--panel-2); }
.chart .bar.on { background: var(--panel-2); outline: var(--edge) solid var(--line-hi); }

.chart .bar .num {
  font-size: 9.5px; color: var(--ink-dim); font-variant-numeric: tabular-nums;
  height: 13px; line-height: 13px;
}
.chart .bar.on .num { color: var(--amber); font-weight: 700; }

.chart .stack {
  flex: 1; width: 100%; display: flex; flex-direction: column-reverse;
  justify-content: flex-start; overflow: hidden;
  background: var(--panel-2); min-height: 2px;
  border: var(--edge) solid var(--line); border-bottom: 0;
}
.chart .stack i { display: block; width: 100%; min-height: 2px; }

.chart .bar .lbl {
  font-size: 8.5px; color: var(--ink-far); white-space: nowrap;
  height: 12px; line-height: 12px;
}
.chart .bar .num:empty, .chart .bar .lbl:empty { visibility: hidden; }

.chart-empty {
  width: 100%; align-self: center; text-align: center;
  color: var(--ink-far); font-size: 10.5px; padding: 0 10px;
  text-transform: uppercase; letter-spacing: .07em; line-height: 1.8;
}

.legend {
  display: flex; flex-wrap: wrap; gap: 5px 12px;
  font-size: 10px; color: var(--ink-dim); margin-bottom: 2px;
}
.legend .li { display: inline-flex; align-items: center; gap: 6px; }
.legend .li i { width: 9px; height: 9px; flex: none; }

/* Таблица */
.tbl { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.tbl th {
  text-align: left; font-size: 8.5px; text-transform: uppercase;
  letter-spacing: .11em; color: var(--ink-dim); font-weight: 700;
  padding: 0 7px 6px 0; white-space: nowrap;
  border-bottom: var(--edge) solid var(--line);
}
.tbl td {
  padding: 8px 7px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top;
}
.tbl tr:last-child td { border-bottom: 0; }
.tbl td:first-child { width: 44%; }
.tbl th:not(:first-child), .tbl td:not(:first-child) {
  text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Вход
   -------------------------------------------------------------------------- */

.login-wrap {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px calc(20px + var(--safe-right)) 24px calc(20px + var(--safe-left));
}
.login-card { width: 100%; max-width: 340px; animation: boot .3s steps(4, end) both; }
.login-card .logo {
  width: 52px; height: 52px; margin: 0 auto 16px;
  background: var(--ink); display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 4px 0 var(--amber-dim);
}
.login-card h1 {
  text-align: center; font-size: 14px; margin: 0 0 6px;
  text-transform: uppercase; letter-spacing: .18em; font-weight: 700;
}
.login-card .sub {
  text-align: center; color: var(--ink-dim); font-size: 10.5px; margin-bottom: 22px;
  text-transform: uppercase; letter-spacing: .07em; line-height: 1.6;
}

/* --------------------------------------------------------------------------
   Экраны пошире: настольный вид
   -------------------------------------------------------------------------- */

@media (min-width: 760px) {
  .wrap { padding: 28px 24px 40px; }
  /* шапка выравнивается по той же колонке, что и содержимое */
  .topbar .row { max-width: 820px; margin: 0 auto; }
  .item .thumb-box { width: 120px; height: 88px; }
  .item .name { font-size: 14.5px; }
  .item .price { font-size: 19px; }
  .stat .num { font-size: 32px; }
  .stat .lbl { font-size: 10px; }
  .chart { height: 200px; }
  .tabbar {
    max-width: 820px; margin: 0 auto;
    border-left: var(--edge) solid var(--line-hi);
    border-right: var(--edge) solid var(--line-hi);
  }
  .tabbar a { font-size: 9.5px; }
  .tabbar.five a { font-size: 9px; }
  .toast { left: auto; right: 20px; width: 380px; bottom: 84px; }
}

/* Узкие экраны (iPhone SE и подобные) */
@media (max-width: 370px) {
  .topbar h1 { font-size: 15px; letter-spacing: .06em; }
  .stat .num { font-size: 22px; }
  .stat .lbl { font-size: 8px; letter-spacing: .05em; }
  .btn { font-size: 11px; letter-spacing: .04em; padding: 0 8px; }
  .tabbar a { font-size: 7.5px; letter-spacing: .02em; }
  .tabbar.five a { font-size: 6.8px; letter-spacing: 0; }
  .item .thumb-box { width: 72px; height: 56px; }
}

/* --------------------------------------------------------------------------
   Если в системе выключены анимации
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .spin {
    animation-duration: .64s !important;
    animation-iteration-count: infinite !important;
  }
}

/* --------------------------------------------------------------------------
   Тумблер: рубленый, с прыжком ползунка по ступеням
   -------------------------------------------------------------------------- */

.toggle {
  position: relative; flex: none; cursor: pointer;
  width: 62px; height: 32px; padding: 0;
  background: var(--bg); border: var(--edge) solid var(--line-hi);
  transition: background .1s steps(2, end), border-color .1s steps(2, end);
}
.toggle .knob {
  position: absolute; top: 2px; left: 2px;
  width: 26px; height: 24px; background: var(--ink-far);
  transition: transform .14s steps(4, end), background .1s steps(2, end);
}
.toggle.on { border-color: var(--amber); }
.toggle.on .knob { transform: translateX(30px); background: var(--amber); }

/* Подпись прямо на теле: ВКЛ слева, ВЫКЛ справа */
.toggle::before, .toggle::after {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 8px; font-weight: 700; letter-spacing: .06em;
  font-family: var(--mono); color: var(--ink-far);
}
.toggle::before { content: 'ВКЛ'; left: 7px; opacity: 0; }
.toggle::after  { content: 'ВЫКЛ'; right: 6px; }
.toggle.on::before { opacity: 1; color: var(--bg); }
.toggle.on::after  { opacity: 0; }
.toggle:active { background: var(--panel-2); }
