/* ==================================================================
   Основные цвета и типографика
   ================================================================== */
:root {
    --bg: #ece1d9;
    --surface: #ffffff;
    --surface-2: #f7f1ec;
    --surface-3: #f3ebe4;
    --text: #2c2622;
    --muted: #7d7169;
    --border: #dfd2c7;
    --border-soft: #eee3da;
    --primary: #3cbccc;
    --primary-dark: #2ba4b2;
    --cancel: #ec7053;
    --cancel-dark: #d65c40;
    --btn-text: #ffffff;
    --dark: #262626;
    --green: #2c7a46;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(80, 60, 40, 0.08);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
    margin: 0 0 10px;
    line-height: 1.2;
    color: var(--text);
}

h1 {
    font-size: 26px;
    font-weight: 700;
}

h2 {
    font-size: 19px;
    font-weight: 700;
}

h3 {
    font-size: 16px;
    font-weight: 700;
}

h4 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

p {
    margin: 0 0 8px;
}

a {
    color: #1b7f8b;
}

p a {
    color: var(--primary-dark);
}

.muted {
    color: var(--muted);
}

.nowrap {
    white-space: nowrap;
}

.mono {
    font-family: ui-monospace, Consolas, "Courier New", monospace;
}

[hidden] {
    display: none !important;
}

.hide {
    display: none!important;
}

/* ==================================================================
   Кнопки, поля, служебные элементы
   ================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    color: var(--btn-text);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
    background: transparent;
}

.btn:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--btn-text);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-cancel {
    background: var(--cancel);
    border-color: var(--cancel);
    color: var(--btn-text);
}

.btn-cancel:hover {
    background: var(--cancel-dark);
    border-color: var(--cancel-dark);
}

.btn-outline {
    background: var(--dark);
    border-color: var(--dark);
    color: var(--btn-text);
}

.btn-outline:hover {
    background: #3d3d3d;
    border-color: #3d3d3d;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12.5px;
    border-radius: 6px;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.input {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    line-height: 1.3;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(60, 188, 204, 0.15);
}

textarea.input {
    resize: vertical;
}

.input-sm {
    padding: 6px 8px;
    font-size: 13px;
    border-radius: 6px;
}

.input-xs {
    padding: 4px 6px;
    margin-top: 4px;
    border-color: transparent;
    background: var(--surface-2);
    font-size: 12px;
    border-radius: 5px;
    color: #5d534c;
}

.input-xs:focus {
    background: var(--surface);
    border-color: var(--primary);
}

.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    cursor: pointer;
    user-select: none;
}

.checkbox input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

input[type="checkbox"] {
    accent-color: var(--primary);
}

.unit {
    color: var(--muted);
    font-size: 12.5px;
    white-space: nowrap;
}

.input-with-unit {
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-with-unit .input {
    min-width: 70px;
}

/* ==================================================================
   Шапка сайта
   ================================================================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 22px;
    /*max-width: 1500px;*/
    margin: 0 auto;
    padding: 12px 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: var(--text);
    font-size: 19px;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: -0.01em;
}

.brand-logo {
    display: block;
    max-height: 40px;
    max-width: 220px;
}

.main-nav {
    display: flex;
    flex: 1;
    flex-wrap: wrap;
    justify-content: center;
    gap: 3px;
}

.nav-link {
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background: var(--surface-2);
}

.nav-link.is-active {
    background: rgba(60, 188, 204, 0.13);
    color: #16707a;
    font-weight: 600;
}

.user-box {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    color: var(--muted);
    font-size: 13.5px;
    white-space: nowrap;
}

.user-name {
    color: var(--text);
}

.user-login {
    color: var(--muted);
}

.user-sep {
    color: #cbb9a9;
}

.logout-form {
    margin: 0;
}

.link-button {
    padding: 0;
    border: none;
    background: none;
    color: var(--cancel);
    font-family: inherit;
    font-size: inherit;
    font-weight: 600;
    cursor: pointer;
}

.link-button:hover {
    text-decoration: underline;
}

/* ==================================================================
   Общий каркас страниц
   ================================================================== */
.page {
    /*max-width: 1500px;*/
    margin: 0 auto;
    padding: 24px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.page-head h1 {
    margin-bottom: 3px;
}

.page-head p {
    margin: 0;
}

.head-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.card {
    margin-bottom: 18px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.table-card {
    padding: 8px;
}

.table-wrap {
    overflow-x: auto;
}

.flash {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 9px;
    font-size: 14px;
}

.flash-success {
    background: #e5f6ea;
    border: 1px solid #b9e3c6;
    color: #226b3c;
}

.flash-error {
    background: #fdece7;
    border: 1px solid #f3b8a8;
    color: #a53b22;
}

.empty-state {
    padding: 44px 24px;
    text-align: center;
}

.empty-state h2 {
    margin-bottom: 8px;
}

.empty-state p {
    max-width: 560px;
    margin: 0 auto 16px;
    color: var(--muted);
}

.empty-state.compact {
    padding: 18px;
}

.empty-state.compact p {
    margin-bottom: 0;
}

/* ==================================================================
   Таблицы
   ================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.data-table th {
    padding: 8px 2px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.data-table td {
    padding: 8px 2px;
    border-bottom: 1px solid var(--border-soft);
    vertical-align: top;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #fdfaf7;
}

.cell-center {
    text-align: center;
}

.cell-check {
    width: 48px;
    text-align: center;
}

.cell-calc {
    color: var(--text);
    font-weight: 600;
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cost-value {
    color: var(--muted);
    font-weight: 500;
}

.margin-value {
    color: var(--green);
}

/* ==================================================================
   Проекты: фильтры и список
   ================================================================== */
.filters .filter-row {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.filters .filter-row:last-of-type {
    margin-bottom: 0;
}

.filter-search {
    flex: 1 1 300px;
    max-width: 460px;
}

.segmented {
    display: inline-flex;
    gap: 3px;
    padding: 3px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
}

.segmented-btn {
    padding: 7px 14px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
}

.segmented-btn.is-active {
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.filter-statuses {
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}

.filter-label {
    color: var(--muted);
    font-size: 13px;
}

.filter-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.filter-meta .filter-summary {
    margin-top: 0;
}

.filter-save-status {
    min-height: 1em;
    color: var(--muted);
    font-size: 12px;
}

.filter-save-status.is-error {
    color: var(--cancel);
}

.filter-summary {
    margin-top: 8px;
    font-size: 13px;
}

.projects-table {
    min-width: 1080px;
}

.projects-table .col-date {
    width: 150px;
}

.projects-table .col-user {
    width: 190px;
}

.projects-table .col-status {
    width: 120px;
}

.projects-table .col-actions {
    width: 360px;
}

.project-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.project-link:hover .project-name {
    color: var(--primary-dark);
    text-decoration: underline;
}

.project-name {
    color: var(--text);
    font-size: 14.5px;
    font-weight: 600;
    text-decoration: none;
}

.project-desc {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12.5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.row-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-soft {
    margin-left: 6px;
    background: var(--surface-3);
    color: var(--muted);
    font-weight: 500;
}

.status-new {
    background: #e8f4f6;
    color: #1f7a86;
}

.status-work {
    background: #fff1d6;
    color: #946700;
}

.status-done {
    background: #e3f5e8;
    color: #2c7a46;
}

.status-archive {
    background: #eee9e5;
    color: #7d7169;
}

/* ==================================================================
   Формы
   ================================================================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.field > span {
    color: var(--muted);
}

.field input,
.field textarea,
.field select {
    font-weight: 400;
    color: var(--text);
}

.field-wide {
    grid-column: 1 / -1;
}

.public-toggle {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
}

.public-toggle input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.public-toggle-check {
    width: 20px;
    height: 20px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: var(--surface);
    color: transparent;
    flex: 0 0 auto;
}

.public-toggle input:checked ~ .public-toggle-check {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.public-toggle.is-on {
    border-color: var(--primary);
}

.public-toggle input:focus-visible ~ .public-toggle-check {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.field em {
    color: var(--cancel);
    font-style: normal;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}

.form-errors {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #f3b8a8;
    border-radius: 8px;
    background: #fdece7;
    color: #a53b22;
    font-size: 13.5px;
}

.form-errors div + div {
    margin-top: 4px;
}

.user-cell {
    font-weight: 600;
}

.users-table {
    min-width: 680px;
}

/* ==================================================================
   Авторизация
   ================================================================== */
.auth-page {
    min-height: 100vh;
    background: var(--bg);
}

.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    width: min(390px, 100%);
    padding: 32px 28px;
    border-radius: 14px;
    background: var(--dark);
    color: #ffffff;
    box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
}

.auth-brand {
    margin-bottom: 12px;
    color: #a3a3a3;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.auth-card h1 {
    color: #ffffff;
    font-size: 22px;
    margin-bottom: 20px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.auth-field span {
    color: #d9d9d9;
    font-size: 13px;
}

.auth-field input {
    padding: 10px 12px;
    border: 1px solid #4a4a4a;
    border-radius: 8px;
    background: #333333;
    color: #ffffff;
    font-family: inherit;
    font-size: 14px;
}

.auth-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(60, 188, 204, 0.25);
}

.auth-card .btn {
    margin-top: 8px;
}

.auth-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(236, 112, 83, 0.55);
    border-radius: 8px;
    background: rgba(236, 112, 83, 0.12);
    color: #ec7053;
    font-size: 13px;
}

/* ==================================================================
   Товары и услуги
   ================================================================== */
.store-block .block-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.block-name {
    padding-left: 0;
    border-color: transparent;
    background: transparent;
    font-size: 17px;
    font-weight: 700;
}

.block-name:hover {
    border-color: var(--border);
    background: var(--surface);
}

.block-description {
    margin-bottom: 14px;
    background: var(--surface-2);
    font-size: 13.5px;
}

.products-table {
    min-width: 1250px;
}

.products-table td {
    vertical-align: middle;
}

.products-table .cell-name {
    min-width: 170px;
}

.product-row > td {
    background: var(--surface);
    background-color: #f7f1ec;
}

.variations-row > td {
    padding: 10px 14px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
    background-color: #ededed;
}

.variations-row-free {
    background-color: #fff!important;
}

.variations-title {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.variations-table {
    min-width: 900px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
}

.variations-table th {
    background: var(--surface-3);
    background: #d3d3d3;
    font-size: 10.5px;
}

.variations {
    display: block;
}

.variations .variations-table {
    display: none;
}

.variations.has-variations .variations-table {
    display: table;
}

.variations-empty {
    margin: 0 0 8px;
    font-size: 13px;
}

.variations.has-variations .variations-empty {
    display: none;
}

.js-add-variation {
    margin-top: 10px;
    background-color: #ece1d9;
    border-color: #dfd2c7;
    color: #7d7169;
}

.store-draft-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid #e3b27a;
    border-radius: 10px;
    background: #fff4e3;
    color: #7a4b12;
}

.store-draft-banner .muted {
    margin-left: 8px;
    color: #8a6a45;
}

.store-draft-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.store-actions {
    position: sticky;
    bottom: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0 10px;
    background: linear-gradient(to top, var(--bg) 65%, rgba(236, 225, 217, 0));
}

.save-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.save-status {
    color: var(--muted);
    font-size: 13px;
}

.save-status.is-success {
    color: var(--green);
}

.save-status.is-error {
    color: var(--cancel);
}

.is-deleted {
    display: none !important;
}

/* ==================================================================
   Секции
   ================================================================== */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.tab {
    display: inline-flex;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.tab:hover {
    border-color: #cbb9a9;
}

.tab.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--btn-text);
}

.section-editor > form > h2 {
    margin-top: 20px;
}

.fields-table {
    min-width: 700px;
}

.dropdown-form {
    position: relative;
}

.dropdown-form > summary {
    list-style: none;
    cursor: pointer;
}

.dropdown-form > summary::-webkit-details-marker {
    display: none;
}

.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    width: min(380px, 90vw);
    margin: 0;
    text-align: left;
}

.dropdown-panel .field {
    margin-bottom: 12px;
}

.add-field-form,
.add-product-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.add-field-form .input {
    flex: 1 1 150px;
    width: auto;
}

.add-product-form .input {
    flex: 1 1 320px;
    width: auto;
}

.inline-create {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    max-width: 520px;
    margin: 0 auto;
}

.inline-create .input {
    flex: 1 1 260px;
    width: auto;
}

/* ==================================================================
   Редактирование проекта
   ================================================================== */
.project-layout {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.project-sidebar {
    position: sticky;
    top: 84px;
}

.sidebar-card {
    padding: 14px;
}

.sidebar-title {
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 700;
}

.sidebar-list {
    max-height: 58vh;
    margin: 0 0 10px;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.sidebar-link {
    display: block;
    padding: 7px 9px;
    overflow: hidden;
    border-radius: 7px;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
    /*text-overflow: ellipsis;*/
    /*white-space: nowrap;*/
}

.sidebar-link:hover {
    background: var(--surface-2);
}

.sidebar-link.is-active {
    background: rgba(60, 188, 204, 0.14);
    color: #16707a;
    font-weight: 600;
}

.sidebar-all {
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.project-main {
    min-width: 0;
}

.graphics-canvas {
    min-height: 130px;
    border: 1px dashed var(--border);
    border-radius: 8px;
    background: var(--surface-2);
}

.section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.section-hint {
    margin-bottom: 12px;
    font-size: 13px;
}

.section-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    cursor: pointer;
    user-select: none;
}

.section-tab.is-active {
    border-color: var(--primary);
    background: var(--surface);
    box-shadow: 0 0 0 2px rgba(60, 188, 204, 0.18);
}

.tab-check {
    width: 16px;
    height: 16px;
    margin: 0;
}

.tab-name {
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.section-fields {
    margin-bottom: 20px;
}

.section-fields-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.section-fields-head h3 {
    margin: 0;
}

.section-calc-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.fields-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.field-inline {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-label {
    color: var(--muted);
    font-size: 12.5px;
}

.field-label small {
    color: #a09287;
    font-weight: 400;
}

.category-block {
    margin-bottom: 16px;
}

.category-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.category-head h4 {
    margin: 0;
}

.cell-calc-action {
    width: 130px;
    white-space: nowrap;
}

.cell-calc-action .btn {
    padding: 6px 9px;
    font-size: 12px;
}

.project-products {
    min-width: 1080px;
}

.project-products th {
    font-size: 8px;
    text-align: center;
}

.project-products td {
    vertical-align: middle;
    text-align: center;
}

.project-products .input-sm {
    min-width: 70px;
}

.custom-add-product {
    margin-top: 8px;
}

.custom-row-remove {
    margin-top: 4px;
}

.cell-name .input {
    min-width: 190px;
}

.cell-additional {
    width: 160px;
}

.cell-additional .input {
    min-width: 140px;
}

.cell-additional-name {
    min-width: 150px;
}

.cell-qty {
    width: 110px;
}

.cell-qty-custom {
    width: 150px;
}

.custom-qty {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.custom-qty .input {
    width: 100%;
    min-width: 0;
}

.cell-price {
    width: 125px;
}

.project-product-row:not(.is-enabled) {
    opacity: 0.55;
}

.project-product-row.is-enabled {
    background: #fcfdfd;
}

.category-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px 20px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 13px;
}

.category-total-label {
    margin-right: auto;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.category-total-sum {
    font-size: 16px;
    font-weight: 700;
    white-space: nowrap;
}

.category-total-sum strong,
.category-total-extra strong,
.project-total-sum strong,
.project-total-extra strong {
    font-variant-numeric: tabular-nums;
}

.category-total-extra {
    color: var(--muted);
    font-size: 12.5px;
}

.category-total-extra strong {
    color: var(--text);
    font-weight: 600;
}

.project-total-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    border-left: 4px solid var(--primary);
    width: 100%;
}

.project-total-main {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.project-total-label {
    font-size: 15px;
    font-weight: 700;
}

.project-total-sum {
    color: var(--text);
    font-size: 24px;
    font-weight: 800;
    white-space: nowrap;
}

.project-total-note {
    color: var(--muted);
    font-size: 12px;
}

.project-total-extra {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px 14px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
}

.project-total-costs {
    white-space: normal;
}

.project-save-controls {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.project-total-extra strong {
    color: var(--text);
    font-weight: 600;
}

.project-total-sep {
    margin: 0 6px;
    color: #b9a99c;
}

.project-total-breakdown {
    display: flex;
    flex-basis: 100%;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 18px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
}

.project-total-breakdown-title {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.project-total-section {
    display: inline-flex;
    align-items: baseline;
    gap: 6px;
    color: var(--muted);
    font-size: 12.5px;
}

.project-total-section-value {
    color: var(--muted);
}

.project-total-section-sum {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.project-total-section.is-off {
    opacity: 0.55;
}

.project-total-section.is-off .project-total-section-sum {
    text-decoration: line-through;
}

.project-total-section.is-off::after {
    content: "не включена";
    color: var(--cancel);
    font-size: 11px;
}

.project-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 12;
    margin-top: 0;
    padding: 12px 0;
    background: linear-gradient(to top, var(--bg) 65%, rgba(236, 225, 217, 0));
}

/* ==================================================================
   Публичное предложение
   ================================================================== */
.proposal-page {
    background: var(--bg);
}

.proposal {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

.proposal-head {
    margin-bottom: 26px;
    text-align: center;
}

.proposal-company {
    margin-bottom: 10px;
    color: #8a7b71;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.proposal-head h1 {
    font-size: 30px;
}

.proposal-desc {
    max-width: 720px;
    margin: 8px auto 0;
    color: var(--muted);
    white-space: pre-line;
}

.proposal-section {
    margin-bottom: 20px;
    padding: 24px 26px;
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.proposal-section h3 {
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary);
    font-size: 20px;
}

.proposal-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 26px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    /*background: var(--surface-2);*/
}

.proposal-field {
    display: block;
    gap: 8px;
    font-size: 14px;
    width: 100%;
}

.proposal-field-name {
    /*color: var(--muted);*/
}

.proposal-field-value {
    font-weight: 600;
}

.proposal-category h4 {
    margin-top: 14px;
}

.proposal-table {
    min-width: 640px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.proposal-table th {
    background: var(--surface-2);
}

.proposal-product-name {
    font-weight: 600;
}

.proposal-product-desc {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12.5px;
}

.section-total {
    margin-top: 14px;
    color: var(--muted);
    font-size: 14px;
    text-align: right;
}

.section-total strong {
    color: var(--text);
    font-size: 17px;
}

.proposal-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 26px;
    border-radius: 12px;
    background: var(--dark);
    color: #ffffff;
    font-size: 15px;
}

.proposal-total strong {
    font-size: 24px;
}

.proposal-empty {
    padding: 44px;
    border-radius: 12px;
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow);
}

/* ==================================================================
   Ошибки
   ================================================================== */
.error-page {
    /*min-height: 100vh;*/
    background: var(--bg);
}

.error-page .error-box {
    max-width: 500px;
    margin: 10vh auto;
    padding: 40px;
    border-radius: 14px;
    background: var(--surface);
    text-align: center;
    box-shadow: var(--shadow);
}

.error-code {
    color: var(--cancel);
    font-size: 58px;
    font-weight: 800;
    line-height: 1;
}

.error-box p {
    color: var(--muted);
}

.error-box pre {
    margin: 14px 0;
    padding: 10px;
    overflow-x: auto;
    border-radius: 6px;
    background: var(--surface-2);
    font-size: 12px;
    text-align: left;
}

/* ==================================================================
   Адаптивность и печать
   ================================================================== */
@media (max-width: 1200px) {
    .project-layout {
        grid-template-columns: 220px minmax(0, 1fr);
    }

    .header-inner {
        gap: 14px;
        padding: 10px 18px;
    }

    .nav-link {
        padding: 7px 9px;
        font-size: 13px;
    }
}

@media (max-width: 980px) {
    .header-inner {
        flex-wrap: wrap;
    }

    .main-nav {
        order: 3;
        flex-basis: 100%;
        justify-content: flex-start;
    }

    .user-box {
        margin-left: auto;
    }

    .project-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .project-sidebar {
        position: static;
    }

    .sidebar-list {
        display: flex;
        gap: 5px;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .sidebar-link {
        /*white-space: nowrap;*/
    }

    .form-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 640px) {
    html {
        font-size: 14px;
    }

    .page {
        padding: 14px;
    }

    .card {
        padding: 14px;
    }

    h1 {
        font-size: 22px;
    }

    .header-inner {
        padding: 10px 14px;
    }

    .brand {
        font-size: 17px;
    }

    .user-box {
        width: 100%;
        justify-content: space-between;
    }

    .filter-search {
        max-width: none;
    }

    .store-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .save-area {
        justify-content: space-between;
    }

    .proposal {
        padding: 18px 12px 40px;
    }

    .proposal-section {
        padding: 18px 14px;
    }

    .proposal-head h1 {
        font-size: 24px;
    }

    .proposal-total {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media print {
    body,
    .proposal-page {
        background: #ffffff;
    }

    .proposal {
        max-width: none;
        padding: 0;
    }

    .proposal-section,
    .proposal-total {
        border: 1px solid #dddddd;
        box-shadow: none;
        break-inside: avoid;
    }
}

.js-copy{
    color: var(--text);
}

.btn-projects{
    padding: 5px !important;
}
.btn-projects:hover{
    background-color: #ddd;
}




.slab { display: flex; gap: 16px; align-items: flex-start; }

/* ---------------- чертёж ---------------- */
.slab-board { position: relative; /*border: 1px solid #ccc; background: #fafafa;*/ }
.slab-board canvas { display: block; cursor: default; user-select: none; }
.slab-overlay { position: absolute; inset: 0; pointer-events: none; }

/* поля ввода прямо на чертеже */
.slab-field {
    position: absolute; transform: translate(-50%, -50%);
    display: flex; align-items: center; gap: 2px;
    padding: 0 3px; background: #fff; border: 1px solid #b9c4d0;
    border-radius: 4px; pointer-events: auto;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.slab-field input {
    width: 44px; border: 0; outline: 0; background: transparent;
    font: 12px/18px sans-serif; text-align: right; color: #2c3e50;
    -moz-appearance: textfield; appearance: textfield;
}
.slab-field input::-webkit-outer-spin-button,
.slab-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.slab-field .unit { font-size: 11px; color: #7f8c8d; }
.slab-field.ang { border-color: #a9cdf0; }
.slab-field.ang input { width: 32px; color: #0b6bcb; font-weight: 700; }
/* значение, которое фигура выполнить не может */
.slab-field.bad { border-color: #e05252; background: #fdecec; }
.slab-field.bad input { color: #c0392b; }
.slab-field.bad .unit { color: #c0392b; }

/* ---------------- панель справа ---------------- */
.slab-side { width: 290px; background: #fff; border: 1px solid #ccc; padding: 12px 14px; }
.slab-side h3 { margin: 0 0 10px; font-size: 15px; }
.slab-res { display: flex; align-items: baseline; gap: 6px; padding: 7px 0; border-bottom: 1px dashed #e2e6ea; }
.slab-res span { flex: 1; font-size: 13px; color: #7f8c8d; }
.slab-res b { font-size: 17px; }
.slab-res i { font-size: 12px; font-style: normal; color: #7f8c8d; }
.slab-state { margin-top: 10px; padding: 6px 8px; border-radius: 4px; font-size: 12px; }
.slab-state.ok { background: #eaf7ee; color: #1e7a3c; }
.slab-state.bad { background: #fdf3e2; color: #98631b; }
.slab-hint { margin: 12px 0; font-size: 12px; color: #7f8c8d; }
/* быстрый прямоугольник */
.slab-quick { margin-top: 12px; padding-top: 10px; border-top: 1px dashed #e2e6ea; }
.slab-quick > span { font-size: 12px; color: #7f8c8d; }
.slab-quick-row { display: flex; gap: 8px; margin: 6px 0 8px; }
.slab-quick-row label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #7f8c8d; }
.slab-quick-row input {
    width: 64px; padding: 3px 5px; border: 1px solid #b9c4d0; border-radius: 4px;
    font: 12px/16px sans-serif; text-align: right; color: #2c3e50;
    -moz-appearance: textfield; appearance: textfield;
}
.slab-quick-row input::-webkit-outer-spin-button,
.slab-quick-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.slab-btns { display: flex; gap: 8px; }
.slab-side button { padding: 5px 10px; font: 13px sans-serif; cursor: pointer; }
.slab-side button:disabled { color: #aab; cursor: default; }
.slab-json { margin-top: 12px; font-size: 11px; color: #7f8c8d; }
.slab-json pre {
    margin: 4px 0 0; padding: 6px; border: 1px solid #e2e6ea; border-radius: 4px;
    background: #f5f7f9; color: #2c3e50; font: 11px/1.4 monospace;
    white-space: pre-wrap; word-break: break-all;
}


.wrap { display: flex; gap: 16px; align-items: flex-start; height: 400px; }
.scheme { border: 1px solid #ccc; background: #fafafa; }
.sect-panel { width: 330px; background: #fff; border: 1px solid #ccc; padding: 10px 12px; height: 380px; }
.sect-panel h3 { margin: 0 0 8px; font-size: 15px; }
.sect-head, .sect-row { display: grid; grid-template-columns: 18px 16px 1fr 58px 58px; gap: 6px; align-items: center; }
.sect-head { font-size: 11px; color: #7f8c8d; padding-bottom: 4px; }
.sect-head span:nth-child(4), .sect-head span:nth-child(5) { text-align: right; }
.sect-row { padding: 4px 0; cursor: pointer; }
.sect-row + .sect-row { border-top: 1px dashed #e2e6ea; }
.sect-sw { width: 14px; height: 14px; border: 1px solid #aab; }
.sect-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sect-h { width: 100%; min-width: 0; text-align: right; box-sizing: border-box; border: 0 !important; }
.sect-hint { margin-top: 10px; font-size: 12px; color: #7f8c8d; }
#block_sr input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}
#block_sr input[type="number"]::-webkit-outer-spin-button,
#block_sr input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
    outline: none;
    box-shadow: none;
}

#block_sr input[type="number"]:hover,
#block_sr input[type="number"]:focus {
    border: 0 !important;
    outline: none;
    box-shadow: none;
}

#block_sr input[type="number"]:hover::-webkit-outer-spin-button,
#block_sr input[type="number"]:hover::-webkit-inner-spin-button {
    border: 0 !important;
    margin: 0;
    outline: none;
    box-shadow: none;
}

.mrg25{
    margin: 25px;
}