/* Import Nunito Font */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&display=swap');

/* CSS Variables for Dark Theme */
:root {
    /* Modern blue theme color palette inspired by reference */
    --primary-color: #4F46E5;
    --primary-light: #6366F1;
    --primary-dark: #3730A3;
    --secondary-color: #7C3AED;
    --accent-color: #06B6D4;
    --success-color: #10B981;
    --warning-color: #F59E0B;
    --error-color: #EF4444;
    
    /* Background colors - modern gradient approach */
    --bg-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-secondary: #F8FAFC;
    --bg-tertiary: #F1F5F9;
    --bg-card: #FFFFFF;
    --bg-sidebar: #1E293B;
    --bg-sidebar-hover: #334155;
    
    /* Text colors */
    --text-primary: #1E293B;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --text-white: #FFFFFF;
    --text-sidebar: #CBD5E1;
    
    /* Border and divider colors */
    --border-color: #E2E8F0;
    --divider-color: #CBD5E1;
    
    /* Elevation and shadows */
    --shadow-light: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-medium: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-heavy: 0 10px 15px rgba(0,0,0,0.1);
    --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    
    /* Gradient backgrounds */
    --gradient-primary: linear-gradient(135deg, #4F46E5 0%, #7C3AED 100%);
    --gradient-secondary: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%);
    --gradient-card: linear-gradient(145deg, #FFFFFF 0%, #F8FAFC 100%);
}

/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-weight: 400;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {   
    min-height: 100vh;
    background: var(--bg-secondary);
}

/* Dark Header Styles */
.header-dark {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    padding: 1rem 0;
    box-shadow: var(--elevation-3);
    border-bottom: 2px solid var(--primary-color);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-title {
    color: var(--text-primary);
    font-size: 1.8rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.solar-icon {
    font-size: 2rem;
    filter: drop-shadow(0 0 8px var(--primary-color));
}

.welcome-text {
    color: var(--text-secondary);
    margin-right: 1rem;
    font-size: 1rem;
    font-weight: 500;
}

/* Box Style Login Button (Not Rounded) */
.btn-login-box {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-primary);
    border: none;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    border-radius: 4px; /* Minimal radius for box style */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--elevation-2);
    margin-left: 0.5rem;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-width: 120px;
}

.btn-login-box:hover {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    box-shadow: var(--elevation-3);
    transform: translateY(-2px);
    color: var(--text-primary);
    text-decoration: none;
}

.btn-logout {
    background: linear-gradient(135deg, #d32f2f 0%, #f44336 100%);
}

.btn-logout:hover {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
}

/* Enhanced Container and Cards */
.container {
    max-width: 1200px;
    padding: 0 1rem;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
  
    box-shadow: var(--elevation-2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--elevation-3);
    transform: translateY(-2px);
}

.card-header {
   background: #384965;
    color: #fffdfa;
    position: relative;
}

.card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    
}

.card-body {
 background-color: white !important;
}

/* Collapsible cards: minimize by default and expand on header click */
.card.collapsible .card-header {
    cursor: pointer;
    user-select: none;
}
.card.collapsible.collapsed .card-body {
    display: none;
}
/* Visual indicator for collapse/expand state */
.card.collapsible .card-header::before {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1rem;
    opacity: 0.85;
}
.card.collapsible.collapsed .card-header::before {
    content: '▸';
}

/* Section Titles */
.section-title {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Enhanced Form Controls with Increased Font Size */
.form-label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.1rem; /* Increased font size */
    margin-bottom: 0.75rem;
    display: block;
}

.form-control-enhanced {
    background: var(--bg-surface-elevated);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 1rem;
    font-size: 1.1rem; /* Increased font size */
    font-family: 'Nunito', sans-serif;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-height: 50px;
    width: 100%;
}
input{
    color: var(--text-primary) !important;
}

.form-control-enhanced:focus {
    outline: none;
    color: var(--text-primary);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 109, 0, 0.2);
    background: var(--bg-surface);
}

.form-control-enhanced::placeholder {
    color: var(--text-disabled);
    font-size: 1rem;
}

/* Ensure Two Fields Per Row with Proper Spacing */
.row {
    margin-left: -0.75rem;
    margin-right: -0.75rem;
}

.row > [class*="col-"] {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.mb-3, .mb-4 {
    margin-bottom: 1.5rem !important;
}

/* Fieldset Styles */
.breaker-fieldset, .wire-fieldset {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    background: var(--bg-surface-elevated);
    box-shadow: var(--elevation-1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.breaker-fieldset:hover, .wire-fieldset:hover {
    border-color: var(--primary-color);
    box-shadow: var(--elevation-2);
}

.fieldset-legend {
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.5rem; /* Increased font size */
    padding: 0 1rem;
    background: var(--bg-surface);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* System Type Highlights */
.system-type-highlight {
    color: #FF6D00;
    font-weight: 700;
    text-transform: uppercase;
    background: linear-gradient(135deg, #FF6D00 0%, #FF8F00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 10px rgba(255, 109, 0, 0.3);
    font-size: 1rem;
}

/* Enhanced Calculate Button */
.btn-calculate {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--text-primary);
    border: none;
    border-radius: 50px;
    padding: 1rem 3rem;
    font-size: 1.2rem; /* Increased font size */
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--elevation-3);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 250px;
}

.btn-calculate:hover {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    box-shadow: var(--elevation-4);
    transform: translateY(-3px) scale(1.02);
}

.btn-calculate:active {
    transform: translateY(-1px) scale(0.98);
}

/* Modal Styles */
.modal-dark .modal-content {
    background: var(--bg-surface);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--elevation-4);
}

.modal-dark .modal-header {
    background: linear-gradient(135deg, var(--bg-surface-elevated) 0%, var(--bg-surface) 100%);
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-primary);
}

.modal-dark .modal-title {
    font-weight: 700;
    font-size: 1.4rem; /* Increased font size */
    color: var(--text-primary);
}

.modal-dark .modal-body {
    background: var(--bg-surface);
    color: var(--text-primary);
    max-height: 70vh;
    overflow-y: auto;
    padding: 1.5rem;
}

.modal-dark .modal-footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-color);
}

/* Enhanced scrollable modal */
.modal-dialog-scrollable {
    height: calc(100% - 1rem);
}

.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 1rem);
    overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

/* Custom scrollbar for modal */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: var(--bg-surface-elevated);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--elevation-2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    box-shadow: var(--elevation-3);
    transform: translateY(-2px);
    color: var(--text-primary);
}

.btn-secondary {
    background: var(--bg-surface-elevated);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--primary-color);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* Results Section */
#results {
    animation: slideInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.hidden{
    display: none;
}
.show{
    display: inline !important;
}
/* Alert Styles */
.alert {
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
}

.alert-danger {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid var(--error-color);
    color: #ff041d;
}

.alert-success {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid var(--success-color);
    color: #c8e6c9;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0;
        max-width: 100%;
    }
    
    .card {
        width: 100%;
        margin: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .header-title {
        font-size: 1.4rem;
    }
    
    .btn-login-box {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        min-width: 100px;
    }
    
    .welcome-text {
        display: none;
    }
    
    .form-control-enhanced {
        font-size: 1rem;
        padding: 0.875rem;
    }
    
    .form-label {
        font-size: 1rem;
    }
    
    .fieldset-legend {
        font-size: 1.1rem;
    }
    
    .btn-calculate {
        font-size: 1.1rem;
        padding: 0.875rem 2rem;
        min-width: 200px;
    }
}

@media (max-width: 576px) {
    .row > [class*="col-"] {
        margin-bottom: 1rem;
    }
    
    .header-dark .container-fluid {
        padding: 0 1rem;
    }
    
    .header-title {
        font-size: 1.2rem;
    }
    
    .btn-login-box {
        display: block;
        margin: 0.5rem 0;
        width: 100%;
    }
}

/* Sidebar Navigation */
.sidebar {
    width: 100px;
    background: var(--bg-sidebar);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-medium);
    transition: all 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--bg-sidebar-hover);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-white);
    letter-spacing: -0.5px;
}

.sidebar-menu {
    flex: 1;
    padding: 20px 0;
    overflow-y: auto;
}

.menu-section {
    margin-bottom: 32px;
}

.menu-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 0 20px 12px;
}

.menu-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    color: var(--text-sidebar);
    text-decoration: none;
    transition: all 0.3s ease;
    border-radius: 15px;
    margin: 8px 10px;
    position: relative;
    overflow: hidden;
    width: 60px;
    height: 60px;
    border-left: none;
}

.menu-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
    transform: scale(1.1);
}

.menu-item.active {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
    transform: scale(1.05);
    box-shadow: inset 0 0 0 1px rgba(79, 70, 229, 0.2);
}

.menu-icon {
    font-size: 28px;
    width: auto;
    text-align: center;
}

.menu-text {
    display: none;
}

.sidebar-footer {
    padding: 20px;
    
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    margin-bottom: 16px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    color: var(--text-white);
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.logout-btn, .login-btn {
    display: flex;
    align-items: center;
    
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: 1px solid var(--bg-sidebar-hover);
    border-radius: 8px;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.logout-btn:hover, .login-btn:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
    border-color: var(--primary-color);
}

.login-btn-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.login-btn-header:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.user-info-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-secondary);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 500;
}

/* Main Content Area */
.main-content {
    margin-left: 100px;
    min-height: 100vh;
    background: var(--bg-secondary);
    padding: 20px;
    display: flex;
    gap: 20px;
}

.content-left {
    width: 100%;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.top-header {
    background: var(--bg-card);
    padding: 24px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-light);
}

.header-center {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
}

.header-right {
    width: auto;
    min-width: 100px; /* Balance the layout */
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-title-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    z-index: 1001;
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 15px;
    border-radius: 10px;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    min-width: 50px;
    min-height: 50px;
    align-items: center;
    justify-content: center;
}

.mobile-menu-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.header-left {
    flex: 1;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-stats {
    display: flex;
    gap: 32px;
}

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Content Sections */
.content-sections {
    flex: 1;
    padding: 32px;
}

.content-section {
    display: none;
}

.content-section.active {
    display: block;
}

.section-header {
    margin-bottom: 32px;
}

.section-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.section-icon {
    font-size: 28px;
}

.section-description {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 0;
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

/* Allow specific cards to span full width across the grid */
.cards-grid .card.card-full {
    grid-column: 1 / -1;
}

/* Generic hidden utility */
.hidden {
    display: none !important;
}

/* Animated reveal container for grouped fields */
.reveal-group {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.4s ease, opacity 0.4s ease;
}
.reveal-group.revealed {
    max-height: 2000px; /* large enough to fit content */
    opacity: 1;
    pointer-events: auto;
}
.inverter-separator {
    margin: 12px 0;
}

/* Stepper (multi-step) layout and animations */
.step {
    display: none;
    opacity: 0;
    transform: translateY(12px);
}
.step.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
    animation: stepFadeIn 0.35s ease forwards;
}
.step.slide-up {
    animation: stepSlideUp 0.35s ease forwards;
}
.step.slide-in {
    animation: stepSlideIn 0.35s ease forwards;
}

/* Direction-aware, professional transitions */
.step.slide-out-up-bounce {
    animation: stepSlideOutUpBounce 0.48s cubic-bezier(.22,.61,.36,1) forwards;
    will-change: transform, opacity;
}
.step.slide-out-down-bounce {
    animation: stepSlideOutDownBounce 0.48s cubic-bezier(.22,.61,.36,1) forwards;
    will-change: transform, opacity;
}
.step.slide-in-up {
    animation: stepSlideInUp 0.42s cubic-bezier(.22,.61,.36,1) forwards;
    will-change: transform, opacity;
}
.step.slide-in-down {
    animation: stepSlideInDown 0.42s cubic-bezier(.22,.61,.36,1) forwards;
    will-change: transform, opacity;
}

@keyframes stepFadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes stepSlideUp {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-16px); }
}
@keyframes stepSlideIn {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Outgoing animation for forward (up) with subtle down-then-up bounce */
@keyframes stepSlideOutUpBounce {
    0%   { opacity: 1; transform: translateY(0); }
    28%  { opacity: 1; transform: translateY(8px); }
    100% { opacity: 0; transform: translateY(-28px); }
}

/* Outgoing animation for back (down) with subtle up-then-down bounce */
@keyframes stepSlideOutDownBounce {
    0%   { opacity: 1; transform: translateY(0); }
    28%  { opacity: 1; transform: translateY(-8px); }
    100% { opacity: 0; transform: translateY(28px); }
}

/* Incoming animations (direction-aware) */
@keyframes stepSlideInUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes stepSlideInDown {
    from { opacity: 0; transform: translateY(-18px); }
    to   { opacity: 1; transform: translateY(0); }
}

.step-nav {
    grid-column: 1 / -1;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 8px;
}
.btn-next, .btn-prev {
    background: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.btn-prev {
    background: #64748B; /* slate */
}
.btn-next:disabled, .btn-prev:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-next:hover:not(:disabled), .btn-prev:hover:not(:disabled) {
    transform: translateY(-1px);
}

/* Deemphasize previous inputs once inverter fields appear */
.form-group.deemphasized .form-control,
.form-group.deemphasized select {
    background-color: #f3f4f6; /* light gray */
    color: #6b7280; /* gray-600 */
}
.form-group.deemphasized .input-icon,
.form-group.deemphasized .form-label {
    color: #6b7280;
}

/* Modern Form Styles */
.form-group {
    margin-bottom: 0px !important;
    position: relative;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.label-icon {
    font-size: 16px;
    color: var(--primary-color);
}

.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: var(--text-secondary);
    z-index: 10; /* ensure icon stays above input focus ring */
    pointer-events: none; /* prevent icon from interfering with focus */
    transition: color 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
}

.form-control {
    width: 100%;
    padding: 16px 16px 16px 48px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 500;
    transition: all 0.3s ease;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control:focus + .input-icon {
    color: var(--primary-color);
    opacity: 1;
    visibility: visible;
}

/* Robust focus state to keep icons visible when any child is focused */
.input-group:focus-within .input-icon {
    color: var(--primary-color);
    opacity: 1;
    visibility: visible;
}

/* Ensure label icons/images remain visible on focus */
.form-group:focus-within .form-label img,
.form-group:focus-within .form-label .label-icon {
    opacity: 1;
    visibility: visible;
}

.form-control::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

/* Input Field Variations */
.input-group.has-icon .form-control {
    padding-left: 48px;
}

.input-group.no-icon .form-control {
    padding-left: 16px;
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

/* Allow certain fields to span both columns in two-column grids */
.form-grid-2 .full-width {
    grid-column: 1 / -1;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Fieldset Styles */
.fieldset-card {
    background: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 16px;
    transition: all 0.3s ease;
}

.fieldset-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-card);
}

.fieldset-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.fieldset-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.fieldset-icon {
    font-size: 24px;
    color: var(--primary-color);
}

.fieldset-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0 0 0;
}

/* Calculate Button */
.calculate-section {
    text-align: center;
    padding: 12px 0 0 0; /* reduce vertical padding */
    margin: 8px 0 0 0;   /* remove large gap under cards */
}

.btn-calculate-modern {
    background: var(--gradient-primary);
    color: var(--text-white);
    border: none;
    border-radius: 16px;
    padding: 20px 48px;
    font-size: 18px;
    font-weight: 700;
    font-family: 'Nunito', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 280px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Quick Selection Buttons */
.quick-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.btn-quick {
    background: linear-gradient(135deg, #8facdb 0%, #034abd 100%);
    color: white;
    border: none;
    padding: 2px 2px;
    border-radius: 0px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.3);
}

.btn-quick:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

.btn-calculate-modern:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-heavy);
}

.btn-calculate-modern:active {
    transform: translateY(-1px);
}

.btn-calculate-modern::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s ease;
}

/* System Type SVG Picker */
.system-type-picker {
    display: flex;
    gap: 12px;
    flex-wrap: nowrap; /* keep in a single row */
    margin-top: 8px;
}

.system-type-option {
    position: relative;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 12px;
    background: var(--bg-card);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    box-shadow: var(--shadow-card);
}

.system-type-option img {
    width: 91px; /* 30% reduction from 130px */
    height: auto;
    pointer-events: none;
    transition: transform 0.2s ease, filter 0.2s ease;
}

.system-type-option .option-label {
    margin-top: 6px;
    font-weight: 600;
    color: var(--text-secondary);
}

.system-type-option:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-heavy);
    border-color: var(--primary-color);
}

.system-type-option:hover img {
    transform: scale(1.03);
    filter: drop-shadow(0 4px 8px rgba(76, 29, 149, 0.2));
}

.system-type-option.selected {
    border-color: var(--secondary-color);
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
}

.system-type-option.selected img {
    transform: scale(1.05);
    filter: drop-shadow(0 6px 12px rgba(124, 58, 237, 0.4));
}

.system-type-option.selected::after {
    content: '✔';
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 14px;
    background: var(--secondary-color);
    color: var(--text-white);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-medium);
}

.system-type-option:focus {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
}

.btn-calculate-modern:hover::before {
    left: 100%;
}

/* Results Card */
.results-card {
    background: var(--bg-card);
    border: 2px solid var(--success-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    margin-top: 32px;
}

.results-header {
    background: linear-gradient(135deg, var(--success-color) 0%, var(--accent-color) 100%);
    color: var(--text-white);
    padding: 24px;
    text-align: center;
}

.results-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.results-body {
    padding: 32px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
}

.result-item {
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.result-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-light);
}

.result-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.result-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
}

.result-currency {
    font-size: 20px;
    color: var(--text-secondary);
}

/* Responsive Design Updates */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
    
    .form-grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-left: 200px;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        width: 280px;
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
        height: 100vh;
        top: 0;
        left: 0;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    /* Mobile overlay */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .mobile-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
        flex-direction: column;
        padding: 0;
        gap: 0;
    }
    
    .content-left {
        width: 100%;
        order: 1;
    }
    
    .top-header {
        padding: 1rem 0.5rem;
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    
    .header-left {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
    
    .header-right {
        display: none; /* Hide stats on mobile */
    }
    
    .page-title {
        font-size: 1.5rem;
    }
    
    .page-subtitle {
        font-size: 0.9rem;
    }
    
    .content-sections {
        padding: 0;
    }
    
    .form-grid,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .cards-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .header-stats {
        display: none;
    }
    
    .btn-calculate-modern {
        width: 100%;
        min-width: auto;
    }
    
    .card {
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .card-header {
      
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Show mobile menu button */
    .mobile-menu-btn {
        display: flex !important;
    }
}

@media (max-width: 480px) {
    .top-header {
        padding: 16px 8px;
        flex-direction: column;
        gap: 12px;
    }
    
    .header-center {
        order: -1; /* Move login button to top */
        width: 100%;
    }
    
    .login-btn-header {
        padding: 10px 16px;
        font-size: 0.9rem;
    }
    
    .content-section {
        padding: 0;
    }
    
    .card {
        margin: 0;
        width: 100%;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .card-header {
        padding: 1rem;
        border-radius: 0;
    }
    
    .fieldset-card {
        padding: 16px;
    }
    
    .card-body {
        padding: 0.75rem;
        background-color: white !important;
    }
    
    .form-control {
        padding: 0.75rem;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px; /* Better touch target */
        border-radius: 8px;
    }
    
    .input-icon {
        left: 14px;
        font-size: 1rem;
    }
    
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        font-weight: 600;
    }
    
    .label-icon {
        font-size: 1rem;
    }
    
    .btn, button {
        min-height: 44px; /* Better touch target */
        padding: 12px 20px;
        font-size: 16px;
        border-radius: 8px;
    }
    
    .btn-calculate-modern {
        padding: 15px 25px;
        font-size: 18px;
        min-height: 50px;
    }
    
    /* Improve select dropdowns on mobile */
    select.form-control {
        background-size: 20px;
        padding-right: 40px;
    }
    
    /* Better spacing for mobile */
    .form-grid,
    .form-grid-2,
    .form-grid-3 {
        gap: 1.5rem;
    }
    
    .input-group {
        margin-bottom: 1rem;
    }
    
    .page-title {
        font-size: 1.25rem;
    }
    
    .section-header h2 {
        font-size: 1.1rem;
    }
    
    .btn-calculate-modern {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
    }
}

/* High contrast mode for accessibility */
@media (prefers-contrast: high) {
    :root {
        --text-primary: #000000;
        --text-secondary: #333333;
        --border-color: #000000;
        --bg-primary: #ffffff;
        --bg-secondary: #f0f0f0;
    }
    
    .card {
        border: 2px solid var(--border-color);
    }
    
    .form-control {
        border: 2px solid var(--border-color);
    }
    
    .btn-calculate-modern {
        border: 2px solid var(--primary-color);
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for better accessibility */
/* .form-control:focus,
.btn-calculate-modern:focus,
.menu-item:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
} */

/* Print styles */
@media print {
    .sidebar {
        display: none;
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .btn-calculate-modern {
        display: none;
    }
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.mobile-menu-toggle:hover {
    background: var(--bg-tertiary);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    .sidebar-overlay.active {
        display: block;
    }
}

/* Cost Breakdown Modal Styles */
.cost-breakdown-section {
    background: #4e3fa7;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid #444;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.cost-section-title {
    color: #000000;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #f9f9f9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cost-breakdown-content {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.cost-breakdown-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #333;
    transition: background-color 0.2s ease;
}

.cost-breakdown-item:hover {
    background-color: rgba(76, 175, 80, 0.1);
    border-radius: 6px;
    margin: 0 -0.5rem;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

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

.cost-item-label {
    color: #e0e0e0;
    font-weight: 500;
    flex: 1;
}

.cost-item-details {
    color: #bbb;
    font-size: 0.9rem;
    margin-left: 1rem;
    text-align: right;
}

.cost-item-value {
    color: #4CAF50;
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 120px;
    text-align: right;
}

.cost-total-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid #4CAF50;
}

.cost-total-item {
    padding: 0.5rem 0;
    font-size: 1.2rem;
    color: #4CAF50;
}

.cost-profit-item {
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

.profit-highlight {
    color: #FFD700 !important;
}

.cost-summary-section {
    background: #6454c7;
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid #4CAF50;
}

.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    
}

.summary-label {
    color: #040404;
    font-weight: 500;
}

.summary-value {
    color: #000000;
    font-weight: bolder;
    font-size: 1.1rem;
}

/* Professional Cost Breakdown Table */
table.professional-breakdown {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
}

/* Wider modal for Detailed Cost Breakdown */
#costBreakdownModal .modal-dialog {
    width: 95vw;
    max-width: 95vw;
    margin-left: auto;
    margin-right: auto;
}

/* Mobile optimizations for breakdown modal to avoid horizontal scroll */
@media (max-width: 576px) {
    #costBreakdownModal .modal-title {
        font-size: 1rem;
    }
    #costBreakdownModal .modal-body {
        font-size: 12px;
    }
    table.professional-breakdown th,
    table.professional-breakdown td {
        font-size: 12px;
        padding: 6px;
    }
    #costBreakdownModal .breakdown-controls .btn {
        font-size: 12px;
        padding: 4px 8px;
    }
    /* Smaller icons within table rows on mobile */
    table.professional-breakdown .item-icon {
        width: 20px;
        height: 20px;
    }
}

table.professional-breakdown thead th {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border: none;
}

/* Left half (Items, Quantity, Per Unit Cost) — dark theme */
table.professional-breakdown thead th:nth-child(-n+3),
table.professional-breakdown tbody td:nth-child(-n+3),
table.professional-breakdown tfoot th:nth-child(-n+3) {
    background: #1f2937; /* slate-800 */
    color: #e5e7eb;      /* slate-200 */
}

/* Right half (Offer Price, Cost Price) — green theme */
table.professional-breakdown thead th:nth-child(n+4),
table.professional-breakdown tbody td:nth-child(n+4),
table.professional-breakdown tfoot th:nth-child(n+4) {
    background: #d5ff95; /* bootstrap green-900 */
    color: #000000;      /* light mint */
}

table.professional-breakdown tbody tr {
    border-top: 1px solid rgba(255,255,255,0.05);
}

table.professional-breakdown tbody tr:hover td:nth-child(-n+3) {
    background: #111827; /* darker slate */
}

table.professional-breakdown tbody tr:hover td:nth-child(n+4) {
    background: #14532d; /* darker green */
}

table.professional-breakdown .total-row th:nth-child(n+4),
table.professional-breakdown .profit-row th:nth-child(n+4),
table.professional-breakdown .profit-percentage-row th:nth-child(n+4) {
    background: #14532d;
    color: #e8fff3;
}

table.professional-breakdown .cost-price-column {
    font-weight: 600;
}

/* Distinguish Cost Price column with purple background */
table.professional-breakdown thead.table-primary th.cost-price-column,
table.professional-breakdown tbody td.cost-price-column,
table.professional-breakdown tfoot th.cost-price-column {
    background: #6959ba;
    color: #ffffff;
}

/* Preserve purple on hover for Cost Price column */
table.professional-breakdown tbody tr:hover td.cost-price-column {
    background: #6959ba;
    color: #ffffff;
}

table.professional-breakdown td,
table.professional-breakdown th {
    border: none;
}

/* Custom scrollbar for cost breakdown content */
.cost-breakdown-content::-webkit-scrollbar {
    width: 6px;
}

.cost-breakdown-content::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 3px;
}

.cost-breakdown-content::-webkit-scrollbar-thumb {
    background: #4CAF50;
    border-radius: 3px;
}

.cost-breakdown-content::-webkit-scrollbar-thumb:hover {
    background: #45a049;
}

/* Responsive adjustments for cost breakdown modal */
@media (max-width: 768px) {
    .cost-breakdown-section {
        padding: 1rem;
        margin-bottom: 0.75rem;
    }
    
    .cost-section-title {
        font-size: 1rem;
    }
    
    .cost-breakdown-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .cost-item-details {
        margin-left: 0;
        text-align: left;
    }
    
    .cost-item-value {
        min-width: auto;
        text-align: left;
        font-size: 1rem;
    }
    
    .summary-stats {
        grid-template-columns: 1fr;
    }
    
    .summary-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Item icons inside breakdown table */
table.professional-breakdown .item-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    object-fit: contain;
}

/* Item icons inside cost item labels */
.cost-item-label .item-icon {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    vertical-align: middle;
    object-fit: contain;
}

/* --- Custom tweaks for breakdown totals --- */
table.professional-breakdown tfoot .total-row th {
    border-top: 2px solid #ffffff !important; /* horizontal white line above totals */
}
table.professional-breakdown .total-cell .total-label {
    font-weight: 700;
}
table.professional-breakdown .total-cell .total-amount {
    color: #ffffff;
}