:root {
    /* Color Palette - Premium Dark Theme SCADA Style */
    --bg-main: #0a0e17;
    --bg-secondary: #111827;
    --primary-glow: rgba(56, 189, 248, 0.3);
    --accent: #38bdf8;
    --accent-hover: #7dd3fc;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --glass-bg: rgba(17, 24, 39, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    font-size: 13px; /* Smaller base font for denser layout */
    overflow-x: hidden;
    position: relative;
    background: radial-gradient(circle at 10% 50%, rgba(56, 189, 248, 0.05), transparent 50%),
                var(--bg-main);
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.brand-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px var(--primary-glow);
}

.brand h1 {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.2;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(56, 189, 248, 0.1);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.sidebar-footer {
    display: block;
    margin-top: auto; /* Push it to the bottom */
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

.section-header {
    margin-bottom: 1.25rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.75rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 0.25rem;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.view-section {
    display: none;
    animation: fadeIn 0.2s ease-out forwards;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Cards */
.glass-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--card-shadow);
}

.glass-card h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 0.5rem;
}

/* Input Grids */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.75rem;
}

.input-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-field.full-width {
    grid-column: 1 / -1;
}

.input-field label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-field input {
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    color: #fff;
    font-size: 0.85rem;
    font-family: 'Inter', monospace;
    outline: none;
    transition: all 0.2s;
}

.input-field input:focus {
    border-color: var(--accent);
}

/* Calculations Specific */
.calc-results-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.full-width-card {
    grid-column: 1 / -1;
}

.calc-card .formula {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: monospace;
    background: rgba(0,0,0,0.2);
    padding: 0.4rem;
    border-radius: 4px;
    margin-bottom: 0.75rem;
}

.calc-output {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent);
    font-family: monospace;
}

.loss-breakdown-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}

.loss-item {
    background: rgba(0,0,0,0.2);
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255,255,255,0.02);
}

.loss-item h4 {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
    color: #e2e8f0;
}

.loss-item span {
    font-size: 0.65rem;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
    font-family: monospace;
}

.loss-val {
    font-size: 1rem;
    font-weight: 600;
    color: var(--warning);
    font-family: monospace;
}

/* Summary Dashboard */
.summary-dashboard {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
}

.efficiency-gauges-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.efficiency-card {
    text-align: center;
    padding: 1rem;
}

.efficiency-circle {
    width: 120px;
    margin: 0.5rem auto;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 100%;
    max-height: 120px;
}

.circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.05);
    stroke-width: 2.5;
}

.circle {
    fill: none;
    stroke-width: 2.5;
    stroke-linecap: round;
    transition: stroke-dasharray 0.5s ease-out;
}

.percentage {
    fill: #fff;
    font-family: 'Inter', monospace;
    font-size: 6.5px;
    font-weight: 600;
    text-anchor: middle;
}

.eff-formula {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.losses-bars {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 0.75rem 1.5rem;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bar-label {
    width: 110px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-container {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
    overflow: hidden;
}

.bar {
    height: 100%;
    background: var(--warning);
    border-radius: 3px;
    transition: width 0.5s ease-out;
}

.bar-val {
    width: 40px;
    text-align: right;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: monospace;
}

@media (max-width: 768px) {
    .summary-dashboard {
        grid-template-columns: 1fr;
    }
    .losses-bars {
        grid-template-columns: 1fr;
    }
}

.hidden {
    display: none !important;
}
