/* Headers now handled by headers.css */

/* Estimating Tab Specific Styling for AMD Construction Pro */

/* Main Layout */
.estimating-main-layout {
    display: flex;
    gap: 8px; /* Reduced from 12px */
    padding: 8px; /* Reduced from 12px */
    background: #f5f7fa;
    height: 100%;
    min-height: 0;
    box-sizing: border-box;
    overflow: hidden;
}

.estimating-workspace-shell {
    flex: 1 1 0;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 8px;
    background: #f5f7fa;
    box-sizing: border-box;
    overflow: hidden;
}

.estimating-estimates-sidebar {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.estimates-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.estimates-sidebar-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.estimates-project-context {
    padding: 10px 12px;
    font-size: 12px;
    color: #4b5563;
    border-bottom: 1px solid #edf2f7;
    background: #f8fafc;
}

.estimates-sidebar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px 10px 8px;
    border-bottom: 1px solid #edf2f7;
}

.estimating-estimates-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
}

.estimate-list-empty {
    color: #64748b;
    font-size: 12px;
    padding: 12px;
    text-align: center;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.estimate-list-hidden-note {
    margin-bottom: 8px;
    padding: 8px 10px;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 11px;
    line-height: 1.35;
}

.estimate-list-item {
    width: 100%;
    text-align: left;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    padding: 10px 10px 9px;
    margin-bottom: 8px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.estimate-list-item:hover {
    border-color: #93c5fd;
    box-shadow: 0 2px 10px rgba(52, 152, 219, 0.14);
}

.estimate-list-item.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.3);
}

.estimate-list-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.estimate-list-number {
    font-size: 11px;
    color: #475569;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.estimate-list-status {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 999px;
    padding: 2px 7px;
    letter-spacing: 0.04em;
}

.estimate-list-status.draft {
    background: #fef3c7;
    color: #92400e;
}

.estimate-list-status.sent {
    background: #dbeafe;
    color: #1e40af;
}

.estimate-list-status.approved {
    background: #dcfce7;
    color: #166534;
}

.estimate-list-status.rejected {
    background: #fee2e2;
    color: #991b1b;
}

.estimate-list-title {
    font-size: 13px;
    color: #0f172a;
    font-weight: 600;
    margin-bottom: 6px;
    line-height: 1.25;
}

.estimate-list-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #64748b;
}

.estimate-list-total {
    font-weight: 700;
    color: #0f172a;
}

/* ---- Estimates List Panel (split layout) ---- */
.estimates-list-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    min-height: 0;
    overflow: hidden;
}
.estimates-list-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    gap: 8px;
}
.estimates-list-panel__header h3 {
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
}
.estimates-list-panel__actions {
    display: flex;
    gap: 6px;
}
.estimates-list-panel__actions .btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    font-weight: 600;
    transition: background 0.15s, border-color 0.15s;
}
.estimates-list-panel__actions .btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}
.estimates-list-panel__actions .btn.primary {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.estimates-list-panel__actions .btn.primary:hover {
    background: #1d4ed8;
}
.estimates-list-panel__search {
    padding: 0 14px 6px;
}
.estimates-list-panel__search input {
    width: 100%;
    padding: 6px 10px;
    font-size: 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    outline: none;
    transition: border-color 0.15s;
}
.estimates-list-panel__search input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.10);
}
.estimates-list-panel__filter {
    padding: 0 14px 10px;
}
.estimates-list-panel__filter select {
    width: 100%;
    padding: 5px 8px;
    font-size: 11px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}
.estimates-list-panel__list {
    flex: 1;
    overflow-y: auto;
    padding: 0 14px 14px;
    scrollbar-width: thin;
}
.estimate-detail-panel {
    min-height: 0;
}

/* Estimate detail action buttons */
.estimating-sub-link--accent {
    background: #2563eb !important;
    color: #fff !important;
    border-color: #2563eb !important;
}
.estimating-sub-link--accent:hover:not(:disabled) {
    background: #1d4ed8 !important;
}
.estimating-sub-link--accent:disabled {
    opacity: 0.5;
}

.estimating-workspace-main {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.08);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.estimating-sub-ribbon {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 0 10px;
    min-height: 42px;
    background: #1f3b63;
    border-bottom: 1px solid #0f2139;
    overflow-x: auto;
    scrollbar-width: thin;
}

.estimating-sub-ribbon-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.estimating-ribbon-estimates {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px;
    border: 1px solid rgba(188, 208, 235, 0.35);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.07);
}

.estimate-ribbon-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #bcd0eb;
    text-transform: uppercase;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.estimate-ribbon-select {
    min-width: 180px;
    max-width: 260px;
    border: 1px solid rgba(188, 208, 235, 0.45);
    border-radius: 6px;
    background: rgba(15, 33, 57, 0.78);
    color: #e2e8f0;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 8px;
}

.estimating-sub-link {
    border: 1px solid rgba(188, 208, 235, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    color: #dbe8fb;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 6px 9px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.estimating-sub-link:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
    border-color: rgba(188, 208, 235, 0.85);
}

.estimating-sub-tab {
    border: none;
    background: transparent;
    color: #bcd0eb;
    border-bottom: 3px solid transparent;
    font-size: 12px;
    font-weight: 700;
    padding: 11px 12px 9px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
}

.estimating-sub-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.estimating-sub-tab.active {
    color: #fff;
    border-bottom-color: #60a5fa;
}

.estimating-sub-panel-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: #f8fafc;
}

.estimating-sub-panel {
    display: none;
    height: 100%;
    min-height: 0;
}

.estimating-sub-panel.active {
    display: block;
}

.estimating-sub-panel[data-panel="takeoff"] .estimating-main-layout {
    height: 100%;
}

.takeoff-workflow-ribbon {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #dbe5ef;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    overflow-x: auto;
    scrollbar-width: thin;
}

.takeoff-workflow-btn {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #ffffff;
    color: #1f3b63;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    padding: 6px 10px;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.takeoff-workflow-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.takeoff-workflow-btn.active {
    background: #1f3b63;
    color: #ffffff;
    border-color: #1f3b63;
}

.estimating-resource-view {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 12px;
}

.estimating-resource-header {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.estimating-resource-header h3 {
    margin: 0;
    font-size: 18px;
    color: #0f172a;
}

.estimating-resource-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.estimating-resource-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #fff;
    padding: 10px;
}

.estimating-summary-view {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    padding: 14px;
    gap: 12px;
}

.estimating-summary-header {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    padding: 12px 14px;
    background: #fff;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.estimating-summary-controls {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.estimating-summary-controls .estimate-ribbon-label {
    color: #475569;
    max-width: 180px;
}

.estimating-summary-controls .estimate-ribbon-select {
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
    min-width: 200px;
}

.estimating-summary-controls .estimating-sub-link {
    background: #f8fafc;
    color: #1f3b63;
    border-color: #cbd5e1;
}

.estimating-summary-controls .estimating-sub-link:hover {
    background: #e2e8f0;
    color: #0f172a;
    border-color: #94a3b8;
}

.estimating-summary-header h3 {
    margin: 0 0 4px;
    font-size: 18px;
    color: #0f172a;
}

.estimating-summary-header p {
    margin: 0;
    font-size: 12px;
    color: #64748b;
}

.estimating-summary-header-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #334155;
}

.estimating-summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

.estimating-summary-cards .summary-card {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #fff;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.estimating-summary-cards .summary-card label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.estimating-summary-cards .summary-card strong {
    font-size: 18px;
    color: #0f172a;
}

.estimating-overhead-meta {
    margin-top: -2px;
    padding: 8px 10px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #475569;
    font-size: 11px;
    line-height: 1.35;
}

.estimating-summary-table-wrap {
    flex: 1;
    min-height: 0;
    background: #fff;
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    overflow: auto;
}

.estimating-summary-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.estimating-summary-table th,
.estimating-summary-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 12px;
}

.estimating-summary-table th {
    text-align: left;
    background: #f8fafc;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 10px;
}

.estimating-summary-table small {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 10px;
    line-height: 1.3;
}

.estimating-pipeline-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(220px, 1fr));
    gap: 10px;
    min-height: 0;
}

.estimating-pipeline-panel {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #fff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 180px;
}

.estimating-pipeline-panel h4 {
    margin: 0;
    font-size: 12px;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.estimating-pipeline-table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.estimating-pipeline-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 340px;
}

.estimating-pipeline-table th,
.estimating-pipeline-table td {
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
}

.estimating-pipeline-table th {
    text-align: left;
    background: #f8fafc;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 10px;
}

.estimating-pipeline-table small {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 10px;
    line-height: 1.3;
}

.estimating-pipeline-labor-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(120px, 1fr));
    gap: 8px;
}

.estimating-pipeline-labor-grid .summary-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
}

.estimating-pipeline-labor-grid .summary-card label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.estimating-pipeline-labor-grid .summary-card strong {
    font-size: 16px;
    color: #0f172a;
}

.estimating-schedule-task-mappings {
    flex: 1;
    min-height: 0;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 8px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.estimating-schedule-task-item {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #fff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.estimating-schedule-task-item strong {
    font-size: 12px;
    color: #0f172a;
}

.estimating-schedule-task-meta {
    font-size: 11px;
    color: #475569;
}

.estimating-proposal-view {
    height: 100%;
    min-height: 0;
    overflow: auto;
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 12px;
}

.proposal-section {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #fff;
    padding: 12px 14px;
    min-height: 120px;
}

.proposal-section h4 {
    margin: 0 0 10px;
    font-size: 14px;
    color: #0f172a;
}

.proposal-section p {
    margin: 0;
    white-space: pre-wrap;
    font-size: 12px;
    color: #334155;
    line-height: 1.5;
}

.proposal-empty {
    color: #64748b;
    font-style: italic;
}

/* Toolbar Styling */
.estimating-toolbar {
    display: flex;
    align-items: center;
    gap: 6px; /* Reduced from 8px */
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 8px 16px; /* Reduced from 10px 20px */
    flex-shrink: 0;
    box-sizing: border-box;
    overflow-x: auto; /* Allow horizontal scroll for toolbar if needed */
}

.estimating-toolbar .btn {
    background: #e5e9f2;
    color: #25344a;
    border: 1px solid #b5c7e3;
    border-radius: 6px;
    padding: 5px 10px; /* Reduced from 6px 12px */
    font-size: 11px; /* Reduced from 12px */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.estimating-toolbar .btn:hover {
    background: #d1ddf0;
    border-color: #25344a;
}

.estimating-toolbar .btn.primary {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.estimating-toolbar .btn.primary:hover {
    background: #2980b9;
    border-color: #2980b9;
}

/* Left Sidebar */
.left-sidebar {
    width: 240px;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    gap: 8px; /* Reduced from 12px */
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    overflow: hidden;
}

#estimating-tab #ai-estimate-btn {
    padding: 4px 10px !important;
    font-size: 11px !important;
    box-shadow: none !important;
    gap: 4px !important;
}

#estimating-tab #ai-estimate-btn span:first-child {
    font-size: 12px !important;
}

.left-sidebar-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: #1f3b63;
    border-radius: 8px 8px 0 0;
    padding: 4px;
}

.left-sidebar-tab {
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: #dbe8fb;
    font-size: 11px;
    font-weight: 700;
    padding: 7px 8px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.left-sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.2);
}

.left-sidebar-tab.active {
    background: #ffffff;
    color: #1f3b63;
    border-color: #bfdbfe;
}

.left-sidebar-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
    gap: 8px;
}

.left-sidebar-panel.active {
    display: flex;
}

/* Plan Level Panel */
.plan-level-panel {
    flex: 1; /* 50% of available height */
    width: 100%;
    background: #fff;
    border-radius: 6px; /* Reduced from 8px */
    box-shadow: 0 2px 6px rgba(44,62,80,0.06); /* Reduced shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
    border: none;
    min-height: 0;
}

/* Current Measurements Panel */
.current-measurements-panel {
    flex: 1; /* 50% of available height - changed from fixed height */
    width: 100%;
    background: #fff;
    border-radius: 6px; /* Reduced from 8px */
    box-shadow: 0 2px 6px rgba(44,62,80,0.06); /* Reduced shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
    border: none;
    min-height: 0; /* Allow panel to shrink if needed */
}

/* Layers Panel */
.layers-panel {
    flex: 0 0 160px;
    width: 100%;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 2px 6px rgba(44,62,80,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    margin: 0;
    border: none;
    min-height: 140px;
}

.layers-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.layer-row {
    display: grid;
    grid-template-columns: 16px 1fr auto;
    gap: 6px;
    align-items: center;
    padding: 6px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.layer-row.active {
    background: #e8f3ff;
    border-color: #90caf9;
}

.layer-row.hidden {
    opacity: 0.6;
}

.layer-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2);
}

.layer-toggle {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    border: 1px solid #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #475569;
    background: #fff;
}

.layer-row.hidden .layer-toggle {
    background: #e2e8f0;
    color: #94a3b8;
}

.layer-name {
    font-size: 11px;
    font-weight: 600;
    color: #334155;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.layer-actions {
    display: flex;
    gap: 4px;
}

.layer-actions button {
    background: #fff;
    color: #475569;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.layer-actions .layer-toggle {
    padding: 0;
    width: 18px;
    height: 18px;
}

.layer-actions button:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

/* Ensure sections match container width and use global headers */
.plan-level-panel .section-header,
.current-measurements-panel .section-header {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    border-radius: 8px 8px 0 0 !important;
    border: none !important;
}

.plan-tree {
    font-size: 12px;
}

.plan-tree-empty {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
    padding: 12px;
    border: 1px dashed #b8c7d9;
    border-radius: 10px;
    background: #f8fafc;
}

.plan-tree-empty strong {
    color: #1e293b;
    font-size: 12px;
}

.plan-tree-empty .btn {
    align-self: flex-start;
}

.takeoff-plan-tree-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.takeoff-plan-tree-header__copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.takeoff-plan-tree-header__copy h3 {
    margin: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
}

#plan-pages-context-meta {
    font-size: 10px;
    color: #8aa0ba;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-page-node {
    display: block;
    margin-bottom: 2px;
    position: relative;
}

.tree-page-children,
.tree-children {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 3px 0 6px 12px;
    padding-left: 10px;
    border-left: 1px dashed #d7e1ee;
}

.tree-page-children-empty {
    margin-left: 12px;
    padding: 4px 6px;
    font-size: 10px;
    color: #94a3b8;
}

.tree-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 6px;
    cursor: pointer;
    border-radius: 10px;
    margin-bottom: 2px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    min-height: 24px;
    min-width: 0;
}

.tree-item:hover {
    background: #f8fbff;
}

.tree-item.selected {
    background: #ecf5ff;
    color: #174ea6;
    box-shadow: inset 0 0 0 1px #bfdbfe;
}

.tree-item.sub-item {
    margin-left: 10px;
    color: #64748b;
}

.tree-item.plan-file-item {
    padding: 5px 8px;
    border: 1px solid #dbe6f2;
    background: linear-gradient(180deg, #fdfefe 0%, #f6f9fc 100%);
    color: #20324a;
    gap: 8px;
    min-width: 0;
}

.tree-item.plan-file-item .tree-label {
    font-weight: 600;
}

.tree-file-icon {
    width: auto;
    min-width: 26px;
    padding: 2px 6px;
    border-radius: 999px;
    background: #e8eef8;
    color: #2f5f9e;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.tree-file-count {
    flex-shrink: 0;
    margin-left: auto;
    font-size: 9px;
    color: #6b7f97;
    border: 1px solid #d7e1ee;
    background: #fff;
    border-radius: 999px;
    padding: 2px 6px;
}

.tree-item.page-item {
    margin-left: 10px;
    background: #fbfdff;
    border: 1px solid #dde7f2;
    padding: 4px 6px 4px 4px;
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    grid-template-areas:
        "expand card"
        "actions actions";
    align-items: flex-start;
    column-gap: 6px;
    row-gap: 5px;
    min-height: 38px;
    position: relative;
    min-width: 0;
}

.tree-page-row {
    cursor: pointer;
}

.tree-item.page-item:hover,
.tree-item.page-item.selected {
    border-color: #c8d8eb;
}

.tree-item.measurement-sub-item {
    margin-left: 10px;
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: center;
    column-gap: 6px;
    padding: 4px 8px;
    font-size: 11px;
    line-height: 1.35;
    color: #475569;
    cursor: default;
    border: 1px solid #e6edf5;
    border-radius: 8px;
    background: #ffffff;
}

.tree-item.takeoff-item-sub-item {
    margin-left: 10px;
    display: block;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    color: #334155;
    min-height: 40px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.tree-assembly-row {
    cursor: pointer;
}

.tree-item.takeoff-item-sub-item.selected {
    background: #edf5ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
    box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.22);
}

.tree-item.takeoff-item-sub-item:hover {
    background: #f8fbff;
}

.tree-page-expand-btn {
    grid-area: expand;
    width: 16px;
    height: 16px;
    border: 1px solid transparent;
    background: transparent;
    color: #475569;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

.tree-page-expand-btn:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.tree-page-expand-btn .tree-icon {
    width: auto;
    font-size: 11px;
    line-height: 1;
}

.tree-page-sheet-icon {
    width: 18px;
    height: 18px;
    border-radius: 5px;
    border: 1px solid #d8e2ee;
    background: #fff;
    color: #6b7f97;
    font-size: 9px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    letter-spacing: -0.05em;
}

.tree-page-card {
    grid-area: card;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-page-card__title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-page-card__meta {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.tree-page-title-wrap {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1 1 auto;
}

.tree-page-sheet-label {
    flex-shrink: 0;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #7a8ca3;
}

.tree-page-quick-btn {
    border: 1px solid #d7e1ee;
    background: #fff;
    color: #5d728c;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    width: 22px;
    height: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.tree-page-quick-btn:hover {
    background: #eef4fb;
    border-color: #b9ccdf;
}

.tree-item.takeoff-item-sub-item .tree-icon {
    width: 12px;
}

.tree-takeoff-bullet {
    color: #7a8ca3;
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

.tree-takeoff-color {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    display: inline-block;
}

.tree-takeoff-type {
    font-size: 8px;
    color: #64748b;
    border: 1px solid #dbe2ea;
    border-radius: 999px;
    padding: 1px 5px;
    line-height: 1.15;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #f8fafc;
}

.tree-takeoff-qty {
    font-size: 9px;
    color: #0f172a;
    font-weight: 600;
    white-space: nowrap;
}

.tree-assembly-meta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
    flex-wrap: wrap;
}

.tree-assembly-geom-badge {
    font-size: 8px;
    color: #475569;
    border: 1px solid #dbe2ea;
    border-radius: 999px;
    padding: 1px 4px;
    line-height: 1.1;
    white-space: nowrap;
}

.tree-assembly-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.tree-takeoff-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tree-takeoff-card__title {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree-takeoff-card__footer {
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
}

.tree-takeoff-color-input {
    width: 16px;
    height: 16px;
    padding: 0;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
}

.tree-takeoff-visibility-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 9px;
    font-weight: 700;
    border-radius: 5px;
    width: 22px;
    min-width: 22px;
    height: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.tree-takeoff-visibility-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.tree-takeoff-action-btn {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #475569;
    font-size: 10px;
    font-weight: 700;
    border-radius: 5px;
    width: 22px;
    min-width: 22px;
    height: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.tree-takeoff-action-btn:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.tree-takeoff-action-btn.danger {
    color: #b91c1c;
    border-color: #fecaca;
    background: #fff5f5;
}

.tree-takeoff-action-btn.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.tree-item.tree-item-muted {
    cursor: default;
    opacity: 0.75;
}

.tree-page-count {
    font-size: 9px;
    color: #64748b;
    font-weight: 600;
    margin-left: 4px;
    white-space: nowrap;
}

.tree-page-revision {
    font-size: 9px;
    color: #1d4ed8;
    background: #dbeafe;
    border: 1px solid #93c5fd;
    border-radius: 999px;
    padding: 1px 5px;
    line-height: 1.1;
    margin-left: 4px;
    font-weight: 700;
}

.tree-page-number {
    font-size: 9px;
    color: #5c728c;
    border: 1px solid #d5e0ec;
    border-radius: 999px;
    padding: 1px 6px;
    line-height: 1.1;
    background: #fff;
}

.tree-page-label-input {
    width: 100%;
    min-width: 0;
    border: 1px solid #93c5fd;
    background: #ffffff;
    color: #0f172a;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 12px;
    line-height: 1.2;
}

.tree-page-label-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.tree-page-actions {
    grid-area: actions;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    align-self: center;
    gap: 5px;
    margin-left: 24px;
    max-width: calc(100% - 24px);
    min-width: 0;
    flex-wrap: wrap;
}

.tree-page-primary-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
    flex-wrap: wrap;
}

.tree-page-action-pill {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
    cursor: pointer;
    min-height: 22px;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.tree-page-action-pill:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.tree-page-action-pill--accent {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.18);
}

.tree-page-action-pill--accent:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.tree-page-menu-btn {
    border: 1px solid #d4deea;
    background: #fff;
    color: #5e738d;
    font-size: 12px;
    font-weight: 700;
    border-radius: 6px;
    min-width: 24px;
    height: 20px;
    cursor: pointer;
    line-height: 1;
    padding: 0 6px;
}

.tree-page-menu-btn:hover {
    background: #eef4fb;
    border-color: #b8cbdf;
}

.tree-page-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 5;
    min-width: 132px;
    padding: 5px;
    border-radius: 10px;
    border: 1px solid #d8e2ee;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
}

.tree-page-menu-item {
    width: 100%;
    border: none;
    background: transparent;
    color: #334155;
    font-size: 11px;
    text-align: left;
    border-radius: 7px;
    padding: 7px 8px;
    cursor: pointer;
}

.tree-page-menu-item:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.tree-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.tree-item.page-item .tree-icon {
    width: 12px;
}

.tree-label {
    flex: 1;
    min-width: 0;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Add scroll wheels for overflow data in left sidebar */
.plan-level-panel .panel-content,
.current-measurements-panel .panel-content {
    flex: 1;
    padding: 8px; /* Reduced from 12px */
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    border: none;
}

.measurements-list {
    font-size: 11px;
}

.measurements-list .measurement-row {
    display: grid;
    grid-template-columns: 20px minmax(120px, 1fr) 90px 78px 78px minmax(145px, 170px);
    gap: 6px;
    align-items: center;
    padding: 6px;
    border-bottom: 1px solid #eef2f7;
    font-size: 11px;
    cursor: pointer;
}

.measurements-list .measurement-row.header {
    font-weight: 600;
    text-transform: uppercase;
    font-size: 10px;
    color: #64748b;
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.measurements-list .measurement-row.selected {
    background: #e3f2fd;
    border-color: #bbdefb;
}

.measurements-list .measurement-row.hidden {
    opacity: 0.6;
}

.measurements-list .measurement-row input,
.measurements-list .measurement-row select {
    width: 100%;
    padding: 4px 6px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 11px;
    background: #fff;
}

.measurements-list .measurement-name {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.measurements-list .measurement-name input {
    font-weight: 600;
}

.measurements-list .measurement-formula input {
    font-size: 10px;
    color: #475569;
}

.measurements-list .measurement-row .pill {
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 10px;
    background: #eef2ff;
    color: #4338ca;
    text-align: center;
}

.measurement-controls {
    display: grid;
    grid-template-columns: minmax(82px, 1fr) 26px 26px;
    gap: 4px;
    align-items: center;
}

.measurement-controls select {
    font-size: 10px;
    padding: 3px 4px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
}

.measurement-controls button {
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #fff;
    color: #334155;
    font-size: 10px;
    line-height: 1;
    min-height: 24px;
    cursor: pointer;
}

.measurement-controls button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

.measurement-controls button.is-hidden {
    background: #e2e8f0;
    color: #64748b;
}

.left-assemblies-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.assembly-library-controls {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(220px, 280px);
    gap: 8px;
}

.assembly-library-controls input,
.assembly-library-controls select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #b5c7e3;
    border-radius: 6px;
    font-size: 11px;
    color: #25344a;
    background: #fff;
}

.assembly-tree-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assembly-tree-node {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
}

.assembly-tree-node.depth-2 {
    margin-left: 14px;
}

.assembly-tree-node.depth-3 {
    margin-left: 28px;
}

.assembly-tree-node.depth-4 {
    margin-left: 42px;
}

.assembly-tree-row {
    display: grid;
    grid-template-columns: 16px minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
}

.assembly-tree-row.node-level-division {
    background: #f1f5f9;
}

.assembly-tree-row.node-level-category {
    background: #f8fafc;
}

.assembly-tree-row.node-level-subcategory {
    background: #fbfdff;
}

.assembly-tree-row.node-level-template {
    background: #ffffff;
}

.assembly-tree-row.node-level-template.is-selected {
    background: #eff6ff;
    border-left: 3px solid #2563eb;
    padding-left: 5px;
}

.assembly-tree-toggle {
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 14px;
    height: 14px;
    text-align: center;
}

.assembly-tree-node.is-leaf .assembly-tree-toggle {
    visibility: hidden;
}

.assembly-tree-label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.assembly-tree-label strong {
    color: #0f172a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.assembly-tree-meta {
    color: #64748b;
    font-size: 10px;
    line-height: 1.2;
}

.takeoff-parameter-help {
    display: block;
    margin-top: 3px;
    font-size: 10px;
    line-height: 1.35;
    color: #64748b;
    font-weight: 500;
    text-transform: none;
    letter-spacing: normal;
}

.takeoff-parameter-unit {
    color: #475569;
    font-size: 10px;
    font-weight: 700;
}

.takeoff-parameter-required {
    color: #b91c1c;
    font-weight: 800;
}

.assembly-tree-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.assembly-tree-actions .btn {
    padding: 3px 6px;
    font-size: 10px;
}

.assembly-tree-children {
    display: block;
    padding: 0 4px 4px;
}

.assembly-tree-node.collapsed > .assembly-tree-children {
    display: none;
}

.compact-assemblies-list .assembly-tree-row {
    padding: 5px 6px;
    gap: 6px;
}

.compact-assemblies-list .assembly-tree-node.depth-2 {
    margin-left: 10px;
}

.compact-assemblies-list .assembly-tree-node.depth-3 {
    margin-left: 20px;
}

.compact-assemblies-list .assembly-tree-node.depth-4 {
    margin-left: 30px;
}

.compact-assemblies-list .assembly-tree-label strong {
    font-size: 11px;
}

.compact-assemblies-list .assembly-tree-meta {
    font-size: 9px;
}

.assembly-editor-panel {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assembly-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-editor-header strong {
    font-size: 12px;
    color: #0f172a;
}

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

.assembly-editor-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 8px;
}

.assembly-editor-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    font-weight: 700;
}

.assembly-editor-grid input,
.assembly-editor-grid select,
.assembly-editor-grid textarea {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 7px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

.assembly-editor-grid input[readonly] {
    background: #f8fafc;
    color: #64748b;
}

.assembly-editor-description {
    grid-column: 1 / -1;
}

.assembly-editor-section {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.assembly-editor-section__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-editor-section__header strong {
    display: block;
    font-size: 11px;
    color: #0f172a;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.assembly-editor-section__header span {
    display: block;
    margin-top: 3px;
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
}

.assembly-editor-dynamic-grid,
.assembly-editor-override-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 8px;
}

.assembly-editor-dynamic-grid label,
.assembly-editor-override-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    font-weight: 700;
}

.assembly-editor-dynamic-grid input,
.assembly-editor-dynamic-grid select,
.assembly-editor-override-grid input,
.assembly-editor-override-grid select,
.assembly-editor-override-grid textarea {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 7px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

.assembly-editor-dynamic-grid textarea,
.assembly-editor-override-grid textarea {
    min-height: 72px;
    resize: vertical;
}

.assembly-editor-param-group {
    grid-column: 1 / -1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assembly-editor-param-group h4 {
    margin: 0;
    font-size: 11px;
    color: #1f3b63;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.assembly-editor-param-group-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 8px;
}

.assembly-editor-param-help {
    font-size: 11px;
    color: #64748b;
    line-height: 1.35;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
}

.assembly-editor-checkbox {
    justify-content: flex-end;
}

.assembly-editor-checkbox input {
    width: 16px;
    height: 16px;
}

.assembly-formula-preview {
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-formula-preview label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #475569;
    font-weight: 700;
}

.assembly-formula-preview input {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 7px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
    min-width: 120px;
}

.assembly-formula-preview-result {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assembly-formula-preview-result strong {
    font-size: 18px;
    color: #0f172a;
}

.assembly-formula-preview-result span {
    font-size: 11px;
    color: #475569;
}

.assembly-editor-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-editor-footer span {
    font-size: 11px;
    color: #475569;
    flex: 1;
}

.assembly-editor-panel.is-disabled {
    opacity: 0.75;
}

.cost-items-panel-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.cost-items-panel-controls input,
.cost-items-panel-controls select {
    flex: 1;
    min-width: 140px;
    padding: 6px 8px;
    border: 1px solid #b5c7e3;
    border-radius: 6px;
    font-size: 11px;
    color: #25344a;
    background: #fff;
}

.cost-items-panel-controls #costbook-market-zip {
    flex: 0 1 170px;
    min-width: 140px;
}

.cost-items-market-note {
    margin-bottom: 8px;
    font-size: 11px;
    color: #334155;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 6px 8px;
}

.costbook-manual-form {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
}

.costbook-manual-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: #334155;
}

.costbook-manual-form input,
.costbook-manual-form select {
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 11px;
    color: #0f172a;
    background: #fff;
}

.costbook-manual-actions {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.costbook-items-inline {
    flex: 1;
    min-height: 120px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #fff;
    padding: 8px;
}

.cost-items-group {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #fff;
    margin-bottom: 8px;
    overflow: hidden;
}

.cost-items-group-header {
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
    background: #f1f5f9;
    border-bottom: 1px solid #e2e8f0;
}

.cost-item-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(180px, 1fr) auto;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border-bottom: 1px solid #e2e8f0;
}

.cost-item-row:last-child {
    border-bottom: none;
}

.cost-item-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.cost-item-title strong {
    font-size: 12px;
    color: #0f172a;
    line-height: 1.2;
}

.cost-item-meta {
    font-size: 10px;
    color: #64748b;
    line-height: 1.25;
}

.cost-item-pricing {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.cost-item-pricing span {
    display: block;
    font-size: 10px;
    color: #475569;
}

.cost-item-pricing strong {
    font-size: 12px;
    color: #0f172a;
}

.cost-item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

.cost-item-actions .btn {
    padding: 3px 6px;
    font-size: 10px;
}

.estimating-change-orders-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.estimating-change-order-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.change-order-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.change-order-status {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1e40af;
    background: #dbeafe;
    border-radius: 999px;
    padding: 2px 7px;
}

.change-order-meta {
    font-size: 11px;
    color: #64748b;
}

.estimating-change-order-card p {
    margin: 0;
    font-size: 11px;
    color: #334155;
    line-height: 1.35;
}

.left-assembly-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.left-assembly-card h5 {
    margin: 0;
    font-size: 12px;
    color: #0f172a;
}

.left-assembly-card p {
    margin: 0;
    font-size: 11px;
    color: #475569;
    line-height: 1.35;
}

.left-assembly-card .assembly-meta {
    font-size: 10px;
    color: #64748b;
}

.assembly-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.assembly-tag {
    font-size: 10px;
    font-weight: 600;
    color: #1e3a8a;
    background: #e0e7ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    padding: 2px 7px;
    line-height: 1.2;
}

.measurement-group {
    margin-bottom: 12px;
}

.measurement-group .group-header {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.measurement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 4px;
    margin-bottom: 1px;
    font-size: 10px;
}

.measure-label {
    flex: 1;
    color: #64748b;
}

.measure-value {
    font-weight: 500;
    color: #374151;
    min-width: 40px;
    text-align: right;
}

.measurements-summary {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    font-size: 11px;
}

.measurements-summary .summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: #334155;
}

/* Center Panel */
.center-panel {
    flex: 1;
    background: #fff;
    border-radius: 6px; /* Reduced from 8px */
    box-shadow: 0 2px 6px rgba(44,62,80,0.06); /* Reduced shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    box-sizing: border-box;
}

.pdf-viewer-container {
    flex: 1;
    background: #f8f9fa;
    padding: 12px; /* Reduced from 16px */
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    overflow: hidden;
    box-sizing: border-box;
}

#estimating-tab .assembly-placement-hud {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding: 10px 12px;
    border: 1px solid #cddcf0;
    border-radius: 10px;
    background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

#estimating-tab .assembly-placement-hud[hidden] {
    display: none !important;
}

#estimating-tab .assembly-placement-hud__info {
    min-width: 0;
    display: grid;
    gap: 4px;
}

#estimating-tab .assembly-placement-hud__eyebrow {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #4f6b93;
    font-weight: 700;
}

#estimating-tab .assembly-placement-hud__title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

#estimating-tab .assembly-placement-hud__title-row strong {
    color: #10233f;
    font-size: 14px;
    line-height: 1.2;
}

#estimating-tab .assembly-placement-hud__mode {
    font-size: 11px;
    color: #24446f;
    background: #dbeafe;
    border: 1px solid #bfd7fb;
    border-radius: 999px;
    padding: 2px 8px;
    font-weight: 700;
}

#estimating-tab .assembly-placement-hud__pill {
    font-size: 11px;
    color: #065f46;
    background: #d1fae5;
    border: 1px solid #a7f3d0;
    border-radius: 999px;
    padding: 2px 8px;
    font-weight: 700;
}

#estimating-tab .assembly-placement-hud__summary {
    color: #355173;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

#estimating-tab .assembly-placement-hud__metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 1fr));
    gap: 8px;
}

#estimating-tab .assembly-placement-hud__metric {
    border: 1px solid #d7e4f4;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.78);
    padding: 7px 8px;
    display: grid;
    gap: 3px;
}

#estimating-tab .assembly-placement-hud__metric span {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #5d7698;
    font-weight: 700;
}

#estimating-tab .assembly-placement-hud__metric strong {
    color: #132945;
    font-size: 13px;
    line-height: 1.2;
}

#estimating-tab .assembly-placement-hud__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#estimating-tab .assembly-placement-hud__breakdown {
    display: grid;
    grid-template-columns: repeat(2, minmax(170px, 1fr));
    gap: 6px 10px;
    padding-top: 2px;
}

#estimating-tab .assembly-placement-hud__breakdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px dashed #d7e3f3;
    padding: 3px 0;
    font-size: 12px;
    color: #334d70;
}

#estimating-tab .assembly-placement-hud__breakdown-row span {
    overflow-wrap: anywhere;
}

#estimating-tab .assembly-placement-hud__breakdown-row strong {
    color: #10223e;
    font-size: 12px;
    white-space: nowrap;
}

#estimating-tab .assembly-placement-hud__breakdown-row.is-total {
    border-bottom: 0;
    margin-top: 2px;
    padding-top: 5px;
    border-top: 1px solid #cfdff1;
    font-weight: 700;
}

#estimating-tab .assembly-placement-hud__breakdown-row.is-total strong {
    font-size: 13px;
    color: #0c3a70;
}

.pdf-file-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.pdf-file-toolbar select {
    min-width: 260px;
    max-width: 560px;
    padding: 5px 8px;
    border: 1px solid #b5c7e3;
    border-radius: 6px;
    font-size: 11px;
    background: #fff;
    color: #25344a;
}

#estimating-tab .scale-config-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.36);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 20px;
}

#estimating-tab .scale-config-modal[hidden] {
    display: none !important;
}

#estimating-tab .scale-config-panel {
    width: min(520px, 96vw);
    background: #ffffff;
    border: 1px solid #d7e0ed;
    border-radius: 10px;
    box-shadow: 0 18px 36px rgba(15, 23, 42, 0.24);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#estimating-tab .scale-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

#estimating-tab .scale-config-header h3 {
    margin: 0;
    color: #0f172a;
    font-size: 15px;
}

#estimating-tab .scale-config-content {
    display: grid;
    gap: 10px;
}

#estimating-tab .scale-config-section {
    border: 1px solid #dce4ef;
    border-radius: 8px;
    padding: 10px;
    display: grid;
    gap: 8px;
    background: #f8fbff;
}

#estimating-tab .scale-config-section strong {
    color: #1f2d44;
}

#estimating-tab .scale-config-section p {
    margin: 0;
    color: #4b5d78;
    font-size: 12px;
    line-height: 1.4;
}

#estimating-tab .scale-config-row {
    display: flex;
    gap: 8px;
}

#estimating-tab .scale-config-row select {
    flex: 1;
    min-width: 0;
    border: 1px solid #b5c7e3;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 12px;
    color: #243449;
    background: #fff;
}

.pdf-placeholder {
    width: 100%;
    height: 100%;
    background: #fff;
    border: 2px dashed #cbd5e1;
    border-radius: 6px; /* Reduced from 8px */
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-size: 14px; /* Reduced from 16px */
    font-weight: 500;
    box-sizing: border-box;
}

.drywall-planner-panel {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 320px;
    overflow: auto;
}

.drywall-planner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.drywall-planner-header h3 {
    margin: 0;
    font-size: 14px;
    color: #0f172a;
    letter-spacing: 0.02em;
}

.drywall-planner-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.drywall-planner-toolbar {
    border-top: 1px dashed #dbe5ef;
    padding-top: 8px;
}

.drywall-planner-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(320px, 1fr));
    gap: 10px;
}

.drywall-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
}

.drywall-card h4 {
    margin: 0 0 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #334155;
}

.drywall-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
    gap: 8px;
}

.drywall-field-grid label,
.drywall-mix-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: #334155;
    font-weight: 600;
}

.drywall-field-grid input,
.drywall-field-grid select,
.drywall-mix-grid input {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 5px 7px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

.drywall-mix-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(80px, 1fr));
    gap: 8px;
    margin-bottom: 8px;
}

.drywall-pricing-source {
    margin: 8px 0 0;
    font-size: 11px;
    color: #475569;
}

.drywall-results {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #ffffff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drywall-result-cards {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 8px;
}

.drywall-result-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.drywall-result-card label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.drywall-result-card strong {
    font-size: 14px;
    color: #0f172a;
}

.drywall-tables-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(280px, 1fr));
    gap: 10px;
}

.drywall-table-wrap h4 {
    margin: 0 0 6px;
    font-size: 12px;
    color: #334155;
}

.drywall-table-wrap {
    min-height: 180px;
}

.drywall-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.drywall-table th,
.drywall-table td {
    padding: 7px 8px;
    font-size: 11px;
    border-bottom: 1px solid #e2e8f0;
}

.drywall-table th {
    background: #f8fafc;
    text-align: left;
    color: #475569;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.drywall-notes {
    margin: 0;
    font-size: 11px;
    color: #475569;
}

.drywall-planner-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9990;
    padding: 16px;
}

.drywall-planner-modal[hidden] {
    display: none !important;
}

.drywall-planner-modal .drywall-planner-panel {
    width: min(1240px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    min-height: 420px;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
}

.assembly-formula-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9991;
    padding: 16px;
}

.assembly-formula-modal[hidden] {
    display: none !important;
}

.assembly-formula-modal .assembly-editor-panel {
    width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
}

.assembly-config-modal {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.54);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9992;
    padding: 16px;
}

.assembly-config-modal[hidden] {
    display: none !important;
}

.assembly-config-panel {
    width: min(1100px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    overflow: auto;
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #ffffff;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
}

.assembly-config-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-config-header h3 {
    margin: 0;
    font-size: 14px;
    color: #0f172a;
    letter-spacing: 0.02em;
}

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

.assembly-config-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 8px;
}

.assembly-config-grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: #334155;
    font-weight: 600;
}

.assembly-config-grid input,
.assembly-config-grid select {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 7px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

.assembly-config-preview {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr));
    gap: 8px;
}

.assembly-config-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.assembly-config-card label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 700;
}

.assembly-config-card strong {
    font-size: 14px;
    color: #0f172a;
}

.assembly-config-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.assembly-config-footer span {
    flex: 1;
    font-size: 11px;
    color: #475569;
}

/* Right Sidebar - Split 60/40 by height */
.right-sidebar {
    width: 280px; /* Reduced from 320px */
    min-width: 280px; /* Reduced from 320px */
    background: #fff;
    border-radius: 6px; /* Reduced from 8px */
    box-shadow: 0 2px 6px rgba(44,62,80,0.06); /* Reduced shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    transition: width 0.22s ease, min-width 0.22s ease;
}

.right-sidebar.collapsed {
    width: 66px;
    min-width: 66px;
}

.right-sidebar.collapsed .assemblies-content {
    display: none;
}

.right-sidebar.collapsed .section-header {
    border-radius: 8px !important;
    padding: 12px 6px !important;
    justify-content: center !important;
}

.right-sidebar.collapsed .section-header h3 {
    display: none !important;
}

.right-sidebar.collapsed .section-header::before {
    content: 'Catalog';
    color: #ffffff;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

/* Assemblies Content - Top 60% */
.assemblies-content {
    flex: 0 0 60%; /* Fixed 60% height */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-radius: 8px 8px 0 0;
}

/* Assemblies Bottom Section - Bottom 40% */
.assemblies-bottom {
    flex: 0 0 40%; /* Fixed 40% height */
    border-top: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 0 0 8px 8px;
}

/* Right sidebar header styling to match global headers */
.right-sidebar .section-header,
.assemblies-bottom .section-header {
    width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    color: #fff !important;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    padding: 14px 18px 12px 18px !important;
    border-radius: 8px 8px 0 0 !important;
    letter-spacing: 0.5px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: none !important;
    border: none !important;
    text-shadow: none !important;
}

.right-sidebar .section-header h3,
.assemblies-bottom .section-header h3 {
    margin: 0 !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    letter-spacing: 0.5px !important;
}

/* Bottom section header specific styling */
.assemblies-bottom .section-header {
    border-radius: 0 !important; /* No border radius for middle section */
    border-top: 1px solid rgba(255,255,255,0.1) !important;
}

/* Takeoffs Tree */
.takeoffs-tree {
    font-size: 11px;
}

.assembly-group {
    margin-bottom: 8px;
}

.assembly-group .group-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 600;
    color: #374151;
}

.assembly-group .group-header:hover {
    background: #f1f5f9;
}

.expand-icon {
    font-size: 10px;
    color: #64748b;
    transition: transform 0.2s ease;
}

.color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.group-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-items {
    margin-left: 20px;
    margin-top: 4px;
}

.assembly-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.2s ease;
    margin-bottom: 2px;
}

.assembly-item:hover {
    background: #f1f5f9;
}

.assembly-item.selected {
    background: #e3f2fd;
    color: #1976d2;
}

.item-name {
    flex: 1;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.assembly-item.selected .item-name {
    color: #1976d2;
}

/* Assemblies Bottom Section - moved to right sidebar section above */

.assemblies-bottom .section-header {
    font-weight: 600;
    font-size: 16px !important;
    color: #fff !important;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.assembly-tree {
    font-size: 11px;
}

.assembly-tree .assembly-item {
    margin-bottom: 3px;
}

.assembly-icon {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

.assembly-name {
    flex: 1;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sub-assemblies {
    margin-left: 16px;
}

/* Panel Headers - Use global header styles */
#estimating-tab .section-header {
    color: #fff !important;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    padding: 8px 10px !important;
    margin: 0 !important;
    border-radius: 6px 6px 0 0 !important;
    letter-spacing: 0.2px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    box-shadow: none !important;
    border: none !important;
    text-shadow: none !important;
}

#estimating-tab .section-header h3 {
    margin: 0 !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    letter-spacing: 0.2px !important;
}

/* Ensure no unwanted borders or margins in left sidebar */
#estimating-tab .left-sidebar * {
    box-sizing: border-box;
}

#estimating-tab .left-sidebar .plan-level-panel,
#estimating-tab .left-sidebar .layers-panel,
#estimating-tab .left-sidebar .current-measurements-panel {
    border: none !important;
    outline: none !important;
    margin: 0 !important;
}

/* Takeoff uses the Plan Pages tree as the only left sidebar UI (no standalone layers/current-page panels). */
#estimating-tab .left-sidebar {
    min-height: 0;
}

#estimating-tab .left-sidebar .left-sidebar-panel {
    min-height: 0;
    height: 100%;
}

#estimating-tab .left-sidebar .plan-level-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

#estimating-tab .left-sidebar .plan-level-panel .panel-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

#estimating-tab .plan-tree {
    min-height: 0;
}

.header-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-btn:hover {
    background: rgba(255,255,255,0.3);
    border-color: rgba(255,255,255,0.5);
}

#estimating-tab .takeoff-left-panel-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}

#estimating-tab .takeoff-left-panel-btn.active {
    background: #ffffff;
    color: #1f3b63;
    border-color: #bfdbfe;
}

/* Panel Content */
.panel-content {
    flex: 1;
    padding: 8px; /* Reduced from 12px */
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Tab Content Area */
.tab-content-area {
    flex: 1;
    padding: 8px; /* Reduced from 12px */
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* Bottom section content with proper spacing */
.assemblies-bottom .section-header + div {
    flex: 1;
    padding: 8px; /* Reduced from 12px */
    overflow-y: auto;
    overflow-x: hidden;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* Costbook items list container */
#costbook-items-list {
    max-height: none; /* Remove max-height to use flex space */
    flex: 1;
    overflow-y: auto;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    padding: 8px;
    box-sizing: border-box;
}


/* Responsive Design */
@media (max-width: 1400px) {
    .left-sidebar {
        width: 210px;
        min-width: 210px;
    }
    
    .right-sidebar {
        width: 260px; /* Further reduced */
        min-width: 260px;
    }
    
    .estimating-main-layout {
        gap: 6px;
        padding: 6px;
    }
}

@media (max-width: 1200px) {
    .estimating-workspace-shell {
        padding: 6px;
    }

    .estimating-main-layout {
        gap: 4px;
        padding: 4px;
    }

    .drywall-planner-grid {
        grid-template-columns: 1fr;
    }

    .drywall-result-cards {
        grid-template-columns: repeat(3, minmax(120px, 1fr));
    }
    
    .left-sidebar {
        width: 180px;
        min-width: 180px;
    }
    
    .right-sidebar {
        width: 240px;
        min-width: 240px;
    }
    
    .estimating-toolbar {
        gap: 4px;
        padding: 6px 12px;
    }
    
    .estimating-toolbar .btn {
        padding: 3px 6px;
        font-size: 10px;
    }
}

@media (max-width: 1000px) {
    .estimating-workspace-shell {
        grid-template-columns: 1fr;
    }

    .estimating-summary-cards {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

    .estimating-pipeline-grid {
        grid-template-columns: 1fr;
    }

    .assembly-editor-grid,
    .assembly-editor-dynamic-grid,
    .assembly-editor-override-grid,
    .assembly-editor-param-group-grid {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
    }

    .estimating-proposal-view {
        grid-template-columns: 1fr;
    }

    .estimating-main-layout {
        flex-direction: column;
        gap: 4px;
        padding: 4px;
    }

    .drywall-tables-grid {
        grid-template-columns: 1fr;
    }
    
    .left-sidebar,
    .right-sidebar {
        width: 100%;
        min-width: 0;
        flex-direction: row;
        height: 180px; /* Reduced height */
    }
    
    .left-sidebar {
        order: 2;
        gap: 4px;
    }
    
    .plan-level-panel,
    .current-measurements-panel {
        flex: 1;
        height: 180px;
    }
    
    .center-panel {
        order: 1;
        height: 350px; /* Reduced height */
    }
    
    .right-sidebar {
        order: 3;
    }
    
    .assemblies-content,
    .assemblies-bottom {
        flex: 1;
    }
}

@media (max-width: 768px) {
    .estimating-workspace-shell {
        padding: 4px;
    }

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

    .estimating-ribbon-estimates {
        width: 100%;
        justify-content: flex-start;
    }

    .estimate-ribbon-select {
        min-width: 130px;
        max-width: 190px;
    }

    .estimate-ribbon-label {
        max-width: 90px;
    }

    .drywall-planner-modal {
        padding: 6px;
    }

    .drywall-planner-modal .drywall-planner-panel {
        width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
    }

    .assembly-formula-modal {
        padding: 6px;
    }

    .assembly-formula-modal .assembly-editor-panel {
        width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
    }

    .assembly-config-modal {
        padding: 6px;
    }

    .assembly-config-panel {
        width: calc(100vw - 12px);
        max-height: calc(100vh - 12px);
    }

    .assembly-config-grid {
        grid-template-columns: 1fr;
    }

    .assembly-config-preview {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    .costbook-manual-form {
        grid-template-columns: 1fr;
    }

    .cost-item-row {
        grid-template-columns: 1fr;
    }

    .cost-item-pricing {
        grid-template-columns: repeat(3, minmax(80px, 1fr));
    }

    .estimating-toolbar {
        flex-wrap: wrap;
        gap: 3px;
        padding: 4px 8px;
    }

    .estimating-summary-controls {
        width: 100%;
        justify-content: flex-start;
    }

    .estimating-summary-controls .estimate-ribbon-select {
        min-width: 160px;
    }

    .pdf-file-toolbar {
        flex-wrap: wrap;
    }

    .pdf-file-toolbar select {
        min-width: 180px;
        max-width: 100%;
        flex: 1;
    }

    .assembly-library-controls {
        grid-template-columns: 1fr;
    }

    .assembly-editor-grid,
    .assembly-editor-dynamic-grid,
    .assembly-editor-override-grid,
    .assembly-editor-param-group-grid {
        grid-template-columns: 1fr;
    }

    .estimating-toolbar .btn {
        font-size: 9px;
        padding: 2px 4px;
    }
    
    .estimating-main-layout {
        gap: 3px;
        padding: 3px;
    }

    .drywall-field-grid {
        grid-template-columns: 1fr;
    }

    .drywall-mix-grid {
        grid-template-columns: repeat(2, minmax(100px, 1fr));
    }

    .drywall-result-cards {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }
    
    .left-sidebar,
    .right-sidebar {
        height: 150px;
    }
    
    .center-panel {
        height: 300px;
    }
}

/* PDF Stage Canvases */
#pdf-stage {
    position: relative;
    width: 100%;
    overflow: auto;
    overscroll-behavior: contain;
    border: 1px solid #d5deea !important;
    border-radius: 6px !important;
    background: #f7f9fc !important;
}

#pdf-stage.has-loaded-plan #pdf-drop-hint,
#pdf-stage.has-active-pdf #pdf-drop-hint {
    display: none !important;
}

#pdf-stage #pdf-wrapper {
    position: relative;
    min-width: 100%;
    min-height: 100%;
}

#pdf-stage canvas#pdf-canvas {
    position: relative;
    z-index: 1;
}

#pdf-stage canvas#measure-canvas {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    pointer-events: auto;
}

@media (max-width: 1100px) {
    #estimating-tab .assembly-placement-hud {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    #estimating-tab .assembly-placement-hud__actions {
        justify-content: flex-start;
    }

    #estimating-tab .assembly-placement-hud__metrics {
        grid-template-columns: repeat(2, minmax(120px, 1fr));
    }

    #estimating-tab .assembly-placement-hud__breakdown {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    #estimating-tab .assembly-placement-hud__metrics {
        grid-template-columns: 1fr;
    }
}

/* Takeoff QA + tool state polish (additive) */
#estimating-tab .estimating-toolbar .btn.active-tool {
    background: #1f3b63;
    color: #fff;
    border-color: #1f3b63;
    box-shadow: 0 0 0 1px rgba(31, 59, 99, 0.28);
}

#estimating-tab .tree-page-uncalibrated {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
}

#estimating-tab .takeoff-qa-panel {
    margin-top: 10px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#estimating-tab .takeoff-qa-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
}

#estimating-tab .takeoff-qa-panel__header strong {
    font-size: 12px;
    letter-spacing: 0.03em;
    color: #1f3b63;
    text-transform: uppercase;
}

#estimating-tab .takeoff-qa-panel__list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px;
    max-height: 180px;
    overflow-y: auto;
    min-height: 0;
}

#estimating-tab .takeoff-qa-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: start;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    padding: 7px 8px;
}

#estimating-tab .takeoff-qa-row.warn {
    border-color: #fcd34d;
    background: #fffbeb;
}

#estimating-tab .takeoff-qa-row__code {
    font-size: 10px;
    font-weight: 700;
    color: #92400e;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

#estimating-tab .takeoff-qa-row__label {
    font-size: 11px;
    color: #334155;
    line-height: 1.35;
}

#estimating-tab .measurement-controls {
    flex-wrap: wrap;
    justify-content: flex-end;
}

#estimating-tab .measurement-controls button {
    white-space: nowrap;
}

/* Final takeoff layout guardrails to prevent nested scroll traps / tiny widgets */
#estimating-tab,
#estimating-tab .estimating-workspace-shell,
#estimating-tab .estimating-workspace-main,
#estimating-tab .estimating-sub-panel-container,
#estimating-tab .estimating-sub-panel,
#estimating-tab .estimating-main-layout,
#estimating-tab .left-sidebar,
#estimating-tab .center-panel,
#estimating-tab .right-sidebar,
#estimating-tab .pdf-viewer-container {
    min-height: 0;
}

#estimating-tab .left-sidebar,
#estimating-tab .right-sidebar,
#estimating-tab .center-panel {
    align-self: stretch;
}

#estimating-tab .current-measurements-panel .panel-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

@media (max-width: 900px) {
    #estimating-tab .left-sidebar,
    #estimating-tab .right-sidebar {
        height: auto !important;
        min-height: 220px;
    }

    #estimating-tab .center-panel {
        height: auto !important;
        min-height: 420px;
    }
}

@media (max-width: 640px) {
    #estimating-tab .left-sidebar,
    #estimating-tab .right-sidebar {
        min-height: 180px;
    }

    #estimating-tab .center-panel {
        min-height: 360px;
    }
}

/* Scope-first takeoff item tree */
#estimating-tab .measurements-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
}

#estimating-tab .takeoff-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border: 1px solid #dbeafe;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f6ff 100%);
    border-radius: 10px;
}

#estimating-tab .takeoff-page-header__title {
    font-weight: 700;
    color: #1e3a8a;
    font-size: 11px;
    min-width: 0;
}

#estimating-tab .takeoff-page-header__meta {
    color: #64748b;
    font-size: 10px;
    text-align: right;
}

#estimating-tab .takeoff-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 8px;
    cursor: pointer;
}

#estimating-tab .takeoff-item-row.active {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
    background: #f8fbff;
}

#estimating-tab .takeoff-item-row.is-hidden {
    opacity: 0.75;
    background: #f8fafc;
}

#estimating-tab .takeoff-item-row--unassigned {
    border-style: dashed;
    background: #f8fafc;
    cursor: default;
}

#estimating-tab .takeoff-item-row__main {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    flex: 1;
}

#estimating-tab .takeoff-item-row__swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    margin-top: 2px;
    border: 1px solid rgba(15, 23, 42, 0.15);
    flex-shrink: 0;
}

#estimating-tab .takeoff-item-row__name-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#estimating-tab .takeoff-item-row__name {
    font-weight: 700;
    color: #0f172a;
    font-size: 11px;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

#estimating-tab .takeoff-item-row__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    color: #64748b;
    font-size: 9px;
    line-height: 1.2;
}

#estimating-tab .takeoff-item-row__meta > span {
    padding: 1px 5px;
    border-radius: 999px;
    background: #f1f5f9;
}

#estimating-tab .takeoff-item-row__summary {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

#estimating-tab .takeoff-item-row__summary > span {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #334155;
    font-size: 10px;
    line-height: 1.25;
    font-weight: 600;
}

#estimating-tab .takeoff-item-row__actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

#estimating-tab .takeoff-item-row__actions input[type="color"] {
    width: 28px;
    height: 24px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 2px;
    background: #fff;
    cursor: pointer;
}

#estimating-tab .takeoff-item-row__actions button {
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
    border-radius: 5px;
    font-size: 9px;
    line-height: 1;
    padding: 5px 6px;
    cursor: pointer;
}

#estimating-tab .takeoff-item-row__actions button:hover {
    background: #eff6ff;
    border-color: #93c5fd;
}

#estimating-tab .takeoff-item-children {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: -1px 0 3px 12px;
    padding-left: 8px;
    border-left: 1px solid #dbe5ef;
}

#estimating-tab .takeoff-item-children__empty {
    color: #64748b;
    font-size: 11px;
    padding: 6px 4px 2px;
}

#estimating-tab .measurements-list .measurement-row.takeoff-geometry-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

#estimating-tab .measurements-list .measurement-row.takeoff-geometry-row:hover {
    border-color: #93c5fd;
    box-shadow: 0 1px 4px rgba(59, 130, 246, 0.1);
}

#estimating-tab .measurements-list .measurement-row.takeoff-geometry-row.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.18);
    background: #f8fbff;
}

#estimating-tab .measurements-list .measurement-row.takeoff-geometry-row.layer-hidden {
    opacity: 0.55;
    border-style: dashed;
}

#estimating-tab .geom-assembly-summary {
    margin-top: 8px;
    padding: 7px 8px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    color: #334155;
    font-size: 11px;
    line-height: 1.4;
}

/* Geometry row header */
#estimating-tab .geom-row-header {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 7px 3px;
    border-bottom: 1px solid #f1f5f9;
}

#estimating-tab .geom-type-badge {
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #fff;
    background: #6366f1;
    flex-shrink: 0;
    line-height: 1.4;
}
#estimating-tab .type-badge--linear { background: #0ea5e9; }
#estimating-tab .type-badge--area { background: #6366f1; }
#estimating-tab .type-badge--perimeter { background: #8b5cf6; }
#estimating-tab .type-badge--strip { background: #f59e0b; color: #1a1a1a; }
#estimating-tab .type-badge--volume { background: #10b981; }
#estimating-tab .type-badge--count { background: #ec4899; }
#estimating-tab .type-badge--segment { background: #64748b; }

#estimating-tab .geom-row-header .measurement-name-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    font-weight: 600;
    font-size: 11px;
    color: #0f172a;
    padding: 2px 4px;
    border-radius: 4px;
}
#estimating-tab .geom-row-header .measurement-name-input:focus {
    background: #f1f5f9;
    outline: 1px solid #93c5fd;
}

#estimating-tab .geom-row-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

#estimating-tab .geom-action-btn {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    padding: 1px 3px;
    border-radius: 4px;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.15s, background 0.15s;
}
#estimating-tab .geom-action-btn:hover {
    opacity: 1;
    background: #f1f5f9;
}
#estimating-tab .geom-action-btn--danger:hover {
    background: #fee2e2;
    color: #dc2626;
    opacity: 1;
}

/* Geometry row body */
#estimating-tab .geom-row-body {
    padding: 3px 7px 2px;
}

#estimating-tab .geom-values {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 5px;
    margin-bottom: 3px;
}

#estimating-tab .geom-value-cell {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

#estimating-tab .geom-value-label {
    font-size: 9px;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    letter-spacing: 0.3px;
}

#estimating-tab .geom-value-number {
    font-size: 12px;
    font-weight: 700;
    color: #1e293b;
}
#estimating-tab .geom-value-number small {
    font-size: 10px;
    font-weight: 500;
    color: #64748b;
}

#estimating-tab .geom-value-cell--total .geom-value-number {
    color: #059669;
}

#estimating-tab .geom-cost-input {
    width: 100%;
    max-width: 72px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 5px;
    background: #fff;
    color: #1e293b;
}
#estimating-tab .geom-cost-input:focus {
    border-color: #3b82f6;
    outline: none;
}

#estimating-tab .geom-pills {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
#estimating-tab .geom-pills .pill {
    font-size: 9px;
}
#estimating-tab .pill--waste { background: #fef3c7; color: #92400e; }
#estimating-tab .pill--locked { background: #fee2e2; color: #991b1b; }

#estimating-tab .geom-formula-row {
    margin-bottom: 2px;
}
#estimating-tab .geom-formula-row .measurement-formula-input {
    width: 100%;
    border: 1px dashed #e2e8f0;
    border-radius: 4px;
    font-size: 9px;
    padding: 2px 5px;
    color: #475569;
    background: #fafbfc;
}
#estimating-tab .geom-formula-row .measurement-formula-input:focus {
    border-style: solid;
    border-color: #93c5fd;
    background: #fff;
}

/* Geometry row footer */
#estimating-tab .geom-row-footer {
    display: flex;
    gap: 4px;
    padding: 3px 7px 5px;
    border-top: 1px solid #f1f5f9;
    flex-wrap: wrap;
}

#estimating-tab .geom-layer-select {
    font-size: 10px;
    padding: 3px 5px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    background: #fff;
    color: #334155;
    max-width: 100px;
}

#estimating-tab .geom-config-btn {
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    border-radius: 4px;
    font-size: 9px;
    padding: 2px 6px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s;
}
#estimating-tab .geom-config-btn:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1e40af;
}

@media (max-width: 1500px) {
    #estimating-tab .takeoff-item-row {
        flex-direction: column;
        align-items: stretch;
    }
    #estimating-tab .takeoff-item-row__actions {
        flex-wrap: wrap;
    }
}

/* Takeoff link + estimate preview workflow */
#estimating-tab .estimating-project-filter-legacy {
    display: none !important;
}

#estimating-tab .estimating-profile-gate {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    min-width: 0;
}

#estimating-tab .estimating-profile-gate__status {
    font-size: 11px;
    line-height: 1.2;
    padding: 6px 8px;
    border: 1px solid #dbe5ef;
    border-radius: 7px;
    background: #ffffff;
    color: #334155;
    min-width: 180px;
    max-width: min(34vw, 360px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#estimating-tab .estimating-profile-gate__status.is-ready {
    color: #14532d;
    background: #ecfdf5;
    border-color: #86efac;
}

#estimating-tab .estimating-profile-gate__status.is-loading {
    color: #1d4ed8;
    background: #eff6ff;
    border-color: #bfdbfe;
}

#estimating-tab .estimating-profile-gate__status.is-missing,
#estimating-tab .estimating-profile-gate__status.is-error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

#estimating-tab .estimating-link-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
    flex: 1 1 auto;
}

#estimating-tab .estimating-link-toolbar__status,
#estimating-tab .estimating-link-toolbar__source {
    font-size: 11px;
    line-height: 1.2;
    padding: 6px 8px;
    border: 1px solid #dbe5ef;
    border-radius: 7px;
    background: #ffffff;
    color: #334155;
    max-width: min(42vw, 420px);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#estimating-tab .estimating-link-toolbar__status {
    font-weight: 700;
    color: #1f3b63;
    background: #eff6ff;
    border-color: #bfdbfe;
}

#estimating-tab .takeoff-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

#estimating-tab .takeoff-workspace-header h3 {
    margin-right: auto;
}

#estimating-tab .estimating-takeoff-tools-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-bottom: 1px solid #dbe5ef;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    overflow-x: auto;
    flex-wrap: wrap;
}

#estimating-tab .estimating-takeoff-tools-row.is-hidden {
    display: none !important;
}

#estimating-tab .estimating-takeoff-tools-row .btn {
    flex: 0 0 auto !important;
    min-height: 32px;
    padding: 6px 10px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: auto !important;
    max-width: max-content;
}

#estimating-tab .estimating-takeoff-tools-row #export-excel-btn,
#estimating-tab .estimating-takeoff-tools-row #import-template-btn,
#estimating-tab .estimating-takeoff-tools-row #refresh-btn {
    min-width: 86px;
}

#estimating-tab .estimating-takeoff-tools-row__spacer {
    flex: 1 1 24px;
    min-width: 24px;
    max-width: 100%;
}

#estimating-tab .estimating-link-modal__panel {
    width: min(960px, calc(100vw - 32px));
}

#estimating-tab .takeoff-current-page-modal__panel {
    width: min(1320px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    padding: 12px;
    overflow: hidden;
}

#estimating-tab .takeoff-current-page-modal__intro {
    margin: 4px 0 0;
    font-size: 12px;
    color: #64748b;
    font-weight: 500;
}

#estimating-tab .takeoff-current-page-modal__body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 12px;
    min-height: min(72vh, 760px);
}

#estimating-tab .takeoff-current-page-modal__section {
    border: 1px solid #dbe5ef;
    border-radius: 10px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

#estimating-tab .takeoff-current-page-modal__section--measurements {
    background: #fff;
}

#estimating-tab .takeoff-current-page-modal__sidebar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

#estimating-tab .takeoff-current-page-modal__section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

#estimating-tab .takeoff-current-page-modal__section-header strong {
    display: block;
    font-size: 12px;
    font-weight: 800;
    color: #1f3b63;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

#estimating-tab .takeoff-current-page-modal__section-header span {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #64748b;
    line-height: 1.35;
}

#estimating-tab .takeoff-current-page-modal__measurements-list {
    flex: 1 1 auto;
    min-height: 0;
    padding: 12px;
    overflow-y: auto;
}

#estimating-tab .takeoff-current-page-modal #layers-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
}

#estimating-tab .takeoff-current-page-modal .takeoff-qa-panel {
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 0;
}

#estimating-tab .takeoff-current-page-modal .takeoff-qa-panel__header {
    background: transparent;
    border-bottom: 1px solid #e2e8f0;
}

#estimating-tab .takeoff-current-page-modal .takeoff-qa-panel__list {
    flex: 1 1 auto;
    max-height: none;
}

#estimating-tab .estimating-link-modal__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 10px;
}

#estimating-tab .estimating-link-modal__grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
}

#estimating-tab .estimating-link-modal__grid input,
#estimating-tab .estimating-link-modal__grid select {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 7px 8px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

#estimating-tab .estimating-link-modal__section {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#estimating-tab .estimating-link-modal__section h4 {
    margin: 0;
    font-size: 12px;
    color: #1f3b63;
    letter-spacing: 0.02em;
}

#estimating-tab .estimating-preview-modal__panel {
    width: min(1100px, calc(100vw - 32px));
}

#estimating-tab .estimating-preview-modal__summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    font-size: 12px;
    color: #334155;
    font-weight: 600;
}

#estimating-tab .estimating-preview-modal__table-wrap {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    overflow: auto;
    max-height: min(55vh, 520px);
    background: #fff;
}

#estimating-tab .takeoff-property-modal__panel {
    width: min(860px, calc(100vw - 32px));
}

#estimating-tab .takeoff-property-modal__grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(140px, 1fr));
    gap: 10px;
}

#estimating-tab .takeoff-property-modal__grid label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    color: #334155;
}

#estimating-tab .takeoff-property-modal__grid input,
#estimating-tab .takeoff-property-modal__grid select {
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    padding: 7px 8px;
    font-size: 12px;
    color: #0f172a;
    background: #fff;
}

#estimating-tab .takeoff-property-modal__section {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #f8fafc;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#estimating-tab .takeoff-property-modal__section[hidden] {
    display: none !important;
}

#estimating-tab .takeoff-property-modal__section h4 {
    margin: 0;
    font-size: 12px;
    color: #1f3b63;
    letter-spacing: 0.02em;
}

#estimating-tab .takeoff-property-modal__assembly-card {
    border: 1px solid #dbe5ef;
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#estimating-tab .takeoff-property-modal__assembly-card strong {
    font-size: 13px;
    color: #0f172a;
}

#estimating-tab .takeoff-property-modal__assembly-card span {
    font-size: 11px;
    color: #475569;
}

#estimating-tab .takeoff-property-modal__assembly-card p {
    margin: 0;
    font-size: 11px;
    line-height: 1.45;
    color: #64748b;
}

@media (max-width: 960px) {
    #estimating-tab .takeoff-current-page-modal__body {
        grid-template-columns: 1fr;
    }

    #estimating-tab .estimating-link-modal__grid {
        grid-template-columns: 1fr;
    }
    #estimating-tab .takeoff-property-modal__grid {
        grid-template-columns: 1fr;
    }
    #estimating-tab .estimating-link-toolbar__status,
    #estimating-tab .estimating-link-toolbar__source {
        max-width: 100%;
    }
    #estimating-tab .estimating-takeoff-tools-row__spacer {
        display: none;
    }

    #estimating-tab .estimating-profile-gate {
        width: 100%;
    }

    #estimating-tab .estimating-profile-gate__status {
        max-width: 100%;
        min-width: 0;
        flex: 1 1 220px;
    }
}
