/* Inter (SIL OFL 1.1, лицензия в /fonts/LICENSE-Inter.txt) — локально, без внешних запросов */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/inter-cyrillic.woff2') format('woff2'); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/inter-latin-ext.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 700; font-display: swap; src: url('/fonts/inter-latin.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* Калькулятор заявок СК «Авангард» — adm.m-ska.ru. Токены совпадают с m-ska.ru. */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --offset: #eceef2;
  --divider: #e1e4e9;
  --border: #d3d7de;
  --text: #0e1b2e;
  --muted: #56616f;
  --faint: #98a1ab;
  --primary: #0a2540;
  --primary-hover: #133a63;
  --primary-hl: #d7e0ea;
  --steel: #2f6fa8;
  --steel-hover: #245a8a;
  --steel-hl: #e3edf6;
  --warning: #a3591a;
  --warning-hl: #f6ecdf;
  --error: #b4302f;
  --error-hl: #f5e1e0;
  --success: #2c7a4b;
  --success-hl: #dfeee5;
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --font-display: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 2px rgba(14, 27, 46, .05), 0 1px 3px rgba(14, 27, 46, .04);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 400 15px/1.5 var(--font-body); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--steel); text-decoration: none; }
a:hover { color: var(--steel-hover); text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--steel); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ── шапка ── */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--surface);
  border-bottom: 1px solid var(--divider);
}
.top-in {
  max-width: 1440px; margin: 0 auto; padding: 0 20px; height: 56px;
  display: flex; align-items: center; gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--primary); font-weight: 600; white-space: nowrap; }
.brand:hover { text-decoration: none; color: var(--primary); }
.brand svg { width: 26px; height: 26px; color: var(--primary); flex: none; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); line-height: 1.1; }
.brand b { display: block; font-family: var(--font-display); font-size: 15px; line-height: 1.15; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 12px; border-radius: var(--r-md); color: var(--muted); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--offset); color: var(--text); text-decoration: none; }
.nav a.on { background: var(--steel-hl); color: var(--primary); }
.who { display: flex; align-items: center; gap: 12px; white-space: nowrap; font-size: 13px; color: var(--muted); }
.who b { color: var(--text); font-weight: 600; }

/* ── каркас ── */
.page { max-width: 1440px; margin: 0 auto; padding: 24px 20px 64px; }
.page-narrow { max-width: 960px; }
.page-mid { max-width: 1120px; }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { color: var(--muted); margin-top: 4px; }
.card {
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 18px 20px;
}
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h p { color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ── кнопки ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 7px 14px; border-radius: var(--r-md); border: 1px solid transparent;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px; cursor: pointer;
  white-space: nowrap; text-decoration: none; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--primary-hover); color: #fff; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn-2 { background: var(--surface); color: var(--primary); border-color: var(--border); }
.btn-2:hover { background: var(--offset); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--steel); padding: 6px 8px; min-height: 30px; font-weight: 500; }
.btn-ghost:hover { background: var(--steel-hl); color: var(--steel-hover); }
.btn-danger { color: var(--error); }
.btn-danger:hover { background: var(--error-hl); color: var(--error); }
.btn-sm { min-height: 30px; padding: 4px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.x {
  width: 28px; height: 28px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--faint);
  cursor: pointer; font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center;
}
.x:hover { background: var(--error-hl); color: var(--error); }

/* ── формы ── */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 500; }
.field > em { font-style: normal; font-size: 12px; color: var(--faint); }
.inp, .sel, .ta {
  width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.ta { min-height: 72px; resize: vertical; line-height: 1.45; }
.inp:hover, .sel:hover, .ta:hover { border-color: #b9bfc9; }
.inp:focus, .sel:focus, .ta:focus { outline: none; border-color: var(--steel); box-shadow: 0 0 0 3px var(--steel-hl); }
.inp[readonly], .inp:disabled, .sel:disabled, .ta:disabled { background: var(--surface-2); color: var(--muted); }
.inp::placeholder, .ta::placeholder { color: var(--faint); }
.inp.n { text-align: right; }
.grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid-2 { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-2 { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--steel); }
.ro { padding: 7px 0; min-height: 36px; }
.ro-v { white-space: pre-wrap; }

/* ── таблицы ── */
.tw { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 6px 8px;
  border-bottom: 1px solid var(--divider); white-space: nowrap; background: var(--surface);
}
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl.rows tbody tr { cursor: pointer; }
.tbl.rows tbody tr:hover td { background: var(--surface-2); }
.tbl .t-title { font-weight: 600; color: var(--text); }
.tbl .t-sub { font-size: 12px; color: var(--muted); }
.lines td { padding: 4px 4px; }
.lines th { padding: 4px 4px; }
.lines .inp, .lines .sel { min-height: 32px; padding: 5px 8px; font-size: 14px; }
.lines td.sum { font-weight: 600; padding-left: 10px; }
.lines tfoot td { border-top: 1px solid var(--divider); border-bottom: 0; font-weight: 600; padding-top: 8px; }
.w-name { min-width: 190px; }
.w-mid { min-width: 120px; }
.w-sm { width: 92px; min-width: 80px; }
.w-xs { width: 74px; min-width: 64px; }
.w-unit { width: 88px; min-width: 80px; }
.w-date { width: 142px; min-width: 132px; }
.w-rate { width: 190px; min-width: 150px; }
.stale { color: var(--warning); }
.inp.stale { border-color: var(--warning); background: var(--warning-hl); }

/* ── статусы ── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--offset); color: var(--muted);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { background: var(--steel-hl); color: var(--steel); }
.st-supply, .st-tech { background: var(--warning-hl); color: var(--warning); }
.st-price { background: var(--primary-hl); color: var(--primary); }
.st-approved, .st-sent { background: var(--steel-hl); color: var(--steel-hover); }
.st-won, .st-done { background: var(--success-hl); color: var(--success); }
.st-lost { background: var(--error-hl); color: var(--error); }
.wait { color: var(--warning); font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ── вкладки ── */
.tabs { display: flex; gap: 4px; background: var(--offset); padding: 3px; border-radius: var(--r-md); width: max-content; max-width: 100%; overflow-x: auto; }
.tabs a { padding: 6px 12px; border-radius: 5px; color: var(--muted); font-weight: 500; font-size: 14px; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.tabs .cnt { font-size: 12px; color: var(--warning); font-weight: 700; margin-left: 4px; }
.bar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 14px; }
.search { max-width: 300px; }

/* ── шаги ── */
.steps { position: relative; display: flex; gap: 0; margin: 4px 0 18px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 4px; }
.step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--faint); white-space: nowrap; }
.step + .step::before { content: ""; width: 22px; height: 1px; background: var(--border); margin: 0 8px; }
.step i {
  width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--border); display: inline-flex;
  align-items: center; justify-content: center; font-style: normal; font-size: 11px; font-weight: 700; flex: none;
}
.step.done { color: var(--muted); }
.step.done i { background: var(--steel); border-color: var(--steel); color: #fff; }
.step.cur { color: var(--primary); font-weight: 600; }
.step.cur i { border-color: var(--primary); background: var(--primary); color: #fff; }
.step.lost { color: var(--error); font-weight: 600; }
.step.lost i { background: var(--error); border-color: var(--error); color: #fff; }

/* ── страница расчёта ── */
.calc { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.side { position: sticky; top: 72px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 88px); overflow-y: auto; scrollbar-width: thin; padding-bottom: 4px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row .id { color: var(--faint); font-weight: 500; font-size: 15px; }
.back { display: inline-block; font-size: 13px; margin-bottom: 8px; }
.pos { padding: 0; overflow: hidden; }
.pos-h { display: flex; gap: 10px; align-items: flex-end; padding: 14px 16px; border-bottom: 1px solid var(--divider); background: var(--surface-2); flex-wrap: wrap; }
.pos-h .n { font-family: var(--font-display); font-weight: 600; color: var(--muted); padding-bottom: 8px; min-width: 22px; }
.pos-h .f-name { flex: 1 1 260px; }
.pos-h .f-qty { width: 110px; }
.pos-h .f-unit { width: 110px; }
.pos-h .pos-title { flex: 1 1 260px; font-weight: 600; font-size: 16px; padding-bottom: 6px; }
.pos-h .f-note { flex: 1 1 100%; margin-left: 32px; }
.pos-b { padding: 6px 16px 14px; }
.blk { padding-top: 12px; }
.blk + .blk { border-top: 1px dashed var(--divider); margin-top: 10px; }
.blk-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.blk-h h3 { font-size: 14px; }
.blk-h .tot { font-weight: 600; font-size: 14px; white-space: nowrap; }
.blk-h .row { flex-wrap: wrap; justify-content: flex-end; gap: 2px 10px; }
.empty-blk { font-size: 13px; color: var(--faint); padding: 4px 0 2px; }
.pos-sum { display: flex; flex-wrap: wrap; gap: 6px 22px; padding: 10px 16px; border-top: 1px solid var(--divider); background: var(--surface-2); font-size: 13px; color: var(--muted); }
.pos-sum b { color: var(--text); font-weight: 600; }
.pos-sum .price b { color: var(--primary); }
.hint {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 4px; padding: 8px 12px;
  background: var(--steel-hl); border-radius: var(--r-md); font-size: 13px; color: var(--primary);
}
.fact { margin-top: 12px; padding: 12px; border-radius: var(--r-md); background: var(--success-hl); }
.fact h3 { font-size: 14px; margin-bottom: 8px; color: var(--success); }
.fact .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
.add-pos { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px auto; gap: 10px; align-items: end; }
.lead-box { border-left: 3px solid var(--steel); }
.lead-msg { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--divider); border-radius: var(--r-md); padding: 10px 12px; margin-top: 8px; font-size: 14px; }
.files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.file {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--r-md); font-size: 13px; background: var(--surface); color: var(--primary);
}
.file:hover { border-color: var(--steel); text-decoration: none; }
.file small { color: var(--muted); }

/* ── итог справа ── */
.sum-card { padding: 16px 18px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.kv span { color: var(--muted); }
.kv b { font-weight: 600; white-space: nowrap; }
.kv.sub span { padding-left: 12px; font-size: 13px; }
.kv.sub b { font-weight: 500; color: var(--muted); font-size: 13px; }
.kv.big { font-size: 16px; padding: 8px 0 4px; }
.kv.big span { color: var(--text); font-weight: 600; }
.kv.big b { color: var(--primary); font-size: 20px; font-family: var(--font-display); }
.kv.good b { color: var(--success); }
.sep { height: 1px; background: var(--divider); margin: 8px 0; }
.price-wait { font-size: 13px; color: var(--muted); background: var(--surface-2); border-radius: var(--r-md); padding: 10px 12px; }
.pricing { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.pricing .field > span { font-size: 12px; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.checks li { font-size: 13px; padding: 7px 10px; border-radius: var(--r-md); line-height: 1.4; }
.checks .error { background: var(--error-hl); color: var(--error); }
.checks .warn { background: var(--warning-hl); color: var(--warning); }
.acts { display: flex; flex-direction: column; gap: 8px; }
.acts .why { font-size: 12px; color: var(--warning); margin-top: -4px; }
.acts-2 { display: flex; flex-wrap: wrap; gap: 6px; }
.events { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.events li { border-left: 2px solid var(--divider); padding-left: 10px; }
.events time { display: block; font-size: 12px; color: var(--faint); }
details summary { cursor: pointer; font-weight: 600; font-family: var(--font-display); list-style: none; display: flex; justify-content: space-between; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; color: var(--muted); font-weight: 500; }
details[open] summary::after { content: "−"; }
.frozen { font-size: 12px; color: var(--muted); background: var(--offset); padding: 6px 10px; border-radius: var(--r-md); }
.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 12px 16px; margin-bottom: 18px; border-radius: var(--r-lg); background: var(--warning-hl); color: var(--warning); font-size: 14px;
}
.banner b { font-weight: 600; }
.savebar {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 16px 0; padding: 12px 0; background: rgba(245, 246, 248, .94); border-top: 1px solid var(--divider);
}
.lost-note { padding: 10px 14px; border-radius: var(--r-md); background: var(--error-hl); color: var(--error); font-size: 14px; margin-bottom: 16px; }

/* ── вход ── */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth .brand { margin-bottom: 22px; }
.auth form > * + * { margin-top: 14px; }
.auth h1 { margin-bottom: 6px; }
.auth h1 + form, .auth p + form { margin-top: 18px; }
.auth form + p { margin-top: 14px; margin-bottom: 0; }
.auth .err:empty { display: none; }
.err { color: var(--error); font-size: 13px; min-height: 18px; }

/* ── прочее ── */
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }
.empty b { display: block; color: var(--text); font-family: var(--font-display); font-size: 16px; margin-bottom: 4px; }
.loading { color: var(--faint); padding: 40px 0; text-align: center; }
.copy-box { display: flex; gap: 8px; margin-top: 10px; }
.copy-box .inp { font-size: 13px; }
.ok-box { padding: 12px 14px; border-radius: var(--r-md); background: var(--success-hl); color: var(--success); font-size: 14px; margin-top: 12px; }
.calib td .inp { min-width: 88px; }
.calib th { white-space: normal; vertical-align: bottom; line-height: 1.25; }
.calib .w-name { min-width: 150px; }
.calib td[data-out] { min-width: 64px; }
.calib-res td { font-weight: 600; }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--primary); color: #fff; padding: 10px 16px; border-radius: var(--r-md); font-size: 14px;
  box-shadow: 0 8px 24px rgba(14, 27, 46, .18); transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--error); }
.saving { position: fixed; top: 64px; right: 20px; font-size: 12px; color: var(--muted); background: var(--surface); border: 1px solid var(--divider); padding: 3px 10px; border-radius: 999px; z-index: 30; }

@media (max-width: 1100px) {
  .calc { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; overflow: visible; order: -1; }
}
@media (max-width: 720px) {
  .top-in { height: auto; flex-wrap: wrap; gap: 8px 14px; padding: 10px 14px; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: wrap; overflow: visible; }
  .who .role { display: none; }
  .page { padding: 16px 12px 48px; }
  .card { padding: 14px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .add-pos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .add-pos .f-name { grid-column: 1 / -1; }
  .pos-h .f-qty, .pos-h .f-unit { width: calc(50% - 26px); }
  .pos-h .f-note { margin-left: 0; }
  .search { max-width: none; width: 100%; }
  h1 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.sel-role { min-width: 190px; }
