/* calc-styles.css */

/* --- GLOBAL RESET (Add this to the very top) --- */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden; /* Prevents the horizontal drift */
    width: 100%;
    position: relative;
}

/* --- LAYOUT & CARDS --- */
.card { background: var(--surface, #ffffff); border: 1px solid var(--border, #e2e8f0); border-radius: 0.75rem; padding: 1.25rem; margin-bottom: 1.5rem; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
h2 { margin: 0 0 1.5rem 0; font-size: 1.1rem; font-weight: 700; color: var(--primary, #0f172a); border-bottom: 1px solid var(--border, #e2e8f0); padding-bottom: 1rem; display: flex; align-items: center; gap: 0.5rem; }
.card h3 { font-size: 0.85rem; font-weight: 700; color: var(--text-light, #64748b); text-transform: uppercase; letter-spacing: 0.05em; margin: 1.2rem 0 0.8rem 0; }
.card h3:first-of-type { margin-top: 0.5rem; }

/* Container */
.container {
    max-width: 100%;       /* Allows the container to stretch fully */
    margin: 0;             /* Removes centering, pulling it left to the sidebar */
    padding-left: 0rem;    
    padding-right: 0rem;   
    padding-bottom: 3rem;
}

body { 
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; 
            background: var(--bg); 
            color: var(--text); 
            margin: 0; 
            height: 100vh; 
            display: flex; 
            overflow: hidden; 
        }

/* Grid Layouts */
.grid-layout { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-responsive { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
.col-span-2 { grid-column: span 2; }

.intro-box { background: #eff6ff; border: 1px solid #dbeafe; padding: 1.25rem; border-radius: 0.75rem; margin-bottom: 1.5rem; }
.intro-box h3 { margin-top: 0; color: #1e40af; font-size: 1rem; }
.intro-box p { font-size: 0.9rem; line-height: 1.6; color: #1e3a8a; margin-bottom: 0.5rem; }
.intro-box ul { margin: 0; padding-left: 1.5rem; font-size: 0.9rem; color: #1e3a8a; }
.intro-box li { margin-bottom: 0.25rem; }

/* --- TABS --- */
.tab-nav { display: flex; gap: 1rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border, #e2e8f0); }
.tab-btn { background: none; border: none; padding: 1rem; font-size: 1rem; font-weight: 600; color: var(--text-light, #64748b); cursor: pointer; border-bottom: 3px solid transparent; transition: 0.2s; }
.tab-btn:hover { color: var(--text, #334155); }
.tab-btn.active { color: var(--accent, #3b82f6); border-bottom-color: var(--accent, #3b82f6); }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.tabs { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; border-bottom: 1px solid var(--border); overflow-x: auto; padding-bottom: 1px; }
.tabs .tab-btn { padding: 0.75rem 1.5rem; background: none; border: none; font-weight: 600; color: var(--text-light); cursor: pointer; border-bottom: 3px solid transparent; transition: all 0.2s; white-space: nowrap; font-size: 0.95rem; }
.tabs .tab-btn:hover { color: var(--primary); background: #f1f5f9; border-radius: 6px 6px 0 0; }
.tabs .tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); background: var(--surface); border-radius: 6px 6px 0 0; border: 1px solid var(--border); border-bottom: none; margin-bottom: -1px; }

/* --- INPUTS, GRIDS & CHECKBOXES --- */
.subsection { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); font-weight: 700; margin-top: 1.5rem; margin-bottom: 0.75rem; border-bottom: 1px solid #e2e8f0; padding-bottom: 0.25rem; }

/* Input Grids */
.input-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.5rem; align-items: end; margin-bottom: 1.5rem; }
.input-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; gap: 6px; }
.label-row label { font-size: 0.85rem; font-weight: 600; color: var(--text); }

/* input-group / input-wrapper */
.input-group, .input-wrapper { margin-bottom: 1rem; position: relative; } 
.input-group label, .input-wrapper label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-light, #64748b); text-transform: uppercase; letter-spacing: 0.05em; margin:0 0 0.4rem 0; }
.input-group input, .input-group select, .input-wrapper input, .input-wrapper select, input[type="number"], input[type="text"], select { width: 100%; padding: 0.75rem; border: 1px solid var(--border, #e2e8f0); border-radius: 0.4rem; font-family: inherit; font-size: 0.95rem; color: var(--text, #334155); transition: 0.2s; background: var(--surface); box-sizing: border-box; }
.input-group input:focus, .input-group select:focus, .input-wrapper input:focus, .input-wrapper select:focus, input:focus, select:focus { border-color: var(--accent, #3b82f6); outline: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2); }
.input-group small, .input-wrapper small { display: block; margin-top: 0.3rem; color: var(--text-light); font-size: 0.75rem; }

/* In-field absolute positioning units */
.unit { position: absolute; right: 10px; top: 31px; color: var(--text-light); font-size: 0.85rem; pointer-events: none; }
.unit-label { font-size:0.75rem; color:#94a3b8; margin-top:0.4rem; display:block; }

/* Options & Checkboxes */
.options-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; cursor: pointer; background: #f8fafc; padding: 0.75rem; border-radius: 6px; border: 1px solid var(--border); transition: 0.2s; position: relative; }
.checkbox-label:hover { border-color: var(--accent); background: var(--accent); }
.checkbox-label input { width: auto; transform: scale(1.2); }
.checkbox-info { position: absolute; top: 5px; right: 5px; color: var(--accent); font-size: 14px; opacity: 0.6; }
.checkbox-label:hover .checkbox-info { opacity: 1; }

/* Toggle Rows (For inline Boolean states) */
.toggle-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem; background: #f1f5f9; border-radius: 0.5rem; margin-top: 0.5rem; cursor: pointer; border: 1px solid transparent; transition: all 0.2s; position: relative; }
.toggle-row:hover { background: #e2e8f0; }
.toggle-row:has(input:checked) { background: #eff6ff; border-color: #bfdbfe; }
.toggle-row label { text-transform: none; font-weight: 600; font-size: 0.85rem; color: var(--text); letter-spacing: normal; }
.checkbox-custom { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }
.toggle-info { position: absolute; right: 10px; top: 10px; }

/* Spec Tables & Info Triggers */
.spec-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; margin-top: 0.5rem; background: #f8fafc; display: none; border-radius: 4px; overflow: hidden; }
.spec-table th, .spec-table td { padding: 6px 10px; border: 1px solid #e2e8f0; text-align: left; }
.spec-table th { background: #e2e8f0; color: #475569; font-weight: 600; }
.info-btn { font-size: 0.75rem; color: var(--accent); cursor: pointer; text-decoration: none; margin-left: 5px; font-weight: 600; }
.info-btn:hover { text-decoration: underline; }

/* --- ENGINEERING DIAGRAMS --- */
.diagram-container { display: flex; gap: 1rem; margin-bottom: 1.5rem; overflow-x: auto; padding-bottom: 0.5rem; scrollbar-width: thin; }
.diagram-box { flex: 1; min-width: 250px; background: var(--surface); border: 1px solid var(--border); border-radius: 0.5rem; padding: 1rem; text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.diagram-scroll { flex: 0 0 320px; } /* Modifier for forcing horizontal scroll */
.diagram-caption { font-size: 0.75rem; color: #64748b; margin-top: 0.5rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.diagram-box svg { max-height: 140px; width: 100%; max-width: 300px; height: auto; }

/* --- VISUALIZERS / CANVAS --- */
.canvas-box { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 0.5rem; min-height: 200px; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; margin-bottom: 1rem; }
.canvas-box canvas { max-width: 100%; height: auto; }
.canvas-wrapper { position: relative; width: 100%; height: 500px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px; }
.canvas-wrapper canvas { display: block; width: 100%; height: 100%; }

/* Chart.js Container */
.chart-container { position: relative; height: 250px; width: 100%; margin: 1rem 0; border: 1px solid var(--border, #e2e8f0); border-radius: 0.5rem; background: var(--surface); padding: 10px; box-sizing: border-box; }
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* --- UNIFIED RESULTS STYLING --- */
.result-box { background: var(--surface); border: 1px solid #e2e8f0; padding: 1.5rem; border-radius: 0.5rem; margin-top: 1.5rem; }
.result-box.success { background: var(--surface); border-color: #bbf7d0; } 
.res-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; margin-bottom: 20px; }
.res-box { background: var(--surface); padding: 10px; border-radius: 6px; text-align: center; border: 1px solid var(--border); }
.res-val { font-weight: bold; font-size: 1.1rem; color: var(--primary); display: block; }
.res-lbl { font-size: 0.75rem; color: #64748b; }
.pass { color: var(--success); } .fail { color: var(--danger); }

.check-container { background: #f8fafc; padding: 15px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 20px; }
.check-item { margin-bottom: 12px; transition: background 0.1s; border: 1px solid transparent; border-radius: 6px; padding: 0.25rem;}
.check-item:last-child { margin-bottom: 0; }
.check-item:hover { background: #f1f5f9; border-color: var(--border); }
.check-header { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; font-weight: 600; color: var(--text); }

.progress-track { width: 100%; height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--success); transition: width 0.5s ease; }
.progress-fill.warn { background: var(--warning); }
.progress-fill.fail { background: var(--danger); }

.info-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }

/* Large Number Displays */
.ratio-display { font-size: 3.5rem; font-weight: 800; line-height: 1; margin: 0.5rem 0; text-align: center; cursor: pointer; transition: opacity 0.2s; }
.ratio-display:hover { opacity: 0.8; }
.ratio-label { font-size: 0.8rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 1px; text-align: center; }

.u-val-display { font-size: 3.5rem; font-weight: 800; line-height: 1; margin: 1.5rem 0; text-align: center; cursor: pointer; transition: opacity 0.2s;  }
.u-val-display:hover { opacity: 0.8; }
.u-unit { font-size: 1rem; font-weight: 400; opacity: 0.7; vertical-align: super; }

.carbon-display { text-align: center; padding: 1.5rem; background: #f0fdf4; border-radius: 0.5rem; border: 1px solid #bbf7d0; margin-bottom: 1rem; }
.carbon-val { display: block; font-size: 2.5rem; font-weight: 800; color: #15803d; line-height: 1.1; margin: 0.5rem 0; }

/* Status Indicators & Checking Items */
.check-item { margin-bottom: 0.5rem; padding: 0.5rem; border-radius: 6px; cursor: pointer; transition: background 0.1s; border: 1px solid transparent; }
.check-item:hover { background: #f8fafc; border-color: var(--border); }

.status { padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; margin-left: 8px; display: inline-block; min-width: 40px; text-align: center; }
.status.pass { background: #dcfce7; color: #15803d; }
.status.fail { background: #fee2e2; color: #b91c1c; }

/* --- Styles for Detailed Table --- */
        .check-table-wrapper {
            margin-top: 0.5rem;
            overflow-x: auto;
            border: 1px solid var(--border);
            border-radius: 8px;
            margin-bottom: 2rem;
        }
        .check-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 0.85rem;
            color: var(--text);
        }
        .check-table th {
            background: var(--bg-secondary);
            padding: 10px 12px;
            text-align: left;
            font-weight: 600;
            border-bottom: 2px solid var(--border);
            white-space: nowrap;
        }
        .check-table td {
            padding: 10px 12px;
            border-bottom: 1px solid var(--border);
        }
        .check-table tr:last-child td { border-bottom: none; }

.status-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 0.75rem;
            font-weight: 700;
            text-transform: uppercase;
        }

.status-bar { padding: 0.5rem; border-radius: 0.25rem; text-align: center; font-weight: 700; margin-bottom: 1.5rem; text-transform: uppercase; letter-spacing: 1px; font-size: 0.85rem; }
.status-pass { background: #22c55e; color: white; }
.status-fail { background: #ef4444; color: white; }
.status-warn { background: rgba(234, 179, 8, 0.15); color: #854d0e; }

[data-theme="dark"] .status-pass { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
[data-theme="dark"] .status-fail { background: rgba(239, 68, 68, 0.2); color: #f87171; }


/* Result Badges */
.badge { padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; }
.badge.pass { background: #dcfce7; color: #15803d; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.fail { background: #fee2e2; color: #b91c1c; }

/* Result Rows */
.result-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; font-size: 0.95rem; border-bottom: 1px dashed #cbd5e1; padding-bottom: 0.75rem; cursor: pointer; border-radius: 4px; padding-left: 5px; padding-right: 5px; transition: background 0.2s; }
.result-row:hover { background: rgba(59, 130, 246, 0.05); }
.result-row:last-of-type { margin-bottom: 0; padding-top: 0.75rem; padding-bottom: 0; border-bottom: none; border-top: 2px solid #cbd5e1; font-weight: 700; color: var(--primary, #0f172a); font-size: 1.1rem; }

.breakdown-row { display: flex; justify-content: space-between; font-size: 0.9rem; margin-bottom: 0.5rem; opacity: 0.9; cursor: pointer; padding: 4px; border-radius: 4px; }
.breakdown-row:hover { background: rgba(255,255,255,0.1); }
.total-row { border-top: 1px solid rgba(255,255,255,0.2); margin-top: 0.5rem; padding-top: 0.5rem; font-weight: 700; font-size: 1rem; }

.result-label { background: var(--surface); font-size: 0.9rem; opacity: 0.8; }
.result-val { font-weight: 700; font-size: 1.1rem; color: var(--primary); }
.res-box .result-val { color: var(--primary); } /* Ensure white text if inside dark res-box */
.big-result { font-size: 1.4rem; color: var(--accent); } 
.equation { font-family: inherit; font-weight: 500; font-size: 1.1rem; color: var(--primary, #0f172a); }
.formula { display: block; text-align: right; font-size: 0.75rem; color: var(--text-light); margin-top: 4px; font-family: monospace; opacity: 0.8; }

/* Icons & Highlights */
.res-icon { opacity: 0.5; font-size: 12px; margin-left: 5px; transition: 0.2s; }
.result-row:hover .res-icon { opacity: 1; }
.result-highlight { background: var(--surface); margin-top: 1.5rem; padding: 1rem; border-radius: 6px; border: 1px solid #bfdbfe; display: flex; justify-content: space-between; align-items: center; }
.result-highlight span:first-child { color: var(--primary, #0f172a); font-weight: 600; font-size: 0.9rem; }
.result-highlight span:last-child { color: var(--accent, #3b82f6); font-size: 1.2rem; font-weight: 800; }

/* Breakdown Tables (For deep calculation dives) */
.breakdown-card { background: var(--surface); border: 1px solid var(--border); border-radius: 0.75rem; padding: 1.5rem; }
.breakdown-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-top: 1rem; }
.breakdown-table th { text-align: left; color: #64748b; font-weight: 600; padding: 0.5rem 0; border-bottom: 1px solid #e2e8f0; }
.breakdown-table td { padding: 0.5rem 0; border-bottom: 1px solid #f1f5f9; color: var(--text); }
.breakdown-table tr { cursor: pointer; transition: background 0.1s; }
.breakdown-table tr:hover { background: #f8fafc; }
.coeff-val { font-family: monospace; font-weight: 700; color: var(--accent); background: #eff6ff; padding: 2px 6px; border-radius: 4px; }

/* --- TAGS (Load Combinations) --- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 700; }
.tag-g { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.tag-q { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.tag-a { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.tag-equ { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.tag-str { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.tag-geo { background: #eff6ff; color: #1e3a8a; border: 1px solid #bfdbfe; }
.tag-sls { background: #f8fafc; color: #475569; border: 1px solid #e2e8f0; }

/* --- BUTTONS & ACTION BAR --- */
.action-bar { display: flex; gap: 0.5rem; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid rgba(255,255,255,0.2); flex-wrap: wrap; }
.button-row { display: flex; gap: 10px; margin-top: 1.5rem; }
.btn-action { flex: 1; min-width: 120px; padding: 0.75rem; border: none; border-radius: 0.4rem; font-weight: 600; font-size: 0.9rem; cursor: pointer; color: white; display: flex; align-items: center; justify-content: center; gap: 0.4rem; transition: opacity 0.2s; }
.btn-excel { background: #16a34a; }
.btn-pdf { background: #e11d48; }
.btn-save { background: #7c3aed; }
.btn-cloud { background: var(--primary); }
.btn-calc { background: var(--primary, #0f172a); color: white; border: none; padding: 0.85rem 2rem; border-radius: 0.4rem; cursor: pointer; font-weight: 600; font-size: 1rem; width: 100%; transition: opacity 0.2s; }
.btn-outline { width: 100%; padding: 0.875rem; background: var(--surface); color: var(--primary); border: 1px solid var(--border); border-radius: 0.5rem; font-weight: 600; cursor: pointer; margin-top: 10px; transition: 0.2s; font-size: 1rem; }
.btn-add { background: var(--accent); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: 0.4rem; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: opacity 0.2s; white-space: nowrap; }
.btn-remove { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; padding: 0.4rem 0.8rem; border-radius: 0.4rem; cursor: pointer; font-size: 0.8rem; transition: 0.2s; }
.btn-action:hover, .btn-calc:hover, .btn-add:hover { opacity: 0.9; }
.btn-outline:hover { background: #f1f5f9; }
.btn-remove:hover { background: #fecaca; }
.btn-dashed { background: var(--surface); border: 1px dashed var(--accent); color: var(--accent); width: 100%; padding: 0.75rem; border-radius: 0.5rem; cursor: pointer; font-weight: 600; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 0.5rem; font-size: 0.95rem; }
.btn-dashed:hover { background: #eff6ff; }
.btn-del { color: var(--danger, #ef4444); background: none; border: none; cursor: pointer; font-size: 1.4rem; padding: 0 0.5rem; opacity: 0.7; }
.btn-del:hover { opacity: 1; }

/* --- REFERENCE TABLES --- */
.ref-table-container { overflow-x: auto; border-radius: 0.5rem; border: 1px solid var(--border, #e2e8f0); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 1rem; }
th { text-align: left; background: #f8fafc; padding: 0.75rem; font-weight: 600; border-bottom: 2px solid #e2e8f0; color: var(--text-light); font-size: 0.8rem; text-transform: uppercase; }
td { padding: 0.75rem; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
#resultsTable tr:hover { background-color: #f8fafc; cursor: pointer; }

.equation-cell { font-family: inherit; font-size: 0.9rem; color: #334155; line-height: 1.6; }
.factor { color: #64748b; font-weight: 500; }
.load-ref { color: var(--primary); font-weight: 600; }
.val { font-weight: 700; color: var(--primary); font-size: 0.95rem; }
.clause-ref { font-size: 0.7rem; color: #94a3b8; font-style: italic; display: block; margin-top: 2px; }

/* --- MODALS & TOAST --- */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal { background: var(--surface); padding: 2rem; border-radius: 1rem; width: 90%; max-width: 450px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); position: relative; }
.modal h3 { margin-top: 0; color: var(--primary, #0f172a); margin-bottom: 1.5rem; }
.modal label { display:block; font-size:0.8rem; font-weight:600; color:var(--text-light); margin-bottom:0.5rem; }
.modal input[type="text"] { width:100%; padding:0.6rem; border:1px solid var(--border); border-radius:0.4rem; margin-bottom: 1rem; }
.btn-close-modal { position: absolute; top: 1rem; right: 1rem; border: none; background: none; font-size: 1.5rem; cursor: pointer; color: var(--text-light); width: auto; margin:0; padding:0; }
.modal-btn-group { margin-top: 1.5rem; display: flex; gap: 1rem; justify-content: flex-end; }
.btn-cancel { background: transparent; border: 1px solid var(--border, #e2e8f0); color: var(--text, #334155); padding: 0.5rem 1rem; border-radius: 0.4rem; cursor: pointer; font-weight: 600; width: auto; margin-top: 0; }
.btn-confirm { background: var(--accent, #3b82f6); border: none; color: white; padding: 0.75rem 1.25rem; border-radius: 0.4rem; cursor: pointer; font-weight: 600; width: auto; margin-top: 0; }

.toast { visibility: hidden; min-width: 250px; margin-left: -125px; background-color: #1e293b; color: #fff; text-align: center; border-radius: 8px; padding: 16px; position: fixed; z-index: 2000; left: 50%; bottom: 30px; font-size: 14px; opacity: 0; transition: opacity 0.3s, bottom 0.3s; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.toast.show { visibility: visible; opacity: 1; bottom: 50px; }

/* --- INFO / CLAUSE TRIGGERS & DISCLAIMER --- */
.info-trigger { background: var(--bg, #f8fafc); color: var(--accent, #3b82f6); border: 1px solid var(--border, #e2e8f0); border-radius: 50%; width: 18px; height: 18px; font-size: 11px; display: flex; align-items: center; justify-content: center; cursor: pointer; font-weight: 700; flex-shrink: 0; transition: 0.2s; }
.info-trigger:hover { background: var(--accent, #3b82f6); color: white; border-color: var(--accent, #3b82f6); }
.clause-header { border-bottom: 1px solid var(--border, #e2e8f0); padding-bottom: 1rem; margin-bottom: 1rem; }
.clause-badge { display: inline-block; background: #eff6ff; color: #1e40af; padding: 4px 8px; border-radius: 4px; font-family: monospace; font-size: 0.85rem; font-weight: 700; margin-bottom: 0.5rem; border: 1px solid #bfdbfe; }
.clause-title { margin: 0; color: var(--primary, #0f172a); font-size: 1.25rem; font-weight: 700; }
.clause-content { font-size: 0.95rem; color: var(--text, #334155); line-height: 1.6; }
.formula-box { background: #f8fafc; padding: 1rem; border-left: 3px solid var(--accent, #3b82f6); font-family: 'Courier New', monospace; margin: 1rem 0; font-weight: 600; color: var(--primary, #0f172a); word-break: break-all; }

.disclaimer-box { margin-top: 3rem; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border, #e2e8f0); border-radius: 0.75rem; font-size: 0.8rem; line-height: 1.5; color: #64748b; width: 100%; box-sizing: border-box;}
.disclaimer-header { display: flex; align-items: center; gap: 0.6rem; color: var(--primary, #0f172a); font-weight: 800; margin-bottom: 1rem; text-transform: uppercase; font-size: 0.85rem; }
.disclaimer-box p { font-size: 0.8rem; color: var(--text-light, #64748b); line-height: 1.5; margin: 0; }

/* --- DYNAMIC TABLES (e.g., U-Value) --- */
.table-responsive { overflow-x: auto; margin-bottom: 1rem; -webkit-overflow-scrolling: touch; }
.layer-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 450px; }
.layer-table th { text-align: left; padding: 0.75rem; background: #f8fafc; border-bottom: 2px solid var(--border); color: #64748b; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.layer-table td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.boq-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 1rem; min-width: 500px; }
.boq-table th { text-align: left; background: #f8fafc; padding: 0.75rem; border-bottom: 2px solid #e2e8f0; color: var(--text-light); font-weight: 600; text-transform: uppercase; font-size: 0.8rem; }
.boq-table td { padding: 0.75rem; border-bottom: 1px solid #f1f5f9; color: var(--text); }
.boq-total { font-weight: 700; font-size: 1.1rem; color: var(--primary); border-top: 2px solid var(--primary); }

.detail-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-top: 1rem; }
.detail-table th { text-align: left; border-bottom: 2px solid #e2e8f0; padding: 10px; background: #f8fafc; color: var(--text-light); font-weight: 600; }
.detail-table td { border-bottom: 1px solid #f1f5f9; padding: 10px; }

/* --- SCROLLING TABS (Material Estimator specific) --- */
.scroll-tabs { 
    display: flex; gap: 0.5rem; margin-bottom: 1.5rem; overflow-x: auto; 
    padding-bottom: 0.5rem; scroll-behavior: smooth; max-width: 100%; 
    scrollbar-width: none; -ms-overflow-style: none;
}
.scroll-tabs::-webkit-scrollbar { display: none; }
.scroll-tabs .tab-btn { 
    /* ADD THIS LINE TO FIX THE ISSUE */
    width: auto;
    padding: 0.75rem 1rem; background: var(--bg); border: 1px solid var(--border); 
    border-radius: 0.5rem; cursor: pointer; font-weight: 600; color: var(--text-light); 
    transition: 0.2s; white-space: nowrap; font-size: 0.9rem; flex-shrink: 0; 
}
.scroll-tabs .tab-btn.active { background: var(--accent); color: white; border-color: var(--accent); }

/* --- VISUALIZER SVG BOX --- */
.visualizer-box { 
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 0.5rem; 
    height: 260px; width: 100%; display: flex; align-items: center; justify-content: center; 
    overflow: hidden; position: relative; margin-bottom: 1.5rem; 
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); transition: height 0.3s ease; 
}
.visualizer-title { 
    position: absolute; top: 10px; left: 10px; font-size: 0.8rem; font-weight: 600; 
    color: #64748b; background: rgba(255,255,255,0.8); padding: 2px 8px; border-radius: 4px; z-index: 10; 
}
.visualizer-svg { width: 100%; height: 100%; }

/* --- COST BREAKDOWN BAR --- */
.cost-bar-container { width: 100%; height: 12px; background: #e2e8f0; border-radius: 6px; overflow: hidden; display: flex; margin-top: 1rem; margin-bottom: 0.5rem; }
.cost-segment { height: 100%; transition: width 0.4s ease; }
.cost-legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 0.75rem; color: var(--text-light); justify-content: center; }
.legend-item { display: flex; align-items: center; gap: 4px; }
.legend-color { width: 10px; height: 10px; border-radius: 2px; }

/* --- LOGISTICS WIDGET --- */
.logistics-box { background: #f0fdf4; border: 1px dashed #22c55e; padding: 1.25rem; border-radius: 0.5rem; margin-top: 1.5rem; max-width: 100%; }
.logistics-box h4 { margin: 0 0 1rem 0; color: #166534; font-size: 0.95rem; text-transform: uppercase; border-bottom: 1px solid #bbf7d0; padding-bottom: 0.5rem; }
.log-item { display: flex; justify-content: space-between; font-size: 0.95rem; margin-bottom: 0.5rem; font-weight: 600; color: #15803d; }
.log-material-wrap { margin-bottom: 0.75rem; padding-bottom: 0.75rem; border-bottom: 1px dashed #bbf7d0; }
.log-material-wrap:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* --- STEEL BEAM CALC SPECIFIC (IMPORTED FROM HTML) --- */
.search-container { position: relative; margin-bottom: 0.5rem; width: 100%; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.search-input { padding-left: 2.5rem !important; }

/* Standardizes general calculator buttons */
button { width: 100%; padding: 0.8rem; background: var(--primary); color: white; border: none; border-radius: 0.5rem; font-weight: 600; cursor: pointer; margin-top: 0.5rem; transition: 0.2s; font-size: 0.95rem; }
button:hover { opacity: 0.9; }


/* =========================================
   ADD TO BOTTOM OF calc-styles.css
   Section Properties Specific Styles
   ========================================= */

/* --- PARTS TABLE SPECIFICS --- */
.parts-table-wrapper { 
    width: 100%; 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    margin-bottom: 1rem; 
    border: 1px solid var(--border); 
    border-radius: 0.4rem; 
}

/* Specific input sizing for the parts table */
.parts-table-wrapper td select { min-width: 85px; padding: 0.4rem; font-size: 0.8rem; }
.parts-table-wrapper td input { padding: 0.4rem; font-size: 0.85rem; min-width: 70px; }
.parts-table-wrapper tr:hover td { background-color: #f1f5f9; cursor: crosshair; }

/* Void Row Styling (Red Highlight) */
.row-void td { background-color: #fef2f2 !important; }
.row-void:hover td { background-color: #fee2e2 !important; }
.row-void input, .row-void select { background-color: #fff; border-color: #fca5a5; }

/* Add Part Button */
.btn-add-part { 
    width: 100%; 
    padding: 0.75rem; 
    background: #eff6ff; 
    border: 1px dashed #3b82f6; 
    color: #1e40af; 
    border-radius: 0.4rem; 
    cursor: pointer; 
    font-weight: 600; 
    transition: 0.2s; 
    margin-top: 0.5rem; 
}
.btn-add-part:hover { background: #dbeafe; }

/* --- DIAGRAM OVERRIDES --- */
/* Force the specific height for this tool's canvas */
.diagram-box-section { 
    height: 550px !important; 
    position: relative; 
    width: 100%; 
    max-width: 100%; 
    min-width: 0; /* <--- ADD THIS LINE */
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}
 
/* --- RESPONSIVE / MOBILE OVERRIDES --- */
@media (max-width: 850px) {
    /* --- 1. THE CULPRIT: Force everything to obey screen width & Unlock Height --- */
    html, body {
        width: 100vw;
        max-width: 100vw;
        overflow-x: hidden;
        overflow-y: auto;  /* <-- ADDED: Enables vertical scrolling */
        height: auto;      /* <-- ADDED: Removes the rigid 100vh lock */
        min-height: 100vh; /* <-- ADDED: Ensures background covers at least the screen */
    }

    .app-wrapper { 
        flex-direction: column; 
        height: auto; 
        min-height: 100vh; /* <-- ADDED */
        width: 100vw; 
        max-width: 100vw;
        overflow-x: hidden; 
    }

    /* --- 2. Fix the padding so nothing bleeds off screen --- */
    .main-content { 
        padding: 1rem; 
        padding-top: calc(var(--nav-height-mobile, 60px) + 1rem); 
        padding-bottom: calc(var(--nav-height-mobile, 60px) + 2rem); 
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: visible; /* <-- ADDED: Lets the body handle the scrolling instead of trapping it */
    }
    
    .container { width: 100%; max-width: 100%; box-sizing: border-box; }
    .card { padding: 1.2rem; margin-bottom: 1rem; width: 100%; box-sizing: border-box; overflow-x: hidden;}

    /* --- 3. Grid Collapses --- */
    .grid-layout, .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 1rem; }
    .grid-responsive { grid-template-columns: 1fr; }
    .col-span-2 { grid-column: span 1; }
    
    .mobile-reverse > div:first-child { order: 2; }
    .mobile-reverse > div:last-child { order: 1; }

    /* --- 4. Results & Info Grids --- */
    .res-summary { grid-template-columns: 1fr 1fr; gap: 0.5rem; }
    .info-grid { grid-template-columns: 1fr; gap: 0.5rem; } 
    .res-val { font-size: 1.1rem; }
    
    /* This ensures the table scrolls horizontally, rather than breaking the page */
    .check-table-wrapper { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .check-table { min-width: 400px; } /* Ensures table content doesn't squish */

    /* --- 5. Inputs & Form Elements --- */
    .input-grid { grid-template-columns: 1fr; gap: 1rem; }
    .input-row { grid-template-columns: 1fr; }
    select, input { font-size: 16px; /* Prevent iOS Zoom */ }

    /* --- 6. Nav & Sidebar Fixes --- */
    .sidebar { 
        width: 100vw; height: var(--nav-height-mobile, 60px); padding: 0 1rem; flex-direction: row; 
        justify-content: space-between; align-items: center; position: fixed; 
        top: 0; left: 0; z-index: 1000; border-bottom: 1px solid rgba(255,255,255,0.1); 
        box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    }
    .brand { margin-bottom: 0; font-size: 1rem; }
    .brand svg { width: 18px; height: 18px; }
    
    .nav-links { 
        position: fixed; bottom: 0; left: 0; width: 100vw; height: var(--nav-height-mobile, 60px);
        background: var(--primary, #0f172a); flex-direction: row; justify-content: space-around; 
        align-items: center; padding: 0 5px; z-index: 1000; border-top: 1px solid rgba(255,255,255,0.1);
    }
    .nav-item { padding: 0.5rem; flex-direction: column; justify-content: center; }
    .nav-item span { display: none; } 
    .nav-item svg { width: 22px; height: 22px; margin: 0; opacity: 1; }
    .nav-item[href="Contact.html"], .nav-item[href="Settings.html"], .nav-item[href="Pricing.html"] { display: none; }
    
    .user-profile { display: flex !important; margin-top: 0; padding-top: 0; border-top: none; flex-direction: row; align-items: center; width: auto; }
    .user-profile .auth-card > div:last-child { display: none; }
    .btn-signout { width: 32px; height: 32px; margin-top: 0; padding: 0; margin-left: 10px; }
    .btn-signout span { display: none; } 
    .btn-signout svg { display: block; width: 20px; height: 20px; }

/* --- 7. Diagram & Canvas Fixes --- */
    .canvas-wrapper { 
        height: 480px !important;  /* <-- INCREASED FROM 280px */
        margin-bottom: 10px; 
        max-width: 100%; 
        overflow: hidden;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    /* Increased height slightly for better visibility and fixed canvas stretching */
    .canvas-medium { height: 260px !important; }
    canvas { max-width: 100% !important; height: 100% !important; display: block; }
    
    .diagram-container { padding-bottom: 1rem; }
    .diagram-scroll { flex: 0 0 280px; }
    
    div > .card[style*="position: sticky"] { 
        position: relative !important; 
        top: 0 !important; 
        width: 100% !important;
        z-index: 1;
        align-items: center;
        box-sizing: border-box;
    }
}

@media (max-width: 500px) {
    .grid-4 { grid-template-columns: 1fr; }
    .res-summary { grid-template-columns: 1fr 1fr; } 
}

/* =========================================
   MOBILE FIX: PREVENT CARDS & DIAGRAMS FROM CROPPING
   ========================================= */

/* 1. Force grid items to shrink and obey the screen width */
.grid-layout > div,
.grid-2 > div,
.grid-3 > div,
.grid-4 > div {
    min-width: 0;
}

/* 2. Make the custom section canvas scale proportionally without getting cropped */
.diagram-box-section canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    height: auto !important; /* Overrides the mobile height: 100% rule */
    width: auto !important;
    object-fit: contain;
    display: block;
}

/* 3. Ensure the parts table respects the bounds of its shrinking card */
.parts-table-wrapper {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
