@import url('https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600&family=Tektur:wght@500;700&display=swap');

:root {
  --paper: #F2F4F5;
  --sheet: #FFFFFF;
  --ink: #1B242B;
  --steel: #66737D;
  --line: #D5DBDF;
  --dim: #2148D0;
  --beam: #F5C431;
  --warn: #9A6B00;
  --bad: #B3261E;
  --radius-s: 4px;
  --radius-m: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.55 'Golos Text', system-ui, sans-serif;
}
a { color: var(--dim); }
:focus-visible { outline: 2px solid var(--dim); outline-offset: 2px; }

h1, h2, h3, .wordmark { font-family: 'Tektur', 'Golos Text', sans-serif; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.04; margin: 0 0 20px; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); line-height: 1.1; margin: 0 0 24px; }
h3 { font-size: 1.1rem; font-weight: 500; margin: 0 0 6px; }
p { margin: 0 0 12px; max-width: 62ch; }

.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }

/* header */
.top { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 10; }
.top .wrap { display: flex; align-items: center; gap: 28px; height: 64px; }
.wordmark { font-size: 1.25rem; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 10px; }
.wordmark svg { width: 22px; height: 22px; }
.top nav { display: flex; gap: 22px; margin-left: auto; }
.top nav a { color: var(--ink); text-decoration: none; font-size: .95rem; }
.top nav a:hover { color: var(--dim); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 22px; border-radius: var(--radius-s);
  font: 500 1rem 'Golos Text', sans-serif; text-decoration: none; cursor: pointer;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
}
.btn:hover { background: var(--dim); border-color: var(--dim); }
.btn.ghost { background: transparent; color: var(--ink); }
.btn.ghost:hover { border-color: var(--dim); color: var(--dim); background: transparent; }
.btn.small { white-space: nowrap; height: 38px; padding: 0 16px; font-size: .92rem; }
.btn:disabled, .btn:disabled:hover {
  cursor: not-allowed; background: transparent; border-color: var(--line); color: #8A959D;
}

/* hero */
.hero { padding: 72px 0 88px; }
.hero .wrap { display: grid; grid-template-columns: 1fr 1.05fr; gap: 56px; align-items: center; }
.hero p.lead { font-size: 1.15rem; color: #3A4650; margin-bottom: 28px; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }

.drawing {
  margin: 0;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  overflow: hidden;
}
.drawing .field {
  background-image:
    linear-gradient(var(--paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper) 1px, transparent 1px);
  background-size: 20px 20px;
  padding: 18px;
}
.drawing svg { display: block; width: 100%; height: auto; }
.part-outline { fill: none; stroke: var(--ink); stroke-width: 2; }
.part-dim { stroke: var(--dim); stroke-width: 1; fill: none; }
.part-dim-text { fill: var(--dim); font: 500 12px 'Golos Text', sans-serif; }
.part-bend { stroke: var(--steel); stroke-width: 1; stroke-dasharray: 8 4 2 4; }
.beam { fill: none; stroke: var(--beam); stroke-width: 4; stroke-linecap: round; }
.spark { fill: var(--beam); }

/* штамп чертежа */
.stamp { display: grid; grid-template-columns: repeat(5, 1fr); border-top: 2px solid var(--ink); }
.stamp div { padding: 10px 12px; border-right: 1px solid var(--line); }
.stamp div:last-child { border-right: 0; background: var(--ink); color: #fff; }
.stamp span { display: block; font-size: .75rem; color: var(--steel); }
.stamp div:last-child span { color: #AEB8BF; }
.stamp b { font: 700 1.15rem 'Tektur', sans-serif; }

@media (prefers-reduced-motion: no-preference) {
  .beam { stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: cut 2.6s .4s cubic-bezier(.5,0,.4,1) forwards, cool .8s 3s forwards; }
  .spark { offset-rotate: 0deg; animation: spark 2.6s .4s cubic-bezier(.5,0,.4,1) forwards, fade .3s 3s forwards; }
  .stamp b { opacity: 0; animation: show .4s forwards; }
  .stamp div:nth-child(1) b { animation-delay: 3.0s; }
  .stamp div:nth-child(2) b { animation-delay: 3.15s; }
  .stamp div:nth-child(3) b { animation-delay: 3.3s; }
  .stamp div:nth-child(4) b { animation-delay: 3.45s; }
  .stamp div:nth-child(5) b { animation-delay: 3.7s; }
}
@keyframes cut { to { stroke-dashoffset: 0; } }
@keyframes cool { to { stroke: var(--ink); stroke-width: 2; } }
@keyframes spark { from { offset-distance: 0%; } to { offset-distance: 100%; } }
@keyframes fade { to { opacity: 0; } }
@keyframes show { to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .spark { display: none; } .beam { stroke: var(--ink); stroke-width: 2; } }

/* sections */
section.block { padding: 80px 0; border-top: 1px solid var(--line); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; counter-reset: s; }
.steps li { list-style: none; padding: 0 28px 0 0; counter-increment: s; }
.steps li::before {
  content: counter(s); display: block; font: 700 2.6rem/1 'Tektur', sans-serif; color: var(--dim); margin-bottom: 14px;
}
.steps { padding: 0; margin: 0; }
.steps p { color: #3A4650; }

.spec { width: 100%; border-collapse: collapse; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.spec th, .spec td { text-align: left; padding: 14px 18px; border-bottom: 1px solid var(--line); vertical-align: top; }
.spec tr:last-child td { border-bottom: 0; }
.spec th { font-weight: 500; color: var(--steel); font-size: .9rem; background: #F8F9FA; }
.spec td:first-child { font-weight: 500; width: 34%; }
.tag { display: inline-block; font-size: .82rem; padding: 2px 8px; border-radius: var(--radius-s); background: #E8EDFB; color: var(--dim); }
.tag.code { background: #EEF0F1; color: var(--ink); }

.plan { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: start; }
.price-card { background: var(--ink); color: #fff; border-radius: var(--radius-m); padding: 32px; }
.price-card .sum { font: 700 3rem/1 'Tektur', sans-serif; margin: 6px 0 4px; }
.price-card .per { color: #AEB8BF; margin-bottom: 22px; }
.price-card ul { padding: 0; margin: 0 0 26px; list-style: none; }
.price-card li { padding: 9px 0; border-top: 1px solid #2E3A43; }
.price-card .btn { background: var(--beam); color: var(--ink); border-color: var(--beam); width: 100%; }
.price-card .btn:hover { background: #fff; border-color: #fff; }

footer { border-top: 1px solid var(--line); padding: 28px 0; color: var(--steel); font-size: .9rem; }
footer .wrap { display: flex; gap: 20px; flex-wrap: wrap; justify-content: space-between; }

/* ---------- приложение ---------- */
.workspace { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 28px; padding-top: 28px; padding-bottom: 60px; align-items: start; }
.workspace > * { min-width: 0; }
.panel { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; }
.rates h2 { font-size: 1.15rem; margin-bottom: 4px; }
.rates .hint { color: var(--steel); font-size: .88rem; margin-bottom: 16px; }
.rates fieldset { border: 0; padding: 0; margin: 0 0 18px; }
.rates legend { font-weight: 600; font-size: .92rem; margin-bottom: 8px; }
.row { display: grid; grid-template-columns: 1fr 92px; gap: 8px; align-items: center; margin-bottom: 8px; font-size: .9rem; }
.row input, .row select, .ops-grid input {
  width: 100%; height: 34px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 8px;
  font: 500 .92rem 'Golos Text', sans-serif; text-align: right; background: #fff; color: var(--ink);
}
.row select { text-align: left; }
.check { display: flex; gap: 8px; align-items: center; font-size: .92rem; margin-bottom: 6px; }
.check input { width: 16px; height: 16px; accent-color: var(--dim); }

.drop {
  display: block;
  border: 2px dashed #B8C1C7; border-radius: var(--radius-m); background: var(--sheet);
  padding: 40px 24px; text-align: center; cursor: pointer;
  background-image:
    linear-gradient(var(--paper) 1px, transparent 1px),
    linear-gradient(90deg, var(--paper) 1px, transparent 1px);
  background-size: 20px 20px;
}
.drop.over { border-color: var(--dim); background-color: #F3F6FE; }
.drop h2 { font-size: 1.4rem; margin-bottom: 6px; }
.drop p { margin: 0 auto 18px; color: #3A4650; }
.drop input { display: none; }
.queue { margin: 14px 0 0; display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: #EEF0F1; border-radius: var(--radius-s); padding: 4px 10px; font-size: .86rem; }

.results { margin-top: 24px; }
.results-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.results-head h2 { margin: 0; font-size: 1.35rem; }
.results-head #recalc { margin-left: auto; }
.table-scroll { overflow-x: auto; background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); }
table.parts { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 820px; }
.parts th { text-align: left; font-weight: 500; color: var(--steel); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #F8F9FA; white-space: nowrap; }
.parts td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.parts td.num, .parts th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.parts tbody tr.part { cursor: pointer; }
.parts tbody tr.part:hover { background: #F8F9FA; }
.parts input.qty { width: 56px; height: 30px; border: 1px solid var(--line); border-radius: var(--radius-s); text-align: right; padding: 0 6px; font: inherit; }
.parts .fname { font-weight: 500; }
.parts .sub { color: var(--steel); font-size: .82rem; }
.parts .warn { color: var(--warn); font-size: .82rem; }
.parts .err td { color: var(--bad); }
.detail td { background: #F8F9FA; }
.detail dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px 24px; margin: 4px 0; }
.detail dt { color: var(--steel); font-size: .8rem; }
.detail dd { margin: 0 0 6px; font-weight: 500; }

.totals { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; background: var(--sheet); }
.totals div { padding: 14px 18px; border-right: 1px solid var(--line); }
.totals div:last-child { border-right: 0; background: var(--ink); color: #fff; }
.totals span { display: block; font-size: .8rem; color: var(--steel); }
.totals div:last-child span { color: #AEB8BF; }
.totals b { font: 700 1.35rem 'Tektur', sans-serif; font-variant-numeric: tabular-nums; }

.empty { padding: 32px; text-align: center; color: var(--steel); }
.busy { display: inline-block; width: 14px; height: 14px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .hero .wrap, .plan, .workspace { grid-template-columns: 1fr; }
  .hero { padding: 40px 0 56px; }
  .steps { grid-template-columns: 1fr; gap: 28px; }
  .top nav a:not(.keep) { display: none; }
  .totals { grid-template-columns: 1fr 1fr; }
  .totals div:nth-child(2) { border-right: 0; }
  .totals div:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .stamp { grid-template-columns: repeat(2, 1fr); }
  .stamp div { border-bottom: 1px solid var(--line); }
  .stamp div:last-child { grid-column: 1 / -1; }
  section.block { padding: 56px 0; }
}

/* ---------- прогресс расчёта ---------- */
.progress { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 16px 18px 14px; margin-bottom: 14px; }
.beam-track { position: relative; height: 4px; background: var(--paper); border-radius: 2px; overflow: hidden; margin-bottom: 14px; }
.beam-track span { position: absolute; top: 0; left: -30%; width: 30%; height: 100%; background: var(--beam); border-radius: 2px; box-shadow: 0 0 8px var(--beam); animation: sweep 1.6s ease-in-out infinite; }
@keyframes sweep { 0% { left: -30%; } 100% { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .beam-track span { animation: none; left: 0; width: 100%; opacity: .6; } }
.progress-text { display: flex; align-items: baseline; gap: 12px; }
.progress-text b { font: 700 1.1rem 'Tektur', sans-serif; }
#p-time { font-variant-numeric: tabular-nums; color: var(--steel); }
.progress-hint { color: var(--steel); font-size: .88rem; margin-top: 2px; }
.progress-files { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.progress-files li { display: inline-flex; align-items: center; gap: 7px; font-size: .84rem; background: var(--paper); border-radius: var(--radius-s); padding: 4px 10px; }
.progress-files .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--beam); animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }
.btn.is-busy { border-color: var(--bad); color: var(--bad); }
.btn.is-busy:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
body.calculating .table-scroll, body.calculating .totals { opacity: .5; transition: opacity .2s; }
.parts td:first-child { min-width: 230px; }
.ai-cost { color: var(--steel); font-size: .85rem; margin: 8px 2px 0; text-align: right; max-width: none; }
.ai-cost:empty { display: none; }

/* ---------- расходы ---------- */
.usage { padding-top: 28px; padding-bottom: 60px; }
.usage-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.usage-head h1 { font-size: 1.8rem; margin: 0; }
.usage-head select { height: 38px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 10px; font: inherit; background: #fff; margin-left: auto; }
.usage h2 { font-size: 1.15rem; margin: 30px 0 10px; }
.usage .totals { margin-top: 0; }
.usage .note { color: var(--steel); font-size: .88rem; margin-top: 8px; }
.usage table.parts { min-width: 640px; }
.row.wide { grid-template-columns: 1fr 150px; }
.row.wide input { text-align: left; }
.ops-grid { display: grid; grid-template-columns: 1fr 84px 52px; gap: 6px 8px; align-items: center; margin-top: 4px; font-size: .9rem; }
.ops-grid .h { font-size: .78rem; color: var(--steel); }
.ops-grid input { box-sizing: border-box; text-align: center; padding: 0 4px; }
