* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-body, 'Segoe UI', Roboto, system-ui, sans-serif);
    background: #f4f7fb;
    padding: 2rem 1rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    color: #0b2b4a;
}
.card {
    max-width: 1100px;
    width: 100%;
    background: white;
    border-radius: 32px;
    box-shadow: 0 20px 40px rgba(0, 20, 40, 0.12);
    padding: 2rem 1.5rem 2.5rem;
}
h1, h2, h3, h4 { font-family: var(--font-heading, var(--font-body, 'Segoe UI', Roboto, system-ui, sans-serif)); }
h1 { font-size: 1.9rem; font-weight: 600; color: #0b2b4a; }
.top-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.subhead {
    color: #2c5778; font-size: 1rem; margin-bottom: 2rem;
    border-left: 4px solid #3a7ca5; background: #eef4fa;
    border-radius: 0 12px 12px 0; padding: 10px 18px;
}
.subhead strong { color: #16445f; font-weight: 600; }

/* Загрузка */
.loading { text-align: center; padding: 3rem; color: #2c5778; font-size: 1.1rem; }
.spinner {
    display: inline-block; width: 30px; height: 30px;
    border: 3px solid #dde9f2; border-top: 3px solid #3a7ca5;
    border-radius: 50%; animation: spin 0.8s linear infinite;
    margin-right: 12px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Вкладки */
.service-tabs { display: flex; gap: 8px; margin-bottom: 1.5rem; flex-wrap: wrap; }
.service-tab {
    padding: 8px 20px; border-radius: 30px; border: 2px solid #dde9f2;
    background: white; cursor: pointer; font-weight: 500; color: #1c4968;
    font-size: 0.9rem; transition: 0.15s; text-decoration: none;
}
.service-tab:hover { background: #eef4fa; }
.service-tab.active { background: #1c4968; color: white; border-color: #1c4968; }

/* Калькулятор */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.8rem; margin: 1.8rem 0 2rem; }
.grid-2col > div { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 720px) {
    .grid-2col { grid-template-columns: 1fr; gap: 1.2rem; }
    .card { padding: 1.5rem 1rem; }
    h1 { font-size: 1.6rem; }
}
.param-group { background: #f9fcff; border-radius: 20px; padding: 1.4rem 1.4rem 1.8rem; border: 1px solid #dde9f2; display: flex; flex-direction: column; height: auto; flex: 1 1 auto; }
.param-group h3 { font-weight: 500; font-size: 1.1rem; color: #1c4968; margin-bottom: 1.2rem; }
.select-row { margin-bottom: 1rem; }
.select-row label { display: block; font-size: 0.8rem; font-weight: 600; color: #1c3f59; margin-bottom: 4px; }
.select-row select, .select-row input {
    width: 100%; padding: 10px 12px; border-radius: 14px;
    border: 1px solid #c9dae8; background: white; font-size: 0.95rem;
    font-weight: 500; color: #0b2b3f; transition: 0.15s; outline: none;
}
.select-row select:focus, .select-row input:focus { outline: 2px solid #3a8bb9; border-color: transparent; }

/* Результат */
.result-box {
    background: #e3eef9; border-radius: 20px; padding: 1.6rem 1.8rem;
    margin: 0.5rem 0 1.2rem; display: flex; justify-content: space-between;
    align-items: center; flex-wrap: wrap; gap: 1rem; border: 1px solid #bdd6e9;
}
.result-box .price { font-size: 2.5rem; font-weight: 700; color: #003153; line-height: 1; }
.result-box .price small { font-size: 1.2rem; font-weight: 400; color: #1b4f72; margin-left: 6px; }
.result-box .label { font-size: 0.9rem; font-weight: 500; color: #1d4b69; }
.detail-info {
    background: #f2f8fe; border-radius: 16px; padding: 1rem 1.4rem;
    font-size: 0.9rem; color: #124162; border: 1px solid #d4e3f0;
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 20px;
}
.detail-info span {
    background: white; padding: 3px 12px; border-radius: 30px;
    border: 1px solid #c7dbea; font-weight: 500;
}

/* Кнопки */
.btn-reset {
    background: transparent; border: 1px solid #b2cedf; padding: 6px 18px;
    border-radius: 40px; font-size: 0.8rem; color: #1b5172; cursor: pointer;
    font-weight: 500; transition: 0.15s;
}
.btn-reset:hover { background: #d3e4f0; border-color: #7faec9; }
.btn-add {
    background: #1e7a3d; color: white; border: none; padding: 6px 18px;
    border-radius: 40px; font-size: 0.8rem; cursor: pointer; font-weight: 500;
    transition: 0.15s;
}
.btn-add:hover { background: #155a2c; }
.hidden { display: none !important; }
.service-content { display: none; }
.service-content.active { display: block; }

/* Внутренний блок (себестоимость) */
.internal-box {
    margin-top: 10px; background: #fff4e5; border: 1px dashed #f0b260;
    border-radius: 14px; padding: 12px 16px; font-size: 0.9rem;
    color: #7a4a00; display: flex; flex-direction: column; gap: 6px;
}
.internal-box .row-inner { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.internal-box .pos { color: #1e7a3d; font-weight: 600; }
.internal-box .neg { color: #b13e4b; font-weight: 600; }

/* Футер и шапка */
.footer-note {
    margin-top: 2rem; font-size: 0.8rem; color: #3a6483; text-align: center;
    border-top: 1px solid #d2e1ed; padding-top: 1.6rem;
    display: flex; justify-content: center; flex-wrap: wrap; gap: 1.2rem;
}
.footer-note span { background: #eaf2f9; padding: 4px 16px; border-radius: 40px; }
.btn-auth {
    background: #1c4968; color: #fff; border: none; padding: 8px 18px;
    border-radius: 30px; cursor: pointer; font-weight: 500; text-decoration: none;
    display: inline-block; font-size: 0.9rem; transition: 0.15s;
}
.btn-auth:hover { background: #16445f; }
.btn-auth.logout { background: #b13e4b; }
.btn-auth.logout:hover { background: #962a38; }
.user-badge {
    background: #e3eef9; color: #003153; padding: 6px 14px;
    border-radius: 30px; font-size: 0.85rem; font-weight: 600;
    display: inline-block;
}

/* Модалки */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0, 20, 40, 0.55);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-card {
    background: #fff; border-radius: 20px; padding: 0;
    width: 100%; max-width: 360px; max-height: 90vh; overflow: hidden;
    display: flex; flex-direction: column;
    box-shadow: 0 20px 50px rgba(0, 20, 40, 0.3);
}
.modal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 0 1.8rem 1.8rem; }
.modal-card.modal-lg { max-width: 800px; }
.modal-card h2 { margin-bottom: 1.2rem; color: #0b2b4a; font-size: 1.2rem; }
.modal-card input {
    width: 100%; padding: 10px 12px; border-radius: 12px;
    border: 1px solid #c9dae8; margin-bottom: 10px; font-size: 0.95rem; outline:none;
}
.modal-card .error { color: #b13e4b; font-size: 0.85rem; margin-bottom: 10px; min-height: 1em; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }
.modal-actions button {
    padding: 8px 16px; border-radius: 30px; border: none;
    cursor: pointer; font-weight: 500;
}
.modal-actions .primary { background: #1c4968; color: #fff; }
.modal-actions .secondary { background: #eef4fa; color: #1c4968; }

/* Смета */
.cart-table-wrap { overflow-x: auto; }
.cart-table { width: 100%; min-width: 680px; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.cart-table th, .cart-table td { padding: 10px; border-bottom: 1px solid #dde9f2; text-align: left; }
.cart-table th { background: #f2f8fe; color: #1c4968; font-weight: 600; }
.qty-input {
    display: inline-flex; align-items: stretch; width: 68px; height: 26px;
    border: 1px solid #c9dae8; border-radius: 8px; background: #fff;
    overflow: hidden; vertical-align: middle;
}
.qty-input:focus-within { border-color: #3a8bb9; box-shadow: 0 0 0 2px rgba(58,139,185,0.12); }
.qty-input input {
    flex: 1 1 auto; width: 100%; min-width: 0; height: 100%; padding: 3px 3px;
    text-align: center; border: 0; border-radius: 0; background: transparent;
    font-size: 0.78rem; color: #0b2b3f; outline: none;
    -moz-appearance: textfield; appearance: textfield;
}
.qty-input input:focus { border: 0; box-shadow: none; }
.qty-input input::-webkit-outer-spin-button,
.qty-input input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.qty-arrows {
    flex: 0 0 16px; display: flex; flex-direction: column; justify-content: center;
    gap: 1px; border-left: 1px solid #dde9f2; background: #f8fbfe;
}
.qty-arrows button {
    width: 16px; height: 11px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 0; background: transparent;
    color: #5a7791; font-size: 8px; line-height: 1;
    cursor: pointer;
}
.qty-arrows button:hover { background: #eef4fa; color: #1c4968; }
.cart-summary { display: flex; justify-content: space-between; align-items: flex-end; margin-top: 1.5rem; flex-wrap: wrap; gap: 10px;}
.cart-total { font-size: 1.5rem; font-weight: 700; color: #003153; }
.cart-margin-total {
    margin-top: 1rem; padding-top: 0.8rem;
    border-top: 1px solid #dde9f2; text-align: right;
    font-size: 1.05rem; color: #16445f;
}
.export-filename {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.8rem; color: #5a7791; font-weight: 500;
}
.export-filename input {
    padding: 6px 10px; border-radius: 10px; border: 1px solid #c9dae8;
    font-size: 0.85rem; color: #0b2b3f; outline: none; width: 150px;
}
.export-filename input:focus { border-color: #3a8bb9; }
.cart-table .pos, .cart-margin-total .pos { color: #1e7a3d; }
.cart-table .neg, .cart-margin-total .neg { color: #b13e4b; }
.old-price {
    text-decoration: line-through; color: #8a9bab;
    font-size: 0.65em; font-weight: 500;
    margin-right: 4px; white-space: nowrap;
}.modal-top-actions {
    flex: 0 0 auto;
    display: flex; justify-content: flex-end; align-items: center; gap: 8px;
    margin: 0; padding: 1rem 1.8rem 0.6rem;
    background: #fff;
}
.modal-close {
    width: 30px; height: 30px; padding: 0; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #c9dae8; border-radius: 50%; background: #fff; color: #5a7791;
    font-size: 1rem; line-height: 1; cursor: pointer; transition: 0.15s;
}
.modal-close:hover { background: #eef4fa; color: #1c4968; border-color: #9fc3dd; }
.modal-save {
    border: none; border-radius: 8px; padding: 6px 14px; background: #1e7a3d; color: #fff;
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.modal-save:hover { background: #16632f; }
.cart-item-name {
    width: 100%; min-width: 130px; padding: 6px 8px; margin-bottom: 0; border: 1px solid #c9dae8; border-radius: 8px;
    font-size: 0.82rem; color: #0b2b3f; background: #fff; outline: none;
}
.cart-item-name:focus { border-color: #3a8bb9; box-shadow: 0 0 0 2px rgba(58,139,185,0.15); }
.section-icon { display: inline-flex; align-items: center; justify-content: center; width: 1.1em; height: 1.1em; vertical-align: -0.15em; }
.section-icon svg { width: 100%; height: 100%; display: block; }
.section-icon.icon-flat svg { fill: currentColor; stroke: none; }
.section-icon.icon-lineart svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mail-field { display:block; font-size:0.85rem; font-weight:600; color:#1c4968; margin-bottom:12px; }
.mail-field input { display:block; width:100%; margin-top:6px; padding:9px 11px; border:1px solid #c9dae8; border-radius:9px; font-size:0.9rem; outline:none; }
.mail-field input:focus { border-color:#3a8bb9; }
.mail-attachment-list { display:flex; align-items:center; gap:12px; flex-wrap:wrap; font-size:0.85rem; color:#1c4968; margin-bottom:10px; }
.mail-attachment-list label { display:flex; align-items:center; gap:5px; cursor:pointer; }
.mail-status { min-height:20px; color:#b13e4b; font-size:0.82rem; line-height:1.4; margin-bottom:8px; }
@media (max-width: 760px) {
    .cart-table-wrap { overflow: visible; }
    .cart-table { min-width: 0; display: block; width: 100%; }
    .cart-table thead { display: none; }
    .cart-table tbody, .cart-table tr, .cart-table td { display: block; width: 100%; }
    .cart-table tr {
        margin-bottom: 12px; border: 1px solid #dde9f2; border-radius: 12px;
        background: #fff; overflow: hidden;
    }
    .cart-table td {
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 8px 10px; border: 0; border-bottom: 1px solid #edf3f8; text-align: right;
    }
    .cart-table td:last-child { border-bottom: 0; }
    .cart-table td::before {
        content: attr(data-label); flex: 0 0 38%; text-align: left;
        font-size: 0.76rem; font-weight: 600; color: #5a7791; line-height: 1.35;
    }
    .cart-table td[data-label=""]::before { display: none; }
    .cart-table td[data-label=""] { justify-content: flex-end; }
    .cart-table td .cart-item-name { width: 100%; min-width: 0; text-align: right; }
    .cart-table td .qty-input { margin-left: auto; }
    .cart-summary { flex-direction: column; align-items: stretch; }
    .cart-summary > div:last-child { align-items: stretch !important; }
    .cart-summary .export-filename { width: 100%; }
    .cart-summary .export-filename input { width: 100%; }
}
.cart-clear-top { background: #b13e4b; }
.cart-clear-top:hover { background: #95313e; }
.cart-summary-left { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; flex: 1 1 320px; }
.cart-export-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-start; }
.cart-summary-right { text-align: right; flex: 0 0 auto; }
.cart-margin-total { text-align: right; }
#cartModalContent { font-size: 0.8rem; }
#cartModalContent h2 { font-size: 1.05rem; }
#cartModalContent .cart-table { font-size: 0.75rem; }
#cartModalContent .cart-table th, #cartModalContent .cart-table td { padding: 7px 6px; }
#cartModalContent .cart-table th { font-size: 0.7rem; }
#cartModalContent .cart-item-name { min-width: 110px; padding: 5px 6px; font-size: 0.75rem; }
#cartModalContent .cart-total { font-size: 1.25rem; }
#cartModalContent .cart-margin-total { font-size: 0.95rem; }
#cartModalContent .cart-summary { margin-top: 1rem; }
#cartModalContent .cart-summary-right { font-size: 0.78rem; line-height: 1.4; }
#cartModalContent .export-filename { font-size: 0.72rem; }
#cartModalContent .export-filename input { width: 160px; padding: 5px 8px; font-size: 0.75rem; }
#cartModalContent .cart-export-buttons .btn-add { padding: 5px 12px; font-size: 0.72rem; }
#cartModalContent .old-price { font-size: 0.62em; }
@media (max-width: 760px) {
    #cartModalContent .cart-table td::before { font-size: 0.7rem; }
    #cartModalContent .cart-summary-right { text-align: right; }
}
@media (max-width: 760px) {
    #cartModalContent .cart-summary-left,
    #cartModalContent .cart-summary-right { width: 100%; }
    #cartModalContent .cart-summary .export-filename { width: 100%; }
    #cartModalContent .cart-summary .export-filename input { width: 100%; }
}
