/* Калькулятор «Ремонт квартир» (components/calc/RepairCalc.tsx).
   Бетонный серый, прямые углы, волосяные линии; жёлтый — только лента рулетки
   и кнопка. Справа графитовая доска со сметой-графиком. Всё заперто под .rep. */

.rep {
  --rep-bg: #d4d3cf; --rep-panel: #e3e2de; --rep-ink: #1d1e20; --rep-mute: #5c5d60;
  --rep-line: rgba(29, 30, 32, .2); --rep-sig: #ffcd1c; --rep-board: #242527; --rep-board-line: rgba(255, 255, 255, .12);
  --rep-mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  min-height: 560px; background: var(--rep-bg); color: var(--rep-ink);
  font-family: var(--font-onest, system-ui, sans-serif);
}
.rep button { font-family: inherit; color: inherit; cursor: pointer; }
.rep-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── форма ── */
.rep-form { padding: 30px 30px 28px; }
.rep-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.rep-h { font-size: 1.35rem; font-weight: 700; letter-spacing: -.015em; }
.rep-area { font-family: var(--rep-mono); font-size: .95rem; color: var(--rep-mute); white-space: nowrap; }
.rep-area b { font-size: 2rem; font-weight: 600; color: var(--rep-ink); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

/* рулетка */
.rep-tape { display: flex; align-items: stretch; gap: 0; margin: 14px 0 26px; }
.rep-case { flex: none; width: 58px; height: 58px; position: relative; z-index: 2; }
.rep-case rect:first-child { fill: #2b2c2e; }
.rep-case circle:nth-of-type(1) { fill: none; stroke: #4a4b4e; stroke-width: 2; }
.rep-case circle:nth-of-type(2) { fill: #4a4b4e; }
.rep-case rect:last-child { fill: #2b2c2e; }
.rep-scale {
  position: relative; flex: 1; height: 58px; margin-right: 16px;
  /* «пустой» отрезок, куда лента ещё не вытянута */
  background: linear-gradient(var(--rep-panel), var(--rep-panel)) 0 9px / 100% 40px no-repeat;
}
.rep-blade {
  position: absolute; inset: 9px 0; background: var(--rep-sig);
  transform-origin: left; transform: scaleX(max(var(--p), .012));
  transition: transform .18s ease-out;
}
.rep-ticks {
  position: absolute; inset: 9px 0; pointer-events: none;
  background:
    linear-gradient(to right, rgba(29, 30, 32, .75) 1px, transparent 1px) 0 0 / calc(100% / 14) 62% repeat-x,
    linear-gradient(to right, rgba(29, 30, 32, .5) 1px, transparent 1px) 0 0 / calc(100% / 70) 26% repeat-x;
}
.rep-mark {
  position: absolute; bottom: 12px; transform: translateX(4px); pointer-events: none;
  font: 600 .72rem/1 var(--rep-mono); font-variant-numeric: tabular-nums; color: var(--rep-ink);
}
.rep-hook { position: absolute; inset: 0; pointer-events: none; transform: translateX(calc(var(--p) * 100%)); transition: transform .18s ease-out; }
.rep-hook i { position: absolute; left: -2px; top: 0; bottom: 0; width: 5px; background: var(--rep-ink); }
.rep-hook i::after { content: ''; position: absolute; left: 0; top: 0; width: 12px; height: 9px; background: var(--rep-ink); }
.rep-scale input {
  position: absolute; top: 0; bottom: 0; left: -14px; width: calc(100% + 28px); height: auto;
  margin: 0; opacity: 0; cursor: ew-resize; -webkit-appearance: none; appearance: none;
}
.rep-scale input::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 58px; }
.rep-scale input::-moz-range-thumb { width: 28px; height: 58px; border: 0; }
.rep-tape:has(input:focus-visible) .rep-scale { outline: 2px solid var(--rep-ink); outline-offset: 12px; }

/* тип ремонта: строки сметы */
.rep-types { border-top: 1px solid var(--rep-ink); margin-bottom: 18px; }
.rep-types button {
  display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; grid-template-areas: 'm t r' 'm n r';
  column-gap: 12px; align-items: center; width: 100%; text-align: left;
  padding: 11px 0; background: none; border: 0; border-bottom: 1px solid var(--rep-line);
}
.rep-types button::before {
  content: ''; grid-area: m; width: 12px; height: 12px; border: 1.5px solid var(--rep-ink); box-sizing: border-box;
}
.rep-types button[aria-checked="true"]::before { background: var(--rep-ink); box-shadow: inset 0 0 0 2px var(--rep-bg); }
.rep-types b { grid-area: t; font-size: .95rem; font-weight: 600; }
.rep-types span { grid-area: n; font-size: .78rem; color: var(--rep-mute); }
.rep-types em { grid-area: r; font: 500 .82rem/1 var(--rep-mono); font-style: normal; font-variant-numeric: tabular-nums; color: var(--rep-mute); }
.rep-types button[aria-checked="true"] em { color: var(--rep-ink); }
.rep-types button:hover b { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }

.rep-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; }
.rep-row > span { font-size: .88rem; color: var(--rep-mute); }
.rep-dig, .rep-mat { display: flex; }
.rep-dig button {
  width: 42px; height: 40px; margin-left: -1px; background: none; border: 1px solid var(--rep-ink);
  font: 500 .95rem/1 var(--rep-mono); font-variant-numeric: tabular-nums; transition: background .12s;
}
.rep-dig button:hover, .rep-mat button:hover { background: var(--rep-panel); }
.rep-dig button[aria-checked="true"] { background: var(--rep-ink); color: #fff; }
.rep-mat button {
  height: 40px; padding: 0 14px; margin-left: -1px; background: none; border: 1px solid var(--rep-ink); font-size: .88rem;
}
.rep-mat button[aria-checked="true"] { background: var(--rep-ink); color: #fff; }

/* ── доска со сметой ── */
.rep-res {
  display: flex; flex-direction: column; padding: 30px 28px 28px;
  background: var(--rep-board); color: #f1f0ec;
}
.rep-res-top { display: flex; justify-content: space-between; align-items: baseline; padding-bottom: 12px; border-bottom: 1px solid var(--rep-board-line); }
.rep-res-top span { font-size: .88rem; color: #a3a3a0; }
.rep-res-top b { font-size: 1.05rem; font-weight: 600; }

.rep-gantt { --lab: 84px; --sum: 70px; padding: 6px 0 4px; }
.rep-g-axis, .rep-g-row { display: grid; grid-template-columns: var(--lab) minmax(0, 1fr) var(--sum); column-gap: 10px; align-items: center; }
.rep-g-axis { grid-template-columns: calc(var(--lab) + 10px) repeat(var(--n), minmax(0, 1fr)) calc(var(--sum) + 10px); column-gap: 0; }
.rep-g-axis::before { content: ''; }
.rep-g-axis::after { content: 'BYN'; text-align: right; font: .68rem/1 var(--rep-mono); color: #8b8b88; }
.rep-g-axis i { font: normal .66rem/1 var(--rep-mono); color: #8b8b88; text-align: left; padding: 6px 0 6px 2px; white-space: nowrap; overflow: visible; }
.rep-g-row { padding: 12px 0; border-top: 1px solid var(--rep-board-line); }
.rep-g-row > span { font-size: .84rem; color: #d5d4cf; }
.rep-g-row > b { text-align: right; font: 500 .84rem/1 var(--rep-mono); font-variant-numeric: tabular-nums; }
.rep-g-track {
  position: relative; height: 18px;
  background: repeating-linear-gradient(to right, var(--rep-board-line) 0 1px, transparent 1px calc(100% / var(--n) * var(--g)));
}
.rep-bar {
  position: absolute; top: 2px; bottom: 2px; transform-origin: left;
  animation: rep-grow .5s calc(var(--i) * .09s) cubic-bezier(.3, .7, .2, 1) both;
}
.rep-bar-0 { background: #7d7e80; }
.rep-bar-1 { background: #b4b3ae; }
.rep-bar-2 { background: #ecebe6; }
/* материалы — чертёжная штриховка: это поставки, а не работа */
.rep-bar-m { background: repeating-linear-gradient(-45deg, #b4b3ae 0 1.5px, transparent 1.5px 6px); box-shadow: inset 0 0 0 1px #8d8c88; }
.rep-g-row.is-off .rep-bar-m { background: none; box-shadow: inset 0 0 0 1px #4b4c4e; }
.rep-g-row.is-off > span, .rep-g-row.is-off > b { color: #7d7e80; }
.rep-g-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 12px; border-top: 1px solid var(--rep-board-line); font-size: .74rem; color: #8b8b88; }
.rep-g-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rep-g-legend i { display: inline-block; width: 16px; height: 9px; }
.rep-g-legend span:last-child { margin-left: auto; }
@keyframes rep-grow { from { transform: scaleX(0); } }

.rep-total { margin-top: auto; padding-top: 22px; border-top: 1px solid var(--rep-board-line); }
.rep-total-k { font-size: .84rem; color: #a3a3a0; }
.rep-total-v {
  display: flex; align-items: baseline; gap: 8px; margin: 4px 0 2px;
  font: 600 2.35rem/1.1 var(--font-unbounded, var(--font-onest, sans-serif)); letter-spacing: -.02em; font-variant-numeric: tabular-nums;
}
.rep-total-v small { font: 500 .95rem/1 var(--font-onest, sans-serif); color: #a3a3a0; letter-spacing: 0; }
.rep-total-sub { font: .8rem/1.4 var(--rep-mono); color: #a3a3a0; font-variant-numeric: tabular-nums; }
.rep-roll { display: inline-flex; }
.rep-roll-d { display: inline-block; height: 1.1em; overflow: hidden; }
.rep-roll-d > span { display: block; transition: transform .55s cubic-bezier(.3, .8, .25, 1); }
.rep-roll-d i { display: block; height: 1.1em; font-style: normal; }
.rep-roll-s { display: inline-block; width: .32em; }

.rep-btn {
  margin-top: 18px; padding: 16px 18px; border: 0; background: var(--rep-sig); color: var(--rep-ink) !important;
  font: 600 .95rem/1.2 var(--font-onest, sans-serif); text-align: left;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; transition: background .15s;
}
.rep-btn::after { content: '→'; font-size: 1.1rem; }
.rep-btn:hover { background: #ffd84d; }
.rep button:focus-visible { outline: 2px solid var(--rep-ink); outline-offset: 2px; }
.rep-res button:focus-visible { outline-color: var(--rep-sig); }

@media (max-width: 720px) {
  .rep { grid-template-columns: 1fr; min-height: 0; }
  .rep-form { padding: 22px 16px 20px; }
  .rep-h { font-size: 1.12rem; }
  .rep-area b { font-size: 1.6rem; }
  .rep-case { width: 46px; height: 46px; margin-top: 6px; }
  .rep-scale { margin-right: 12px; }
  .rep-mark { font-size: .64rem; }
  .rep-types span { font-size: .74rem; }
  .rep-dig button { width: 40px; }
  .rep-mat button { padding: 0 10px; font-size: .84rem; }
  .rep-res { padding: 22px 16px 20px; }
  .rep-gantt { --lab: 74px; --sum: 58px; }
  .rep-g-row > span, .rep-g-row > b { font-size: .78rem; }
  .rep-g-legend span:last-child { display: none; }
  .rep-total-v { font-size: 1.85rem; }
}
@media (prefers-reduced-motion: reduce) {
  .rep-blade, .rep-hook, .rep-roll-d > span { transition: none; }
  .rep-bar { animation: none; }
}
