/* fkr-scan2 — веб-интерфейс. Ко-бренд Софтлайн Аутсорсинг + ФКР МО. Только системные шрифты. */
:root {
  --bg: #EBEEF2;
  --bg-2: #E2E6EB;
  --surface: #FFFFFF;
  --line: #D3D9E0;
  --line-2: #E6EAEE;
  --ink: #383E48;          /* графит */
  --ink-2: #5A6270;        /* 6:1 на белом */
  --ink-3: #7A828F;        /* только крупное/служебное */
  --azure: #1E9CD7;        /* фирменный азур — полосы, выделение */
  --azure-bg: #E5F3FB;
  --btn: #0E6C99;          /* глубокий азур — кнопки, 5.9:1 с белым */
  --btn-hover: #0A5A80;
  --terra: #E8641E;        /* акцент ФКР — только «проверьте» */
  --terra-ink: #A3440E;    /* текст в терракоте, 5.6:1 */
  --terra-bg: #FDF0E7;
  --err: #B42318;
  --err-bg: #FCEBE9;
  --ok: #257046;
  --ok-bg: #E7F3EC;
  --stage: #383E48;        /* «световой стол» под сканом */
  --radius-s: 6px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(56, 62, 72, .08), 0 4px 14px rgba(56, 62, 72, .06);
  --focus: 0 0 0 3px #FFFFFF, 0 0 0 5px var(--btn);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --t: 160ms cubic-bezier(.2, .7, .3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { overflow-x: hidden; }
body {
  margin: 0;
  font: 15px/1.5 var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.h2 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -.005em; }
.h3 { font-size: 15px; font-weight: 650; margin: 0 0 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ic--s { width: 16px; height: 16px; }

:focus-visible { outline: none; box-shadow: var(--focus); }
.skip { position: absolute; left: 8px; top: -60px; background: var(--btn); color: #fff; padding: 10px 14px; border-radius: var(--radius-s); z-index: 100; }
.skip:focus { top: 8px; }

/* ---------- Кнопки ---------- */
.btn {
  text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--radius-s);
  border: 1px solid transparent; font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.btn--primary { background: var(--btn); color: #fff; }
.btn--primary:hover { background: var(--btn-hover); }
.btn--secondary { background: var(--surface); border-color: var(--btn); color: var(--btn); }
.btn--secondary:hover { background: var(--azure-bg); }
.btn--ghost { background: transparent; color: var(--ink); }
.btn--ghost:hover { background: var(--bg-2); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: var(--radius-s); background: transparent; color: var(--ink);
}
.icon-btn:hover { background: var(--bg-2); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--azure-bg); color: var(--btn);
}
.chip:empty { display: none; }

/* ---------- Шапка ---------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  height: 64px; padding: 0 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar::after { /* тонкая фирменная полоса */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--azure) 0 72%, var(--terra) 72% 100%);
}
.brand { display: flex; align-items: center; gap: 14px; flex: none; }
.brand__logo { display: block; height: 38px; width: auto; }
.brand__logo--fkr { height: 40px; }
.brand__sep { width: 1px; height: 28px; background: var(--line); }
.topbar__title { font-size: 16px; font-weight: 600; margin: 0 0 0 8px; color: var(--ink-2); white-space: nowrap; }
.topbar__right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.demo-flag { font-size: 12px; color: var(--terra-ink); background: var(--terra-bg); padding: 4px 10px; border-radius: 999px; }

/* ---------- Раскладка ---------- */
.app { height: calc(100vh - 64px); height: calc(100dvh - 64px); display: grid; }
.app[data-state="empty"] { grid-template-columns: 1fr; }
.app[data-state="empty"] .queue, .app[data-state="empty"] .work { display: none; }
.app[data-state="work"] { grid-template-columns: 300px minmax(0, 1fr); }
.app[data-state="work"] .hero { display: none; }

/* ---------- Пустой экран ---------- */
.hero { display: grid; place-items: center; padding: 32px; }
.drop {
  display: flex; cursor: pointer; border: 2px dashed #A9B4C1; background: var(--surface);
  transition: border-color var(--t), background var(--t);
}
.drop:hover, .drop.is-over { border-color: var(--azure); background: #F4FAFD; }
.drop--big {
  width: min(760px, 100%); min-height: 420px; border-radius: 18px;
  flex-direction: column; align-items: center; justify-content: center; text-align: center;
  padding: 48px 40px; gap: 6px;
}
.drop__art { position: relative; width: 120px; height: 120px; margin-bottom: 18px; }
.sheet {
  position: absolute; inset: 10px 18px; border-radius: 6px; background: var(--surface);
  border: 1.5px solid #B7C1CC; transition: transform 260ms cubic-bezier(.2, .8, .3, 1.2);
}
.sheet--3 { transform: rotate(-9deg) translate(-8px, 4px); background: #F1F4F7; }
.sheet--2 { transform: rotate(6deg) translate(8px, 2px); background: #F6F8FA; }
.sheet--1 { display: grid; place-items: center; border-color: var(--azure); color: var(--azure); }
.sheet--1 .ic { width: 36px; height: 36px; stroke-width: 1.6; }
.drop--big:hover .sheet--3, .drop--big.is-over .sheet--3 { transform: rotate(-14deg) translate(-16px, 6px); }
.drop--big:hover .sheet--2, .drop--big.is-over .sheet--2 { transform: rotate(11deg) translate(16px, 4px); }
.drop--big:hover .sheet--1, .drop--big.is-over .sheet--1 { transform: translateY(-6px); }
.drop__title { font-size: 28px; font-weight: 650; letter-spacing: -.01em; }
.drop__sub { font-size: 17px; color: var(--ink-2); }
.drop__hint { margin-top: 18px; max-width: 46ch; font-size: 14px; color: var(--ink-2); }

/* ---------- Очередь ---------- */
.queue {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-right: 1px solid var(--line);
}
.queue__head { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 16px 10px; }
.drop--small {
  margin: 0 12px 10px; padding: 12px 14px; border-radius: var(--radius); gap: 12px; align-items: center;
  font-size: 14px; line-height: 1.3; border-width: 1.5px; background: #F7F9FB;
}
.drop--small .ic { color: var(--btn); width: 24px; height: 24px; }
.qlist { list-style: none; margin: 0; padding: 0 8px 12px; overflow-y: auto; flex: 1; min-height: 0; }
.qitem {
  position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 8px;
  padding: 10px 8px 10px 10px; border-radius: var(--radius-s); margin-bottom: 2px;
  border: 1px solid transparent;
}
.qitem:hover { background: #F4F6F8; }
.qitem.is-active { background: var(--azure-bg); border-color: #BFE0F2; }
.qitem.is-active::before { content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px; border-radius: 2px; background: var(--azure); }
.qitem__check { grid-row: 1 / span 2; align-self: start; margin-top: 3px; width: 18px; height: 18px; accent-color: var(--btn); }
.qitem__check:disabled { visibility: hidden; }
.qitem__open {
  all: unset; cursor: pointer; display: block; min-width: 0; font-weight: 600; font-size: 14px; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word;
}
.qitem__open:focus-visible { box-shadow: var(--focus); border-radius: 3px; }
.qitem__open::after { content: ""; position: absolute; inset: 0; } /* вся строка кликабельна */
.qitem__del { position: relative; z-index: 1; width: 32px; height: 32px; opacity: 0; color: var(--ink-2); }
.qitem:hover .qitem__del, .qitem__del:focus-visible, .qitem.is-active .qitem__del { opacity: 1; }
.qitem__meta { grid-column: 2 / span 2; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; min-width: 0; }
.qitem__meta .ic { width: 16px; height: 16px; }
.qitem__meta--attn { color: var(--terra-ink); }
.qitem__meta--err { color: var(--err); }
.qitem__meta--ok { color: var(--ok); }
.qitem__check, .qitem__meta { position: relative; z-index: 1; pointer-events: none; }
.qitem__check { pointer-events: auto; }
.bar { grid-column: 2 / span 2; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.bar__fill { height: 100%; background: var(--azure); border-radius: 3px; transition: width 400ms ease-out; }
.bar--wait .bar__fill { width: 30% !important; background: #B9C3CE; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.queue__foot { padding: 12px; border-top: 1px solid var(--line-2); }

/* ---------- Рабочая зона ---------- */
.work { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.jobhead {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.jobhead__main { min-width: 0; flex: 1; }
.jobhead__name { font-size: 18px; font-weight: 650; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobhead__sub { font-size: 14px; color: var(--ink-2); display: flex; gap: 14px; flex-wrap: wrap; margin-top: 2px; }
.jobhead__sub .attn { color: var(--terra-ink); font-weight: 600; }
.jobhead__actions { display: flex; gap: 8px; }

.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 500px; }

/* --- Просмотр скана --- */
.viewer { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--stage); }
.vtool {
  display: flex; align-items: center; gap: 4px; padding: 6px 10px; color: #E7EBF0;
  background: #30353E; border-bottom: 1px solid #262A31;
}
.vtool .icon-btn { color: #E7EBF0; width: 36px; height: 36px; }
.vtool .icon-btn:hover { background: #454C58; }
.vtool .icon-btn:focus-visible { box-shadow: 0 0 0 2px var(--azure); }
.vtool__page { min-width: 110px; text-align: center; font-size: 14px; }
.vtool__sep { width: 1px; height: 20px; background: #4B525E; margin: 0 6px; }
.vtool__zoom { min-width: 84px; white-space: nowrap; text-align: center; font-size: 13px; color: #C6CDD6; }
.vtool__doc { margin-left: auto; font-size: 13px; color: #C6CDD6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 20px; outline: none; }
.stage:focus-visible { box-shadow: inset 0 0 0 2px var(--azure); }
.stage__img {
  display: block; margin: 0 auto; width: calc(var(--z, 1) * 100%); max-width: none; height: auto;
  background: #fff; box-shadow: 0 6px 24px rgba(0, 0, 0, .35); border-radius: 2px;
}
.stage.is-fit .stage__img { width: auto; max-width: 100%; max-height: 100%; }
.quote {
  position: sticky; bottom: 0; margin: -60px auto 0; width: fit-content;
  max-width: 100%; display: flex; gap: 10px; align-items: flex-start;
  background: rgba(255, 255, 255, .97); color: var(--ink); padding: 10px 14px; border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .35); font-size: 14px; border-left: 4px solid var(--azure);
}
.quote .ic { color: var(--btn); margin-top: 1px; }
.quote q { font-weight: 600; quotes: "«" "»"; }
.thumbs { display: flex; gap: 14px; padding: 10px 12px; overflow-x: auto; background: #30353E; border-top: 1px solid #262A31; }
.tgroup { display: flex; flex-direction: column; gap: 4px; flex: none; }
.tgroup__label { font-size: 12px; color: #C6CDD6; white-space: nowrap; }
.tgroup.is-active .tgroup__label { color: #fff; font-weight: 600; }
.tgroup__row { display: flex; gap: 6px; padding: 3px; border-radius: 6px; }
.tgroup.is-active .tgroup__row { background: #454C58; }
.thumb { padding: 0; border: 2px solid transparent; border-radius: 3px; background: none; line-height: 0; }
.thumb img { width: 42px; height: 59px; object-fit: cover; border-radius: 1px; display: block; }
.thumb.is-active { border-color: var(--azure); }
.thumb:focus-visible { box-shadow: 0 0 0 2px #fff; }

/* --- Документы и поля --- */
.review { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.docs { list-style: none; margin: 0; padding: 10px 12px; display: grid; gap: 6px; max-height: 38%; overflow-y: auto; border-bottom: 1px solid var(--line); background: #F7F9FB; flex: none; }
.dcard {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; width: 100%; text-align: left;
  padding: 8px 12px 8px 14px; border-radius: var(--radius-s); background: var(--surface);
  border: 1px solid var(--line); transition: border-color var(--t), box-shadow var(--t);
}
.dcard:hover { border-color: #A9B4C1; }
.dcard.is-active { border-color: var(--azure); box-shadow: 0 0 0 1px var(--azure); }
.dcard.is-active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 6px 0 0 6px; background: var(--azure); }
.dcard__form { font-weight: 650; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard__no { color: var(--ink-2); font-weight: 400; }
.dcard__sum { font-weight: 650; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; }
.dcard__who { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dcard__state { font-size: 13px; text-align: right; display: inline-flex; gap: 4px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.dcard__state .ic { width: 16px; height: 16px; }
.st-attn { color: var(--terra-ink); font-weight: 600; }
.st-ok { color: var(--ok); }
.st-err { color: var(--err); font-weight: 600; }

.fields-wrap { flex: 1; min-height: 0; overflow-y: auto; scroll-padding: 80px 0 24px; }
.dochead { padding: 14px 16px 10px; display: flex; align-items: flex-start; gap: 10px; }
.dochead__t { flex: 1; min-width: 0; }
.dochead__t .h2 { font-size: 16px; }
.dochead__pages { font-size: 13px; color: var(--ink-2); }
.dochead .btn { min-height: 36px; padding: 0 12px; font-size: 13px; }

.guide {
  position: sticky; top: 0; z-index: 2; margin: 0 12px 8px; padding: 10px 12px;
  display: flex; align-items: center; gap: 10px; border-radius: var(--radius-s);
  background: var(--terra-bg); border: 1px solid #F6CFB6; color: var(--terra-ink);
}
.guide__n {
  display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 999px;
  background: var(--terra); color: #fff; font-weight: 700; font-variant-numeric: tabular-nums;
}
.guide__t { flex: 1; font-size: 14px; line-height: 1.35; }
.guide__t b { color: var(--ink); }
.guide .btn { min-height: 34px; padding: 0 12px; font-size: 13px; }
.guide--done { background: var(--ok-bg); border-color: #BFDDCB; color: var(--ok); }
.guide--done .guide__n { background: var(--ok); }
kbd {
  font: 600 12px/1 var(--font); padding: 3px 6px; border-radius: 4px; border: 1px solid currentColor;
  border-bottom-width: 2px; opacity: .9;
}

.checks { list-style: none; margin: 0 12px 10px; padding: 0; display: grid; gap: 6px; }
.check {
  display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--radius-s);
  font-size: 14px; line-height: 1.4; border: 1px solid transparent;
}
.check .ic { width: 18px; height: 18px; margin-top: 1px; }
.check--error { background: var(--err-bg); color: var(--err); border-color: #F3C4BF; }
.check--warn { background: var(--terra-bg); color: var(--terra-ink); border-color: #F6CFB6; }
.check.is-seen { opacity: .62; }
.check.is-current { box-shadow: 0 0 0 2px var(--btn); }
.checks-ok { margin: 0 16px 8px; font-size: 13px; color: var(--ok); }
.checks-ok summary { cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 4px 0; list-style: none; }
.checks-ok summary::-webkit-details-marker { display: none; }
.checks-ok summary .ic { width: 16px; height: 16px; }
.checks-ok ul { margin: 4px 0 0; padding-left: 22px; color: var(--ink-2); }

.fields { list-style: none; margin: 0; padding: 0 0 24px; }
.field {
  position: relative; display: grid; grid-template-columns: 138px minmax(0, 1fr); gap: 4px 12px; align-items: center;
  padding: 7px 16px 7px 16px; border-top: 1px solid var(--line-2);
}
.field::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; }
.field--check::before { background: var(--terra); }
.field--missing::before { background: repeating-linear-gradient(180deg, var(--terra) 0 6px, transparent 6px 10px); }
.field--edited::before { background: var(--azure); }
.field--check, .field--missing { background: #FFF9F5; }
.field.is-focus { background: #F2F8FC; }
.field.is-focus::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--btn); pointer-events: none; }
.field__head { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 0; }
.field__label { font-size: 13px; color: var(--ink-2); line-height: 1.3; }
textarea.field__input { resize: none; overflow: hidden; height: 36px; padding: 7px 10px; line-height: 1.4; display: block; }
.field__ctl { display: flex; align-items: center; gap: 6px; min-width: 0; }
.field__input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; border: 1px solid transparent; border-radius: var(--radius-s);
  background: transparent; font-size: 15px; transition: border-color var(--t), background var(--t);
}
.field__input:hover { border-color: var(--line); background: #fff; }
.field__input:focus { border-color: var(--btn); background: #fff; box-shadow: 0 0 0 3px rgba(14, 108, 153, .18); outline: none; }
.field__input.is-num { font-variant-numeric: tabular-nums; }
.field__input::placeholder { color: var(--terra-ink); opacity: .8; font-style: italic; }
select.field__input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: right 14px center, right 9px center; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 26px; }
.field__mark { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.field__mark .ic { width: 16px; height: 16px; }
.field__mark--check, .field__mark--missing { color: var(--terra-ink); }
.field__mark--edited { color: var(--btn); }
.field__mark--saving { color: var(--ink-2); font-weight: 400; }
.field__issue { grid-column: 2; font-size: 13px; color: var(--terra-ink); padding-left: 11px; line-height: 1.35; }
.field__more { grid-column: 1 / -1; display: grid; gap: 8px; padding: 6px 0 4px; }
.evi { font-size: 13px; color: var(--ink-2); display: flex; gap: 6px; align-items: flex-start; }
.evi .ic { width: 16px; height: 16px; margin-top: 1px; }
.evi q { color: var(--ink); quotes: "«" "»"; }
.linkbtn { all: unset; cursor: pointer; color: var(--btn); text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:focus-visible { box-shadow: var(--focus); border-radius: 2px; }
.alts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.alt {
  display: inline-flex; align-items: baseline; gap: 6px; min-height: 32px; padding: 4px 10px; border-radius: var(--radius-s);
  border: 1px solid var(--btn); background: #fff; color: var(--btn); font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums;
}
.alt small { font-weight: 400; color: var(--ink-2); font-size: 12px; }
.alt:hover { background: var(--azure-bg); }
.keys { font-size: 12px; color: var(--ink-2); }

/* --- Ход распознавания (выбран файл в работе) --- */
.progress-view { flex: 1; display: grid; place-items: center; padding: 32px; }
.pcard { width: min(560px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 28px 30px; }
.pcard__name { font-size: 18px; font-weight: 650; margin: 0 0 4px; word-break: break-word; }
.pcard__msg { color: var(--ink-2); margin: 0 0 18px; }
.pcard .bar { height: 8px; margin-bottom: 22px; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; counter-reset: s; }
.step { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 10px; padding: 7px 0; color: var(--ink-3); }
.step__dot { width: 24px; height: 24px; border-radius: 50%; border: 2px solid #C5CDD6; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.step__dot::before { counter-increment: s; content: counter(s); }
.step.is-done { color: var(--ink); }
.step.is-done .step__dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.is-done .step__dot::before { content: "✓"; }
.step.is-now { color: var(--ink); font-weight: 600; }
.step.is-now .step__dot { border-color: var(--azure); color: var(--azure); animation: pulse 1.6s ease-in-out infinite; }
.step__n { font-size: 13px; color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; }
@keyframes pulse { 50% { box-shadow: 0 0 0 5px rgba(30, 156, 215, .18); } }
.pcard--err { border-top: 4px solid var(--err); }
.pcard--err .pcard__msg { color: var(--err); }

.blank { flex: 1; display: grid; place-items: center; color: var(--ink-2); text-align: center; padding: 32px; }

/* ---------- Диалоги ---------- */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); }
dialog::backdrop { background: rgba(35, 40, 48, .45); }
.sheet-dlg {
  margin: 0 0 0 auto; height: 100vh; height: 100dvh; max-height: none; width: min(480px, 100vw);
  box-shadow: -10px 0 40px rgba(0, 0, 0, .18);
}
.sheet-dlg[open] { animation: sheetIn 220ms cubic-bezier(.2, .8, .3, 1); }
@keyframes sheetIn { from { transform: translateX(40px); opacity: 0; } }
.sheet-dlg__inner { display: flex; flex-direction: column; gap: 14px; height: 100%; padding: 20px 22px 0; overflow-y: auto; }
.sheet-dlg__head { display: flex; align-items: center; justify-content: space-between; }
.sheet-dlg__inner > p { margin: -8px 0 0; }
.sheet-dlg__foot { position: sticky; bottom: 0; margin: auto -22px 0; padding: 14px 22px; background: var(--surface); border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; }
.set { border: 0; margin: 0; padding: 0; }
.set legend { font-weight: 650; font-size: 14px; padding: 0; margin-bottom: 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg__opt { position: relative; cursor: pointer; }
.seg__opt input { position: absolute; opacity: 0; }
.seg__opt span {
  display: flex; flex-direction: column; gap: 1px; padding: 10px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line); height: 100%; transition: border-color var(--t), background var(--t);
}
.seg__opt small { font-size: 12px; color: var(--ink-2); line-height: 1.3; }
.seg__opt input:checked + span { border-color: var(--btn); background: var(--azure-bg); box-shadow: inset 0 0 0 1px var(--btn); }
.seg__opt input:focus-visible + span { box-shadow: var(--focus); }
.mlist { display: grid; gap: 4px; max-height: 250px; overflow-y: auto; padding: 2px; }
.mlist--short { max-height: 300px; }
.mopt { position: relative; cursor: pointer; }
.mopt input { position: absolute; opacity: 0; }
.mopt__box {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 2px 10px; padding: 8px 12px; border-radius: var(--radius-s);
  border: 1px solid var(--line-2);
}
.mopt__box::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #9AA5B2; }
.mopt input:checked + .mopt__box { border-color: var(--btn); background: var(--azure-bg); }
.mopt input:checked + .mopt__box::before { border-color: var(--btn); background: radial-gradient(circle, var(--btn) 0 4px, transparent 4.5px); }
.mopt input:focus-visible + .mopt__box { box-shadow: var(--focus); }
.mopt__name { font-weight: 600; font-size: 14px; }
.mopt__meta { justify-content: flex-end; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--ink-2); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge .ic { width: 14px; height: 14px; }
.badge--vision { background: var(--azure-bg); color: var(--btn); }
.badge--ctx { background: var(--bg); color: var(--ink-2); font-weight: 500; font-variant-numeric: tabular-nums; }
.keybox { background: #F7F9FB; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 12px 14px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.meter { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; margin: 2px 0 6px; }
.meter i { display: block; height: 100%; background: var(--azure); }
.meter.is-low i { background: var(--terra); }

.modal { width: min(460px, calc(100vw - 32px)); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal__inner { padding: 22px; display: grid; gap: 12px; }
.modal__inner p { margin: 0; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- Перетаскивание на окно ---------- */
.dropveil { position: fixed; inset: 0; z-index: 50; background: rgba(30, 156, 215, .12); display: grid; place-items: center; pointer-events: none; }
.dropveil__box { padding: 22px 32px; border-radius: 14px; background: var(--surface); border: 2px dashed var(--azure); font-size: 18px; font-weight: 600; box-shadow: var(--shadow); }

/* ---------- Уведомления ---------- */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 8px; }
.toast {
  display: flex; gap: 10px; align-items: center; max-width: 380px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--ink); color: #fff; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); font-size: 14px;
  animation: toastIn 200ms ease-out;
}
.toast--err { background: var(--err); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Знак, корректировки, сверка пакета, лимит ---------- */
.neg { color: var(--err); font-weight: 700; }
.field__input.is-neg { color: var(--err); font-weight: 600; }
.corr {
  margin: 0 12px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s);
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 14px; font-variant-numeric: tabular-nums;
}
.corr > div { display: flex; flex-direction: column; }
.corr__k { font-size: 12px; color: var(--ink-2); }
.corr__v { font-weight: 650; }
.corr__arrow { color: var(--ink-3); padding-bottom: 2px; }
.corr__d { margin-left: auto; text-align: right; }
.top { flex: none; max-height: 46%; overflow-y: auto; border-bottom: 1px solid var(--line); background: #F7F9FB; }
.top .docs { max-height: none; overflow: visible; border-bottom: 0; }
.pkg { padding: 12px 12px 0; }
.pkg__t { font-size: 13px; font-weight: 650; margin: 0 0 6px; color: var(--ink-2); }
.pkg .checks { margin: 0 0 6px; }
.pkg .checks-ok { margin: 0 4px 2px; }
.quota { margin: 0; padding: 8px 16px 10px; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line-2); }
.quota.is-low { color: var(--terra-ink); font-weight: 600; }

/* ---------- Адаптив ---------- */
@media (max-width: 1360px) {
  .app[data-state="work"] { grid-template-columns: 260px minmax(0, 1fr); }
  .split { grid-template-columns: minmax(0, 1fr) 440px; }
  .field { grid-template-columns: 118px minmax(0, 1fr); }
  .topbar__title { display: none; }
}
@media (max-width: 1100px) {
  .app[data-state="work"] { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .queue { border-right: 0; border-bottom: 1px solid var(--line); }
  .queue__head { display: none; }
  .queue { flex-direction: row; align-items: stretch; padding: 10px 12px; gap: 10px; min-width: 0; }
  .qlist { min-width: 0; }
  .drop--small { margin: 0; flex: none; width: 190px; }
  .qlist { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 0; }
  .qitem { flex: none; width: 250px; margin: 0; border-color: var(--line-2); }
  .qitem.is-active::before { display: none; }
  .qitem__del { opacity: 1; }
  .queue__foot { border: 0; padding: 0; display: flex; align-items: center; }
  .quota { display: none; }
  .split { grid-template-columns: minmax(0, 1fr) 400px; }
  .demo-flag { display: none; }
}
@media (max-width: 860px) {
  .app { height: auto; min-height: calc(100dvh - 64px); }
  .split { grid-template-columns: 1fr; }
  .viewer { height: 70vh; }
  .review { border-left: 0; }
  .docs { max-height: none; }
  .top { max-height: none; }
  .fields-wrap { overflow: visible; }
}
@media (max-width: 640px) {
  .brand__logo--sl { height: 26px; }
  .brand__logo--fkr { height: 28px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .topbar .btn span:not(.chip) { display: none; }
  .drop--big { min-height: 320px; padding: 32px 20px; }
  .drop__title { font-size: 22px; }
  .field { grid-template-columns: 1fr; }
  .field__issue { grid-column: 1; }
  .seg { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* ---------- Реальный режим: категория, сбои, переизвлечение, расшифровка ---------- */
.btn--sm { min-height: 32px; padding: 0 10px; font-size: 13px; color: var(--ink-2); }
.jobhead__actions { align-items: center; }
.catsel select {
  font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 1px 26px 1px 8px; max-width: 320px;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 13px) 55%, calc(100% - 8px) 55%; background-size: 5px 5px; background-repeat: no-repeat;
}
.catsel select:hover { border-color: var(--btn); }
.warns {
  display: flex; gap: 8px; align-items: flex-start; margin: 0 20px 10px; padding: 8px 12px;
  background: var(--terra-bg); color: var(--terra-ink); border: 1px solid #F6CFB6; border-radius: var(--radius-s); font-size: 13px;
}
.warns .ic { margin-top: 2px; }
.warns ul { margin: 2px 0 0; padding-left: 18px; }
.busy {
  display: flex; gap: 10px; align-items: center; margin: 0 20px 10px; padding: 8px 12px;
  background: var(--azure-bg); color: var(--btn); border-radius: var(--radius-s); font-size: 13px; font-weight: 600;
}
.spin { width: 14px; height: 14px; flex: none; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }
.vbtn {
  display: inline-flex; align-items: center; gap: 4px; flex: none; margin-left: 8px;
  border: 1px solid #5A6270; border-radius: var(--radius-s); background: transparent; color: #C6CDD6;
  font-size: 12px; padding: 3px 8px;
}
.vbtn:hover { background: #454C58; color: #fff; }
.vbtn:focus-visible { box-shadow: 0 0 0 2px var(--azure); }
.modal--wide { width: min(760px, calc(100vw - 32px)); }
.txtbody {
  margin: 0; max-height: 60vh; overflow: auto; padding: 12px; background: var(--bg); border-radius: var(--radius-s);
  font: 12.5px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word;
}
.mopt__warn { grid-column: 1 / -1; display: flex; gap: 5px; align-items: center; font-size: 12px; color: var(--terra-ink); font-weight: 600; }
.field__mark--missing { color: var(--ink-3); font-weight: 500; }
.field__mark--confirmed { color: var(--ok); }
.whoread { font-size: 12px; }
.fields-empty { margin: 4px 16px 12px; border-top: 1px solid var(--line-2); padding-top: 8px; }
.fields-empty > summary { cursor: pointer; font-size: 13px; color: var(--ink-2); display: flex; align-items: center; gap: 6px; padding: 6px 0; list-style: none; }
.fields-empty > summary::-webkit-details-marker { display: none; }
.fields-empty > summary .ic { width: 16px; height: 16px; }
.fields-empty > summary:hover { color: var(--ink); }
.fields-empty > .fields { padding: 0; }
.fields-empty .field--missing { background: transparent; }
.fields-empty .field--missing::before { background: none; }
.fields-empty .field__input::placeholder { color: var(--ink-3); }
.field--confirmed::before { background: var(--ok); }
.mopt__warn { grid-column: 2 / -1; }
.qitem__meta { flex-wrap: wrap; row-gap: 0; }
.qitem__when { flex-basis: 100%; font-size: 12px; color: var(--ink-3); padding-left: 22px; }
.qitem__meta:not(.qitem__meta--attn):not(.qitem__meta--ok):not(.qitem__meta--err) .qitem__when { padding-left: 0; }
.mopt__vendor { font-weight: 400; font-size: 12px; color: var(--ink-3); margin-left: 4px; }
#settings .mlist { max-height: 300px; }

/* ---------- Вход и пользователь ---------- */
.login-page { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.login { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px 24px; display: grid; gap: 14px; }
.login__brand { display: flex; gap: 14px; align-items: center; }
.login__form { display: grid; gap: 6px; }
.login__label { font-size: 13px; color: var(--ink-2); margin-top: 6px; }
.login__input { height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--surface); }
.login__form .btn { margin-top: 12px; justify-content: center; }
.login__err { margin: 6px 0 0; color: var(--err); font-size: 14px; }
.whoami { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
