:root {
            --primary: #3b82f6;
            --primary-hover: #2563eb;
            --bg-main: #f8fafc;
            --bg-card: #ffffff;
            --text-main: #0f172a;
            --text-muted: #64748b;
            --border: #e2e8f0;
            --success: #10b981;
            --danger: #ef4444;
            --warning: #f59e0b;
            --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.02);
            --modal-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }

        body.theme-dark {
            --bg-main: #0f172a;
            --bg-card: #1e293b;
            --border: rgba(255, 255, 255, 0.05);
        }

        /* body removed for CRM integration */

        .container {
            max-width: 1440px;
            width: 100%;
            background: var(--bg-card);
            border-radius: 16px;
            box-shadow: var(--card-shadow);
            border: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Header Layout */
        .jc-header {
            background: linear-gradient(135deg, var(--primary) 0%, #1e40af 100%);
            border-bottom: 1px solid rgba(255,255,255,0.1);
            color: white;
            padding: 20px 30px;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .jc-header h1 {
            margin: 0;
            font-size: 1.5rem;
            font-weight: 800;
            letter-spacing: -0.5px;
            display: flex;
            align-items: center;
            gap: 10px;
        }

        .header h1 span {
            color: var(--primary);
        }

        .badge-dev {
            font-size: 0.75rem;
            font-weight: 700;
            background: rgba(59, 130, 246, 0.2);
            color: #93c5fd;
            padding: 6px 14px;
            border-radius: 20px;
            border: 1px solid rgba(147, 197, 253, 0.3);
        }

        /* Top Fields Panel */
        .top-fields {
            padding: 24px 30px;
            background: var(--bg-main);
            border-bottom: 1px solid var(--border);
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
            gap: 20px;
        }

        .field-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .field-group label {
            font-weight: 700;
            font-size: 0.75rem;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .field-group input, .field-group select {
            padding: 12px;
            border: 1px solid var(--border);
            border-radius: 8px;
            font-size: 0.95rem;
            font-weight: 600;
            background: var(--bg-card);
            color: var(--text-main);
            transition: all 0.2s ease;
            font-family: inherit;
        }

        .field-group input:focus, .field-group select:focus {
            outline: none;
            border-color: var(--primary);
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
        }

        /* Workspace split */
        .workspace-split {
            display: flex;
            flex: 1;
            overflow: hidden;
            min-height: 550px;
        }

        /* Spreadsheet Costing Area */
        .table-area {
            flex: 7;
            padding: 30px;
            overflow-y: auto;
            border-right: 1px solid var(--border);
            display: flex;
            flex-direction: column;
            gap: 20px;
        }

        .table-header-action {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .table-header-action h2 {
            font-size: 1.15rem;
            font-weight: 800;
            margin: 0;
            color: var(--text-main);
        }

        .btn-add-lib {
            background: var(--primary);
            color: white;
            border: none;
            border-radius: 8px;
            padding: 10px 16px;
            font-size: 0.85rem;
            font-weight: 700;
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 6px;
            transition: background 0.2s ease;
        }

        .btn-add-lib:hover {
            background: var(--primary-hover);
        }

        .table-container {
            border: 1px solid var(--border);
            border-radius: 12px;
            overflow: hidden;
            background: var(--bg-card);
            box-shadow: var(--card-shadow);
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th {
            background: var(--bg-main);
            color: var(--text-muted);
            font-weight: 800;
            text-transform: uppercase;
            font-size: 0.75rem;
            letter-spacing: 0.5px;
            padding: 14px 16px;
            text-align: left;
            border-bottom: 1px solid var(--border);
        }

        td {
            padding: 10px 16px;
            border-bottom: 1px solid var(--border);
            vertical-align: middle;
        }

        tr:last-child td {
            border-bottom: none;
        }

        .row-hidden {
            display: none;
        }

        /* Elegant Inputs Inside Cells */
        input.cell-input, select.cell-input {
            width: 100%;
            padding: 10px;
            border: 1px solid transparent;
            border-radius: 6px;
            font-family: inherit;
            font-size: 0.9rem;
            font-weight: 600;
            box-sizing: border-box;
            background: var(--bg-main);
            color: var(--text-main);
            transition: all 0.2s ease;
        }

        input.cell-input:focus, select.cell-input:focus {
            border-color: var(--primary);
            background: var(--bg-card);
            outline: none;
            box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
        }

        input.cell-input:hover:not(:focus) {
            background: var(--bg-main);
        }

        input.number-input {
            text-align: right;
        }

        /* Foreign Currency Flex Layout */
        .foreign-currency-flex {
            display: flex;
            gap: 6px;
            align-items: center;
        }

        .foreign-currency-flex select {
            width: 80px;
            flex-shrink: 0;
        }

        /* Dynamic row deletions */
        .btn-delete-row {
            background: transparent;
            color: var(--text-muted);
            border: none;
            cursor: pointer;
            padding: 4px;
            border-radius: 4px;
            transition: all 0.2s;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .btn-delete-row:hover {
            color: var(--danger);
            background: #fee2e2;
        }

        /* Side Control Panel & Visual Metrics */
        .sidebar-area {
            flex: 3;
            padding: 30px;
            background: var(--bg-main);
            display: flex;
            flex-direction: column;
            gap: 24px;
            overflow-y: auto;
        }

        .panel-title {
            font-size: 1.05rem;
            font-weight: 800;
            margin: 0;
            color: var(--text-main);
            border-bottom: 1px solid var(--border);
            padding-bottom: 12px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .kpi-card-group {
            display: grid;
            grid-template-columns: 1fr;
            gap: 15px;
        }

        .kpi-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 16px 20px;
            box-shadow: var(--card-shadow);
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .kpi-label {
            font-size: 0.75rem;
            font-weight: 700;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .kpi-value {
            font-size: 1.35rem;
            font-weight: 800;
        }

        /* Range Slider Styling */
        .slider-wrapper {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            box-shadow: var(--card-shadow);
            display: flex;
            flex-direction: column;
            gap: 15px;
        }

        .slider-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .slider-header label {
            font-size: 0.8rem;
            font-weight: 700;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .slider-controls {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .slider-controls input[type="range"] {
            flex: 1;
            accent-color: var(--primary);
            cursor: pointer;
            height: 6px;
        }

        .slider-input-box {
            display: flex;
            align-items: center;
            border: 1px solid var(--border);
            border-radius: 6px;
            padding: 6px 10px;
            background: var(--bg-main);
            width: 90px;
            flex-shrink: 0;
        }

        .slider-input-box input {
            border: none;
            background: transparent;
            text-align: right;
            width: 100%;
            font-weight: 700;
            font-size: 0.9rem;
            outline: none;
        }

        .slider-input-box span {
            font-weight: 800;
            color: var(--text-muted);
            margin-left: 4px;
        }

        /* Chart card */
        .chart-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            box-shadow: var(--card-shadow);
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 15px;
        }

        .chart-container {
            width: 100%;
            max-width: 180px;
            height: 180px;
            position: relative;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .chart-legend {
            width: 100%;
            display: flex;
            flex-direction: column;
            gap: 8px;
            font-size: 0.75rem;
            color: var(--text-muted);
            border-top: 1px solid var(--border);
            padding-top: 15px;
        }

        .legend-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .legend-label-color {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .color-dot {
            width: 10px;
            height: 10px;
            border-radius: 3px;
        }

        /* Library Picker Modal */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(4px);
            z-index: 1000;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .modal-content {
            background: var(--bg-card);
            border-radius: 16px;
            max-width: 650px;
            width: 100%;
            box-shadow: var(--modal-shadow);
            overflow: hidden;
            display: flex;
            flex-direction: column;
            max-height: 80vh;
        }

        .modal-header {
            padding: 20px 24px;
            background: #0f172a;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }

        .modal-header h3 {
            margin: 0;
            font-size: 1.15rem;
            font-weight: 800;
        }

        .modal-close-btn {
            background: transparent;
            color: rgba(255, 255, 255, 0.7);
            border: none;
            font-size: 1.5rem;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: color 0.2s;
        }

        .modal-close-btn:hover {
            color: white;
        }

        .modal-body {
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        .modal-tabs {
            display: flex;
            border-bottom: 1px solid var(--border);
            background: var(--bg-main);
        }

        .modal-tab-btn {
            padding: 14px 20px;
            border: none;
            background: transparent;
            cursor: pointer;
            font-size: 0.85rem;
            font-weight: 700;
            color: var(--text-muted);
            border-bottom: 2px solid transparent;
            transition: all 0.2s;
        }

        .modal-tab-btn.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
            background: var(--bg-card);
        }

        .modal-tab-btn:hover:not(.active) {
            color: var(--text-main);
            background: var(--bg-main);
        }

        .library-items-list {
            padding: 20px;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            gap: 10px;
            max-height: 400px;
        }

        .library-item-card {
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 12px 16px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .library-item-card:hover {
            border-color: var(--primary);
            background: rgba(59, 130, 246, 0.04);
            transform: translateY(-1px);
            box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
        }

        .library-item-info {
            display: flex;
            flex-direction: column;
            gap: 4px;
        }

        .library-item-name {
            font-weight: 700;
            font-size: 0.9rem;
        }

        .library-item-meta {
            font-size: 0.75rem;
            color: var(--text-muted);
        }

        .library-item-rate {
            font-weight: 800;
            color: var(--primary);
            font-size: 1rem;
        }

        /* Badges */
        .variance-badge {
            font-size: 0.8rem;
            font-weight: 800;
        }

        .text-green { color: var(--success); }
        .text-red { color: var(--danger); }
        .text-muted { color: var(--text-muted); }