/**
 * QPS Cost Review Portal — Estimating Module Styles
 * Rate Library & First-Principles Build-Up Estimator
 */

/* ─── Rate Library Tab ───────────────────────────────────────────────────── */
.rate-library-toolbar { display:flex; gap:.75rem; align-items:center; flex-wrap:wrap; margin-bottom:1.25rem; }
.rate-library-toolbar .rl-search { flex:1 1 260px; min-width:180px; padding:.55rem 1rem .55rem 2.4rem; border-radius:8px; border:1px solid var(--border-color,#e2e8f0); background:var(--input-bg,#fff); color:var(--text-primary,#1e293b); font-family:Inter,sans-serif; font-size:.875rem; }
.rate-library-toolbar select { padding:.55rem .85rem; border-radius:8px; border:1px solid var(--border-color,#e2e8f0); background:var(--input-bg,#fff); color:var(--text-primary,#1e293b); font-family:Inter,sans-serif; font-size:.85rem; min-width:150px; }
.rate-library-toolbar .rl-add-btn { margin-left:auto; white-space:nowrap; }
.rate-library-stats { display:flex; gap:1rem; flex-wrap:wrap; margin-bottom:1rem; }
.rl-stat-chip { display:inline-flex; align-items:center; gap:.4rem; padding:.3rem .8rem; border-radius:20px; font-size:.78rem; font-weight:600; font-family:Inter,sans-serif; background:rgba(59,191,200,.12); color:var(--teal,#3bbfc8); border:1px solid rgba(59,191,200,.25); }
.rate-library-table-wrap { overflow-x:auto; border-radius:12px; border:1px solid var(--border-color,#e2e8f0); }
.rate-library-table { width:100%; border-collapse:collapse; font-family:Inter,sans-serif; font-size:.84rem; }
.rate-library-table thead th { padding:.75rem 1rem; text-align:left; font-size:.78rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted,#64748b); background:var(--table-head-bg,#f8fafc); border-bottom:1px solid var(--border-color,#e2e8f0); white-space:nowrap; }
.rate-library-table tbody tr { border-bottom:1px solid var(--border-color-subtle,#f1f5f9); transition:background .15s; }
.rate-library-table tbody tr:hover { background:rgba(59,191,200,.05); }
.rate-library-table tbody td { padding:.7rem 1rem; color:var(--text-primary,#1e293b); vertical-align:middle; }
.rl-code { font-family:'Courier New',monospace; font-size:.78rem; color:var(--text-muted,#64748b); white-space:nowrap; }
.rl-category-badge { display:inline-flex; align-items:center; gap:.3rem; padding:.2rem .6rem; border-radius:12px; font-size:.72rem; font-weight:600; white-space:nowrap; }
.rl-category-badge.labour   { background:rgba(59,130,246,.12); color:#3b82f6; }
.rl-category-badge.materials{ background:rgba(16,185,129,.12); color:#10b981; }
.rl-category-badge.plant    { background:rgba(245,158,11,.12); color:#f59e0b; }
.rl-category-badge.package  { background:rgba(139,92,246,.12); color:#8b5cf6; }
.rl-rate-cell { font-family:'Barlow',sans-serif; font-weight:700; font-size:.92rem; color:var(--teal,#3bbfc8); white-space:nowrap; }
.rl-source-tag { font-size:.7rem; color:var(--text-muted,#94a3b8); font-style:italic; }
.rl-action-btns { display:flex; gap:.4rem; }
.btn-rl-pull { padding:.3rem .65rem; font-size:.75rem; border-radius:6px; border:1px solid var(--teal,#3bbfc8); background:rgba(59,191,200,.08); color:var(--teal,#3bbfc8); cursor:pointer; font-weight:600; transition:all .15s; white-space:nowrap; }
.btn-rl-pull:hover { background:var(--teal,#3bbfc8); color:#fff; }
.btn-rl-edit { padding:.3rem .6rem; font-size:.75rem; border-radius:6px; border:1px solid var(--border-color,#e2e8f0); background:transparent; color:var(--text-muted,#64748b); cursor:pointer; transition:all .15s; }
.btn-rl-edit:hover { background:var(--border-color,#e2e8f0); color:var(--text-primary,#1e293b); }
.btn-rl-delete { padding:.3rem .6rem; font-size:.75rem; border-radius:6px; border:1px solid rgba(239,68,68,.2); background:transparent; color:#ef4444; cursor:pointer; transition:all .15s; }
.btn-rl-delete:hover { background:rgba(239,68,68,.1); }

/* ─── Build-Up Estimator Modal ───────────────────────────────────────────── */
.buildup-modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.55); backdrop-filter:blur(4px); z-index:9000; display:flex; align-items:flex-start; justify-content:center; padding:2rem 1rem; overflow-y:auto; }
.buildup-modal { background:var(--card-bg,#fff); border:1px solid var(--border-color,#e2e8f0); border-radius:16px; width:100%; max-width:980px; box-shadow:0 24px 60px rgba(0,0,0,.2); overflow:hidden; }
.buildup-modal-header { display:flex; align-items:flex-start; justify-content:space-between; gap:1rem; padding:1.5rem 1.75rem 1.25rem; border-bottom:1px solid var(--border-color,#e2e8f0); background:linear-gradient(135deg,rgba(59,191,200,.06),transparent); }
.buildup-modal-header h3 { margin:0; font-family:'Barlow',sans-serif; font-size:1.1rem; font-weight:700; color:var(--text-primary,#1e293b); line-height:1.3; }
.buildup-modal-header .boq-item-ref { font-size:.78rem; font-family:'Courier New',monospace; color:var(--teal,#3bbfc8); margin-top:.25rem; }
.btn-close-modal { background:none; border:none; cursor:pointer; padding:.4rem; color:var(--text-muted,#64748b); font-size:1.25rem; border-radius:6px; transition:all .15s; flex-shrink:0; }
.btn-close-modal:hover { background:var(--border-color,#e2e8f0); color:var(--text-primary,#1e293b); }
.buildup-modal-body { padding:1.5rem 1.75rem; }
.buildup-section-title { display:flex; align-items:center; gap:.5rem; font-family:'Barlow',sans-serif; font-size:.82rem; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--text-muted,#64748b); margin-bottom:.75rem; padding-bottom:.5rem; border-bottom:1px solid var(--border-color,#e2e8f0); }
.buildup-resources-table { width:100%; border-collapse:collapse; font-family:Inter,sans-serif; font-size:.83rem; margin-bottom:.75rem; }
.buildup-resources-table thead th { padding:.55rem .6rem; text-align:left; font-size:.73rem; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted,#64748b); background:var(--table-head-bg,#f8fafc); border-bottom:1px solid var(--border-color,#e2e8f0); }
.buildup-resources-table tbody tr { border-bottom:1px solid var(--border-color-subtle,#f1f5f9); }
.buildup-resources-table tbody tr:hover { background:rgba(59,191,200,.04); }
.buildup-resources-table tbody td { padding:.45rem .6rem; vertical-align:middle; }
.buildup-resources-table tbody td input,
.buildup-resources-table tbody td select { width:100%; padding:.32rem .45rem; border-radius:5px; border:1px solid var(--border-color,#e2e8f0); background:var(--input-bg,#fff); color:var(--text-primary,#1e293b); font-family:Inter,sans-serif; font-size:.81rem; }
.buildup-resources-table tbody td input:focus,
.buildup-resources-table tbody td select:focus { outline:none; border-color:var(--teal,#3bbfc8); box-shadow:0 0 0 2px rgba(59,191,200,.15); }
.resource-type-badge { display:inline-block; padding:.15rem .5rem; border-radius:10px; font-size:.7rem; font-weight:700; white-space:nowrap; }
.resource-type-badge.Labour    { background:rgba(59,130,246,.12); color:#3b82f6; }
.resource-type-badge.Materials { background:rgba(16,185,129,.12); color:#10b981; }
.resource-type-badge.Plant     { background:rgba(245,158,11,.12); color:#f59e0b; }
.row-total-cell { font-weight:700; color:var(--text-primary,#1e293b); white-space:nowrap; text-align:right; }
.btn-pull-library { padding:.22rem .48rem; font-size:.7rem; border-radius:5px; border:1px solid rgba(59,191,200,.4); background:rgba(59,191,200,.08); color:var(--teal,#3bbfc8); cursor:pointer; transition:all .15s; white-space:nowrap; }
.btn-pull-library:hover { background:var(--teal,#3bbfc8); color:#fff; }
.btn-remove-resource { padding:.22rem .48rem; font-size:.72rem; border-radius:5px; border:1px solid rgba(239,68,68,.2); background:transparent; color:#ef4444; cursor:pointer; transition:all .15s; }
.btn-remove-resource:hover { background:rgba(239,68,68,.1); }
.buildup-add-resource-row { display:flex; gap:.5rem; margin-top:.5rem; }
.btn-add-resource { padding:.4rem .9rem; font-size:.8rem; border-radius:7px; border:1px dashed var(--border-color,#cbd5e1); background:transparent; color:var(--text-muted,#64748b); cursor:pointer; font-family:Inter,sans-serif; transition:all .15s; }
.btn-add-resource:hover { border-color:var(--teal,#3bbfc8); color:var(--teal,#3bbfc8); background:rgba(59,191,200,.05); }
.buildup-totals-section { margin-top:1.5rem; display:grid; grid-template-columns:1fr 1fr; gap:1.25rem; }
@media (max-width:640px) { .buildup-totals-section { grid-template-columns:1fr; } }
.buildup-calc-panel { background:var(--table-head-bg,#f8fafc); border:1px solid var(--border-color,#e2e8f0); border-radius:12px; padding:1.1rem 1.25rem; }
.buildup-calc-panel h4 { font-family:'Barlow',sans-serif; font-size:.82rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted,#64748b); margin:0 0 .85rem 0; }
.calc-row { display:flex; align-items:center; justify-content:space-between; gap:.5rem; padding:.35rem 0; font-family:Inter,sans-serif; font-size:.84rem; border-bottom:1px solid var(--border-color-subtle,#f1f5f9); }
.calc-row:last-child { border-bottom:none; }
.calc-row.calc-total { margin-top:.5rem; padding-top:.6rem; border-top:2px solid var(--border-color,#e2e8f0); font-weight:700; font-size:1rem; color:var(--teal,#3bbfc8); }
.calc-row label { color:var(--text-secondary,#475569); flex:1; }
.calc-row .pct-input { width:60px; text-align:right; padding:.25rem .4rem; border-radius:5px; border:1px solid var(--border-color,#e2e8f0); background:var(--input-bg,#fff); font-family:Inter,sans-serif; font-size:.82rem; color:var(--text-primary,#1e293b); }
.calc-row .calc-value { font-weight:600; color:var(--text-primary,#1e293b); min-width:90px; text-align:right; font-family:'Barlow',sans-serif; font-size:.9rem; }
.rate-comparison-panel { margin-top:1.25rem; border:1px solid var(--border-color,#e2e8f0); border-radius:12px; overflow:hidden; }
.rate-comparison-panel .rcp-header { padding:.65rem 1rem; background:linear-gradient(135deg,rgba(59,191,200,.08),transparent); border-bottom:1px solid var(--border-color,#e2e8f0); font-family:'Barlow',sans-serif; font-size:.8rem; font-weight:700; text-transform:uppercase; letter-spacing:.07em; color:var(--text-muted,#64748b); }
.rcp-rows { display:flex; flex-direction:column; }
.rcp-row { display:flex; align-items:center; justify-content:space-between; padding:.65rem 1rem; border-bottom:1px solid var(--border-color-subtle,#f1f5f9); font-family:Inter,sans-serif; font-size:.85rem; }
.rcp-row:last-child { border-bottom:none; }
.rcp-row .rcp-label { color:var(--text-secondary,#475569); }
.rcp-row .rcp-val { font-weight:700; font-family:'Barlow',sans-serif; font-size:.95rem; }
.rcp-row.qps-estimate-row { background:rgba(59,191,200,.05); }
.rcp-row.qps-estimate-row .rcp-val { color:var(--teal,#3bbfc8); }
.rcp-variance { display:inline-flex; align-items:center; gap:.25rem; font-size:.75rem; font-weight:600; padding:.15rem .45rem; border-radius:10px; margin-left:.5rem; }
.rcp-variance.over    { background:rgba(239,68,68,.1); color:#ef4444; }
.rcp-variance.under   { background:rgba(16,185,129,.1); color:#10b981; }
.rcp-variance.neutral { background:rgba(100,116,139,.1); color:#64748b; }
.buildup-modal-footer { display:flex; justify-content:flex-end; gap:.75rem; padding:1.1rem 1.75rem; border-top:1px solid var(--border-color,#e2e8f0); background:var(--table-head-bg,#f8fafc); }
.btn-open-buildup { display:inline-flex; align-items:center; gap:.3rem; padding:.28rem .6rem; font-size:.74rem; border-radius:6px; border:1px solid rgba(59,191,200,.35); background:rgba(59,191,200,.07); color:var(--teal,#3bbfc8); cursor:pointer; font-weight:600; transition:all .15s; white-space:nowrap; }
.btn-open-buildup:hover,.btn-open-buildup.has-data { background:rgba(59,191,200,.15); border-color:var(--teal,#3bbfc8); }
.boq-qps-est-cell { font-weight:700; color:var(--teal,#3bbfc8); white-space:nowrap; }
.boq-qps-est-cell .qps-est-sub { display:block; font-size:.72rem; font-weight:400; color:var(--text-muted,#94a3b8); margin-top:.1rem; }

/* ─── Dark Theme ─────────────────────────────────────────────────────────── */
.dark-theme .rate-library-table thead th,.dark-theme .buildup-resources-table thead th { background:rgba(255,255,255,.03); }
.dark-theme .buildup-modal { background:#1a2535; border-color:rgba(255,255,255,.08); }
.dark-theme .buildup-modal-header,.dark-theme .buildup-modal-footer { border-color:rgba(255,255,255,.08); }
.dark-theme .buildup-modal-footer { background:rgba(255,255,255,.02); }
.dark-theme .buildup-calc-panel { background:rgba(255,255,255,.03); border-color:rgba(255,255,255,.08); }
.dark-theme .rate-library-table-wrap,.dark-theme .rate-comparison-panel { border-color:rgba(255,255,255,.08); }
.dark-theme .rate-library-toolbar .rl-search,.dark-theme .rate-library-toolbar select,
.dark-theme .buildup-resources-table tbody td input,.dark-theme .buildup-resources-table tbody td select,
.dark-theme .calc-row .pct-input { background:rgba(255,255,255,.05); border-color:rgba(255,255,255,.1); color:#e2e8f0; }
