:root {
    --bg-color: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --blob-1: #3b82f6;
    --blob-2: #8b5cf6;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Blobs for dynamic look */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(80px);
    opacity: 0.4;
    border-radius: 50%;
    animation: move 20s infinite alternate ease-in-out;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 50vw;
    height: 50vw;
    background: var(--blob-1);
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 40vw;
    height: 40vw;
    background: var(--blob-2);
    animation-delay: -5s;
}

@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(10%, 10%) scale(1.2); }
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-right: 1px solid var(--panel-border);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.btn-site-home {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(74, 222, 128, 0.45);
    background: rgba(74, 222, 128, 0.1);
    color: #bbf7d0;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.35;
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.btn-site-home:hover {
    background: rgba(74, 222, 128, 0.18);
    border-color: #4ade80;
    color: #ecfdf5;
}
.btn-site-home-sidebar {
    margin-bottom: 0.5rem;
}
.btn-site-home-header {
    flex-shrink: 0;
    white-space: nowrap;
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.logo i {
    font-size: 1.5rem;
    color: var(--accent-color);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.nav-links li {
    padding: 1rem;
    border-radius: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.nav-links li:hover, .nav-links li.active {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.nav-links li.active {
    border-left: 4px solid var(--accent-color);
    background: rgba(59, 130, 246, 0.1);
}

/* Main Content */
.content {
    flex: 1;
    padding: 2rem 4rem;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
}

.header-title h1 {
    font-size: 2rem;
    font-weight: 600;
}

.header-title p {
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.user-profile img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid var(--panel-border);
}

/* Glass Panels */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 2rem;
}

.glass-panel h3 {
    margin-bottom: 1rem;
    font-size: 1.25rem;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
}

.glass-panel p {
    color: var(--text-secondary);
    line-height: 1.6;
}

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

.stat-card {
    background: rgba(255, 255, 255, 0.03);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-card h4 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
}

.stat-card .unit {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Coming Soon */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 0;
    color: var(--text-secondary);
}

.coming-soon i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Views Management */
.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.active-view {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Calculators */
.calculator-tabs {
    display: flex;
    gap: 0.5rem;
    margin: 1.5rem 0;
    border-bottom: 1px solid var(--panel-border);
    padding-bottom: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.calculator-tabs::-webkit-scrollbar {
    height: 4px;
}

.calculator-tabs::-webkit-scrollbar-thumb {
    background: var(--accent-color);
    border-radius: 2px;
}

.calc-tab {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.calc-tab:hover {
    background: rgba(255,255,255,0.05);
}

.calc-tab.active {
    background: var(--accent-color);
    color: white;
}

.calculator-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.active-calc {
    display: block;
}

.input-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.input-group input, .input-group select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--accent-color);
}

.input-group select option {
    background: var(--bg-color);
}

.btn-primary {
    background: var(--accent-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.result-box {
    margin-top: 1.5rem;
    padding: 1rem;
    background: rgba(74, 222, 128, 0.1);
    border-left: 4px solid #4ade80;
    border-radius: 0.5rem;
}

.result-box h5 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.highlight {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4ade80;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.form-grid .input-group {
    margin-bottom: 0.5rem;
}

.form-grid .input-group label {
    font-size: 0.8rem;
}

.form-grid .input-group input,
.form-grid .input-group select {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
}

/* Device forms */
.device-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--panel-border);
}

/* Big button */
.btn-big {
    margin-top: 2rem;
    padding: 1rem 2rem;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

thead th {
    background: rgba(59, 130, 246, 0.15);
    color: var(--text-primary);
    padding: 0.6rem 0.8rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--accent-color);
}

tbody td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
}

tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.year-row td {
    font-weight: 700;
    background: rgba(59, 130, 246, 0.1);
    border-top: 2px solid var(--accent-color);
}

/* Responsive sidebar */
@media (max-width: 900px) {
    .sidebar {
        width: 60px;
        padding: 1rem 0.5rem;
    }
    .sidebar .logo h2,
    .sidebar .nav-links span {
        display: none;
    }
    .sidebar .nav-links li {
        justify-content: center;
        padding: 0.75rem;
    }
    .content {
        padding: 1rem;
    }
}

/* Koszyk */
.basket-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.6rem 1rem; margin-bottom: 0.5rem;
    background: rgba(99,102,241,0.1); border: 1px solid rgba(99,102,241,0.3);
    border-radius: 0.5rem; transition: all 0.2s;
}
.basket-item:hover { background: rgba(99,102,241,0.2); }
.basket-type {
    background: var(--primary); color: #fff; padding: 0.2rem 0.6rem;
    border-radius: 0.25rem; font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.basket-name { flex: 1; color: var(--text-primary); font-weight: 500; }
.basket-remove {
    background: rgba(239,68,68,0.15); border: none; color: #ef4444;
    width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center; transition: 0.2s;
}
.basket-remove:hover { background: #ef4444; color: #fff; }

/* Karty podsumowania */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem;
}
.stat-card {
    background: rgba(30,41,59,0.6); border: 1px solid rgba(99,102,241,0.2);
    border-radius: 0.75rem; padding: 1.25rem; text-align: center;
}
.stat-card h4 { color: var(--text-secondary); font-size: 0.8rem; margin-bottom: 0.5rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-card .value .unit { font-size: 0.85rem; color: var(--text-secondary); font-weight: 400; }

/* Wiersz roczny w tabelach */
.year-row { background: rgba(99,102,241,0.15) !important; font-weight: 700; }

/* BESS */
.bess-mw-display {
    margin-top: 1rem; padding: 1rem 1.5rem; border-radius: 0.75rem;
    background: linear-gradient(135deg, rgba(99,102,241,0.15), rgba(168,85,247,0.15));
    border: 1px solid rgba(99,102,241,0.3);
    display: flex; align-items: center; justify-content: space-between;
}
.highlight-big { font-size: 1.8rem; font-weight: 700; color: var(--primary); }

/* ——— Nawigacja i układ modułów ——— */
.nav-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 0.5rem 1rem 0.25rem;
    pointer-events: none;
    list-style: none;
}
.module-intro { margin-bottom: 1rem; }
.module-intro p { color: var(--text-secondary); margin-top: 0.5rem; line-height: 1.5; }
.module-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.module-card {
    background: rgba(30, 41, 59, 0.6);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}
.module-card:hover, .module-card:focus {
    border-color: var(--accent-color);
    transform: translateY(-2px);
    outline: none;
}
.module-card i { font-size: 1.75rem; color: var(--accent-color); margin-bottom: 0.75rem; }
.module-card h4 { margin-bottom: 0.5rem; }
.module-card p { color: var(--text-secondary); font-size: 0.9rem; line-height: 1.45; margin-bottom: 1rem; }
.module-card-cta { font-size: 0.85rem; font-weight: 600; color: var(--accent-color); }

/* Lead capture BESS */
.bess-lead-panel {
    margin-top: 1.5rem;
    border-color: rgba(74, 222, 128, 0.35);
}
.bess-lead-panel h3 {
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    line-height: 1.4;
}
.bess-lead-intro {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.25rem;
}
.bess-lead-fields {
    margin-top: 0;
}
.bess-lead-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
.bess-lead-rodo {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    margin: 1rem 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
    cursor: pointer;
}
.bess-lead-rodo input {
    margin-top: 0.2rem;
    flex-shrink: 0;
}
.bess-lead-actions {
    margin-top: 0.5rem;
}
.bess-lead-actions .btn-big {
    margin-top: 0;
}
.bess-lead-status {
    margin-top: 1rem;
    font-size: 0.9rem;
    min-height: 1.25rem;
}
.bess-lead-status.is-success { color: #4ade80; }
.bess-lead-status.is-error { color: #f87171; }

/* Tryb analizy BESS/PV */
.bess-mode-panel { margin-bottom: 0; }
.bess-mode-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}
.bess-mode-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
}
.bess-mode-option {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.85rem 1rem;
    border: 1px solid var(--panel-border);
    border-radius: 0.65rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}
.bess-mode-option:hover { border-color: rgba(59, 130, 246, 0.5); }
.bess-mode-option:has(input:checked) {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.12);
}
.bess-mode-option input { margin-top: 0.2rem; flex-shrink: 0; }
.bess-mode-label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.9rem;
}
.bess-mode-label small {
    color: var(--text-secondary);
    font-size: 0.78rem;
    line-height: 1.35;
    font-weight: 400;
}

/* Kroki workflow (budynek, BESS) */
.workflow-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}
.workflow-step {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    border: 1px solid var(--panel-border);
    border-radius: 0.5rem;
    background: rgba(0,0,0,0.2);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}
.workflow-step:hover { border-color: var(--accent-color); color: var(--text-primary); }
.workflow-step.active {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.15);
    color: var(--text-primary);
}
.workflow-step .step-num {
    width: 1.5rem; height: 1.5rem;
    border-radius: 50%;
    background: var(--accent-color);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.workflow-panel { display: none; }
.workflow-panel.active { display: block; }
.workflow-panel-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.btn-secondary {
    background: transparent;
    border: 1px solid var(--panel-border);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.btn-secondary:hover { border-color: var(--accent-color); }

/* Raport – spis treści */
.report-toc {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: rgba(30, 41, 59, 0.5);
    border-radius: 0.5rem;
    border: 1px solid var(--panel-border);
}
.report-toc a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    padding: 0.35rem 0.75rem;
    border-radius: 0.35rem;
}
.report-toc a:hover { background: rgba(59, 130, 246, 0.2); color: var(--text-primary); }

/* Kalkulatory – układ 2-kolumnowy */
.tools-tabs-hidden { display: none !important; }
.tools-layout {
    display: grid;
    grid-template-columns: minmax(200px, 260px) 1fr;
    gap: 0;
    padding: 0;
    overflow: hidden;
}
.tools-sidebar {
    border-right: 1px solid var(--panel-border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.tools-group-pick {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    text-align: left;
    padding: 0.85rem 1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: rgba(0,0,0,0.15);
    color: var(--text-secondary);
    cursor: pointer;
    width: 100%;
    transition: all 0.2s;
}
.tools-group-pick i { color: var(--accent-color); font-size: 1rem; }
.tools-group-pick span { font-weight: 600; color: var(--text-primary); font-size: 0.9rem; }
.tools-group-pick small { font-size: 0.75rem; opacity: 0.8; }
.tools-group-pick:hover, .tools-group-pick.active {
    border-color: var(--accent-color);
    background: rgba(59, 130, 246, 0.12);
}
.tools-main { padding: 1rem 1.25rem; min-width: 0; }
.tools-calc-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--panel-border);
}
.tools-calc-pick {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--panel-border);
    color: var(--text-secondary);
    padding: 0.45rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}
.tools-calc-pick:hover, .tools-calc-pick.active {
    border-color: var(--accent-color);
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.15);
}
.tools-calc-area .calculator-content { max-width: 560px; }
.tools-calc-area h4 { margin-bottom: 1rem; color: var(--text-primary); }

@media (max-width: 900px) {
    .tools-layout { grid-template-columns: 1fr; }
    .tools-sidebar {
        flex-direction: row;
        flex-wrap: wrap;
        border-right: none;
        border-bottom: 1px solid var(--panel-border);
    }
    .tools-group-pick { flex: 1; min-width: 140px; }
}
