/* ── Contenedor principal ── */
.offgrid-calc {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    max-width: 860px;
    margin: 0 auto;
    padding: 24px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    color: #1e293b;
}

.offgrid-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 20px;
    color: #0f172a;
    border-bottom: 2px solid #3b82f6;
    padding-bottom: 10px;
}

/* ── Tabs ── */
.offgrid-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 0;
}

.offgrid-tab {
    padding: 10px 20px;
    border: 1px solid #e2e8f0;
    border-bottom: none;
    background: #f8fafc;
    color: #64748b;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.offgrid-tab:hover {
    background: #eff6ff;
    color: #3b82f6;
}

.offgrid-tab.active {
    background: #ffffff;
    color: #3b82f6;
    border-color: #e2e8f0;
    border-bottom-color: #ffffff;
    font-weight: 600;
}

/* ── Panels ── */
.offgrid-panel {
    display: none;
    margin-bottom: 24px;
    animation: fadeIn 0.2s ease;
}

.offgrid-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.offgrid-hint {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 12px;
}

/* ── Campos ── */
.offgrid-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.offgrid-field label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.offgrid-field input,
.offgrid-field select {
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #1e293b;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.offgrid-field input:focus,
.offgrid-field select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: #ffffff;
}

.offgrid-badge {
    font-size: 0.72rem;
    font-weight: 500;
    background: #dbeafe;
    color: #1d4ed8;
    padding: 2px 8px;
    border-radius: 20px;
}

/* ── Tabla de cargas ── */
.offgrid-table-wrapper {
    overflow-x: auto;
    margin-bottom: 12px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.offgrid-loads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.offgrid-loads-table th {
    background: #f1f5f9;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
}

.offgrid-loads-table td {
    padding: 6px 8px;
    border-top: 1px solid #e2e8f0;
    vertical-align: middle;
}

.offgrid-loads-table tbody tr:hover {
    background: #f8fafc;
}

.offgrid-loads-table tbody input {
    width: 100%;
    min-width: 70px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    background: #ffffff;
    box-sizing: border-box;
}

.offgrid-loads-table tbody input:focus {
    outline: none;
    border-color: #3b82f6;
}

.offgrid-loads-table td.row-wh {
    font-weight: 600;
    color: #1d4ed8;
    white-space: nowrap;
    text-align: right;
    padding-right: 14px;
}

.offgrid-total-row {
    background: #eff6ff;
    font-weight: 700;
}

.offgrid-total-row td {
    padding: 10px 12px;
    color: #1e40af;
}

.offgrid-total-row td:nth-child(2) {
    text-align: right;
    font-size: 1rem;
}

.offgrid-remove-row {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.offgrid-remove-row:hover {
    background: #fee2e2;
}

/* ── Sección de parámetros ── */
.offgrid-section {
    margin-top: 24px;
    padding: 20px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.offgrid-section-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 16px;
}

.offgrid-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

/* ── Botones ── */
.offgrid-actions {
    margin-top: 20px;
    text-align: center;
}

.offgrid-btn-primary {
    padding: 12px 36px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.offgrid-btn-primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

.offgrid-btn-primary:active {
    transform: translateY(0);
}

.offgrid-btn-secondary {
    padding: 8px 18px;
    background: #ffffff;
    color: #2563eb;
    border: 1px solid #2563eb;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.offgrid-btn-secondary:hover {
    background: #eff6ff;
}

/* ── Resultados ── */
.offgrid-results {
    margin-top: 28px;
    padding: 20px;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    animation: fadeIn 0.3s ease;
}

.offgrid-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.result-card {
    background: #ffffff;
    border: 1px solid #e0f2fe;
    border-radius: 10px;
    padding: 14px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-card.highlight {
    border-color: #93c5fd;
    background: #eff6ff;
}

.result-card.primary {
    border-color: #3b82f6;
    background: #1d4ed8;
    color: #ffffff;
}

.result-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.result-card.primary .result-label {
    color: #bfdbfe;
}

.result-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1;
}

.result-card.primary .result-value {
    color: #ffffff;
}

.result-unit {
    font-size: 0.78rem;
    color: #94a3b8;
}

.result-card.primary .result-unit {
    color: #bfdbfe;
}

/* ── Fórmula ── */
.offgrid-formula {
    margin-top: 12px;
    padding: 12px 16px;
    background: #ffffff;
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #374151;
}

.offgrid-formula p {
    margin: 0 0 6px;
}

.offgrid-formula code {
    display: block;
    background: #f1f5f9;
    padding: 6px 10px;
    border-radius: 4px;
    font-family: "Courier New", monospace;
    font-size: 0.82rem;
    color: #1e40af;
    margin-bottom: 4px;
    word-break: break-all;
}

.offgrid-autonomy-note {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: #059669;
}

/* ── Catálogo de equipos ── */
.offgrid-catalog-bar {
    margin-top: 16px;
    margin-bottom: 12px;
}

.offgrid-catalog-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    transition: background 0.2s, border-color 0.2s, color 0.2s, border-radius 0.15s;
    text-align: left;
}

.offgrid-catalog-toggle:hover {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #2563eb;
}

.offgrid-catalog-toggle.open {
    background: #eff6ff;
    border-color: #93c5fd;
    border-bottom-color: transparent;
    border-radius: 10px 10px 0 0;
    color: #2563eb;
}

.catalog-chevron {
    font-size: 1rem;
    transition: transform 0.2s ease;
    line-height: 1;
}

.offgrid-catalog-toggle.open .catalog-chevron {
    transform: rotate(180deg);
}

.offgrid-catalog-panel {
    border: 1px solid #93c5fd;
    border-top: none;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    background: #ffffff;
    animation: fadeIn 0.18s ease;
}

.catalog-search-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.catalog-search-icon {
    font-size: 1.15rem;
    color: #94a3b8;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
}

.catalog-search-input {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    background: #ffffff;
    color: #1e293b;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.catalog-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    background: #ffffff;
}

.catalog-close-btn {
    background: none;
    border: none;
    font-size: 0.9rem;
    color: #94a3b8;
    cursor: pointer;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
}

.catalog-close-btn:hover {
    background: #fee2e2;
    color: #ef4444;
}

.catalog-chips {
    display: flex;
    gap: 6px;
    padding: 10px 14px;
    overflow-x: auto;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    scrollbar-width: none;
}

.catalog-chips::-webkit-scrollbar {
    display: none;
}

.catalog-chip {
    padding: 4px 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    color: #64748b;
    border-radius: 20px;
    font-size: 0.775rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.catalog-chip:hover {
    border-color: #93c5fd;
    color: #2563eb;
    background: #eff6ff;
}

.catalog-chip.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.offgrid-catalog-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #e2e8f0 transparent;
}

.offgrid-catalog-list::-webkit-scrollbar {
    width: 4px;
}

.offgrid-catalog-list::-webkit-scrollbar-track {
    background: transparent;
}

.offgrid-catalog-list::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.catalog-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.1s;
}

.catalog-item:last-child {
    border-bottom: none;
}

.catalog-item:hover {
    background: #f0f9ff;
}

.catalog-item:hover .catalog-add-btn {
    opacity: 1;
}

.catalog-item-name {
    flex: 1;
    font-size: 0.85rem;
    color: #1e293b;
    line-height: 1.3;
}

.catalog-item-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.catalog-item-w {
    font-size: 0.75rem;
    font-weight: 700;
    color: #1d4ed8;
    background: #dbeafe;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.catalog-item-h {
    font-size: 0.75rem;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.catalog-add-btn {
    background: #2563eb;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    opacity: 0.7;
    transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.catalog-add-btn:hover {
    background: #1d4ed8;
    opacity: 1;
    transform: scale(1.05);
}

.catalog-empty {
    padding: 32px 20px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.875rem;
}

/* ── Input + selector de unidad ── */
.offgrid-input-unit {
    display: flex;
    gap: 6px;
    align-items: center;
}

.offgrid-input-unit input {
    flex: 1;
    min-width: 0;
    width: auto;
}

.offgrid-input-unit select {
    width: auto;
    flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .offgrid-calc {
        padding: 16px;
    }

    .offgrid-tabs {
        flex-direction: column;
        border-bottom: none;
        gap: 4px;
    }

    .offgrid-tab {
        border-radius: 8px;
        border-bottom: 1px solid #e2e8f0;
        bottom: 0;
    }

    .offgrid-tab.active {
        border-bottom-color: #3b82f6;
    }

    .offgrid-results-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .offgrid-params-grid {
        grid-template-columns: 1fr;
    }
}