:root {
    --primary-color: #3b82f6; /* Moderni mėlyna */
    --primary-hover: #2563eb;
    --danger-color: #ef4444;
    --text-main: #1f2937;
    --text-secondary: #6b7280;
    --bg-panel: rgba(255, 255, 255, 0.95);
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    
    /* Toolbar Colors */
    --toolbar-bg: #2d3748;
    --toolbar-text: #e2e8f0;
    --toolbar-hover: #4a5568;
}

/* --- BOM workspace --- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.bom-modal-content {
    width: min(1080px, calc(100vw - 32px));
    max-width: 1080px;
    max-height: calc(100vh - 32px);
    margin: 16px auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
    border: 1px solid #dce5e9;
    background: #f8fbfc;
}

.bom-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
}

.bom-modal-header h3 {
    margin: 3px 0 4px;
    color: #142d3a;
    font-size: 1.45rem;
    letter-spacing: -0.02em;
}

.bom-eyebrow {
    display: block;
    color: #176b87;
    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.12em;
}

.bom-modal-subtitle {
    margin: 0;
    color: #657681;
    font-size: 0.86rem;
}

.bom-close-button {
    float: none;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    border: 1px solid #dbe4e8;
    border-radius: 9px;
    background: #fff;
    color: #71808a;
    font-size: 22px;
    line-height: 28px;
}

.bom-close-button:hover,
.bom-close-button:focus-visible {
    background: #edf5f7;
    color: #142d3a;
    outline: 2px solid rgba(23, 107, 135, 0.25);
}

.bom-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.bom-summary-card {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid #dce7eb;
    border-radius: 11px;
    background: #fff;
    box-shadow: 0 3px 12px rgba(22, 49, 64, 0.05);
}

.bom-summary-card span,
.bom-summary-card small {
    display: block;
    color: #6b7c85;
    font-size: 0.74rem;
}

.bom-summary-card strong {
    display: block;
    margin: 4px 0 2px;
    color: #142d3a;
    font-size: 1.12rem;
}

.bom-summary-card small {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bom-summary-card.is-ready {
    border-color: #a8d7c4;
    background: #f1fbf6;
}

.bom-summary-card.is-ready strong {
    color: #12704e;
}

.bom-summary-card.is-alert {
    border-color: #f2c879;
    background: #fff9eb;
}

.bom-summary-card.is-alert strong {
    color: #a45b00;
}

.bom-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #dce7eb;
    border-radius: 10px;
    background: #fff;
}

.bom-check-control {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #344b58;
    font-size: 0.84rem;
    font-weight: 700;
    cursor: pointer;
}

.bom-check-control input {
    accent-color: #176b87;
}

.bom-search-control {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: min(320px, 45%);
    padding: 0 10px;
    border: 1px solid #cfdde2;
    border-radius: 8px;
    background: #fbfdfe;
    color: #78909c;
}

.bom-search-control svg {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.bom-search-control input {
    width: 100%;
    min-width: 0;
    padding: 9px 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: #233b49;
    font: inherit;
    font-size: 0.82rem;
}

.bom-search-control:focus-within {
    border-color: #176b87;
    box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.bom-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: #6b7c85;
    font-size: 0.74rem;
}

.bom-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bom-legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.bom-legend-dot.is-model {
    background: #176b87;
}

.bom-legend-dot.is-bim {
    background: #d97706;
}

.bom-scroll-region {
    min-height: 160px;
    flex: 1 1 auto;
    overflow: auto;
    padding: 2px 4px 8px 0;
    scrollbar-gutter: stable;
}

.bom-materials-list {
    display: grid;
    gap: 12px;
}

.bom-category {
    overflow: hidden;
    border: 1px solid #dce7eb;
    border-radius: 11px;
    background: #fff;
}

.bom-category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 13px 15px;
    border-bottom: 1px solid #dce7eb;
    background: linear-gradient(100deg, #eff7f8, #f8fbfc);
}

.bom-category-header h3 {
    margin: 0 0 3px;
    color: #173b4a;
    font-size: 1rem;
}

.bom-category-header span,
.bom-category-header strong {
    color: #627883;
    font-size: 0.77rem;
}

.bom-category-header strong {
    color: #176b87;
    font-size: 0.95rem;
    white-space: nowrap;
}

.bom-section-group {
    padding: 12px 14px 0;
}

.bom-section-group:last-child {
    padding-bottom: 14px;
}

.bom-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
    color: #344b58;
    font-size: 0.8rem;
}

.bom-section-heading span {
    color: #7a8b93;
    font-size: 0.73rem;
}

.bom-table-wrap,
.bim-table-wrap {
    overflow-x: auto;
}

.bom-table,
.bim-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.bom-table th,
.bim-table th {
    padding: 7px 8px;
    border-bottom: 1px solid #cfdde2;
    color: #71838d;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    white-space: nowrap;
}

.bom-table td,
.bim-table td {
    padding: 9px 8px;
    border-bottom: 1px solid #edf1f3;
    color: #314854;
    vertical-align: top;
}

.bom-table tbody tr:hover,
.bim-table tbody tr:hover {
    background: #f7fbfc;
}

.bom-table td:nth-child(2),
.bom-table td:nth-child(3),
.bom-table td:nth-child(4) {
    white-space: nowrap;
}

.bom-usage {
    color: #71838d !important;
    font-size: 0.73rem;
}

.bom-total-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    padding: 13px 15px;
    border: 1px solid #b8d6df;
    border-radius: 10px;
    background: #edf7f9;
    color: #315666;
    font-size: 0.8rem;
}

.bom-total-row strong {
    color: #176b87;
    white-space: nowrap;
}

.bom-empty-state {
    display: grid;
    place-items: center;
    gap: 6px;
    min-height: 150px;
    padding: 20px;
    border: 1px dashed #b8cbd2;
    border-radius: 11px;
    background: #fff;
    color: #6c808a;
    text-align: center;
}

.bom-empty-state strong {
    color: #304d5b;
}

.bom-note {
    padding: 9px 11px;
    border-left: 3px solid #e2a13a;
    background: #fff9eb;
    color: #76531b;
    font-size: 0.75rem;
    line-height: 1.45;
}

.bom-modal-actions {
    align-items: center;
    gap: 10px;
    margin-top: 0;
    padding-top: 4px;
}

.bom-export-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: auto;
    margin-right: auto;
}

.bom-close-action {
    width: auto;
}

.bim-schedule {
    margin: 18px 0 0;
    padding: 16px;
    border: 1px solid #efc16b;
    border-radius: 11px;
    background: #fffaf0;
}

.bim-schedule-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.bim-schedule h3 {
    margin: 3px 0 0;
    color: #674817;
    font-size: 1rem;
}

.bim-overall-status,
.bim-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 800;
    white-space: nowrap;
}

.bim-overall-status {
    padding: 7px 10px;
}

.bim-overall-status.is-incomplete,
.bim-status.is-missing {
    background: #fff0ce;
    color: #98600b;
}

.bim-overall-status.is-complete,
.bim-status.is-specified {
    background: #dff6e9;
    color: #17724c;
}

.bim-schedule-intro {
    margin: 11px 0;
    color: #745d31;
    font-size: 0.8rem;
    line-height: 1.45;
}

.bim-truss-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #e8c77e;
    border-radius: 8px;
    background: #fff4d8;
    color: #745d31;
    font-size: 0.75rem;
}

.bim-truss-summary strong {
    flex-basis: 100%;
    color: #674817;
}

.bim-truss-summary span {
    padding-right: 8px;
    border-right: 1px solid #e8c77e;
}

.bim-truss-summary span:last-child {
    border-right: 0;
}

.bim-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.bim-summary-grid > div {
    padding: 9px 10px;
    border: 1px solid #f0d89f;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.65);
}

.bim-summary-grid strong,
.bim-summary-grid span {
    display: block;
}

.bim-summary-grid strong {
    color: #674817;
    font-size: 1rem;
}

.bim-summary-grid span {
    margin-top: 2px;
    color: #846d43;
    font-size: 0.7rem;
}

.bim-table {
    min-width: 760px;
}

.bim-table td small {
    display: block;
    max-width: 380px;
    margin-top: 3px;
    color: #8d7957;
    font-size: 0.7rem;
    line-height: 1.35;
}

.bim-status {
    padding: 5px 8px;
}

.bim-blockers {
    margin-top: 13px;
    color: #735a2b;
    font-size: 0.78rem;
}

.bim-blockers summary {
    cursor: pointer;
    font-weight: 800;
}

.bim-blockers ul {
    margin: 9px 0 0;
    padding-left: 20px;
    line-height: 1.45;
}

@media (max-width: 720px) {
    .bom-modal-content {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        margin: 10px auto;
        padding: 16px;
        gap: 11px;
    }

    .bom-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bom-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .bom-search-control {
        min-width: 0;
    }

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

    .bim-schedule-header {
        flex-direction: column;
    }

    .bim-summary-grid {
        grid-template-columns: 1fr;
    }
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif; /* Modernus fontas */
    background-color: #f3f4f6;
    color: var(--text-main);
    overflow: hidden;
}

/* --- Top Toolbar --- */
#top-toolbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 50px;
    background-color: var(--toolbar-bg);
    color: var(--toolbar-text);
    display: flex;
    align-items: center;
    padding: 0 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    z-index: 200;
    box-sizing: border-box;
}

.silto-back-link {
    flex: 0 0 auto;
    margin-right: 10px;
    padding: 7px 10px;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 5px;
    color: var(--toolbar-text);
    font-size: .82rem;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background .2s ease, border-color .2s ease;
}

.silto-back-link:hover {
    border-color: rgba(255, 255, 255, .5);
    background: rgba(255, 255, 255, .1);
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background-color: rgba(255,255,255,0.2);
    margin: 0 10px;
}

.toolbar-spacer {
    flex: 1;
}

.tool-btn {
    background: transparent;
    border: none;
    color: var(--toolbar-text);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

.tool-btn:hover, .tool-btn.active {
    background-color: var(--toolbar-hover);
}

.tool-btn.active {
    border-bottom: 2px solid var(--primary-color);
    background-color: rgba(255,255,255,0.1);
}

.tool-btn:disabled {
    cursor: not-allowed;
    opacity: 0.4;
}

.tool-btn svg {
    width: 18px;
    height: 18px;
}

.tool-btn span {
    display: none; /* Hide text on small screens if needed, but show for now */
}

@media (min-width: 768px) {
    .tool-btn span {
        display: inline;
    }
}

/* --- Sidebar Panel --- */
#ui-container {
    position: absolute;
    top: 70px; /* Adjusted for toolbar */
    left: 20px;
    width: 340px;
    max-height: calc(100vh - 90px);
    background: var(--bg-panel);
    backdrop-filter: blur(8px);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    z-index: 100;
}

/* Header */
.panel-header {
    padding: 20px;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

.panel-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #111827;
}

.panel-header p {
    margin: 5px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.app-status-note {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #fde68a;
    border-radius: 6px;
    background: #fffbeb;
    color: #92400e;
    font-size: 0.82rem;
    line-height: 1.35;
}

.validation-panel {
    margin-top: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    line-height: 1.4;
}

.validation-panel.hidden {
    display: none;
}

.validation-panel.has-errors {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.validation-panel.has-warnings {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1e40af;
}

.validation-panel-details {
    display: block;
}

.validation-panel-summary {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    list-style: none;
    font-weight: 700;
    line-height: 1.2;
}

.validation-panel-summary::-webkit-details-marker {
    display: none;
}

.validation-panel-summary-title {
    flex: 1;
}

.validation-panel-summary-count {
    min-width: 1.9em;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.45);
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.validation-panel-summary::after {
    content: '▾';
    font-size: 0.9rem;
    opacity: 0.85;
}

.validation-panel-details:not([open]) .validation-panel-summary::after {
    content: '▸';
}

.validation-panel-body {
    margin-top: 8px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.validation-panel ul {
    margin: 6px 0 0 18px;
    padding: 0;
}

.calc-assumptions {
    margin-top: 6px;
    font-size: 0.78rem;
    line-height: 1.35;
    opacity: 0.86;
}

.validation-panel details {
    margin-top: 6px;
}

.load-map-summary {
    padding: 10px;
    background-color: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 0.8rem;
    color: #3730a3;
    line-height: 1.35;
}

/* Content Area (Scrollable) */
.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* --- Accordion Sections --- */
.section {
    border-bottom: 1px solid var(--border-color);
}

.section-title {
    padding: 15px 20px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: #f9fafb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
    user-select: none;
}

.section-title:hover {
    background: #f3f4f6;
}

.section-title::after {
    content: '▼';
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.section.active .section-title::after {
    transform: rotate(180deg);
}

.section-body {
    padding: 20px;
    display: none;
    background: #fff;
}

.section.active .section-body {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Forms & Inputs --- */
.control-group {
    margin-bottom: 15px;
}

.control-group:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

input[type="number"],
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.9rem;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

input[type="number"]:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.row {
    display: flex;
    gap: 12px;
}

.col {
    flex: 1;
}

/* --- Buttons --- */
.btn {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: #10b981; /* Green */
    color: white;
    margin-top: 10px;
}

.btn-secondary:hover {
    background-color: #059669;
}

.btn-icon {
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fee2e2;
    color: var(--danger-color);
}

.btn-icon:hover {
    background: var(--danger-color);
    color: white;
}

/* --- Openings List --- */
#openings-list {
    list-style: none;
    padding: 0;
    margin: 15px 0 0 0;
}

#partitions-list {
    list-style: none;
    padding: 0;
    margin: 15px 0 0 0;
}

#openings-list li {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.opening-item {
    gap: 10px;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.opening-item:hover,
.opening-item:focus-within {
    border-color: #79adb7 !important;
    background: #f1f9f9 !important;
}

.opening-item.is-selected {
    border-color: #087f8c !important;
    background: #e8f7f6 !important;
    box-shadow: 0 0 0 2px rgba(8, 127, 140, 0.12);
}

.opening-item-details {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.opening-item-details strong {
    color: #23495a;
    font-size: 0.82rem;
}

.opening-item-details small {
    overflow: hidden;
    color: #6f8089;
    font-size: 0.71rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.opening-item-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 5px;
}

.opening-action {
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid #cbdce2;
    border-radius: 6px;
    background: #fff;
    color: #176b87;
    cursor: pointer;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
}

.opening-action.is-danger {
    border-color: #f0c0bd;
    color: #b43c32;
}

#partitions-list li {
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.partition-item {
    gap: 10px;
    cursor: pointer;
    transition: border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.partition-item:hover,
.partition-item:focus-within {
    border-color: #8fb8c4;
    background: #f0f8fa;
}

.partition-item.is-selected {
    border-color: #176b87;
    background: #eaf6f7;
    box-shadow: 0 0 0 2px rgba(23, 107, 135, 0.12);
}

.partition-item-details {
    min-width: 0;
    display: grid;
    gap: 4px;
}

.partition-item-details strong {
    color: #23495a;
    font-size: 0.82rem;
}

.partition-item-details small {
    overflow: hidden;
    color: #6f8089;
    font-size: 0.72rem;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.partition-item-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 5px;
}

.partition-action {
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid #cbdce2;
    border-radius: 6px;
    background: #fff;
    color: #176b87;
    cursor: pointer;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 700;
}

.partition-action:hover,
.partition-action:focus-visible {
    border-color: #176b87;
    background: #eaf6f7;
    outline: none;
}

.partition-action.is-danger {
    border-color: #f0c0bd;
    color: #b43c32;
}

.partition-action.is-danger:hover,
.partition-action.is-danger:focus-visible {
    border-color: #d45b51;
    background: #fff1f0;
}

.partition-selection-status {
    margin: 2px 0 10px;
    padding: 9px 10px;
    border-left: 3px solid #b8cbd2;
    background: #f6fafb;
    color: #637882;
    font-size: 0.76rem;
    line-height: 1.4;
}

.partition-selection-status.is-selected {
    border-left-color: #176b87;
    background: #eaf6f7;
    color: #0f5971;
    font-weight: 700;
}

.partition-clear-button {
    width: 100%;
    margin-top: 2px;
}

.partition-visibility-button {
    width: 100%;
    margin-top: 6px;
}

.opening-info {
    display: flex;
    flex-direction: column;
}

.opening-tag {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.75rem;
    text-transform: uppercase;
    margin-bottom: 2px;
}

/* --- BOM Table --- */
#bom-container table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

#bom-container th {
    text-align: left;
    color: var(--text-secondary);
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

#bom-container td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

#bom-container tr:last-child td {
    border-bottom: none;
}

/* --- Footer Action --- */
.panel-footer {
    padding: 20px;
    background: #fff;
    border-top: 1px solid var(--border-color);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}


/* Modal Styles */
.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto; 
    padding: 25px;
    border: 1px solid #888;
    width: 400px;
    border-radius: 12px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.close-modal {
    color: #9ca3af;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: #111827;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
}

/* Wall elevation sheets */
.drawings-modal-content {
    width: min(1320px, 96vw);
    max-width: 1320px;
    height: 92vh;
    margin: 4vh auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    border: 1px solid #d8e1e5;
    background: #f7fafb;
}

.drawings-modal-header {
    flex: 0 0 auto;
    margin-bottom: 12px;
    align-items: flex-start;
}

.drawings-modal-header h3 {
    margin: 0;
    color: #142d3a;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

.drawings-modal-subtitle {
    max-width: 760px;
    margin: 6px 0 0;
    color: #6a7b84;
    font-size: 0.82rem;
    line-height: 1.45;
}

.drawings-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 16px;
    flex: 0 0 auto;
    margin-bottom: 12px;
    padding: 10px 12px;
    border: 1px solid #dce6e9;
    border-radius: 10px;
    background: #ffffff;
    color: #526873;
    font-size: 0.75rem;
    font-weight: 600;
}

.drawing-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 5px;
    border-radius: 50%;
    vertical-align: 1px;
}

.dot-frame { background: #b18455; }
.dot-opening { background: #d8694d; }
.dot-brace { background: #c77835; }
.dot-roof { background: #70401f; }
.dot-truss { background: #8b684e; }

.drawings-summary-note {
    margin-left: auto;
    color: #8a9aa1;
    font-weight: 500;
}

.drawings-dimension-guide {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    flex: 0 0 auto;
    margin-bottom: 12px;
    padding: 8px 12px;
    border-left: 3px solid #c77835;
    background: #fffaf1;
    color: #6b5a4b;
    font-size: 0.72rem;
    line-height: 1.4;
}

.drawings-dimension-guide strong {
    color: #23495a;
}

.drawings-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    border: 1px solid #d8e2e6;
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(33, 78, 95, 0.035) 25%, transparent 25%) 0 0 / 18px 18px,
        #e9eff1;
}

.drawing-sheet {
    margin: 0 auto 18px;
    padding: 12px;
    border: 1px solid #d8e1e5;
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(30, 57, 70, 0.08);
}

.drawing-sheet:last-child {
    margin-bottom: 0;
}

.roof-drawing-sheet {
    border-color: #c9b39c;
}

.drawing-sheet-label {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 0 3px 9px;
    color: #23495a;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.drawing-sheet-label span {
    display: inline-grid;
    width: 24px;
    height: 24px;
    place-items: center;
    border-radius: 7px;
    background: #23495a;
    color: #ffffff;
    font-size: 0.68rem;
    letter-spacing: 0;
}

.drawing-sheet-label small {
    margin-left: auto;
    color: #93a1a7;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.drawing-sheet canvas {
    display: block;
    width: 100%;
    height: auto;
    border: 1px solid #edf1f2;
    border-radius: 6px;
}

.drawings-actions {
    flex: 0 0 auto;
    align-items: center;
    margin-top: 14px;
}

.drawings-print-btn {
    margin-right: auto !important;
    width: auto !important;
    background: #23495a !important;
}

.drawings-print-note {
    margin-right: 14px;
    color: #6d7b81;
    font-size: 0.72rem;
    font-weight: 700;
}

.drawings-print-frame {
    position: fixed;
    left: -100000px;
    top: 0;
    width: 1123px;
    height: 794px;
    border: 0;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    body * {
        visibility: hidden;
    }

    #drawings-modal,
    #drawings-modal * {
        visibility: visible;
    }

    #drawings-modal {
        position: absolute;
        inset: 0;
        display: block !important;
        overflow: visible;
        background: #ffffff;
    }

    .drawings-modal-content {
        width: auto;
        max-width: none;
        height: auto;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: #ffffff;
    }

    .drawings-modal-header,
    .drawings-summary,
    .drawings-dimension-guide,
    .drawings-actions,
    .drawing-sheet-label,
    .close-modal {
        display: none !important;
    }

    .drawings-container {
        overflow: visible;
        padding: 0;
        border: 0;
        background: #ffffff;
    }

    .drawing-sheet {
        margin: 0 0 8mm;
        padding: 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .drawing-sheet canvas {
        width: 100%;
        border: 0;
        border-radius: 0;
        filter: grayscale(1) contrast(1.18);
        -webkit-print-color-adjust: economy;
        print-color-adjust: economy;
    }

    .drawing-sheet {
        border-color: #111111;
    }
}

@media (max-width: 767px) {
    .drawings-modal-content {
        width: calc(100vw - 12px) !important;
        max-width: calc(100vw - 12px);
        min-width: 0;
        height: 94vh;
        margin: 3vh 6px;
        padding: 12px;
        border-radius: 14px;
    }

    .drawings-modal-header h3 {
        font-size: 1.05rem;
    }

    .drawings-modal-subtitle {
        padding-right: 22px;
        font-size: 0.7rem;
    }

    .drawings-summary {
        gap: 6px 10px;
        padding: 8px 9px;
        font-size: 0.66rem;
    }

    .drawings-summary-note {
        width: 100%;
        margin-left: 0;
    }

    .drawings-container {
        min-width: 0;
        padding: 8px;
        border-radius: 10px;
        overflow: auto;
    }

    .drawing-sheet {
        width: 1280px;
        max-width: none;
        padding: 7px;
        margin-bottom: 10px;
        border-radius: 8px;
    }

    .drawing-sheet-label {
        padding-bottom: 6px;
        font-size: 0.65rem;
    }

    .drawing-sheet-label small {
        display: none;
    }

    .drawing-sheet canvas {
        width: 1280px;
        max-width: none;
    }

    .drawings-actions {
        margin-top: 8px;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.new-project-modal-content {
    width: 760px;
    max-width: 94vw;
}

.modal-help {
    margin: 12px 0 18px;
    color: #6b7280;
    line-height: 1.5;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.template-card {
    border: 1px solid #d1d5db;
    border-radius: 14px;
    padding: 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    color: #111827;
    cursor: pointer;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    min-height: 108px;
}

.template-card strong {
    font-size: 1rem;
}

.template-card span {
    font-size: 0.88rem;
    color: #6b7280;
    line-height: 1.4;
}

.template-card small {
    font-size: 0.76rem;
    color: #334155;
    line-height: 1.3;
}

.template-card:hover {
    transform: translateY(-2px);
    border-color: #60a5fa;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
}

.template-card:focus-visible {
    outline: 3px solid rgba(59, 130, 246, 0.4);
    outline-offset: 2px;
}

.template-sauna {
    border-left: 5px solid #f59e0b;
}

.template-garage {
    border-left: 5px solid #10b981;
}

.template-garden {
    border-left: 5px solid #06b6d4;
}

.template-house {
    border-left: 5px solid #6366f1;
}

.template-manual {
    border-left: 5px solid #ef4444;
}

@media (max-width: 640px) {
    .template-grid {
        grid-template-columns: 1fr;
    }

    .new-project-modal-content {
        width: 100%;
    }
}

/* BOM Modal Specifics */
#bom-container {
    font-size: 0.9rem;
}
#bom-container table th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.bim-schedule {
    margin: 0 0 16px;
    padding: 12px;
    border: 1px solid #d97706;
    border-radius: 6px;
    background: #fffbeb;
}

.bim-schedule h3 {
    margin: 0 0 8px;
}

.bim-schedule table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.bim-schedule th,
.bim-schedule td {
    padding: 6px;
    border-bottom: 1px solid #fde68a;
    text-align: left;
}

/* --- Workspace hierarchy and responsive controls --- */
:root {
    --primary-color: #176b87;
    --primary-hover: #10566e;
    --toolbar-bg: #172535;
    --toolbar-hover: #284359;
    --workspace-surface: rgba(255, 255, 255, 0.98);
    --workspace-accent: #e7a23a;
}

body {
    font-family: Aptos, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 88% 10%, rgba(23, 107, 135, 0.12), transparent 32%),
        linear-gradient(135deg, #eef3f5 0%, #e8eef2 100%);
}

#top-toolbar {
    height: 58px;
    padding: 0 16px;
    background: linear-gradient(100deg, #172535 0%, #22384d 100%);
    box-shadow: 0 6px 20px rgba(19, 37, 53, 0.22);
}

.tool-btn {
    min-height: 38px;
    border-radius: 8px;
    font-weight: 600;
}

.toolbar-project .tool-btn:first-child {
    background: rgba(231, 162, 58, 0.16);
    color: #ffe2a5;
}

#canvas-container {
    position: fixed;
    inset: 58px 0 0;
    overflow: hidden;
}

#canvas-container canvas {
    display: block;
}

#ui-container {
    top: 76px;
    width: 356px;
    max-height: calc(100vh - 94px);
    background: var(--workspace-surface);
    box-shadow: 0 22px 50px rgba(30, 49, 64, 0.18);
}

.panel-header {
    padding: 18px 20px 16px;
    background: linear-gradient(180deg, #ffffff 0%, #f7fafb 100%);
}

.panel-kicker {
    display: block;
    margin-bottom: 6px;
    color: #176b87;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.11em;
}

.panel-header h1 {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.38rem;
    letter-spacing: -0.02em;
}

.panel-header p {
    margin-top: 6px;
}

.app-status-note {
    border-color: #f1ca83;
    background: #fff8e6;
    color: #725116;
}

.validation-panel {
    padding: 9px 10px;
}

.validation-panel-body {
    max-height: 104px;
}

.section-title {
    padding: 14px 20px;
    font-size: 0.9rem;
    background: #f5f8f9;
}

.section.active .section-title {
    color: #0d4d63;
    background: #edf6f7;
    box-shadow: inset 4px 0 0 #e7a23a;
}

.section-body {
    padding: 18px 20px;
}

input[type="text"],
input[type="number"],
select {
    min-height: 42px;
    border-color: #d5dfe5;
}

.panel-footer {
    position: sticky;
    bottom: 0;
    z-index: 3;
    padding: 14px 20px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 -8px 20px rgba(30, 49, 64, 0.08);
}

.panel-footer .btn-primary {
    min-height: 48px;
    background: linear-gradient(135deg, #176b87 0%, #0f5971 100%);
}

#canvas-hud {
    position: fixed;
    top: 76px;
    right: 20px;
    z-index: 80;
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid rgba(23, 53, 70, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 10px 28px rgba(25, 47, 62, 0.12);
    backdrop-filter: blur(12px);
}

.canvas-status {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 6px;
    color: #23495a;
    font-size: 0.8rem;
    font-weight: 700;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38a169;
    box-shadow: 0 0 0 3px rgba(56, 161, 105, 0.15);
}

.canvas-actions {
    display: flex;
    gap: 6px;
}

.canvas-action {
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid #d5dfe5;
    border-radius: 7px;
    background: #ffffff;
    color: #23495a;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
}

.canvas-action:hover,
.canvas-action:focus-visible {
    border-color: #176b87;
    color: #10566e;
    outline: none;
}

#mobile-nav {
    display: none;
}

#cad-hud {
    position: fixed;
    top: 76px;
    right: 20px;
    z-index: 82;
    display: none;
    align-items: center;
    gap: 14px;
    padding: 10px 12px;
    border: 1px solid rgba(23, 53, 70, 0.12);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 10px 28px rgba(25, 47, 62, 0.12);
    backdrop-filter: blur(12px);
}

.cad-selection-panel {
    position: fixed;
    right: 20px;
    bottom: 22px;
    z-index: 84;
    width: min(440px, calc(100vw - 40px));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border: 1px solid rgba(8, 127, 140, 0.28);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 16px 38px rgba(17, 52, 65, 0.18);
    backdrop-filter: blur(14px);
}

.cad-selection-panel[hidden] {
    display: none;
}

.cad-selection-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.cad-selection-kind {
    color: #087f8c;
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.11em;
}

.cad-selection-copy strong {
    color: #183642;
    font-size: 0.9rem;
}

.cad-selection-copy small {
    overflow: hidden;
    color: #667b86;
    font-size: 0.72rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cad-selection-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
}

.canvas-action.is-danger {
    border-color: #efc7c4;
    color: #b43c32;
}

.canvas-action.is-danger:hover {
    border-color: #d45b51;
    background: #fff1f0;
}

.opening-editor-content {
    width: min(660px, calc(100vw - 28px));
    max-width: 660px;
    margin: 7vh auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #d7e3e6;
    border-radius: 18px;
    background: #f8fbfc;
    box-shadow: 0 28px 80px rgba(15, 38, 52, 0.28);
}

.opening-editor-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 24px 18px;
    border-bottom: 1px solid #dfe9eb;
    background: linear-gradient(135deg, #173746 0%, #225d69 100%);
    color: #fff;
}

.opening-editor-header h3 {
    margin: 6px 0 4px;
    font-size: 1.28rem;
}

.opening-editor-header p {
    margin: 0;
    color: #c9e0e3;
    font-size: 0.78rem;
}

.opening-editor-badge {
    display: inline-flex;
    padding: 4px 8px;
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
    color: #f8d696;
    font-size: 0.65rem;
    font-weight: 900;
    letter-spacing: 0.1em;
}

.opening-editor-close {
    min-width: 36px;
    min-height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.opening-editor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    padding: 22px 24px 8px;
}

.opening-editor-grid .control-group {
    margin: 0;
}

.opening-editor-grid label {
    margin-bottom: 6px;
    color: #34515f;
    font-size: 0.74rem;
}

.opening-editor-grid input,
.opening-editor-grid select {
    min-height: 44px;
    border-color: #cfdde1;
    background: #fff;
    font-weight: 700;
}

.input-with-unit {
    position: relative;
}

.input-with-unit input {
    width: 100%;
    padding-right: 46px;
}

.input-with-unit span {
    position: absolute;
    top: 50%;
    right: 13px;
    color: #82939a;
    font-size: 0.7rem;
    font-weight: 800;
    transform: translateY(-50%);
    pointer-events: none;
}

.opening-editor-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1px;
    margin: 14px 24px 0;
    overflow: hidden;
    border: 1px solid #d6e3e6;
    border-radius: 12px;
    background: #d6e3e6;
}

.opening-editor-summary div {
    display: grid;
    gap: 4px;
    padding: 11px 12px;
    background: #fff;
    text-align: center;
}

.opening-editor-summary span {
    color: #748890;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
}

.opening-editor-summary strong {
    color: #183642;
    font-size: 0.84rem;
}

.opening-editor-validation {
    margin: 10px 24px 0;
    padding: 9px 11px;
    border-left: 3px solid #15936f;
    background: #ecf8f4;
    color: #17624f;
    font-size: 0.74rem;
}

.opening-editor-validation.is-error {
    border-left-color: #c9473e;
    background: #fff0ef;
    color: #9d3029;
}

.opening-editor-actions {
    justify-content: space-between;
    margin: 18px 0 0;
    padding: 16px 24px 20px;
    border-top: 1px solid #e0eaec;
    background: #fff;
}

.opening-editor-actions .btn {
    width: auto;
    min-width: 128px;
}

.opening-delete-button {
    border: 1px solid #efc7c4;
    background: #fff;
    color: #b43c32;
}

.cad-tool-state {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #23495a;
}

.cad-tool-state strong,
.cad-tool-state small {
    display: block;
}

.cad-tool-state strong {
    font-size: 0.8rem;
}

.cad-tool-state small {
    margin-top: 2px;
    color: #667b86;
    font-size: 0.7rem;
}

.cad-actions {
    display: flex;
    gap: 6px;
}

.canvas-action.active {
    border-color: #176b87;
    background: #e2f3f1;
    color: #0d4d63;
}

.is-2d #canvas-container {
    background:
        radial-gradient(circle at 50% 15%, rgba(23, 107, 135, 0.06), transparent 40%),
        #f8fbfc;
}

.is-2d #canvas-hud {
    display: none;
}

.is-2d #cad-hud {
    display: flex;
}

.is-2d #cad-canvas {
    background: #fbfdfd;
}

.is-2d .toolbar-view .tool-btn {
    border: 1px solid rgba(231, 162, 58, 0.82);
    color: #ffe2a5;
}

@media (max-width: 767px) {
    #top-toolbar {
        height: 56px;
        padding: 0 8px;
    }

    #top-toolbar .toolbar-project,
    #top-toolbar .toolbar-export,
    #top-toolbar .toolbar-help,
    #top-toolbar .toolbar-2d,
    #top-toolbar .toolbar-separator {
        display: none !important;
    }

    #top-toolbar .toolbar-spacer {
        flex: 1;
    }

    #top-toolbar .tool-btn {
        min-width: 42px;
        min-height: 42px;
        padding: 7px;
        justify-content: center;
    }

    #canvas-container {
        inset: 56px 0 0;
    }

    #ui-container {
        position: fixed;
        top: 68px;
        right: 8px;
        bottom: 76px;
        left: 8px;
        width: auto;
        max-height: none;
        border-radius: 18px;
    }

    .panel-header {
        padding: 15px 16px 12px;
    }

    .panel-header h1 {
        font-size: 1.2rem;
    }

    .app-status-note {
        margin-top: 9px;
        font-size: 0.76rem;
    }

    .validation-panel-body {
        max-height: 92px;
    }

    .section-title,
    .section-body {
        padding-right: 16px;
        padding-left: 16px;
    }

    .row {
        gap: 9px;
    }

    #canvas-hud {
        top: 66px;
        right: 8px;
        padding: 5px;
    }

    #cad-hud {
        top: 66px;
        right: 8px;
        left: 8px;
        justify-content: space-between;
        gap: 8px;
        padding: 7px 8px;
    }

    .cad-tool-state small {
        display: none;
    }

    .cad-tool-state strong {
        max-width: 135px;
        font-size: 0.74rem;
    }

    .cad-actions {
        gap: 4px;
    }

    #cad-hud .canvas-action {
        min-width: 34px;
        padding: 0 7px;
        font-size: 0.7rem;
    }

    .cad-selection-panel {
        right: 8px;
        bottom: 72px;
        left: 8px;
        width: auto;
        gap: 8px;
        padding: 9px 10px;
        border-radius: 12px;
    }

    .cad-selection-copy strong {
        font-size: 0.8rem;
    }

    .cad-selection-copy small {
        max-width: 48vw;
        font-size: 0.65rem;
    }

    .cad-selection-actions .canvas-action {
        min-height: 36px;
        padding: 0 8px;
        font-size: 0.68rem;
    }

    .opening-editor-content {
        width: calc(100vw - 12px);
        max-width: none;
        max-height: calc(100vh - 24px);
        margin: 12px 6px;
        overflow-y: auto;
        border-radius: 15px;
    }

    .opening-editor-header {
        padding: 17px 16px 14px;
    }

    .opening-editor-grid {
        grid-template-columns: 1fr;
        gap: 11px;
        padding: 16px 16px 4px;
    }

    .opening-editor-summary {
        margin-right: 16px;
        margin-left: 16px;
    }

    .opening-editor-validation {
        margin-right: 16px;
        margin-left: 16px;
    }

    .opening-editor-actions {
        position: sticky;
        bottom: 0;
        padding: 13px 16px;
    }

    .canvas-status {
        display: none;
    }

    .canvas-action {
        min-height: 36px;
        padding: 0 9px;
    }

    #mobile-nav {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 210;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        min-height: 68px;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        border-top: 1px solid rgba(23, 53, 70, 0.14);
        background: rgba(23, 37, 53, 0.97);
        box-shadow: 0 -8px 24px rgba(23, 37, 53, 0.2);
    }

    #mobile-nav button {
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: #dce8ef;
        font: inherit;
        font-size: 0.72rem;
        font-weight: 700;
        cursor: pointer;
    }

    #mobile-nav button.active,
    #mobile-nav button:focus-visible {
        background: rgba(231, 162, 58, 0.17);
        color: #ffe2a5;
        outline: none;
    }

    .modal-content {
        width: auto;
        max-width: calc(100vw - 24px);
        margin: 7vh auto;
        padding: 18px;
    }
}

/* BOM selectors stay last so the legacy modal defaults cannot shrink the estimate view. */
#bom-modal .bom-modal-content {
    width: min(1080px, calc(100vw - 32px));
    max-width: 1080px;
    max-height: calc(100vh - 32px);
    margin: 16px auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow: hidden;
}

#bom-modal .bom-modal-actions {
    margin-top: 0;
    align-items: center;
    gap: 10px;
}

#bom-modal .bom-modal-header {
    margin: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

#bom-modal .bim-schedule {
    margin: 18px 0 0;
    padding: 16px;
    border: 1px solid #efc16b;
    border-radius: 11px;
    background: #fffaf0;
}

#bom-modal .bim-schedule h3 {
    margin: 3px 0 0;
    color: #674817;
    font-size: 1rem;
}

#bom-modal #bom-container .bom-table,
#bom-modal #bom-container .bim-table {
    width: 100%;
    min-width: 680px;
    border-collapse: collapse;
    font-size: 0.78rem;
}

#bom-modal #bom-container .bom-table th,
#bom-modal #bom-container .bom-table td,
#bom-modal #bom-container .bim-table th,
#bom-modal #bom-container .bim-table td {
    padding: 8px;
    border-bottom: 1px solid #edf1f3;
}

.toolbar-2d {
    min-width: 0;
    flex: 0 1 auto;
}

.toolbar-2d .tool-btn {
    flex: 0 0 auto;
    padding-right: 8px;
    padding-left: 8px;
}

@media (min-width: 768px) and (max-width: 1399px) {
    .toolbar-2d {
        max-width: 285px;
        overflow-x: auto;
        scrollbar-width: thin;
    }

    .toolbar-2d .tool-btn span {
        display: none;
    }

    .toolbar-2d #btn-select-partition-2d,
    .toolbar-2d #btn-delete-partition-2d,
    .toolbar-2d #btn-toggle-partitions-2d {
        display: none;
    }
}

@media (max-width: 720px) {
    #bom-modal .bom-modal-content {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
        margin: 10px auto;
        padding: 16px;
        gap: 11px;
    }
}
