/* МедРеестр, облегчённая версия — общий дизайн-код всех экранов.
   Токены, шапка, кнопки, поля, чипы, статусы, плашка, движение. Описание и правила — DESIGN.md.
   Цвета только через токены; тёмная тема переопределяет их. Отступы кратны 4/8 px.
   Экран подключает этот файл первым, а свой style.css — после него. */
:root {
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.45, .64, 1);
  --r-xl: 24px; --r-lg: 20px; --r-md: 12px; --r-sm: 10px;
  --font: "Onest", "Segoe UI", system-ui, sans-serif;
  --display: "Montserrat Alternates", "Onest", "Segoe UI", sans-serif;
  --bg: #F4F5F9; --surface: #FFFFFF; --surface-2: #F7F8FB; --surface-3: #EDEFF4;
  --line: #E2E5EC; --line-soft: #ECEEF3; --line-strong: #CBD0DB;
  --text: #13162A; --text-2: #2D3248; --muted: #565C72; --faint: #6F758A;
  --accent: #4F46E5; --accent-hover: #4338CA; --accent-text: #4F46E5; --accent-soft: #EEF0FF;
  --accent-line: #C4C8F7; --accent-ring: rgba(79, 70, 229, .18); --on-accent: #FFFFFF;
  --ok: #13693F; --ok-soft: #E2F3E8; --warn: #B91D59; --warn-soft: #FCE9F1;
  --info: #4F46E5; --info-soft: #EEF0FF; --queue: #4A5068; --queue-soft: #EEF0F5;
  --mute: #5F6578; --mute-soft: #EEF0F3;
  --danger: #B42318; --danger-hover: #912018; --danger-soft: #F0F1F5;  /* подложка ошибки — серая: красным только текст */
  --warn-fill: #B91D59; --warn-fill-hover: #A3184E;  /* залитая «Подтвердить» — главное действие карточки */
  --sum: #0F766E;  /* суммы в рублях — спокойным сине-зелёным, отдельно от цветов статусов */
  --sh-1: 0 1px 2px rgba(19, 22, 42, .05);
  --sh-2: 0 1px 2px rgba(19, 22, 42, .04), 0 6px 18px rgba(19, 22, 42, .06);
  --sh-3: 0 2px 4px rgba(19, 22, 42, .04), 0 16px 36px rgba(19, 22, 42, .12);
  --glass: rgba(244, 245, 249, .82);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0F1117; --surface: #171A22; --surface-2: #1C2029; --surface-3: #252A36;
  --line: #2A2F3C; --line-soft: #222631; --line-strong: #3B4252;
  --text: #E7E9F1; --text-2: #CDD1DC; --muted: #A6ACBE; --faint: #8D94A8;
  --accent: #6A63EE; --accent-hover: #7A74F1; --accent-text: #AEAAF9; --accent-soft: #25254A;
  --accent-line: #4A4890; --accent-ring: rgba(122, 116, 241, .28); --on-accent: #FFFFFF;
  --ok: #6BD39A; --ok-soft: #1A2D23; --warn: #F48AB0; --warn-soft: #35202B;
  --info: #AEAAF9; --info-soft: #25254A; --queue: #B9BED0; --queue-soft: #262B37;
  --mute: #A6ACBE; --mute-soft: #232733;
  --danger: #F0857A; --danger-hover: #F49B91; --danger-soft: #232733;
  --warn-fill: #CE1E64; --warn-fill-hover: #DA2C70;
  --sum: #5FCDBB;
  --sh-1: 0 1px 2px rgba(0, 0, 0, .35);
  --sh-2: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
  --sh-3: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 36px rgba(0, 0, 0, .45);
  --glass: rgba(15, 17, 23, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
/* Место под полосу прокрутки зарезервировано всегда: при смене экрана ширина и шапка не сдвигаются */
html { -webkit-text-size-adjust: 100%; scrollbar-gutter: stable; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 400 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Смена темы: снимок страницы плавно переходит в новый (core.js, startViewTransition) */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; animation-timing-function: var(--ease); }

/* ---------- Раскладка ---------- */
/* overflow-x: clip — въезд экрана сбоку не даёт горизонтальной прокрутки на телефоне */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px) 80px; overflow-x: clip; }

/* ---------- Шапка и переключатель темы ---------- */
.top { position: sticky; top: 0; z-index: 20; background: var(--glass); -webkit-backdrop-filter: saturate(1.6) blur(14px); backdrop-filter: saturate(1.6) blur(14px); border-bottom: 1px solid var(--line-soft); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 40px); height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; min-height: 44px; color: var(--text); text-decoration: none; font: 700 19px/1 var(--display); letter-spacing: -.01em; border-radius: var(--r-md); }
.mark { width: 36px; height: 36px; flex: none; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; transition: transform .45s var(--spring); }
.brand:hover .mark { transform: rotate(90deg); }

.top-r { display: flex; align-items: center; gap: 12px; }
.view-link { text-decoration: none; }
@media (max-width: 480px) {
  .top-r { gap: 8px; }
  .view-link { width: 40px; height: 40px; padding: 0; justify-content: center; }
  .vl-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}
.sw { position: relative; flex: none; width: 80px; height: 44px; padding: 0 15px 0 13px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; justify-content: space-between; cursor: pointer; transition: border-color .2s; }
.sw:hover { border-color: var(--line-strong); }
.knob { position: absolute; top: 5px; left: 5px; width: 32px; height: 32px; border-radius: 50%; background: var(--accent); box-shadow: 0 2px 8px var(--accent-ring); transition: transform .5s var(--spring); }
.sw[aria-pressed="true"] .knob { transform: translateX(36px); }
.sw svg { position: relative; z-index: 1; transition: color .35s var(--ease), transform .5s var(--spring); }
.i-sun { color: var(--on-accent); }
.sw[aria-pressed="true"] .i-sun { color: var(--faint); transform: rotate(-90deg) scale(.82); }
.i-moon { color: var(--faint); transform: rotate(40deg) scale(.82); }
.sw[aria-pressed="true"] .i-moon { color: var(--on-accent); transform: none; }

/* ---------- Заголовок экрана ---------- */
.head { padding: 36px 0 24px; }
.h1 { margin: 0; font: 700 clamp(28px, 1.4vw + 18px, 36px)/1.15 var(--display); letter-spacing: -.02em; text-wrap: balance; }
.back { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin: 20px 0 0 -10px; padding: 0 14px 0 10px; border: 0; border-radius: var(--r-md); background: none; color: var(--muted); font: 600 15px/1 var(--font); cursor: pointer; transition: background-color .15s, color .15s; }
.back:hover { background: var(--surface-3); color: var(--text); }
.back svg { transition: transform .25s var(--ease); }
.back:hover svg { transform: translateX(-3px); }
.crumbs { display: flex; gap: 8px; margin-top: 8px; color: var(--faint); font-size: 13px; }
.crumbs-here { color: var(--text-2); }

/* ---------- Поле поиска и чипы ---------- */
.search { flex: 1 1 280px; max-width: 400px; height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); color: var(--faint); transition: border-color .2s, box-shadow .2s; }
.search:hover { border-color: var(--line-strong); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; background: none; color: var(--text); -webkit-appearance: none; appearance: none; }
.search input::placeholder { color: var(--faint); }
.search input::-webkit-search-cancel-button { display: none; }
.clear { width: 32px; height: 32px; flex: none; border-radius: 8px; border: 0; background: none; color: var(--faint); display: grid; place-items: center; cursor: pointer; transition: background-color .15s, color .15s; }
.clear:hover { background: var(--surface-3); color: var(--text); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { height: 44px; padding: 0 8px 0 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: 600 14px/1 var(--font); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; cursor: pointer; transition: background-color .2s var(--ease), color .2s, border-color .2s, transform .15s var(--ease); }
.chip:hover { border-color: var(--line-strong); }
.chip:active { transform: scale(.96); }
.chip .n { 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; font-variant-numeric: tabular-nums; transition: background-color .2s, color .2s; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip[aria-pressed="true"] .n { background: rgba(127, 127, 127, .28); color: var(--bg); }
.chip.is-zero { color: var(--faint); }

/* ---------- Кнопки ----------
   .btn — обычная; варианты идут после неё, иначе её фон перебивает их. */
.btn { height: 36px; padding: 0 12px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: 600 13px/1 var(--font); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.btn:active { transform: scale(.96); }
.btn-accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }
.btn-accent:hover { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.btn-warn { background: var(--warn-fill); border-color: transparent; color: #FFFFFF; }
.btn-warn:hover { background: var(--warn-fill-hover); border-color: transparent; color: #FFFFFF; }
.btn.btn-danger-soft { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.btn-danger-soft:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn-primary { height: 48px; padding: 0 20px; border: 0; border-radius: var(--r-md); background: var(--accent); color: var(--on-accent); font: 600 15px/1 var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; box-shadow: 0 6px 18px var(--accent-ring); transition: background-color .15s, transform .15s var(--ease), box-shadow .2s, opacity .2s; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { cursor: not-allowed; opacity: .5; box-shadow: none; transform: none; background: var(--accent); }
.bt { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.icon-btn:active { transform: scale(.94); }

/* ---------- Статусы и мягкие блоки ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; min-width: 0; height: 24px; padding: 0 9px; border-radius: 999px; font: 600 11px/1 var(--font); letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bdot { width: 6px; height: 6px; flex: none; border-radius: 50%; background: currentColor; transform: translateY(-.5px); }
/* Подпись ровно 12 px высотой — встаёт на целые пиксели, точка по центру строчных букв */
.blabel { position: relative; top: -1px; display: block; line-height: 12px; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-queue { background: var(--queue-soft); color: var(--queue); }
.b-mute { background: var(--mute-soft); color: var(--mute); }
.b-bad { background: var(--danger-soft); color: var(--danger); }
.b-info .bdot { animation: pulse 1.6s ease-in-out infinite; }
.panel { min-height: 64px; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line-soft); }
.bar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-fill { position: relative; height: 100%; border-radius: inherit; background: var(--accent); overflow: hidden; }
.bar-fill::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .5), transparent); transform: translateX(-100%); animation: shimmer 1.8s ease-in-out infinite; }

/* ---------- Плашка внизу: «Удалено · Отменить» ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; display: flex; align-items: center; gap: 16px; max-width: min(560px, calc(100% - 32px)); min-height: 52px; padding: 8px 8px 8px 18px; border-radius: 16px; background: var(--text); color: var(--bg); box-shadow: var(--sh-3); font-size: 14px; transform: translateX(-50%); overflow: hidden; }
.toast span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { flex: none; height: 36px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(127, 127, 127, .28); color: inherit; font: 600 14px/1 var(--font); cursor: pointer; }
.toast button:hover { background: rgba(127, 127, 127, .42); }
.toast i { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--accent); transform-origin: left; animation: toast-time var(--toast-time, 6s) linear forwards; }
@keyframes toast-time { to { transform: scaleX(0); } }
.toast:not(:has(button)) { padding-right: 18px; }

/* ---------- Движение ----------
   Переезд 360 мс, появление 280 мс, исчезновение 160 мс; кривая --ease. Подробно — DESIGN.md. */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes pulse { 50% { opacity: .3; } }
@keyframes slide-fwd { from { opacity: 0; transform: translateX(28px); } }
@keyframes slide-back { from { opacity: 0; transform: translateX(-28px); } }
.rise { animation: rise .5s var(--ease) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
.screen-fwd { animation: slide-fwd .4s var(--ease) backwards; }
.screen-back { animation: slide-back .4s var(--ease) backwards; }

@media (max-width: 640px) {
  .top-in { height: 64px; }
  .brand { font-size: 17px; }
  .mark { width: 32px; height: 32px; }
  .head { padding: 24px 0 18px; }
  .search { max-width: none; flex-basis: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 32px); margin: 0 -16px; padding: 0 16px; scrollbar-width: none; scroll-snap-type: x proximity; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: .01ms !important; }
}
