/* ── Flow Hub ── */
.flow-hub {
    background: linear-gradient(145deg, #0f172a 0%, #1e293b 100%);
    border-radius: var(--radius-lg);
    padding: 36px 28px 28px;
    margin: 0 60px 12px;
    max-width: 900px;
    position: relative;
    overflow: hidden;
}
.flow-hub::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
    background-size: 40px 40px;
}
.flow-hub::after {
    content: '';
    position: absolute;
    top: 0; left: 10%; right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(105,190,40,0.4), transparent);
}

.flow-title {
    text-align: center;
    font-size: 0.7rem;
    font-weight: 600;
    color: rgba(255,255,255,0.3);
    letter-spacing: 3px;
    text-transform: uppercase;
    margin-bottom: 28px;
    position: relative;
}

/* ── Node Layout ── */
.flow-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 0;
    position: relative;
    min-height: 260px;
}

.node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.node-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 10px;
    position: relative;
}
.node-icon::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 24px;
    opacity: 0.15;
}

.node-value {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: 4px;
    font-variant-numeric: tabular-nums;
}
.node-unit {
    font-size: 0.8rem;
    font-weight: 400;
    opacity: 0.5;
}
.node-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0.35;
    color: white;
}
.node-sub {
    font-size: 0.65rem;
    font-weight: 500;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    color: white;
}

/* Node: Solar */
.node-solar { grid-column: 1 / -1; grid-row: 1; padding-bottom: 16px; }
.node-solar .node-icon {
    background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(245,158,11,0.05));
    border: 1px solid rgba(251,191,36,0.2);
}
.node-solar .node-icon::before { background: #fbbf24; }
.node-solar .node-value { color: #fbbf24; }
.node-solar .node-sub { background: rgba(251,191,36,0.1); color: #fcd34d; }

/* Node: Grid */
.node-grid { grid-column: 1; grid-row: 2; }
/* Node: Heating */
.node-heating { grid-column: 3; grid-row: 2; }
.node-grid .node-icon {
    background: linear-gradient(135deg, rgba(248,113,113,0.12), rgba(239,68,68,0.04));
    border: 1px solid rgba(248,113,113,0.2);
}
.node-grid .node-icon::before { background: #f87171; }
.node-grid .node-value { color: #f87171; }
.node-grid .node-sub { background: rgba(248,113,113,0.1); color: #fca5a5; }
.node-grid.exporting .node-icon {
    background: linear-gradient(135deg, rgba(16,185,129,0.12), rgba(5,150,105,0.04));
    border: 1px solid rgba(16,185,129,0.2);
}
.node-grid.exporting .node-icon::before { background: #10b981; }
.node-grid.exporting .node-value { color: #34d399; }
.node-grid.exporting .node-sub { background: rgba(16,185,129,0.1); color: #6ee7b7; }

/* Node: House */
.node-house { grid-column: 2; grid-row: 2; }
.node-house .node-icon {
    width: 88px;
    height: 88px;
    border-radius: 24px;
    background: linear-gradient(135deg, rgba(105,190,40,0.15), rgba(16,185,129,0.05));
    border: 1.5px solid rgba(105,190,40,0.25);
    font-size: 2.2rem;
}
.node-house .node-icon::before { background: var(--green); border-radius: 28px; inset: -6px; }
.node-house .node-value { color: var(--green); font-size: 2rem; }

.node-heating .node-icon {
    background: linear-gradient(135deg, rgba(249,115,22,0.12), rgba(234,88,12,0.04));
    border: 1px solid rgba(249,115,22,0.2);
}
.node-heating .node-icon::before { background: #f97316; }
.node-heating .node-value { color: #fb923c; }

/* Node: EV */
.node-ev { grid-column: 4; grid-row: 2; }
.node-ev .node-icon {
    background: linear-gradient(135deg, rgba(96,165,250,0.12), rgba(59,130,246,0.04));
    border: 1px solid rgba(96,165,250,0.2);
}
.node-ev .node-icon::before { background: #60a5fa; }
.node-ev .node-value { color: #60a5fa; }
.node-ev .node-sub { background: rgba(96,165,250,0.1); color: #93c5fd; }

/* ── Flow Lines ── */
.flow-lines {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}
.flow-lines svg {
    width: 100%;
    height: 100%;
}
.flow-dot-anim.inactive {
    display: none;
}

/* ── KPI Strip ── */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 0;
    margin: 0 60px 12px;
    max-width: 900px;
}
.kpi {
    background: var(--dark3);
    border: 1px solid var(--mid);
    border-radius: var(--radius-lg);
    padding: 16px 14px;
    transition: border-color 0.2s;
}
.kpi:hover {
    border-color: var(--mid2, rgba(255,255,255,0.12));
}
.kpi-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.kpi-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.kpi-name {
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--text);
    opacity: 0.5;
    letter-spacing: 0.3px;
}
.kpi-val {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.kpi-u {
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text);
    opacity: 0.4;
    margin-left: 2px;
}

.kpi-solar .kpi-dot { background: #f59e0b; }
.kpi-solar .kpi-val { color: #fbbf24; }
.kpi-green .kpi-dot { background: var(--green); }
.kpi-green .kpi-val { color: var(--green); }
.kpi-blue .kpi-dot { background: #3b82f6; }
.kpi-blue .kpi-val { color: #60a5fa; }
.kpi-purple .kpi-dot { background: #8b5cf6; }
.kpi-purple .kpi-val { color: #a78bfa; }

/* ── Dashboard Footer ── */
.dash-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin: 0 60px 12px;
    max-width: 900px;
}
.temp-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--dark3);
    border: 1px solid var(--mid);
    border-radius: var(--radius-lg);
    padding: 8px 14px;
}
.temp-val {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--white);
}
.temp-label {
    font-size: 0.65rem;
    color: var(--text);
    opacity: 0.5;
}
.live-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.68rem;
    color: var(--text);
    opacity: 0.5;
    font-weight: 500;
}
.live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #888;
    transition: background 0.3s;
}
.live-dot.connected {
    background: var(--green);
    animation: livePulse 2s ease-in-out infinite;
}
.live-dot.connecting {
    background: #f59e0b;
    animation: livePulse 1s ease-in-out infinite;
}
.live-dot.disconnected {
    background: #ef4444;
}
@keyframes livePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(105,190,40,0.3); opacity: 0.6; }
    50% { box-shadow: 0 0 0 4px rgba(105,190,40,0); opacity: 1; }
}

/* ── Offline Overlay ── */
.dashboard-embed {
    position: relative;
}
.dashboard-offline {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-lg);
    z-index: 10;
}
.offline-content {
    text-align: center;
    padding: 40px;
}
.offline-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}
.offline-content h3 {
    font-family: var(--font-head);
    color: var(--white);
    margin-bottom: 8px;
}
.offline-content p {
    color: var(--text);
    margin-bottom: 24px;
    font-size: 0.9rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .flow-hub {
        margin: 0 12px 10px;
        padding: 24px 12px 20px;
    }
    .flow-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        min-height: auto;
        gap: 16px;
    }
    .node-solar { grid-column: 1; grid-row: 1; padding-bottom: 0; }
    .node-grid { grid-column: 1; grid-row: 2; }
    .node-house { grid-column: 1; grid-row: 3; }
    .node-heating { grid-column: 1; grid-row: 4; }
    .node-ev { grid-column: 1; grid-row: 5; }
    .flow-lines { display: none; }
    .kpi-strip {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 12px;
    }
    .dash-footer {
        padding: 0 12px;
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}
