/* МедРеестр, облегчённая версия — главный экран: история поисков и плитка «Новый поиск».
   Общие токены и элементы — в ../shared/base.css, он подключается раньше этого файла. */
:root {
  /* Высота строки поисков: ровно по содержимому карточки. Плитка «Новый поиск» той же высоты,
     даже когда рядом не осталось ни одной карточки */
  --row-h: 280px;
}

/* ---------- Заголовок ---------- */
/* Строка под заголовком всегда одной высоты: появление и исчезновение плашки «ждут подтверждения» ничего не сдвигает */
.sub { margin-top: 10px; min-height: 32px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--muted); }
.need { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 999px; border: 0; background: var(--warn-soft); color: var(--warn); font: 600 13px/1 var(--font); cursor: pointer; transition: transform .15s var(--ease), box-shadow .2s; }
.need:hover { box-shadow: inset 0 0 0 1px var(--warn); }
.need.is-off { visibility: hidden; }
.need:active { transform: scale(.97); }
.need svg { transition: transform .25s var(--ease); }
.need:hover svg { transform: translateX(3px); }

/* ---------- Поиск и чипы ---------- */
.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 28px; }

/* ---------- Сетка и карточки ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 272px), 1fr)); gap: 16px; align-items: stretch; }
.card { container-type: inline-size; position: relative; display: flex; flex-direction: column; gap: 12px; min-width: 0; min-height: var(--row-h); padding: 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1); transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease); }
.card:hover { transform: translateY(-3px); box-shadow: var(--sh-3); border-color: var(--line-strong); }
/* Типографика карточки — три размера: 12 (статус, подписи), 13 (сведения, кнопки), 16 (название, цифры).
   Высоты строк кратны 4 px. Надзаголовок: статус своим цветом с заглавной, дата бледнее;
   от надзаголовка до названия 8 px, от названия до сведений 2 px */
.card-top { display: flex; align-items: baseline; gap: 4px; min-width: 0; height: 16px; margin-bottom: -4px; font: 500 12px/16px var(--font); white-space: nowrap; }
.cap { flex: none; display: inline-block; font-weight: 600; }
.cap::first-letter { text-transform: uppercase; }
.c-ok { color: var(--ok); } .c-warn { color: var(--warn); } .c-info { color: var(--info); }
.c-queue { color: var(--queue); } .c-mute { color: var(--mute); } .c-bad { color: var(--danger); }
.time { flex: none; color: var(--faint); }
.time::before { content: "· "; }
/* Название и сведения — один блок: отступ между ними не зависит от длины названия,
   а запас под вторую строку названия уходит вниз блока */
.card-head { display: flex; flex-direction: column; gap: 2px; min-height: 70px; min-width: 0; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-underline-offset: 3px; }
.card-title { margin: 0; font: 600 16px/24px var(--font); letter-spacing: -.01em; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; text-wrap: pretty; }
.card-meta { margin: 0; color: var(--muted); font-size: 13px; line-height: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-body { margin-top: auto; padding-top: 6px; } /* от сведений до итога — 18 px */
/* Все нижние блоки одной высоты — в ряду они начинаются на одной линии */
.panel.prog { display: flex; flex-direction: column; justify-content: center; }
/* Цифры: число сверху крупно, подпись под ним мелко; три равные колонки */
.s2 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.s2 > div { min-width: 0; }
.s2 .v { display: block; height: 24px; font: 600 16px/24px var(--font); letter-spacing: -.01em; font-variant-numeric: lining-nums proportional-nums; color: var(--text); white-space: nowrap; }
.s2 .v small { margin-left: 3px; font: 500 13px/24px var(--font); letter-spacing: 0; color: inherit; }
.s2 .v.dim { color: var(--faint); font-weight: 500; }
.s2 .v.sum, .s2 .v.sum small { color: var(--sum); }  /* «млн» тем же цветом, что и число */
.s2 .l { display: block; font: 400 12px/16px var(--font); color: var(--faint); white-space: nowrap; }
.prog-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 13px; line-height: 20px; color: var(--muted); }
.prog-row b { font: 600 16px/20px var(--font); color: var(--text); font-variant-numeric: tabular-nums; }
.queue { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; line-height: 18px; border-style: dashed; border-color: var(--line-strong); }
.queue svg { flex: none; color: var(--faint); }
/* Ошибка на карточке: значок, что случилось, кнопка; той же высоты, что другие блоки */
.panel.err-row { display: flex; align-items: center; gap: 8px; border-color: transparent; background: var(--danger-soft); color: var(--danger); font: 600 13px/18px var(--font); }
.err-row > svg { display: none; }  /* красного фона хватает — место отдаём тексту */
/* Причина — до двух строк: блок той же высоты, что у соседних карточек, и слова не обрезаются */
.err-row > span { flex: 1; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.err-row .btn-err { flex: none; height: 32px; padding: 0 10px; border-color: var(--danger); background: var(--surface); color: var(--danger); }
.err-row .btn-err:hover { border-color: var(--danger); color: var(--danger); background: var(--surface); }
/* Низ карточки: главная кнопка по статусу, значок Excel у готового и меню «⋯» */
.card-foot { display: flex; align-items: center; gap: 8px; }
/* Пока открыт ряд «Повторить · Удалить», значок Excel уступает ему место */
.icon-btn.xl { overflow: hidden; transition: width .22s var(--ease), margin .22s var(--ease), opacity .16s var(--ease), border-color .15s, background-color .15s, color .15s; }
.card.acting .icon-btn.xl { width: 0; margin-left: -8px; border-width: 0; opacity: 0; pointer-events: none; }
.btn.btn-main { flex: 1; min-width: 0; justify-content: center; height: 40px; padding: 0 10px; } /* сильнее общего .btn — все нижние ряды 40 px */

/* ---------- Плитка «Новый поиск» ----------
   Узкая: плюс, название и чипы видов поиска. Когда поисков меньше, чем колонок, плитка занимает
   свободные колонки ряда (--span ставит app.js), а чипы становятся плитками видов поиска справа.
   Виды, которых пока нет (нужна своя база ЕИС), приглушены и помечены «скоро». */
/* z-index: карточки, которые переезжают по сетке по диагонали, проходят под плиткой, а не поверх неё */
.new-tile { grid-column: span var(--span, 1); position: relative; z-index: 1; overflow: hidden; display: flex; min-width: 0; min-height: var(--row-h); padding: 0; border-radius: var(--r-lg); border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); text-align: left; box-shadow: 0 8px 24px var(--accent-ring); transition: transform .3s var(--ease), box-shadow .3s var(--ease), background-color .25s; }
.new-tile::before { content: ""; position: absolute; right: -72px; top: -72px; width: 220px; height: 220px; border-radius: 50%; border: 32px solid rgba(255, 255, 255, .08); transition: transform .6s var(--ease); pointer-events: none; }
.new-tile:hover { transform: translateY(-3px); background: var(--accent-hover); box-shadow: 0 16px 36px var(--accent-ring); }
.new-tile:hover::before { transform: scale(1.12); }
.new-tile:has(.nt-hit:active) { transform: translateY(-1px) scale(.99); }
/* Содержимое плитки: контейнер для раскладки узкой и широкой плитки. Во время анимации
   ширины app.js фиксирует его конечный размер, чтобы текст не перестраивался на каждом кадре */
.nt-box { container: tile / inline-size; position: relative; flex: 1; min-width: 0; display: flex; padding: 20px; }
.nt-ghost { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; }
.nt-hit { position: absolute; inset: 0; z-index: 1; padding: 0; border: 0; border-radius: inherit; background: none; color: inherit; cursor: pointer; }
.nt-hit:focus-visible { outline: 3px solid rgba(255, 255, 255, .7); outline-offset: -5px; }
.nt-in { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: space-between; gap: 16px; pointer-events: none; }
.nt-in button { position: relative; z-index: 2; pointer-events: auto; }
.nt-in button:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 2px; }
.nt-icon { position: relative; flex: none; width: 56px; height: 56px; border-radius: 16px; background: rgba(255, 255, 255, .16); display: grid; place-items: center; transition: transform .5s var(--spring); }
.new-tile:hover .nt-icon { transform: rotate(90deg); }
.nt-title { display: block; width: fit-content; max-width: 100%; font: 700 22px/28px var(--display); letter-spacing: -.01em; }
/* Ширина постоянная — перенос строк одинаковый в любой широкой плитке, подзаголовок переезжает, а не мигает */
.nt-sub { display: none; width: fit-content; max-width: 170px; margin-top: 4px; font-size: 14px; line-height: 20px; opacity: .86; }
.nt-k { display: block; width: fit-content; margin: 14px 0 8px; font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; opacity: .78; }
.nt-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nt-chips button { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px 0 9px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .22); background: rgba(255, 255, 255, .14); color: inherit; font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: background-color .15s, transform .15s var(--ease); }
.nt-chips button:hover { background: rgba(255, 255, 255, .26); }
.nt-chips button:active, .nt-type:active { transform: scale(.96); }
.nt-chips svg { flex: none; opacity: .85; }
.nt-chips .is-soon { background: rgba(255, 255, 255, .06); border-color: rgba(255, 255, 255, .14); color: rgba(255, 255, 255, .78); }
.nt-chips i { width: 6px; height: 6px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.nt-types { display: none; }
.nt-type { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; min-height: 64px; padding: 10px 12px; border-radius: 14px; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .12); color: inherit; text-align: left; cursor: pointer; transition: background-color .15s, transform .2s var(--ease); }
.nt-type:hover { background: rgba(255, 255, 255, .26); transform: translateY(-1px); }
.nt-type.is-soon { background: rgba(255, 255, 255, .06); color: rgba(255, 255, 255, .82); }
.nt-type:first-child { grid-column: 1 / -1; flex-direction: row; align-items: center; background: rgba(255, 255, 255, .2); }
.nt-type > svg { flex: none; opacity: .9; }
.nt-tl { font: 600 13px/16px var(--font); }
.nt-type .soon { position: absolute; top: 9px; right: 9px; height: 18px; padding: 0 6px; border-radius: 999px; background: rgba(255, 255, 255, .14); font: 600 10px/18px var(--font); }
@container tile (min-width: 500px) {
  .nt-in { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 300px); grid-template-rows: auto 1fr; gap: 0 28px; }
  .nt-in > .nt-icon { grid-area: 1 / 1; }
  .nt-main { grid-area: 2 / 1; align-self: end; }
  .nt-sub { display: block; }
  .nt-chipwrap { display: none; }
  .nt-types { grid-area: 1 / 2 / 3 / 3; align-self: center; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
/* Во всю ширину — виды поиска в один ряд по нижней линии, рядом с названием */
@container tile (min-width: 820px) {
  .nt-in { grid-template-columns: minmax(0, 1fr) minmax(0, 620px); }
  .nt-types { align-self: end; grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .nt-type, .nt-type:first-child { grid-column: auto; flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 112px; padding: 10px; }
  .nt-type .nt-tl { font-size: 12px; line-height: 15px; }
}

/* ---------- Как устроен поиск — пока истории нет ---------- */
.how { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin: 0 0 28px; padding: 0; list-style: none; }
.how li { display: flex; gap: 14px; min-width: 0; }
.how b { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; font: 700 14px/1 var(--display); color: var(--accent-text); }
.how-t { display: block; font: 600 15px/22px var(--font); color: var(--text); }
.how-s { display: block; margin-top: 2px; font-size: 13px; line-height: 19px; color: var(--muted); }

/* ---------- Колода «Ранее» ---------- */
.deck { grid-column: 1 / -1; position: relative; display: flex; align-items: center; gap: 28px; min-height: 152px; padding: 20px 20px 20px 24px; border-radius: var(--r-xl); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--sh-1); text-align: left; cursor: pointer; transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .3s; }
.deck:hover { transform: translateY(-2px); box-shadow: var(--sh-3); border-color: var(--accent-line); }
.deck:active { transform: translateY(0) scale(.995); }
.fan { position: relative; flex: none; width: 268px; height: 112px; }
.mini { position: absolute; top: 8px; left: 4px; width: 176px; height: 96px; display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2); transition: transform .55s var(--spring); }
.mini-1 { z-index: 1; transform: rotate(-7deg); }
.mini-2 { z-index: 2; transform: translateX(44px) rotate(-1deg); }
.mini-3 { z-index: 3; transform: translateX(88px) rotate(5deg); }
.deck:hover .mini-1 { transform: translate(-8px, -4px) rotate(-11deg); }
.deck:hover .mini-2 { transform: translate(44px, -10px) rotate(-1deg); }
.deck:hover .mini-3 { transform: translate(98px, -4px) rotate(9deg); }
.mini .badge { align-self: flex-start; max-width: 100%; height: 22px; padding: 0 8px; font-size: 11px; }
.mini-t { color: var(--text-2); font-size: 12px; line-height: 16px; font-weight: 600; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; overflow-wrap: anywhere; }
.deck-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.deck-k { font: 600 12px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.deck-n { font: 700 26px/32px var(--display); letter-spacing: -.02em; color: var(--text); }
.deck-cap { color: var(--muted); font-size: 14px; line-height: 20px; }
.deck-cta { flex: none; display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 6px 0 16px; border-radius: var(--r-md); background: var(--accent-soft); color: var(--accent-text); font: 600 14px/1 var(--font); }
.deck-cta i { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; transition: transform .35s var(--spring); }
.deck:hover .deck-cta i { transform: translateY(2px); }

/* Раскрытый блок «Ранее» */
.older-h { display: flex; align-items: center; gap: 12px; min-height: 36px; margin: 36px 0 14px; }
.older-t { margin: 0; font: 600 13px/18px var(--font); letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); white-space: nowrap; }
.older-c { min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font: 700 12px/28px var(--font); text-align: center; }
.older-line { flex: 1; min-width: 16px; height: 1px; background: var(--line); }
.older-h .btn svg { transition: transform .3s var(--spring); }
.older-h .btn:hover svg { transform: translateY(-2px); }
#older { display: flow-root; } /* отступ заголовка остаётся внутри блока — высота считается честно */
/* Пока блок сворачивается, его содержимое не растягивает страницу: высота уменьшается плавно */
#older.is-busy { pointer-events: none; overflow: clip; overflow-clip-margin: 24px; }

/* ---------- Пусто ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 16px; padding: 48px 16px; border: 1px dashed var(--line-strong); border-radius: var(--r-xl); text-align: center; color: var(--muted); }
.empty b { color: var(--text); font-size: 16px; }

/* ---------- Экран нового поиска: «на основе» прошлого поиска (остальное — search.css) ---------- */
.based { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; min-height: 36px; margin-bottom: 16px; padding: 6px 14px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 14px; font-weight: 600; }
.based svg { flex: none; }
.based span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Анимация ---------- */
@keyframes deck-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes fan-1 { from { transform: translateX(44px) rotate(0); } }
@keyframes fan-3 { from { transform: translateX(44px) rotate(0); } }
#home.settled .rise { animation: none; }
.deck.deck-in { animation: deck-in .45s var(--ease) backwards; }
.deck.deck-in .mini-1 { animation: fan-1 .7s var(--spring) .08s backwards; }
.deck.deck-in .mini-3 { animation: fan-3 .7s var(--spring) .08s backwards; }

/* ---------- Ряд действий в карточке ----------
   Главная кнопка и ряд «Повторить · Удалить» лежат в одной ячейке — ширина и высота не меняются.
   Открытие: кнопка уходит влево, «⋯» поворачивается в крестик, действия выезжают справа по очереди.
   Закрытие — в обратном порядке. */
.foot-area { flex: 1; min-width: 0; display: grid; }
.foot-area > * { grid-area: 1 / 1; min-width: 0; display: flex; gap: 6px; }
.lay-a { transition: opacity .16s var(--ease) .05s, transform .22s var(--ease) .05s, visibility 0s .05s; }
.card.acting .lay-a { opacity: 0; transform: translateX(-10px); visibility: hidden; transition: opacity .1s var(--ease), transform .18s var(--ease), visibility 0s .18s; }
.lay-b { visibility: hidden; transition: visibility 0s .16s; }
.lay-b .btn.btn-main { padding: 0 6px; opacity: 0; transform: translateX(var(--from, 10px)); transition: opacity .1s var(--ease) var(--out, 0s), transform .14s var(--ease) var(--out, 0s); }
.lay-b .btn.btn-main:nth-last-child(1) { --in: .02s; --out: .02s; --from: 8px; }
.lay-b .btn.btn-main:nth-last-child(2) { --in: .06s; --out: 0s; --from: 16px; }
.card.acting .lay-b { visibility: visible; transition: none; }
.card.acting .lay-b .btn.btn-main { opacity: 1; transform: none; transition: opacity .16s var(--ease) var(--in), transform .22s var(--ease) var(--in), background-color .15s, border-color .15s; }
/* «⋯» и крестик в одной кнопке: одна иконка поворачивается и уходит, другая встаёт на её место */
.more > span { grid-area: 1 / 1; display: grid; transition: opacity .14s var(--ease), transform .24s var(--ease); }
.more .i-x { opacity: 0; transform: rotate(-90deg) scale(.6); }
.card.acting .more { background: var(--surface-3); border-color: transparent; color: var(--text); }
.card.acting .more .i-more { opacity: 0; transform: rotate(90deg) scale(.6); }
.card.acting .more .i-x { opacity: 1; transform: none; }

/* ---------- Удаление и возврат ---------- */
.ghost { position: absolute; z-index: 15; margin: 0 !important; pointer-events: none; }
@keyframes restored { from { box-shadow: 0 0 0 3px var(--accent-ring), var(--sh-3); border-color: var(--accent); } }
.card.restored { animation: restored 1.2s var(--ease); }
@keyframes pulse-n { 40% { transform: scale(1.08); color: var(--accent-text); } }
.deck-n.changed { display: inline-block; animation: pulse-n .5s var(--spring); transform-origin: left center; }

/* ---------- Экраны ---------- */
/* Страховка для узкой карточки: цифры и статус чуть мельче, но целиком */
/* Узкая карточка: у «Открыть анализ» рядом значок Excel и «⋯» — стрелка уступает место тексту */
@container (max-width: 300px) {
  .lay-a .btn-main.btn-accent > svg { display: none; }
}
@container (max-width: 236px) {
  .s2 .v { font-size: 16px; }
}
@media (max-width: 640px) {
  .card { min-height: 224px; }
  .new-tile { min-height: 160px; }
  .how { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .deck { flex-direction: column; align-items: stretch; gap: 16px; padding: 20px; }
  .fan { align-self: center; }
  .deck-cta { justify-content: space-between; }
}
