/* Layout: sticky total bar on top, three tabs (расчёт / смета заказчика / справочники), each a single column of tables */
:root {
  --bg: #f2f4f3;
  --surface: #ffffff;
  --sunken: #e9edeb;
  --fg: #16201d;
  --muted: #5b6965;
  --line: #d3dad7;
  --accent: #0d6957;
  --accent-fg: #ffffff;
  --accent-soft: #dcefe9;
  --warn: #9a5b00;
  --warn-soft: #fbefd6;
  --bad: #a32a2a;
  --sans: 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121816;
    --surface: #1a2220;
    --sunken: #222c29;
    --fg: #e7eeeb;
    --muted: #9aaaa4;
    --line: #33403c;
    --accent: #4cc2a8;
    --accent-fg: #06251f;
    --accent-soft: #17362f;
    --warn: #f0b450;
    --warn-soft: #3a2d12;
    --bad: #f08a8a;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #121816;
  --surface: #1a2220;
  --sunken: #222c29;
  --fg: #e7eeeb;
  --muted: #9aaaa4;
  --line: #33403c;
  --accent: #4cc2a8;
  --accent-fg: #06251f;
  --accent-soft: #17362f;
  --warn: #f0b450;
  --warn-soft: #3a2d12;
  --bad: #f08a8a;
  color-scheme: dark;
}
* {
  box-sizing: border-box;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}
.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
.muted {
  color: var(--muted);
}
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
input,
select,
button {
  font: inherit;
  color: inherit;
}
input[type='text'],
input[type='number'] {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
  width: 100%;
  min-width: 0;
}
input:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 6px 12px;
}
button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  font-weight: 600;
}
button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 4px 8px;
}
button.ghost:hover {
  color: var(--bad);
}
.head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  align-items: flex-end;
  justify-content: space-between;
}
.head .name {
  flex: 1 1 320px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.head .name input {
  font-size: 16px;
  font-weight: 600;
}
.total {
  text-align: right;
}
.total .big {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.tabs {
  display: flex;
  gap: 0;
  align-items: flex-end;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 0 0 auto;
}
.tg + .tg {
  border-left: 1px solid var(--line);
  margin-left: 10px;
  padding-left: 10px;
}
.tgl {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 0 14px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.tgl select {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  max-width: 260px;
  width: auto;
}
.tgl b {
  color: var(--fg);
  font-size: 13px;
}
.tgb {
  display: flex;
  gap: 4px;
}
.tabs button {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  padding: 8px 14px;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.tabs button[aria-selected='true'] {
  color: var(--fg);
  border-bottom-color: var(--accent);
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.stats div {
  background: var(--surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stats .lbl {
  font-size: 12px;
  color: var(--muted);
}
.stats .v {
  font-family: var(--mono);
  font-size: 16px;
}
.params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.card h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.row label {
  flex: 1 1 120px;
}
.row input[type='number'] {
  width: 84px;
  flex: 0 0 84px;
  text-align: right;
}
.check {
  display: flex;
  gap: 6px;
  align-items: center;
}
.sec {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sec-h {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.tbl {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}
table {
  border-collapse: collapse;
  width: 100%;
}
th {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  text-align: right;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
th:first-child,
td:first-child {
  text-align: left;
}
td {
  padding: 4px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: 0;
}
td.nm {
  min-width: 240px;
}
td.q input {
  text-align: right;
  font-family: var(--mono);
}
td.fin {
  font-weight: 600;
}
tfoot td {
  background: var(--sunken);
  font-weight: 600;
  padding: 8px 10px;
}
.chip {
  display: inline-block;
  font-size: 11px;
  border-radius: 999px;
  padding: 1px 8px;
  margin-left: 6px;
  white-space: nowrap;
}
.chip.auto {
  background: var(--accent-soft);
  color: var(--accent);
}
.chip.miss {
  background: var(--warn-soft);
  color: var(--warn);
}
.note {
  background: var(--warn-soft);
  color: var(--fg);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
}
.note b {
  color: var(--warn);
}
.addrow {
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
select {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  max-width: 100%;
  min-width: 0;
}
.newpos {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
.newpos input.nm {
  flex: 1 1 240px;
}
.newpos input.qn {
  flex: 0 0 90px;
  width: 90px;
  text-align: right;
}
.fin td {
  padding: 7px 10px;
}
.fin td.calc {
  text-align: left;
  color: var(--muted);
  font-size: 12.5px;
}
.fin tr.who td {
  background: var(--sunken);
  font-weight: 600;
  text-align: left;
}
.fin tr.sub td {
  font-weight: 600;
}
.ordbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.ordbar select {
  flex: 1 1 220px;
  font-weight: 600;
}
.items {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.item {
  display: flex;
  gap: 8px 16px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}
.item:first-child {
  border-top: 0;
  padding-top: 0;
}
.src {
  font-size: 12px;
  color: var(--muted);
}
details > summary {
  cursor: pointer;
  font-weight: 600;
  padding: 4px 0;
}
td.bzn {
  text-align: left;
  min-width: 260px;
}
.lock {
  font-size: 12.5px;
  color: var(--muted);
}
.qa {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.qa .q {
  display: flex;
  flex-direction: column;
  gap: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.qa .q:first-of-type {
  border-top: 0;
  padding-top: 0;
}
.qa .qt {
  font-weight: 600;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.qa .ar {
  display: flex;
  gap: 8px;
  align-items: center;
}
.qa .ar input.nm {
  flex: 1 1 220px;
}
.qa .ar input.qn {
  flex: 0 0 90px;
  width: 90px;
  text-align: right;
  font-family: var(--mono);
}
td.q {
  min-width: 50px;
}
td.q input {
  max-width: 60px;
  padding-left: 4px;
  padding-right: 4px;
  margin-left: auto;
  display: block;
}
select.mini {
  font-size: 12px;
  padding: 2px 4px;
  margin-left: 8px;
  color: var(--muted);
  max-width: 170px;
}
.paper tbody tr:last-child td {
  border-bottom: 1px solid var(--line);
}
.row > span.muted {
  flex: 0 0 auto;
}
td.au {
  color: var(--muted);
}
td.dh {
  cursor: grab;
  color: var(--muted);
  text-align: center;
  padding: 4px 2px 4px 8px;
  user-select: none;
  font-size: 15px;
}
tr.dover td {
  box-shadow: inset 0 2px 0 var(--accent);
}
/* customer estimate */
.switch {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.seg button {
  border: 0;
  border-radius: 0;
  background: var(--surface);
  padding: 6px 12px;
}
.seg button[aria-pressed='true'] {
  background: var(--accent);
  color: var(--accent-fg);
}
.paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px clamp(16px, 4vw, 44px);
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.paper .top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.paper .ttl {
  font-size: 37.5px;
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.1;
}
.paper .kind {
  color: var(--accent);
  font-weight: 600;
}
.paper h4 {
  margin: 10px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}
.paper table td,
.paper table th {
  padding: 6px 4px;
}
.paper .tot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-top: 2px solid var(--fg);
  padding-top: 12px;
  font-size: 16px;
  font-weight: 600;
  gap: 12px;
}
.paper .tot .num {
  font-size: 22px;
}
.paper .fine {
  font-size: 12.5px;
  color: var(--muted);
}
/* modules calculator */
.kv {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.kv > span:first-child {
  min-width: 0;
}
.mod .row label {
  flex: 1 1 80px;
}
.row select {
  flex: 0 1 132px;
  width: 132px;
}
.mod {
  gap: 14px;
}
.mod .mname {
  font-weight: 600;
  font-size: 15px;
}
[hidden] { display: none !important; }
