/* Закупки 223-ФЗ. Канцелярская палитра: офисная бумага, чернила, штемпельная краска, красная печать. */

@font-face { font-family: "PT Sans"; src: url("../fonts/PT_Sans-Web-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "PT Sans"; src: url("../fonts/PT_Sans-Web-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }
@font-face { font-family: "PT Serif"; src: url("../fonts/PT_Serif-Web-Regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "PT Serif"; src: url("../fonts/PT_Serif-Web-Bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
  --paper: #F1F3EF;
  --paper-2: #E6EAE4;
  --sheet: #FFFFFF;
  --ink: #1C2433;
  --ink-2: #5B6474;
  --ink-3: #8A92A0;
  --rule: #D2D8D1;
  --rule-strong: #AEB7AD;
  --stamp: #3B47A0;
  --stamp-deep: #2C3680;
  --stamp-wash: #E9EBF6;
  --seal: #B3362E;
  --seal-wash: #F8E9E7;
  --ledger: #2F6B4F;
  --ledger-wash: #E6F0EA;
  --radius: 3px;
  --sans: "PT Sans", "Segoe UI", Arial, sans-serif;
  --serif: "PT Serif", Georgia, "Times New Roman", serif;
  --rail: 300px;
}

* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--sans); line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--stamp); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; margin: 0; line-height: 1.2; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.27rem; }
h3 { font-size: 1.07rem; }
p { margin: 0 0 .6em; }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- каркас ---------- */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side {
  background: var(--paper-2); border-right: 1px solid var(--rule);
  display: flex; flex-direction: column; padding: 22px 0 16px; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 0 20px 20px; border-bottom: 1px solid var(--rule); margin-bottom: 12px; }
.brand-name { font-family: var(--serif); font-size: 1.35rem; font-weight: 700; }
.brand-law { color: var(--stamp); font-family: var(--serif); }
.brand-org { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }
.nav a {
  display: block; padding: 8px 20px; color: var(--ink); text-decoration: none; border-left: 3px solid transparent;
}
.nav a:hover { background: rgba(59, 71, 160, .06); }
.nav a[aria-current="page"] { border-left-color: var(--stamp); background: var(--sheet); font-weight: 700; }
.side-foot { margin-top: auto; padding: 12px 20px 0; border-top: 1px solid var(--rule); font-size: .9rem; color: var(--ink-2); }
.side-foot button { margin-top: 6px; }
.main { padding: 28px 36px 80px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--ink-2); margin-top: 4px; }
.back { display: inline-block; margin-bottom: 8px; color: var(--ink-2); text-decoration: none; }
.back:hover { color: var(--stamp); }

/* ---------- кнопки ---------- */
button, .btn {
  font: inherit; cursor: pointer; border-radius: var(--radius); padding: 7px 14px;
  border: 1px solid var(--rule-strong); background: var(--sheet); color: var(--ink); line-height: 1.3;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--ink-2); }
button.primary, .btn.primary { background: var(--stamp); border-color: var(--stamp); color: #fff; font-weight: 700; }
button.primary:hover, .btn.primary:hover { background: var(--stamp-deep); }
button.link { border: 0; background: none; color: var(--stamp); padding: 2px 0; text-decoration: underline; text-underline-offset: 2px; }
button.danger-link { border: 0; background: none; color: var(--seal); padding: 2px 0; }
button.icon { padding: 4px 9px; color: var(--ink-2); }
button.icon:hover { color: var(--seal); border-color: var(--seal); }
button:disabled { opacity: .55; cursor: default; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- формы ---------- */
.sheet { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 22px 24px; }
.step { margin-bottom: 18px; }
.step-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.step-no { font-family: var(--serif); color: var(--stamp); font-size: 1.27rem; font-weight: 700; min-width: 1.4em; }
.step-note { color: var(--ink-2); margin: -6px 0 14px; max-width: 70ch; }
.grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(12, 1fr); }
.c12 { grid-column: span 12; } .c9 { grid-column: span 9; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; }
.c4 { grid-column: span 4; } .c3 { grid-column: span 3; } .c2 { grid-column: span 2; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: .93rem; color: var(--ink-2); }
label.f > span.lbl { color: var(--ink-2); }
.hint { font-size: .85rem; color: var(--ink-3); }
input[type=text], input[type=date], input[type=number], input[type=password], input[type=search], input:not([type]), select, textarea {
  font: inherit; color: var(--ink); background: #fff; width: 100%;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); padding: 7px 9px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--stamp); box-shadow: 0 0 0 2px var(--stamp-wash); }
textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--ink); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--stamp); }
.seg { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--rule-strong); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"] { background: var(--stamp); color: #fff; }
.inline { display: flex; gap: 8px; align-items: flex-end; }
.inline > * { flex: 1; }
.inline > .shrink { flex: 0 0 auto; }

/* ---------- таблицы ---------- */
table.t { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.t th { text-align: left; font-weight: 700; font-size: .87rem; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--rule-strong); vertical-align: bottom; }
table.t td { padding: 6px 8px; border-bottom: 1px solid var(--rule); vertical-align: top; }
table.t td.r, table.t th.r { text-align: right; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: var(--stamp-wash); }
table.t input, table.t select { padding: 5px 7px; }
.muted { color: var(--ink-2); }
.small { font-size: .87rem; }
.empty { padding: 36px; text-align: center; color: var(--ink-2); }
.empty p { margin-bottom: 14px; }

/* характеристики позиции */
.chars { background: var(--paper); border-left: 3px solid var(--rule-strong); padding: 10px 12px; margin: 2px 0 8px; }
.chars-row { display: grid; grid-template-columns: 2.2em minmax(140px, 1fr) 2.6fr auto; gap: 8px; align-items: start; margin-bottom: 6px; }
.chars-row .n { color: var(--ink-3); padding-top: 7px; text-align: right; font-variant-numeric: tabular-nums; }
.chars-row textarea { min-height: 36px; height: 36px; }

/* ---------- статусы ---------- */
.tag { display: inline-block; font-size: .85rem; padding: 1px 8px; border-radius: 2px; border: 1px solid var(--rule-strong); color: var(--ink-2); white-space: nowrap; }
.tag.kp { border-color: var(--stamp); color: var(--stamp); }
.tag.prices { border-color: var(--ledger); color: var(--ledger); }
.tag.ready { background: var(--ledger); border-color: var(--ledger); color: #fff; }
.warn { color: var(--seal); }
.ok { color: var(--ledger); }
.note-box { border-left: 3px solid var(--seal); background: var(--seal-wash); padding: 8px 12px; margin: 10px 0; }
.note-box.info { border-left-color: var(--stamp); background: var(--stamp-wash); }
.cv-bad { color: var(--seal); font-weight: 700; }

/* ---------- закупка: форма + штамп-резолюция ---------- */
.case { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail); gap: 24px; align-items: start; }
.rail { position: sticky; top: 20px; }
.stamp {
  border: 2px solid var(--stamp); border-radius: 6px; padding: 4px; background: var(--sheet); color: var(--stamp);
}
.stamp-in { border: 1px solid var(--stamp); border-radius: 3px; padding: 14px 16px 12px; }
.stamp-label { font-size: .9rem; }
.stamp-sum { font-family: var(--serif); font-size: 2rem; font-weight: 700; line-height: 1.1; color: var(--stamp-deep); font-variant-numeric: tabular-nums; margin: 2px 0 6px; }
.stamp-sum small { font-size: 1rem; font-weight: 400; }
.stamp-line { display: flex; justify-content: space-between; gap: 10px; border-top: 1px dashed rgba(59, 71, 160, .4); padding: 6px 0; font-size: .93rem; }
.stamp-line b { color: var(--ink); text-align: right; font-weight: 700; }
.stamp-empty { color: var(--ink-2); font-size: .93rem; padding: 4px 0 8px; }
.stamp .warn-list { margin: 6px 0 0; padding: 0; list-style: none; color: var(--seal); font-size: .88rem; }
.stamp .warn-list li { margin-bottom: 4px; }
.docs { margin-top: 14px; }
.docs h3 { margin-bottom: 8px; }
.docs button { width: 100%; justify-content: space-between; margin-bottom: 6px; text-align: left; }
.docs button .ext { color: var(--ink-3); font-size: .85rem; }
.docs button.primary .ext { color: rgba(255,255,255,.8); }
.savebar { display: flex; gap: 10px; align-items: center; margin-top: 14px; }
.dirty { color: var(--seal); font-size: .9rem; }
.saved { color: var(--ledger); font-size: .9rem; }

/* поставщики */
.sup-row { display: grid; grid-template-columns: 1.6em 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--rule); }
.sup-row .n { color: var(--ink-3); text-align: right; }
.sup-name { font-weight: 700; }
.ac { position: relative; }
.ac-list { position: absolute; z-index: 20; top: 100%; left: 0; right: 0; background: #fff; border: 1px solid var(--rule-strong); border-top: 0; max-height: 280px; overflow: auto; }
.ac-list button { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--rule); border-radius: 0; text-align: left; padding: 8px 10px; }
.ac-list button:hover, .ac-list button:focus { background: var(--stamp-wash); }

/* ---------- диалог, уведомления, вход ---------- */
dialog { border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0; width: min(760px, 94vw); color: var(--ink); }
dialog::backdrop { background: rgba(28, 36, 51, .35); }
.dlg-head { padding: 16px 22px; border-bottom: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; }
.dlg-body { padding: 18px 22px; max-height: 70vh; overflow: auto; }
.dlg-foot { padding: 12px 22px; border-top: 1px solid var(--rule); display: flex; justify-content: flex-end; gap: 8px; }
#toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 3px; max-width: 420px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.toast.err { background: var(--seal); }
.toast.ok { background: var(--ledger); }
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-box { width: min(380px, 100%); }
.login-box .stamp-in { padding: 26px 26px 22px; }
.login-box h1 { color: var(--stamp-deep); margin-bottom: 4px; }
.login-box label.f { margin-top: 12px; }
.login-box button.primary { width: 100%; justify-content: center; margin-top: 18px; padding: 9px; }
.err-text { color: var(--seal); margin-top: 10px; min-height: 1.4em; }
.list-tools { display: flex; gap: 10px; margin-bottom: 14px; }
.list-tools input { max-width: 360px; }
.ref { font-size: .9rem; }
.ref code { background: var(--paper); padding: 1px 4px; border-radius: 2px; }
details > summary { cursor: pointer; color: var(--stamp); margin: 6px 0; }

.table-wrap { overflow-x: auto; }

@media (max-width: 1100px) {
  .case { grid-template-columns: minmax(0, 1fr); }
  .rail { position: static; order: -1; }
}
@media (max-width: 760px) {
  html { font-size: 14px; }
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 0; }
  .brand { border: 0; padding: 0 16px 6px; width: 100%; margin: 0; }
  .nav { display: flex; flex-wrap: wrap; }
  .nav a { border-left: 0; border-bottom: 3px solid transparent; padding: 6px 12px; }
  .nav a[aria-current="page"] { border-bottom-color: var(--stamp); }
  .side-foot { display: none; }
  .main { padding: 18px 16px 60px; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .grid > * { grid-column: 1 / -1 !important; }
  .sheet { padding: 16px; }
  .chars-row { grid-template-columns: minmax(0, 1fr) auto; }
  .chars-row .n { display: none; }
  .chars-row > textarea { grid-column: 1 / -1; }
  .chars-row > button { grid-row: 1; grid-column: 2; }
  #toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}

/* источник цены у поставщика */
.src-row { display: flex; gap: 8px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.src-row select { width: auto; padding: 4px 6px; font-size: .9rem; }
.src-row input { flex: 1; min-width: 220px; padding: 4px 8px; font-size: .9rem; }

/* ИИ: пунктир — это черновик, который нужно проверить */
.btn-ai { border: 1px dashed var(--stamp); color: var(--stamp); background: var(--sheet); padding: 5px 12px; }
.btn-ai:hover { background: var(--stamp-wash); border-color: var(--stamp-deep); }
.hint .btn-ai { padding: 1px 8px; font-size: .85rem; margin-top: 2px; }
.ai-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 18px; }
.ai-tile { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 14px 16px; }
.ai-tile .v { font-family: var(--serif); font-size: 1.6rem; font-weight: 700; color: var(--stamp-deep); font-variant-numeric: tabular-nums; }
.ai-tile .l { color: var(--ink-2); font-size: .9rem; }

/* ---------- справка ---------- */
.nav-help {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 10px; padding: 8px 20px;
  border: 0; border-left: 3px solid transparent; border-radius: 0; background: none; color: var(--stamp); text-align: left;
}
.nav-help:hover { background: rgba(59, 71, 160, .06); }
.nav-help[aria-expanded="true"] { border-left-color: var(--stamp); background: var(--sheet); font-weight: 700; }
.nav-help-mark {
  display: inline-grid; place-items: center; width: 20px; height: 20px; border: 1px dashed var(--stamp); border-radius: 50%;
  font-family: var(--serif); font-weight: 700; font-size: .85rem; line-height: 1;
}
.help-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 60;
  display: flex; flex-direction: column; background: var(--sheet); border-left: 1px solid var(--rule-strong);
  box-shadow: -6px 0 22px rgba(28, 36, 51, .12);
}
.help-panel[hidden] { display: none; }
.help-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--rule); }
.help-head h2 { color: var(--stamp-deep); }
.help-src { color: var(--ink-2); font-size: .85rem; margin-top: 3px; }
.help-list { flex: 1; overflow-y: auto; padding: 14px 18px; background: var(--paper); }
.help-intro p { color: var(--ink-2); }
.help-ex { display: flex; flex-direction: column; gap: 6px; margin: 10px 0 14px; }
.help-ex button { text-align: left; justify-content: flex-start; border-style: dashed; border-color: var(--stamp); color: var(--stamp); background: var(--sheet); }
.help-ex button:hover { background: var(--stamp-wash); }
.help-turn { margin-bottom: 18px; }
.help-q { font-weight: 700; margin-bottom: 6px; padding-left: 10px; border-left: 3px solid var(--rule-strong); white-space: pre-wrap; }
.help-a { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); padding: 10px 12px; }
.help-a.not-found { border-left: 3px solid var(--seal); }
.help-a-text p { margin: 0 0 .5em; }
.help-a-text p:last-child { margin-bottom: 0; }
.help-a-text ul { margin: .2em 0 .5em; padding-left: 1.2em; }
.help-a-text li { margin-bottom: .25em; }
.help-wait { color: var(--ink-2); font-style: italic; padding: 6px 0; }
.help-refs { margin-top: 8px; }
.help-refs-lbl { font-size: .85rem; color: var(--ink-3); margin-bottom: 4px; }
.help-ref-item { margin-bottom: 4px; }
.help-ref {
  font-size: .87rem; padding: 2px 8px; border: 1px solid var(--stamp); color: var(--stamp); background: var(--sheet);
  border-radius: 2px; text-align: left;
}
.help-ref[aria-expanded="true"] { background: var(--stamp); color: #fff; }
.help-frag { margin: 6px 0 8px; padding: 8px 10px; background: var(--sheet); border-left: 3px solid var(--stamp); }
.help-frag-head { font-size: .8rem; color: var(--ink-3); margin-bottom: 4px; }
.help-frag-text { font-family: var(--serif); font-size: .9rem; white-space: pre-line; max-height: 320px; overflow-y: auto; }
.help-fb { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.help-foot { border-top: 1px solid var(--rule); padding: 12px 18px 14px; background: var(--sheet); }
.help-foot textarea { min-height: 64px; }
.help-foot-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.help-head .actions { flex-wrap: nowrap; white-space: nowrap; }
@media (min-width: 1600px) {
  .help-open .shell { margin-right: 420px; }
  .help-open #toasts { right: 440px; }
}
@media (max-width: 760px) {
  .nav-help { width: auto; margin: 0; padding: 6px 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .nav-help[aria-expanded="true"] { border-bottom-color: var(--stamp); background: none; }
}
