:root {
  color-scheme: light;
  --page: #f4f7f4;
  --paper: #fff;
  --ink: #162921;
  --muted: #4c6358;
  --line: #d4e0d7;
  --green: #19604b;
  --green-dark: #143f33;
  --tint: #e9f4ec;
  --radius: 16px;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, p, dl, dd { margin: 0; }
h1, h2 { line-height: 1.12; }
button, input, textarea { font: inherit; color: inherit; }
button, summary { cursor: pointer; }
a { color: var(--green); text-underline-offset: .2em; }
:focus-visible { outline: 2px solid #227a60; outline-offset: 3px; }
.wrap { width: min(1200px, 100% - 80px); margin-inline: auto; }
.site-header { background: #fbfcfa; border-bottom: 1px solid var(--line); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand, nav, .nav-button { display: flex; align-items: center; }
.brand { gap: 11px; color: var(--ink); font-weight: 750; letter-spacing: -.025em; font-size: 1.12rem; text-decoration: none; }
.brand-mark { width: 32px; height: 32px; flex: none; display: grid; place-content: center; justify-items: center; gap: 3px; border-radius: 9px; background: var(--green); }
.brand-mark i { display: block; width: 10px; height: 2px; background: #fff; border-radius: 2px; }
.brand-mark i:nth-child(2) { width: 15px; }
nav { gap: 23px; white-space: nowrap; font-size: .91rem; font-weight: 650; }
nav a { text-decoration: none; }
.nav-button { min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.nav-button:hover, .outlined-button:hover { background: var(--tint); }
.guide-nav { display: inline-flex; align-items: center; min-height: 44px; }
.guide-nav:hover { text-decoration: underline; }
.hero { padding: 30px 0 24px; }
.hero h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2.6rem, 5.15vw, 4.25rem); line-height: 1; letter-spacing: -.052em; font-weight: 500; }
.hero-copy { max-width: 640px; margin-top: 9px; font-size: clamp(1rem, 1.5vw, 1.12rem); color: var(--muted); }
.calculator { display: grid; grid-template-columns: minmax(0, 1fr) minmax(296px, 31%); align-items: start; gap: 20px; }
.mobile-summary { display: none; }
.workbench, .result-column { min-width: 0; }
.result-column { display: grid; gap: 14px; }
.panel, .profit-panel, .journal-panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.panel { padding: 24px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.panel-heading h2, .journal-panel h2 { font-size: 1.33rem; letter-spacing: -.03em; }
.draft-label, .input-error { margin: 0 0 12px; border-left: 3px solid; padding: 7px 11px; font-size: .9rem; overflow-wrap: anywhere; }
.draft-label { border-color: #658b77; background: #eef5ee; color: var(--green-dark); }
.input-error { border-color: #a6313d; background: #fff1f1; color: #852533; }
.text-button { border: 0; border-radius: 5px; background: transparent; color: var(--green); font-size: .9rem; font-weight: 700; padding: 4px 0; text-align: left; }
.text-button:hover { text-decoration: underline; text-underline-offset: .18em; }
.panel-heading .text-button { flex-shrink: 0; max-width: 100%; min-height: 44px; overflow-wrap: anywhere; }
.table-head, .service-row { display: grid; grid-template-columns: minmax(0, 2.25fr) minmax(0, .56fr) minmax(0, .73fr) minmax(0, .9fr) minmax(0, .96fr) 36px; gap: 8px; align-items: center; }
.table-head { color: var(--muted); font-size: .88rem; padding-bottom: 6px; font-weight: 640; }
.table-head span:nth-child(5) { padding-left: 5px; }
.service-row + .service-row { margin-top: 8px; }
.service-row label { min-width: 0; }
.service-row label > span { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap; }
input, textarea { min-width: 0; width: 100%; padding: 9px 10px; border: 1px solid #c2d0c7; border-radius: 8px; background: #fff; }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: #61766a; opacity: 1; }
input:focus, textarea:focus { border-color: #318469; background: #fff; }
input[aria-invalid="true"] { border-color: #a6313d; background: #fff6f6; }
.line-total { font-size: .88rem; font-weight: 720; padding-left: 5px; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.remove-button { width: 36px; height: 40px; border: 0; background: #eef4ef; border-radius: 8px; color: var(--muted); font-size: 1.36rem; line-height: 1; }
.remove-button:hover { color: #8e2a31; background: #faeaeb; }
.add-button { margin-top: 14px; border: 1px dashed #b9d4c4; background: #f3faf5; color: var(--green); border-radius: 9px; padding: 9px 12px; font-weight: 720; }
.add-button span { margin-right: 5px; }
.add-button:hover { background: var(--tint); }
.add-button:disabled { opacity: .55; cursor: default; }
.rules, .settings-body { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.rules { margin-top: 20px; padding-block: 16px; border-block: 1px solid var(--line); }
.rule-hint { grid-column: 1 / -1; color: var(--muted); font-size: .875rem; }
.field { display: grid; align-content: start; gap: 5px; color: var(--muted); font-size: .9rem; font-weight: 630; }
.field input, .field textarea { color: var(--ink); font-weight: 400; }
.input-addon { display: grid; align-items: center; position: relative; }
.input-addon > span { position: absolute; right: 12px; pointer-events: none; }
.input-addon input { padding-right: 33px; }
.settings { border-bottom: 1px solid var(--line); }
.settings:last-child { border-bottom: 0; }
.settings summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 0; font-weight: 680; list-style: none; }
.settings:last-child:not([open]) summary { padding-bottom: 0; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary span { width: 8px; height: 8px; border-right: 2px solid var(--green); border-bottom: 2px solid var(--green); transform: translateY(-2px) rotate(45deg); margin-right: 3px; }
.settings[open] summary span { transform: translateY(2px) rotate(225deg); }
.settings-body { padding-bottom: 14px; }
.settings:last-child .settings-body { padding-bottom: 0; }
.wide { grid-column: 1 / -1; }
.save-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 11px 2px 0; color: var(--muted); font-size: .88rem; }
.result-panel { padding: 24px; background: var(--green-dark); color: #fff; border-radius: var(--radius); }
.result-panel h2 { color: #daeee1; font-size: 1rem; font-weight: 650; }
.result-panel :focus-visible { outline-color: #cdf5dc; }
.headline-total { display: block; margin-block: 7px 15px; font-size: clamp(2rem, 4.25vw, 3.65rem); line-height: 1.05; font-weight: 740; letter-spacing: -.075em; overflow-wrap: anywhere; }
.result-list { display: grid; gap: 7px; font-size: .94rem; }
.result-list div { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.result-list dd { flex: 0 1 auto; min-width: 0; font-weight: 700; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.result-panel .result-list { border-top: 1px solid #4b7262; color: #e5f1e9; padding: 11px 0 17px; }
.copy-button, .print-button { width: 100%; min-height: 45px; border-radius: 9px; font-weight: 720; padding: 8px 10px; }
.copy-button { background: #d4f1db; border: 1px solid #d4f1db; color: #153e2f; }
.copy-button:hover { background: #fff; }
.print-button { margin-top: 8px; background: transparent; border: 1px solid #729185; color: #fff; }
.print-button:hover { background: #265646; }
.action-status, .manual-copy { font-size: .9rem; margin-top: 10px; }
.manual-copy { display: grid; gap: 5px; }
.manual-copy textarea { color: var(--ink); }
.profit-panel { padding: 18px 23px; }
.profit-panel h2 { font-size: 1.09rem; margin-bottom: 12px; }
.profit-panel .result-list { color: var(--muted); }
.profit-panel .profit-total { color: var(--green); font-weight: 720; }
.profit-panel .negative { color: #a0182c; }
#costs-hint { margin-top: 10px; color: var(--muted); font-size: .88rem; }
.guide-band, .journal-panel { margin-top: 24px; padding: 23px 25px; }
.guide-band { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: var(--tint); border-radius: var(--radius); }
.guide-band h2 { font-size: 1.15rem; }
.guide-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.outlined-button { display: inline-block; flex: none; text-decoration: none; color: var(--green); background: #fff; border: 1px solid #bad2c6; border-radius: 9px; padding: 9px 13px; font-weight: 720; }
.journal-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-rows: max-content 1fr; grid-template-areas: "copy preview" "offer preview"; align-items: start; gap: 15px 30px; }
.journal-copy { grid-area: copy; }
.journal-copy p { margin-top: .55rem; color: var(--muted); max-width: 49ch; }
.journal-preview { grid-area: preview; margin: 0; }
.journal-preview img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; }
.journal-preview figcaption { margin-top: 5px; color: var(--muted); font-size: .875rem; }
.journal-offer { grid-area: offer; }
.journal-offer p { color: var(--muted); }
.journal-offer .journal-price { color: var(--ink); font-size: 1.5rem; font-weight: 740; letter-spacing: -.04em; }
.journal-offer .outlined-button, .journal-status { margin-top: 8px; }
.journal-buy { background: var(--green); border-color: var(--green); color: #fff; }
.journal-buy:hover { background: var(--green-dark); color: #fff; }
.journal-status { font-size: .88rem; }
.journal-hero { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); align-items: center; gap: clamp(20px, 4vw, 56px); padding-block: clamp(24px, 5vw, 62px) 24px; }
.journal-hero h1 { max-width: 14ch; }
.journal-hero .journal-preview { grid-area: auto; }
.journal-hero-offer { margin-top: 18px; }
.journal-format { max-width: 45ch; margin-top: 14px; color: var(--muted); }
.journal-format code { overflow-wrap: anywhere; }
.journal-detail-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.journal-detail h2 { font-size: 1.25rem; margin-bottom: 11px; }
.journal-detail ol { margin: 0; padding-inline-start: 1.35rem; }
.journal-detail li + li, .journal-detail p + p { margin-top: 8px; }
.journal-related p { margin-top: 6px; color: var(--muted); }
.site-footer { display: flex; justify-content: space-between; align-items: start; gap: 18px; padding-block: 22px 30px; font-size: .9rem; color: var(--muted); }
.site-footer span { font-weight: 720; flex: none; }
.site-footer p { max-width: 62ch; }
.notice { margin-block: 0 24px; }
#print-quote { display: none; }

@media (min-width: 871px) and (min-height: 650px) {
  .result-column { position: sticky; top: 16px; }
}

@media (max-width: 870px) {
  .wrap { width: min(1200px, 100% - 44px); }
  .calculator { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .mobile-summary { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 11px; background: var(--green-dark); color: #fff; }
  .mobile-summary div { min-width: 0; }
  .mobile-summary span { display: block; color: #d9ede0; font-size: .875rem; }
  .mobile-summary output { display: block; font-size: 1.27rem; font-weight: 740; line-height: 1.17; overflow-wrap: anywhere; }
  .mobile-summary a { flex: none; display: inline-flex; align-items: center; min-height: 44px; color: #fff; font-size: .875rem; font-weight: 700; }
  .mobile-summary :focus-visible { outline-color: #cdf5dc; }
  #result-heading { scroll-margin-top: 90px; }
  .result-column { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .result-panel .headline-total { font-size: 2.9rem; }
  .journal-hero { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 560px) {
  .wrap { width: calc(100% - 28px); }
  .header-inner { min-height: 61px; gap: 7px; }
  .brand { font-size: .96rem; gap: 6px; }
  .brand-mark { width: 26px; height: 26px; }
  .nav-button { display: none; }
  .hero { padding-block: 22px 16px; }
  .hero h1 { font-size: clamp(2.1rem, 7.5vw, 2.65rem); }
  .panel, .result-panel, .profit-panel { padding: 16px; }
  .panel-heading { flex-wrap: wrap; margin-bottom: 6px; }
  .table-head { display: none; }
  .service-row { grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; padding-top: 9px; border-top: 1px solid var(--line); }
  .service-row label > span { position: static; display: block; width: auto; height: auto; clip-path: none; margin-bottom: 3px; font-size: .875rem; color: var(--muted); }
  .service-row .service-name { grid-column: 1 / -1; grid-row: 1; margin-right: 50px; }
  .service-row .remove-button { grid-column: 3; grid-row: 1; justify-self: end; width: 44px; height: 44px; }
  .line-total { grid-column: 1 / -1; padding-left: 0; text-align: right; }
  .line-total::before { content: "Сумма "; color: var(--muted); font-weight: 500; }
  .rules .field { align-content: end; }
  .settings summary { justify-content: flex-start; }
  .settings summary span { order: -1; flex: none; margin: 0 3px 0 2px; }
  #result-heading { scroll-margin-top: 120px; }
  .save-bar { align-items: start; }
  .save-bar button { flex: none; }
  .result-column { grid-template-columns: 1fr; }
  .guide-band, .site-footer { align-items: start; flex-direction: column; }
  .guide-band, .journal-panel { padding: 17px; margin-top: 17px; }
  .journal-panel { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "copy" "preview" "offer"; }
  .journal-detail-grid { grid-template-columns: minmax(0, 1fr); }
  .site-footer { gap: 5px; }
}

@media (max-width: 350px) {
  .service-row { gap: 5px; }
  input, textarea { padding-inline: 6px; }
  .save-bar { flex-direction: column; }
}

@page { margin: 17mm; size: A4; }
@media print {
  body:has(> #print-quote) > :not(#print-quote) { display: none !important; }
  :root { background: white; color: black; }
  #print-quote { display: block; font-size: 11pt; }
  #print-quote h1 { font-size: 23pt; font-weight: 700; letter-spacing: 0; margin-bottom: 7mm; max-width: none; }
  #print-quote p { margin-bottom: 4mm; overflow-wrap: anywhere; white-space: pre-wrap; }
  #print-quote table { width: 100%; border-collapse: collapse; margin-bottom: 5mm; }
  #print-quote thead { display: table-header-group; }
  #print-quote tr { break-inside: avoid; }
  #print-quote th, #print-quote td { padding: 2.5mm 2mm; border-bottom: 1px solid #bbb; text-align: left; overflow-wrap: anywhere; }
  #print-quote td:last-child, #print-quote th:last-child { text-align: right; }
  #print-quote strong { font-size: 14pt; }
}
