:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface2: #f4f6f9;
    --text: #1a2332;
    --muted: #5c677d;
    --accent: #1a7fe0;
    --accent-dim: #1566b8;
    --ok: #15803d;
    --border: #d8dee8;
    --radius: 12px;
    --font: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.page {
    max-width: 1180px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

.layout-main {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 1.5rem;
    align-items: start;
}

.layout-col {
    min-width: 0;
}

.layout-col--result {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 901px) {
    .layout-col--result {
        position: sticky;
        top: 1rem;
    }
}

@media (max-width: 900px) {
    .layout-main {
        grid-template-columns: 1fr;
    }

    .layout-col--result {
        position: static;
    }
}

.results-empty {
    margin: 0;
    font-size: 0.95rem;
    color: var(--muted);
    line-height: 1.5;
}

.header {
    margin-bottom: 2rem;
}

.header-title-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.header-logo {
    width: 50px;
    height: 50px;
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0;
}

.lead {
    color: var(--muted);
    margin: 0;
    font-size: 1rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1.5rem 2rem;
    box-shadow: 0 4px 24px rgba(15, 23, 42, 0.06);
    min-width: 0;
    max-width: 100%;
}

.card h2 {
    font-size: 1.2rem;
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem;
    color: var(--accent);
}

.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.blocks-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

@media (max-width: 640px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field > span:first-child {
    font-size: 0.875rem;
    color: var(--muted);
}

.field input[type="number"],
.field input[type="text"],
.field input[type="tel"],
.field select {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 1rem;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(61, 156, 253, 0.25);
}

.field-check {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.6rem;
}

.field-check input {
    margin-top: 0.25rem;
    accent-color: var(--accent);
}

.field-check.sub {
    margin-top: 0.5rem;
}

.mt {
    margin-top: 1rem;
}

.hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin: 1rem 0 0;
    padding: 0.75rem;
    background: var(--surface2);
    border-radius: 8px;
    border-left: 3px solid var(--accent-dim);
}

.openings {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.opening-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(56px, 88px) 42px;
    gap: 0.5rem;
    align-items: end;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.opening-row > * {
    min-width: 0;
}

.opening-row .btn-remove {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
    height: 38px;
    padding: 0;
    box-sizing: border-box;
    justify-self: end;
    align-self: end;
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .opening-row {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .opening-row .opening-qty {
        grid-column: 1;
    }

    .opening-row .btn-remove {
        grid-column: 2;
        justify-self: end;
    }
}

.opening-row label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.75rem;
    color: var(--muted);
}

.opening-row input {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.5rem 0.6rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 0.95rem;
    box-sizing: border-box;
}

.btn {
    font-family: inherit;
    cursor: pointer;
    border: none;
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    transition: background 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    margin-top: 1.5rem;
    background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dim) 100%);
    color: #fff;
    font-weight: 600;
    padding: 0.85rem 1.5rem;
    width: 100%;
}

.btn-primary:hover {
    filter: brightness(1.08);
}

.btn-ghost {
    background: transparent;
    color: var(--accent);
    border: 1px dashed var(--border);
    margin-top: 0.5rem;
}

.btn-ghost:hover {
    border-color: var(--accent);
    background: rgba(61, 156, 253, 0.08);
}

.btn-remove {
    padding: 0.5rem 0.65rem;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-remove:hover {
    color: #ff6b6b;
    border-color: #ff6b6b;
}

.hidden {
    display: none !important;
}

.results {
    margin-top: 0;
}

.results h2 {
    color: var(--ok);
}

.result-section {
    margin-bottom: 1.5rem;
}

.result-section h3 {
    font-size: 1rem;
    margin: 0 0 0.75rem;
    color: var(--muted);
}

.result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.result-table td,
.result-table th {
    text-align: left;
    padding: 0.5rem 0.65rem;
    border-bottom: 1px solid var(--border);
}

.result-table .result-label {
    color: var(--muted);
    font-weight: 500;
    width: 55%;
    vertical-align: top;
}

.result-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.total-row td {
    font-weight: 700;
    font-size: 1.05rem;
    border-bottom: none;
    padding-top: 1rem;
}

.total-row .num {
    color: var(--ok);
}

.footer {
    margin-top: 2rem;
    font-size: 0.8rem;
    color: var(--muted);
    text-align: center;
}

kbd {
    font-family: inherit;
    font-size: 0.85em;
    padding: 0.1em 0.35em;
    background: var(--surface2);
    border-radius: 4px;
}

.pdf-lead {
    font-size: 0.9rem;
    margin: 0 0 1rem;
    color: var(--muted);
}

.pdf-lead code {
    font-size: 0.85em;
    color: var(--accent);
}

/* Разметка для html2pdf (белый фон, тёмный текст) */
.pdf-export-root {
    box-sizing: border-box;
}

.pdf-export-inner {
    box-sizing: border-box;
    width: 100%;
    padding: 14px 16px 18px;
    background: #ffffff;
    color: #1a1a1a;
    font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 10.5pt;
    line-height: 1.45;
}

.pdf-doc-head {
    margin-bottom: 14px;
    border-bottom: 1px solid #cccccc;
    padding-bottom: 10px;
}

.pdf-doc-toprow {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}

.pdf-header-logo {
    width: 50px;
    height: 50px;
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.pdf-doc-top-main {
    flex: 1;
    min-width: 0;
}

.pdf-name-caption {
    margin: 0 0 4px;
    font-size: 9pt;
    color: #666666;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.pdf-doc-head .pdf-doc-title {
    font-size: 17pt;
    margin: 0 0 8px;
    font-weight: 700;
    color: #111111;
    line-height: 1.25;
}

.pdf-doc-kind {
    margin: 0 0 6px;
    font-size: 11pt;
    color: #444444;
    font-weight: 600;
}

.pdf-doc-meta {
    margin: 0 0 8px;
    font-size: 10pt;
    color: #333333;
}

.pdf-date {
    margin: 0;
    font-size: 9pt;
    color: #555555;
}

.pdf-doc-body .result-section {
    margin-bottom: 12px;
}

.pdf-doc-body .result-section h3 {
    font-size: 11pt;
    margin: 0 0 6px;
    color: #222222;
}

.pdf-export-inner .result-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9.5pt;
}

.pdf-export-inner .result-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #e0e0e0;
    color: #222222;
    vertical-align: top;
}

.pdf-export-inner .result-table .result-label {
    color: #222222 !important;
    font-weight: 600;
    width: 50%;
    text-align: left !important;
    font-size: 9.5pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.pdf-export-inner .result-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: #222222;
}

.pdf-export-inner .total-row td {
    font-weight: 700;
    font-size: 10pt;
    border-bottom: none;
    padding-top: 8px;
    color: #111111;
}

.pdf-export-inner .total-row .num {
    color: #111111;
}

.pdf-doc-footer {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #bbbbbb;
}

.pdf-footer-logo {
    width: 50px;
    height: 50px;
    max-width: 50px;
    max-height: 50px;
    object-fit: contain;
    flex-shrink: 0;
    display: block;
}

.pdf-footer-text {
    font-size: 9.5pt;
    color: #222222;
    text-align: right;
    flex: 1;
}

.pdf-footer-text div {
    margin: 2px 0;
}

.pdf-footer-title {
    margin-bottom: 6px !important;
}
