/* МедРеестр, облегчённая версия — экран «Новый поиск»: сводка-навигация слева, редактор раздела справа,
   коды и группы КТРУ, регионы, список ИНН, календарь. Токены и общие элементы — ../shared/base.css. */

/* ---------- Мелкие общие ---------- */
.kicker { color: var(--faint); font: 600 11px/16px var(--font); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.hint { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0; color: var(--muted); font-size: 13px; line-height: 18px; }
.hint > svg { flex: none; width: 14px; height: 14px; }
.input { width: 100%; height: 44px; padding: 0 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); color: var(--text); outline: 0; transition: border-color .2s, box-shadow .2s; }
.input::placeholder { color: var(--faint); }
.input:hover { border-color: var(--line-strong); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.link { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; border: 0; border-radius: 8px; background: none; color: var(--accent-text); font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: background-color .15s, color .15s; }
.link:hover { background: var(--accent-soft); }
.link svg { flex: none; width: 14px; height: 14px; }
.link-mute { color: var(--muted); }
.link-mute:hover { background: var(--surface-3); color: var(--text); }
.err { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: var(--r-md); background: var(--danger-soft); color: var(--danger); font: 600 13px/18px var(--font); animation: pop-in .2s var(--ease); }
.err:empty { display: none; }
.err svg { flex: none; width: 14px; height: 14px; }
.t-bad { color: var(--danger); font-weight: 600; }
.t-warn { color: var(--warn); font-weight: 600; }
mark { padding: 0 1px; border-radius: 3px; background: var(--warn-soft); color: inherit; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } }
@keyframes tk-in { from { opacity: 0; transform: scale(.9); } }
/* Отметка: квадрат, галочка или чёрточка (выбрано частично) */
.ck { flex: none; width: 18px; height: 18px; display: grid; place-items: center; border-radius: 5px; border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--on-accent); font-style: normal; transition: background-color .15s, border-color .15s; }
.ck svg { width: 12px; height: 12px; stroke-width: 3; }
.ck b { width: 8px; height: 2px; border-radius: 1px; background: currentColor; }
.ck.on { border-color: var(--accent); background: var(--accent); }
.ck.mixed { border-color: var(--accent); color: var(--accent-text); }

/* ---------- Экран: шапка, сводка слева, редактор справа ----------
   На широком экране search.js задаёт высоту .np по окну: страница не прокручивается. */
.np-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 24px 0 18px; }
.np-back { width: 44px; height: 44px; border-radius: var(--r-md); }
.np-back svg { transition: transform .25s var(--ease); }
.np-back:hover svg { transform: translateX(-3px); }
.np-head .h1 { margin: 0; }
.np-head .based { margin: 0; }
.np { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 16px; min-height: 0; }
.wrap:has(> #new:not([hidden])) { padding-bottom: 24px; }

.np-nav { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 18px 16px 20px; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2); }
/* Шаги условий: строки одной высоты, подсветка открытого переезжает */
.nv { position: relative; display: flex; flex-direction: column; gap: 4px; }
.nv-ind { position: absolute; left: 0; right: 0; top: 0; height: 80px; border-radius: 14px; background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent-line); transition: transform var(--move, .36s) var(--ease); pointer-events: none; }
.nv-row { position: relative; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 12px; align-items: start; width: 100%; height: 80px; padding: 14px; border: 0; border-radius: 14px; background: none; color: inherit; text-align: left; cursor: pointer; transition: background-color .15s; }
.nv-row:not(.is-on):hover { background: var(--surface-2); }
.nv-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font: 700 12px/1 var(--display); transition: background-color .3s var(--ease), color .3s; }
.nv-row.is-on .nv-n { background: var(--accent); color: var(--on-accent); }
.nv-row.is-bad .nv-n { background: var(--danger-soft); color: var(--danger); }
.nv-tx { min-width: 0; }
.nv-t { display: block; color: var(--text); font: 600 15px/20px var(--font); }
.nv-v { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; margin-top: 2px; color: var(--muted); font-size: 13px; line-height: 18px; overflow-wrap: anywhere; }
.nv-row.is-bad .nv-v { color: var(--danger); font-weight: 600; }
.nv-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 14px 4px 0; border-top: 1px solid var(--line-soft); }
.np-name { display: grid; gap: 6px; animation: pop-in .2s var(--ease); }
.np-name[hidden] { display: none; }
.np-name > span { color: var(--muted); font-size: 13px; }
.name-link { align-self: flex-start; margin-left: -8px; }
.np-nav .btn-primary { width: 100%; }
.btn-primary svg { transition: transform .25s var(--ease); }
.btn-primary:hover svg { transform: translateX(3px); }

.np-pane { min-height: 0; display: flex; flex-direction: column; border-radius: var(--r-xl); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-1); overflow: hidden; }
.pn-h { flex: none; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 20px; padding: 22px 28px 16px; }
.pn-t { margin: 2px 0 0; font: 700 24px/30px var(--display); letter-spacing: -.01em; }
/* Место под полосу прокрутки зарезервировано: она не появляется и не исчезает со сдвигом */
.pn-b { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; scrollbar-gutter: stable; overscroll-behavior: contain; padding: 4px 20px 24px 28px; }
.pn-f { flex: none; display: flex; align-items: center; gap: 12px; min-height: 68px; padding: 12px 28px; border-top: 1px solid var(--line-soft); }
.pn-f .btn { height: 40px; padding: 0 14px; font-size: 14px; }
.pn-sp { flex: 1; }
.back-ic { display: inline-flex; transform: rotate(180deg); }
.btn-next svg { transition: transform .25s var(--ease); }
.btn-next:hover svg { transform: translateX(3px); }

.seg { display: inline-flex; gap: 2px; max-width: 100%; padding: 3px; border-radius: 12px; background: var(--surface-3); }
.seg button { display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 9px; background: none; color: var(--muted); font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: background-color .2s var(--ease), color .2s, box-shadow .2s; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--sh-1); }
.seg svg { flex: none; }

/* ---------- Выбранное: одна строка постоянной высоты ---------- */
.selrow { position: relative; flex: none; display: flex; align-items: center; gap: 8px; height: 32px; }
.selrow > .kicker { flex: none; margin-right: 2px; }
.sel-line { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; overflow: hidden; }
.sel-line > .token { flex: none; }
.sel-empty { color: var(--faint); font-size: 13px; white-space: nowrap; }
.sel-empty.t-bad { color: var(--danger); }
.sel-clear { flex: none; }
.token { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 100%; height: 32px; padding: 0 4px 0 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font: 600 13px/1 var(--font); white-space: nowrap; }
/* Метка региона с длинным названием обрезается; метка кода — всегда целиком, с подписью */
.token:has(> span:first-child) { max-width: 260px; }
.token.is-new { animation: tk-in .28s var(--ease); }
.token > b { flex: none; font-variant-numeric: tabular-nums; }
.token > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.token .n { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent-ring); font-size: 11px; line-height: 20px; text-align: center; }
.token button { flex: none; width: 24px; height: 24px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: none; color: inherit; cursor: pointer; transition: background-color .15s; }
.token button:hover { background: var(--accent-ring); }
.token button svg { width: 14px; height: 14px; }
.tk-n { flex: none; font-size: 11px; font-weight: 600; opacity: .8; }
/* Неактуальный код: красный, статус и дата обновления мелко в той же метке */
.token.is-old, .token.is-bad { background: var(--danger-soft); color: var(--danger); }
.token.is-old button:hover, .token.is-bad button:hover { background: rgba(127, 127, 127, .2); }
.token.is-wait { color: var(--muted); }
.kd-more { align-self: flex-start; margin: 4px 8px; }
.tk-d { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; padding-left: 8px; margin-left: 2px; border-left: 1px solid currentColor; border-left-color: color-mix(in srgb, currentColor 30%, transparent); font-size: 11px; font-weight: 500; line-height: 14px; opacity: .85; }
.sel-more { flex: none; display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 10px 0 12px; border-radius: 999px; border: 1px dashed var(--line-strong); background: none; color: var(--text-2); font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: border-color .15s, background-color .15s, color .15s, transform .15s var(--ease); }
.sel-more:hover, .sel-more[aria-expanded="true"] { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent-text); }
.sel-more:active { transform: scale(.96); }
.sel-more svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.sel-more[aria-expanded="true"] svg { transform: rotate(180deg); }
.sel-pop { position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 20; display: flex; flex-direction: column; gap: 10px; padding: 12px 12px 14px 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--sh-3); transform-origin: top left; }
.sel-pop[hidden] { display: none; }
.sel-pop-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sel-pop-h b { font: 600 14px/20px var(--font); color: var(--text); }
.sel-pop-b { display: flex; flex-wrap: wrap; gap: 6px; max-height: 240px; overflow: auto; }

/* ---------- Товары ---------- */
.types { flex: none; display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.type { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.type:hover { border-color: var(--line-strong); }
.type:active { transform: scale(.96); }
.type svg { flex: none; }
.type[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent-text); }
.type.is-soon { color: var(--faint); border-style: dashed; }
/* Условия поиска — строками; слева «и / или», рамка — группа, за ручку строка переносится */
.sg-k.is-wide { width: auto; min-width: 52px; padding: 0 9px; }
.sg-st.is-n { background: var(--surface-3); color: var(--muted); white-space: nowrap; }
.sg-sec { margin: 10px 0 2px; }
.sg-list > .sg-sec:first-child { margin-top: 0; }
.sg-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
/* Пока в поле есть текст, подсказки — сразу под ним, условия ниже */
.pn-b.has-q > .pk-field, .pn-b.has-q > .f-to { order: -3; }
.pn-b.has-q > .sugs { order: -2; flex: none; max-height: 48vh; overflow: auto; padding-bottom: 8px; border-bottom: 1px solid var(--line-soft); }
.f-to:empty { display: none; }
.conds { flex: none; display: flex; flex-direction: column; gap: 12px; }
.found { flex: 1; margin: 0; color: var(--muted); font-size: 13px; line-height: 20px; overflow-wrap: anywhere; }
.found b { color: var(--text); font-weight: 600; }
.cond-foot { display: flex; align-items: flex-start; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.grip { flex: none; display: grid; place-items: center; color: var(--faint); cursor: grab; touch-action: none; }
/* Слово связи: нажатие меняет «и» на «или». «или» — акцентом, «и» — спокойным: вид связи заметен без чтения */
.jw { min-width: 48px; height: 32px; padding: 0 10px; border: 1px solid transparent; border-radius: 999px; background: var(--surface-3); color: var(--text-2); font: 600 13px/1 var(--font); cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.jw[data-op="or"] { background: var(--accent-soft); color: var(--accent-text); }
.jw:hover { border-color: currentColor; }
.jw:active { transform: scale(.94); }
.is-src { opacity: .35; }
.cnd-ghost { position: fixed; z-index: 70; pointer-events: none; opacity: .95; box-shadow: var(--sh-3) !important; background: var(--surface) !important; }
body.cnd-dragging, body.cnd-dragging * { cursor: grabbing !important; user-select: none; }
.r-row.is-new { animation: cnd-flash 1.1s var(--ease); }
@keyframes cnd-flash { 0%, 45% { box-shadow: 0 0 0 3px var(--accent-ring); border-color: var(--accent-line); } }
.rl { display: flex; flex-direction: column; gap: 6px; }
.r-line { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 8px; align-items: start; }
.r-line > .jw { justify-self: end; margin-top: 7px; }
.r-0 { justify-self: end; padding: 0 10px; color: var(--faint); font: 400 13px/46px var(--font); }
.r-row { position: relative; display: grid; grid-template-columns: 40px 116px minmax(0, 1fr) 40px; align-items: center; min-height: 46px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.r-row:hover { border-color: var(--line-strong); }
.r-row.is-bad, .r-row.is-old { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.r-row .grip { width: 40px; height: 44px; padding: 0; border: 0; border-radius: var(--r-md); background: none; }
.r-row .grip:hover { color: var(--text); }
.r-k { color: var(--muted); font-size: 13px; }
.r-v { min-width: 0; padding: 6px 0; font-size: 14px; line-height: 18px; }
.r-v b { font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.r-v em { margin-left: 8px; color: var(--danger); font-size: 12px; font-style: normal; font-weight: 600; }
.r-v span { display: block; color: var(--muted); font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-row .xb { flex: none; width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: none; color: var(--faint); cursor: pointer; transition: background-color .15s, color .15s; }
.r-row .xb:hover { background: var(--surface-3); color: var(--text); }
.r-row .xb svg { width: 14px; height: 14px; }
.r-grp { position: relative; padding: 10px 10px 4px 0; border: 1px dashed var(--line-strong); border-radius: 16px; background: var(--surface-2); }
.r-grp .r-grp { background: var(--surface); }
.r-grp > .link { margin: 4px 0 4px 58px; }
.r-line:has(> .r-grp) > .jw { margin-top: 18px; }
.r-line:has(> .r-grp) > .r-0 { line-height: 66px; }
.r-more { margin-left: 58px; align-self: flex-start; }
.dz-before::before, .dz-after::after { content: ""; position: absolute; left: 0; right: 0; height: 3px; border-radius: 3px; background: var(--accent); pointer-events: none; }
.dz-before::before { top: -5px; } .dz-after::after { bottom: -5px; }
.dz-on { border-color: var(--accent) !important; border-style: solid !important; box-shadow: 0 0 0 4px var(--accent-ring); }
.dz-on > .dz-t { display: block; }
.dz-t { display: none; position: absolute; right: 48px; top: -11px; z-index: 2; padding: 0 8px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font: 600 11px/20px var(--font); white-space: nowrap; }
.cnd-menu { position: fixed; z-index: 65; min-width: 220px; max-width: calc(100vw - 24px); padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--sh-3); }
.cnd-menu button { display: flex; align-items: center; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--text); font: 400 14px/18px var(--font); text-align: left; cursor: pointer; }
.cnd-menu button:hover, .cnd-menu button:focus-visible { background: var(--surface-3); }
.cnd-menu button.is-bad { color: var(--danger); }
.cnd-menu button:disabled { color: var(--faint); cursor: default; background: none; }
@media (max-width: 640px) {
  .r-line { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .r-line > .jw, .r-line:has(> .r-grp) > .jw { justify-self: start; margin: 0 0 0 10px; height: 40px; min-width: 56px; }
  .r-0 { display: none; }
  .r-row { grid-template-columns: 40px minmax(0, 1fr) 44px; }
  .r-k { grid-column: 2; padding-top: 8px; font-size: 12px; line-height: 14px; }
  .r-v { grid-column: 2; grid-row: 2; padding: 2px 0 8px; }
  .r-row .grip { grid-row: 1 / 3; height: 100%; } .r-row .xb { grid-column: 3; grid-row: 1 / 3; width: 44px; height: 44px; }
  .r-v span { white-space: normal; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .r-grp { padding: 10px; } .r-grp > .link, .r-more { margin-left: 2px; }
  .cond-foot { flex-wrap: wrap; } .cond-foot .found { flex-basis: 100%; }
}
.pk-field { flex: none; max-width: none; height: 48px; }
.code-note:empty { display: none; }
.code-note { margin-top: -8px; }
.sugs { display: flex; flex-direction: column; gap: 8px; }
.sg-list { display: flex; flex-direction: column; gap: 6px; }
.sug-empty { padding: 6px 0; }
.sgw { display: flex; flex-direction: column; }
.sg { display: flex; align-items: stretch; border: 1px solid var(--line-soft); border-radius: 12px; background: var(--surface); transition: background-color .15s, border-color .15s; }
.sg:hover, .sg.is-hi { border-color: var(--line-strong); }
.sg.is-on { background: var(--accent-soft); border-color: var(--accent-line); }
.sg.is-part { border-color: var(--accent-line); }
.sg.is-open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sg-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 12px 8px 14px; border: 0; border-radius: 12px; background: none; color: var(--text); text-align: left; cursor: pointer; }
.sg-k { flex: none; width: 52px; height: 24px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font: 600 11px/24px var(--font); text-align: center; }
.sg.is-on .sg-k { background: var(--surface); color: var(--accent-text); }
.sg-t { flex: 1; min-width: 0; display: grid; gap: 1px; }
.sg-t b { font: 600 14px/18px var(--font); font-variant-numeric: tabular-nums; }
.sg-t span { overflow: hidden; color: var(--muted); font-size: 12px; line-height: 16px; white-space: nowrap; text-overflow: ellipsis; }
.sg-st { flex: none; height: 20px; padding: 0 8px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); font: 600 11px/20px var(--font); font-style: normal; }
.sg-kids { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 56px; margin: 10px 10px 10px 0; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text-2); font: 600 13px/1 var(--font); font-variant-numeric: tabular-nums; cursor: pointer; transition: border-color .15s, color .15s, transform .15s var(--ease); }
.sg-kids:hover { border-color: var(--line-strong); color: var(--text); }
.sg-kids:active { transform: scale(.96); }
.sg-kids[aria-expanded="true"] { border-color: var(--accent-line); color: var(--accent-text); }
.sg-kids svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.sg-kids[aria-expanded="true"] svg { transform: rotate(180deg); }
/* Убрать код из истории */
.sg-x { flex: none; align-self: center; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; margin: 0 10px 0 -2px; border: 0; border-radius: 999px; background: none; color: var(--faint); cursor: pointer; transition: background-color .12s, color .12s; }
.sg-x:hover { background: var(--surface-3); color: var(--text); }
.sg-x svg { width: 14px; height: 14px; }
.kids { display: flex; flex-direction: column; gap: 2px; padding: 6px; border: 1px solid var(--line-soft); border-top: 0; border-radius: 0 0 12px 12px; background: var(--surface-2); }
.kids.is-new { animation: pop-in .24s var(--ease); }
.kd { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px 6px 14px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font-size: 13px; line-height: 18px; text-align: left; cursor: pointer; transition: background-color .12s; }
.kd:hover { background: var(--surface-3); }
.kd b { flex: none; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.kd > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--muted); }
.kd .sg-st { margin-left: auto; }
.kd.is-none { margin-bottom: 4px; border-bottom: 1px dashed var(--line-strong); border-radius: 8px 8px 0 0; }
.kd.is-none b { color: var(--text-2); }
.kd[hidden], .kq-empty[hidden] { display: none; }
/* Поиск внутри раскрытой группы: у настоящей группы КТРУ бывают сотни */
.kq { flex: none; max-width: none; height: 36px; margin: 0 0 6px; background: var(--surface); }
.kq input { font-size: 13px; }
.kq-empty { padding: 8px 14px; }

/* ---------- Заказчики: округа слева, регионы выбранного округа справа ---------- */
.rp { flex: none; display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); }
.rp-d { padding: 6px; border-right: 1px solid var(--line-soft); background: var(--surface-2); }
.rp-r { min-width: 0; padding: 10px 10px 12px; }
.dr { display: flex; align-items: center; min-height: 40px; border-radius: 10px; transition: background-color .12s, box-shadow .2s; }
.dr:hover { background: var(--surface-3); }
.dr.is-on, .dr.is-on:hover { background: var(--surface); box-shadow: var(--sh-1), inset 0 0 0 1px var(--line); }
.dr-ru { margin-bottom: 4px; }
.dr-ck { flex: none; width: 38px; height: 38px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; }
.dr-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 8px 0 0; border: 0; background: none; color: var(--text-2); font: 600 14px/18px var(--font); text-align: left; cursor: pointer; }
.dr-ru .dr-name { color: var(--text); font-weight: 700; cursor: default; }
.dr-name > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dr-short { display: none; }
.dr-name small { flex: none; margin-left: auto; color: var(--faint); font-size: 12px; font-weight: 400; font-variant-numeric: tabular-nums; }
.dr-name svg { flex: none; color: var(--faint); transition: transform .25s var(--ease), color .2s; }
.dr.is-on .dr-name svg { color: var(--accent-text); transform: translateX(2px); }
.rp-q { max-width: none; flex: none; height: 40px; margin-bottom: 6px; }
.rp-h { padding: 8px 10px 6px; color: var(--text); font: 600 14px/20px var(--font); }
.rgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; }
.rp-h.is-new, .rgrid.is-new { animation: pop-in .24s var(--ease); }
.ro { display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 10px; border: 0; border-radius: 8px; background: none; color: var(--text-2); font: 400 14px/18px var(--font); text-align: left; cursor: pointer; transition: background-color .12s; }
.ro:hover { background: var(--surface-3); }
.ro small { color: var(--faint); font-size: 12px; }
.rp-empty { padding: 14px 10px; }

/* Мои списки и ИНН по строкам; справа на той же строке — организация или ошибка */
.lists { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.lists:empty { display: none; }
.lists .kicker { margin-right: 4px; }
.lst { display: inline-flex; align-items: stretch; height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); overflow: hidden; transition: background-color .2s var(--ease), border-color .2s; }
.lst:hover { border-color: var(--line-strong); }
.lst-b { display: inline-flex; align-items: center; gap: 8px; padding: 0 4px 0 14px; border: 0; background: none; color: var(--text-2); font: 600 13px/1 var(--font); white-space: nowrap; cursor: pointer; }
.lst-b .n { min-width: 24px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font: 700 11px/22px var(--font); text-align: center; }
.lst-x { width: 30px; display: grid; place-items: center; padding: 0; border: 0; background: none; color: var(--faint); cursor: pointer; transition: color .15s; }
.lst-x:hover { color: var(--danger); }
.lst-x svg { width: 12px; height: 12px; }
.lst.is-on { background: var(--text); border-color: var(--text); }
.lst.is-on .lst-b, .lst.is-on .lst-x { color: var(--bg); }
.lst.is-on .n { background: rgba(127, 127, 127, .3); color: var(--bg); }
.ledger { flex: none; position: relative; overflow: hidden; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); transition: height .24s var(--ease), border-color .2s, box-shadow .2s; }
.ledger:hover { border-color: var(--line-strong); }
.ledger:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-ring); }
.lg-rows { position: absolute; left: 0; right: 0; top: 8px; pointer-events: none; }
.lg-row { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 14px 0 150px; color: var(--muted); font-size: 13px; line-height: 18px; }
.lg-row > span { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.lg-row i { flex: none; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; }
.lg-row i svg { width: 11px; height: 11px; stroke-width: 3; }
.s-ok i { background: var(--ok-soft); color: var(--ok); }
.s-ok span { color: var(--text-2); }
.s-bad { background: var(--danger-soft); }
.s-bad i, .s-bad span { color: var(--danger); }
.s-bad i { border: 1.5px solid currentColor; }
.s-none i { background: var(--warn-soft); color: var(--warn); }
.s-none span { color: var(--warn); }
.s-dup span, .s-typing span, .s-wait span, .s-dup i { color: var(--faint); }
.s-wait i::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: pulse 1s ease-in-out infinite; }
.lg-ta { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; padding: 8px 14px; border: 0; outline: 0; background: transparent; color: var(--text); font: 500 15px/32px var(--font); font-variant-numeric: tabular-nums; letter-spacing: .02em; white-space: pre; resize: none; overflow: auto; }
.lg-ta::placeholder { color: var(--faint); letter-spacing: 0; }
.inn-meta { flex: none; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.inn-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-left: -8px; }
.saved { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 8px; color: var(--ok); font: 600 13px/1 var(--font); }
.saved svg { width: 14px; height: 14px; }
.save-row { display: flex; flex-wrap: wrap; gap: 8px; width: 100%; padding-left: 8px; }
.save-row .input { flex: 1 1 260px; height: 40px; }
.save-row .btn { height: 40px; }

/* ---------- Период и календарь ---------- */
.opts { flex: none; display: flex; flex-wrap: wrap; gap: 6px; }
.opt { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font: 500 13px/1 var(--font); white-space: nowrap; cursor: pointer; transition: background-color .15s, border-color .15s, color .15s, transform .15s var(--ease); }
.opt:hover { border-color: var(--line-strong); }
.opt:active { transform: scale(.96); }
.opt[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.cal-top { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.cal-ins { display: flex; align-items: center; gap: 8px; color: var(--faint); }
.cal-in { width: 128px; height: 40px; padding: 0 10px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font: 600 14px/1 var(--font); font-variant-numeric: tabular-nums; text-align: center; outline: 0; transition: border-color .2s, box-shadow .2s; }
.cal-in:hover { border-color: var(--line-strong); }
.cal-in:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.cal-in.is-bad { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.cal-in::placeholder { color: var(--faint); font-weight: 400; }
.cal-n { color: var(--muted); font-size: 13px; }
.cal { flex: none; }
.cal-ms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 32px; }
.cal-mh { display: grid; grid-template-columns: 36px minmax(0, 1fr) 36px; align-items: center; height: 36px; margin-bottom: 4px; }
.cal-mh b { font: 600 14px/20px var(--font); text-align: center; }
.cal-nav { width: 36px; height: 36px; display: grid; place-items: center; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); cursor: pointer; transition: border-color .15s, transform .15s var(--ease); }
.cal-nav:hover:not(:disabled) { border-color: var(--line-strong); }
.cal-nav:active:not(:disabled) { transform: scale(.94); }
.cal-nav:disabled { opacity: .35; cursor: default; }
.cal-nav[data-nav="-1"] svg { transform: rotate(90deg); }
.cal-nav[data-nav="1"] svg { transform: rotate(-90deg); }
.cal-w { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); color: var(--faint); font: 600 11px/24px var(--font); text-align: center; }
.cal-g { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: var(--day-h, 36px); row-gap: 2px; }
.day { position: relative; height: 100%; padding: 0; border: 0; border-radius: 10px; background: none; color: var(--text); font: 500 14px/1 var(--font); font-variant-numeric: tabular-nums; cursor: pointer; transition: background-color .12s, color .12s; }
.day:hover:not(:disabled) { background: var(--surface-3); }
.day:disabled { color: var(--faint); opacity: .4; cursor: default; }
/* Период — сплошная полоса со скруглением на концах недели */
.day.in-r, .day.in-h { border-radius: 0; background: var(--accent-soft); color: var(--accent-text); }
.day.in-r.rl, .day.in-h.rl { border-radius: 10px 0 0 10px; }
.day.in-r.rr, .day.in-h.rr { border-radius: 0 10px 10px 0; }
.day.in-r.rl.rr { border-radius: 10px; }
.day.in-r:hover:not(:disabled) { background: var(--accent-line); }
.day.is-s, .day.is-e, .day.is-s:hover, .day.is-e:hover { background: var(--accent); color: var(--on-accent); }
.day.is-s { border-radius: 10px 0 0 10px; }
.day.is-e { border-radius: 0 10px 10px 0; }
.day.is-one, .day.is-s.rr, .day.is-e.rl { border-radius: 10px; }
.day.is-h, .day.is-h:hover:not(:disabled) { border-radius: 10px; background: var(--accent); color: var(--on-accent); }
.day.is-today::after { content: ""; position: absolute; left: 50%; bottom: 5px; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: currentColor; }

/* Невысокое окно ноутбука: плотнее, чтобы календарь вошёл без прокрутки */
@media (min-width: 861px) and (max-height: 820px) {
  .np-head { padding: 12px 0 10px; }
  .np-head .h1 { font-size: 28px; }
  .pn-h { padding: 16px 28px 12px; }
  .pn-b { gap: 12px; }
  .cal-g { --day-h: 32px; }
  .pn-f { min-height: 60px; padding: 10px 28px; }
}
@media (max-width: 1080px) and (min-width: 861px) {
  .np { grid-template-columns: 280px minmax(0, 1fr); }
  .rp { grid-template-columns: minmax(0, 190px) minmax(0, 1fr); }
  .rgrid { grid-template-columns: minmax(0, 1fr); }
  /* Округа коротко: ЦФО, СЗФО — полное название не помещается */
  .dr-full, .dr-ru small { display: none; }
  .dr-short { display: block; }
  .cal-ms { gap: 20px; }
}
/* Узкое окно: редактор сверху, сводка с кнопкой — под ним; прокручивается страница */
@media (max-width: 860px) {
  .np { grid-template-columns: minmax(0, 1fr); }
  .np-pane { order: -1; overflow: visible; }
  .pn-b { overflow: visible; }
  .np-nav { overflow: visible; }
  .rp { grid-template-columns: minmax(0, 1fr); }
  .rp-d { border-right: 0; border-bottom: 1px solid var(--line-soft); }
  /* Кнопка всегда под пальцем: закреплена внизу экрана, плашка встаёт над ней */
  .np-nav .btn-primary { position: fixed; left: 16px; right: 16px; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 30; width: auto; box-shadow: 0 8px 24px var(--accent-ring), var(--sh-3); }
  .wrap:has(> #new:not([hidden])) { padding-bottom: 96px; }
  .wrap:has(> #new:not([hidden])) ~ #toast-root .toast { bottom: 88px; }
}
@media (max-width: 640px) {
  .pn-h { padding: 18px 16px 12px; }
  .pn-b { padding: 4px 16px 20px; }
  .pn-f { padding: 12px 16px; }
  .np-nav { padding: 16px 12px 18px; }
  /* Две кнопки вида — без значков, чтобы встали в строку; не помещаются — переносятся, а не обрезаются */
  .type svg { display: none; }
  .type { padding: 0 12px; }
  .selrow > .kicker { display: none; }
  .token:has(> span:first-child) { max-width: 200px; }
  .rgrid { grid-template-columns: minmax(0, 1fr); }
  .lg-row { padding-left: 128px; font-size: 12px; }
  .lg-ta { font-size: 14px; letter-spacing: 0; }
  .cal-ms { grid-template-columns: minmax(0, 1fr); }
  .cal-in { width: 116px; }
  .sg-k { display: none; }
}
