/* =========================================================
   Energy page (scoped)
   ========================================================= */

.energy-wrap{
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 15px 60px;
}

/* Give the energy page its own sane spacing */
.energy-wrap h1,
.energy-wrap h2,
.energy-wrap h3{
    margin: 0;
}

.energy-wrap .muted{
    opacity: 0.75;
    font-size: 0.9rem;
}

/* Header row */
.energy-header{
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.energy-title{
    font-size: 2.1rem;
    line-height: 1.1;
}

.energy-subtitle{
    margin-top: 6px;
    opacity: 0.75;
    font-size: 0.95rem;
}

/* Controls */
.energy-controls{
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-left: auto;
}

.energy-label{
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.8rem;
    opacity: 0.9;
    min-width: 160px;
}

.energy-select{
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #333;
    color: var(--text);
}

/* Force buttons in energy header to NOT be full width */
.energy-controls .btn,
.energy-header .btn{
    width: auto !important;
    margin: 0 !important;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

/* KPI cards */
.energy-cards{
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 14px 0 18px;
}

.summary-card{
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 16px;
    border-radius: 8px;
}

.kpi-title{ font-size: 0.8rem; opacity: 0.75; }
.kpi-value{ margin-top: 8px; font-size: 1.6rem; font-weight: bold; }
.kpi-sub{ margin-top: 8px; font-size: 0.8rem; opacity: 0.7; line-height: 1.25; }

/* Charts */
.energy-grid{
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.energy-card{
    background: var(--panel2);
    border: 1px solid var(--border);
    padding: 18px;
    border-radius: 8px;
}

.energy-card-head{
    margin-bottom: 10px;
}

.energy-card-head h2{
    font-size: 1.05rem;
}

.chart-box{
    height: 320px;
}

/* Table section */
.energy-table-card .energy-card-head-row{
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
}

.table-wrap{
    overflow-x: auto;
    margin-top: 12px;
}

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

.energy-table th,
.energy-table td{
    padding: 10px 10px;
    border-bottom: 1px dashed var(--border);
    white-space: nowrap;
    text-align: right;
}

.energy-table th:first-child,
.energy-table td:first-child{
    text-align: left;
}

/* Modal hook (your base modal uses display:none; this toggles it) */
.modal.show{
    display: block;
}

/* Modal form spacing */
#addReadingForm{
    margin-top: 10px;
}

#addReadingForm label{
    margin-top: 10px;
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
}

#addReadingForm input{
    width: 100%;
    max-width: 100%;
    text-align: left;
    border-radius: 6px;
}

/* Status message */
.form-msg{
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    border: 1px solid var(--border);
    background: #333;
}

.form-msg--ok{
    border-color: rgba(40,160,80,0.5);
    background: rgba(40,160,80,0.15);
}

.form-msg--err{
    border-color: rgba(200,60,60,0.6);
    background: rgba(200,60,60,0.15);
}

/* Responsive */
@media (max-width: 980px){
    .energy-cards{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .energy-header{ align-items: flex-start; }
}

@media (max-width: 600px){
    .energy-cards{ grid-template-columns: 1fr; }
    .chart-box{ height: 280px; }

    .energy-controls{
        width: 100%;
    }
    .energy-label{
        flex: 1;
        min-width: 0;
    }
}
