:root {
    color-scheme: dark;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    --background: #020a1e;
    --background-deep: #010615;
    --card: #071a38;
    --card-strong: #092144;
    --border: #174171;
    --border-soft: rgba(75, 132, 190, 0.25);
    --solar: #ffc91a;
    --solar-soft: rgba(255, 201, 26, 0.16);
    --positive: #43da6b;
    --positive-soft: rgba(67, 218, 107, 0.12);
    --negative: #ff625f;
    --negative-soft: rgba(255, 98, 95, 0.12);
    --consumption: #83baff;
    --text: #f6f9ff;
    --muted: #91a5c3;
    --subtle: #637b9e;
    --radius: 20px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    background: var(--background-deep);
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 50% -15%, rgba(24, 77, 139, 0.30), transparent 42rem),
        linear-gradient(180deg, #03102a 0%, var(--background) 62%, #010616 100%);
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

button, canvas { -webkit-tap-highlight-color: transparent; }

.dashboard {
    width: min(100%, 1000px);
    margin: 0 auto;
    padding: max(22px, env(safe-area-inset-top)) 22px max(26px, env(safe-area-inset-bottom));
}

.app-header {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 72px;
    margin-bottom: 18px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 62px;
    height: 62px;
    border-radius: 18px;
    color: var(--solar);
    background: var(--solar-soft);
    font-size: 42px;
    line-height: 1;
    text-shadow: 0 0 22px rgba(255, 201, 26, 0.38);
}

.brand-copy { min-width: 0; }

.brand-copy h1 {
    margin: 0;
    font-size: clamp(2rem, 7vw, 2.45rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.connection-line {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 8px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 650;
}

.status-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--subtle);
    box-shadow: 0 0 0 4px rgba(99, 123, 158, 0.12);
}

.status-dot.online {
    background: var(--positive);
    box-shadow: 0 0 0 4px rgba(67, 218, 107, 0.13), 0 0 16px rgba(67, 218, 107, 0.30);
}

.status-dot.error {
    background: var(--negative);
    box-shadow: 0 0 0 4px rgba(255, 98, 95, 0.13);
}

.icon-button {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-left: auto;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(12, 35, 70, 0.86);
    color: var(--text);
    font: inherit;
    font-size: 1.75rem;
    cursor: pointer;
    transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.icon-button:hover { background: #102d59; }
.icon-button:active { transform: scale(0.94); }
.icon-button:disabled { cursor: wait; opacity: 0.55; }
.icon-button.loading { animation: pulse 900ms ease-in-out infinite alternate; }

@keyframes pulse { to { opacity: 0.42; } }

.card {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(10, 34, 70, 0.97), rgba(5, 21, 48, 0.98));
    box-shadow: var(--shadow);
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 1px rgba(255, 255, 255, 0.035);
}

.card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
}

.card h2 {
    margin: 0;
    font-size: clamp(1.05rem, 3.8vw, 1.35rem);
    line-height: 1.2;
    letter-spacing: -0.018em;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 760;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.timestamp {
    color: var(--muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.solar-card {
    padding: 22px;
    margin-bottom: 14px;
}

.solar-card::before {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    right: -110px;
    top: -170px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 201, 26, 0.13), transparent 68%);
    pointer-events: none;
}

.power-reading {
    display: flex;
    align-items: baseline;
    gap: 6px;
    white-space: nowrap;
}

.power-reading strong {
    font-size: clamp(1.85rem, 7vw, 2.45rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.power-reading span {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

.solar-reading { margin-top: 14px; color: var(--solar); }
.solar-reading strong { font-size: clamp(2.7rem, 11vw, 4.2rem); }
.solar-reading span { color: var(--solar); font-size: 1.35rem; }

.capacity-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    color: var(--solar);
    font-size: 0.85rem;
    font-weight: 750;
}

.capacity-track {
    height: 12px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.09);
}

.capacity-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #ffbb00, #ffe14c);
    box-shadow: 0 0 18px rgba(255, 201, 26, 0.35);
    transition: width 450ms ease;
}

.capacity-maximum { color: var(--muted); font-weight: 600; }

.live-chart-wrap { margin-top: 15px; }
#live-chart { display: block; width: 100%; height: 210px; }

.chart-legend {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 6px;
    color: var(--muted);
    font-size: 0.73rem;
}

.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend-line { width: 26px; height: 3px; border-radius: 9px; }
.legend-line.solar { background: var(--solar); }
.legend-line.consumption { background: var(--consumption); }

.credit-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 46px;
    margin-top: 18px;
    padding: 9px 14px;
    border: 1px solid var(--border-soft);
    border-radius: 13px;
    color: var(--muted);
    background: rgba(255, 255, 255, 0.025);
    font-size: 0.86rem;
    font-weight: 720;
    text-align: center;
}

.credit-status.positive {
    border-color: rgba(67, 218, 107, 0.43);
    color: var(--positive);
    background: var(--positive-soft);
}

.credit-status.negative {
    border-color: rgba(255, 98, 95, 0.35);
    color: var(--negative);
    background: var(--negative-soft);
}

.credit-symbol { font-size: 1.2rem; }

.flow-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.flow-card {
    min-height: 204px;
    padding: 18px 14px;
    text-align: center;
}

.flow-card h2 {
    min-height: 2.4em;
    display: grid;
    place-items: center;
    font-size: clamp(0.82rem, 2.5vw, 1rem);
}

.flow-card .power-reading { justify-content: center; margin-top: 9px; }
.flow-card.positive .power-reading,
.flow-card.positive .flow-arrow,
.flow-card.positive .flow-label { color: var(--positive); }
.flow-card.negative .power-reading,
.flow-card.negative .flow-arrow,
.flow-card.negative .flow-label { color: var(--negative); }

.flow-visual {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 6px;
    min-height: 50px;
    margin-top: 10px;
}

.device-icon { color: #aec9ee; font-size: 2rem; line-height: 1; }
.device-icon.battery { font-size: 2.3rem; }
.device-icon.grid { font-size: 2.5rem; transform: rotate(90deg); }
.flow-arrow { color: var(--muted); font-size: 2rem; }
.flow-label { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; font-weight: 750; }

.consumption-card { display: flex; flex-direction: column; align-items: center; }
.large-device-icon { margin: 3px 0 4px; color: var(--consumption); font-size: 4.15rem; line-height: 0.9; }

.meter-card { margin-bottom: 14px; padding: 22px 22px 0; }
.meter-heading { align-items: flex-end; padding-bottom: 17px; }
.meter-total { justify-content: flex-end; }
.meter-total strong { font-size: clamp(2rem, 7vw, 3rem); }

.phase-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 0 -22px;
    border-top: 1px solid var(--border-soft);
}

.phase-grid article { padding: 15px 8px 17px; text-align: center; }
.phase-grid article + article { border-left: 1px solid var(--border-soft); }
.phase-grid h3 { margin: 0 0 4px; color: var(--muted); font-size: 0.8rem; }
.phase-grid strong { display: block; font-size: clamp(1.02rem, 4vw, 1.45rem); }
.phase-grid span { display: block; margin-top: 4px; color: var(--subtle); font-size: 0.68rem; }

.storage-card {
    margin-bottom: 14px;
    padding: 22px;
}

.storage-heading { align-items: center; }

.storage-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    margin-top: 18px;
}

.storage-grid h3 {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
    text-align: center;
}

#storage-gauge,
#storage-2-gauge {
    display: block;
    width: 100%;
    height: 190px;
    margin-top: 4px;
}

.storage-power-values {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 4px;
}

.storage-power-value { text-align: center; }
.storage-power-value strong { display: block; font-size: clamp(1.1rem, 4vw, 1.4rem); }
.storage-power-value span { display: block; margin-top: 3px; color: var(--muted); font-size: 0.72rem; }
.storage-power-value.discharge strong { color: var(--negative); }
.storage-power-value.charge strong { color: var(--positive); }

.storage-warning {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    margin-top: 16px;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--negative);
    background: var(--negative-soft);
    font-size: 0.8rem;
}

.storage-warning[hidden] { display: none; }
.storage-warning > span { font-weight: 900; }
.storage-warning p { margin: 0; }

.storage-timeline-section {
    margin-top: 22px;
    padding-top: 20px;
    border-top: 1px solid var(--border-soft);
}

.storage-timeline-heading h3 {
    margin: 2px 0 0;
    font-size: 1.05rem;
}

#storage-timeline-chart,
#storage-2-timeline-chart {
    display: block;
    width: 100%;
    height: 390px;
    margin-top: 6px;
}

.storage-timeline-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 20px;
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 650;
}

.storage-timeline-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.storage-timeline-legend .legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-dot.storage-charge { background: #43da6b; }
.legend-dot.storage-discharge { background: #ff625f; }
.legend-dot.storage-idle { background: #34425f; }
.legend-dot.storage-missing { background: rgba(255, 255, 255, 0.16); }
.legend-dot.storage-error { background: #fabb24; }
.legend-dot.storage-level { background: #65a9ff; }

.control-interface-card {
    margin-bottom: 14px;
    padding: 22px;
}

.control-interface-heading { align-items: center; }

.control-interface-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.control-interface-toggle {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    background: rgba(12, 35, 70, 0.86);
    font: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 160ms ease, border-color 160ms ease;
}

.control-interface-toggle:hover,
.control-interface-toggle:focus-visible {
    border-color: var(--consumption);
    background: #102d59;
}

.control-interface-toggle:focus-visible {
    outline: 2px solid rgba(131, 186, 255, 0.55);
    outline-offset: 2px;
}

.control-interface-chevron {
    display: inline-block;
    color: var(--consumption);
    font-size: 1rem;
    line-height: 1;
    transition: transform 160ms ease;
}

.control-interface-toggle[aria-expanded="true"] .control-interface-chevron {
    transform: rotate(180deg);
}

.control-interface-content[hidden] { display: none; }

.control-interface-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 18px;
}

.control-metric {
    min-width: 0;
    padding: 15px;
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    background: rgba(2, 15, 38, 0.42);
    transition: border-color 160ms ease, opacity 160ms ease;
}

.control-metric h3 {
    min-height: 2.5em;
    margin: 0;
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.25;
}

.control-reading {
    display: flex;
    align-items: baseline;
    gap: 5px;
    margin-top: 9px;
}

.control-reading strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: clamp(1.3rem, 4vw, 1.85rem);
    line-height: 1;
    letter-spacing: -0.035em;
}

.control-reading span {
    color: var(--subtle);
    font-size: 0.74rem;
    font-weight: 720;
}

.control-metric p {
    min-height: 2.4em;
    margin: 7px 0 0;
    color: var(--subtle);
    font-size: 0.66rem;
    line-height: 1.3;
}

.control-metric.positive {
    border-color: rgba(67, 218, 107, 0.30);
}

.control-metric.positive .control-reading strong { color: var(--positive); }

.control-metric.negative {
    border-color: rgba(255, 98, 95, 0.30);
}

.control-metric.negative .control-reading strong { color: var(--negative); }

.control-metric.unavailable { opacity: 0.48; }

.control-interface-status {
    margin: 13px 0 0;
    color: var(--muted);
    font-size: 0.72rem;
    text-align: right;
}

.control-interface-status.warning { color: #fabb24; }
.control-interface-status.error { color: var(--negative); }

.today-card {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 22px;
    margin-bottom: 14px;
    padding: 22px;
}

.bulb-mark {
    display: grid;
    place-items: center;
    width: 86px;
    height: 86px;
    color: var(--solar);
    border: 3px solid currentColor;
    border-radius: 50%;
    font-size: 3rem;
    text-shadow: 0 0 20px rgba(255, 201, 26, 0.42);
    box-shadow: 0 0 28px rgba(255, 201, 26, 0.13), inset 0 0 20px rgba(255, 201, 26, 0.10);
}

.today-reading { display: flex; align-items: baseline; gap: 7px; margin-top: 8px; }
.today-reading strong { font-size: clamp(2.5rem, 9vw, 3.7rem); letter-spacing: -0.05em; line-height: 1; }
.today-reading span { color: var(--muted); font-size: 1.05rem; font-weight: 720; }
.today-metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 28px; }
.today-metric { min-width: 0; }
.positive-copy { margin: 6px 0 0; color: var(--positive); font-weight: 740; }
.consumption-copy { margin: 6px 0 0; color: var(--accent); font-weight: 740; }
.consumption-note { margin: 3px 0 0; color: var(--muted); font-size: 0.7rem; }
.consumption-note.incomplete { color: var(--negative); }
.muted-copy { margin: 7px 0 0; color: var(--muted); font-size: 0.8rem; }

.timeline-card {
    margin-bottom: 14px;
    padding: 22px;
}

.timeline-heading { align-items: center; }

.day-clock-wrap {
    display: grid;
    place-items: center;
    width: 100%;
    margin-top: 4px;
}

#day-timeline-chart {
    display: block;
    width: 100%;
    height: 360px;
}

.timeline-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin-top: 2px;
    color: var(--text);
    font-size: 0.74rem;
    font-weight: 650;
}

.timeline-legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.22);
}

.legend-dot.solar { background: #61d10a; }
.legend-dot.no-solar { background: #fa7533; }
.legend-dot.pending { background: rgba(255, 255, 255, 0.22); }
.legend-dot.demand { background: var(--consumption); }
.history-card { padding: 22px; }
.history-totals { display: flex; align-items: flex-start; justify-content: flex-end; gap: 22px; }
.history-total { text-align: right; }
.history-total strong { display: block; font-size: clamp(1.65rem, 6vw, 2.25rem); line-height: 1; }
.history-total span { color: var(--muted); font-size: 0.7rem; }
#history-chart { display: block; width: 100%; height: 260px; margin-top: 18px; }
.chart-caption { margin: 9px 0 0; color: var(--muted); font-size: 0.74rem; text-align: center; }
.history-empty { display: grid; place-items: center; min-height: 150px; color: var(--muted); text-align: center; }
.history-empty[hidden] { display: none; }

.total-meter-card {
    margin-top: 14px;
    padding: 22px;
}

.total-meter-heading { align-items: center; }

.total-meter-content {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-top: 18px;
}

.total-meter-icon {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    border: 1px solid rgba(131, 186, 255, 0.35);
    border-radius: 17px;
    color: var(--consumption);
    background: rgba(131, 186, 255, 0.10);
    font-size: 2rem;
}

.total-meter-reading {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.total-meter-reading strong {
    font-size: clamp(2.4rem, 8vw, 3.5rem);
    line-height: 1;
    letter-spacing: -0.045em;
}

.total-meter-reading span {
    color: var(--consumption);
    font-size: 1.05rem;
    font-weight: 740;
}

.total-meter-content p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.76rem;
}

.total-meter-card.unavailable .total-meter-content { opacity: 0.52; }

.system-log-card {
    margin-top: 14px;
    margin-bottom: 14px;
    padding: 22px;
}

.system-log-status {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

.system-log-status.clear { color: var(--positive); }
.system-log-status.error { color: var(--negative); }

.system-log-list {
    display: grid;
    gap: 9px;
    margin: 17px 0 0;
    padding: 0;
    list-style: none;
}

.system-log-entry {
    display: grid;
    gap: 5px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 111, 64, 0.24);
    border-radius: 12px;
    background: rgba(255, 111, 64, 0.07);
}

.system-log-entry.active {
    border-color: rgba(255, 73, 91, 0.58);
    background: rgba(255, 73, 91, 0.13);
}

.system-log-entry strong { color: var(--negative); font-size: 0.82rem; }
.system-log-entry span { color: var(--muted); font-size: 0.7rem; line-height: 1.5; }

.error-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    padding: 13px 15px;
    border: 1px solid rgba(255, 98, 95, 0.38);
    border-radius: 14px;
    background: var(--negative-soft);
    color: #ff9b98;
    font-size: 0.82rem;
}

.error-banner[hidden] { display: none; }
.error-banner > span { font-weight: 900; }
.error-banner p { margin: 0; line-height: 1.4; }

.app-footer {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    padding: 18px 4px 0;
    color: var(--subtle);
    font-size: 0.68rem;
}

.app-footer > span:nth-child(2) { text-align: center; }
.app-footer > span:last-child { text-align: right; }

.footer-version {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.update-indicator {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    color: #fff;
    background: var(--negative);
    box-shadow: 0 0 10px rgba(255, 98, 95, 0.48);
    font-size: 0.64rem;
    font-weight: 900;
    line-height: 1;
}

.update-indicator[hidden] { display: none; }

@media (max-width: 620px) {
    .dashboard { padding-left: 12px; padding-right: 12px; }
    .app-header { padding: 0 5px; }
    .brand-mark { width: 54px; height: 54px; font-size: 36px; }
    .solar-card, .timeline-card, .history-card, .control-interface-card,
    .total-meter-card, .system-log-card { padding: 18px; }
    #live-chart { height: 170px; }
    .flow-grid { gap: 8px; }
    .flow-card { min-height: 184px; padding: 14px 7px; }
    .flow-card .power-reading { gap: 3px; }
    .flow-card .power-reading strong { font-size: clamp(1.3rem, 6vw, 1.8rem); }
    .flow-card .power-reading span { font-size: 0.68rem; }
    .storage-card { padding: 18px; }
    #storage-gauge,
    #storage-2-gauge { height: 180px; }
    #storage-timeline-chart,
    #storage-2-timeline-chart { height: 310px; }
    .storage-timeline-legend { gap: 8px 14px; font-size: 0.66rem; }
    .control-interface-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .control-metric { padding: 13px 11px; }
    .control-interface-status { text-align: left; }
    .control-interface-heading { align-items: flex-start; }
    .control-interface-actions { flex-direction: column; align-items: flex-end; gap: 7px; }
    .device-icon { font-size: 1.55rem; }
    .device-icon.battery { font-size: 1.85rem; }
    .device-icon.grid { font-size: 2rem; }
    .flow-arrow { font-size: 1.5rem; }
    .large-device-icon { font-size: 3.45rem; }
    .meter-card { padding: 18px 16px 0; }
    .meter-heading { display: block; }
    .meter-total { justify-content: flex-start; margin-top: 13px; }
    .phase-grid { margin: 0 -16px; }
    .phase-grid span { font-size: 0.6rem; }
    .today-card { grid-template-columns: 62px 1fr; gap: 15px; padding: 18px; }
    .bulb-mark { width: 60px; height: 60px; font-size: 2rem; border-width: 2px; }
    .today-metrics { gap: 12px; }
    .today-reading strong { font-size: clamp(1.65rem, 6.2vw, 2.6rem); }
    .positive-copy, .consumption-copy { font-size: 0.74rem; }
    .history-totals { gap: 12px; }
    .history-total strong { font-size: clamp(1.3rem, 5vw, 1.8rem); }
    #day-timeline-chart { height: 300px; }
    .timeline-legend { gap: 8px 15px; font-size: 0.68rem; }
    #history-chart { height: 220px; }
    .app-footer { font-size: 0.6rem; }
}

@media (max-width: 380px) {
    .dashboard { padding-left: 8px; padding-right: 8px; }
    .solar-card, .timeline-card, .history-card, .control-interface-card,
    .total-meter-card, .system-log-card { padding: 15px; }
    .total-meter-content { gap: 12px; }
    .total-meter-icon { width: 52px; height: 52px; font-size: 1.55rem; }
    .flow-grid { gap: 5px; }
    .flow-card { padding-left: 4px; padding-right: 4px; }
    .flow-card h2 { font-size: 0.72rem; }
    .flow-card .power-reading strong { font-size: 1.22rem; }
    .flow-visual { gap: 2px; }
    .device-icon { font-size: 1.3rem; }
    .flow-arrow { font-size: 1.25rem; }
    .flow-label { font-size: 0.68rem; }
    .phase-grid strong { font-size: 0.95rem; }
    #day-timeline-chart { height: 280px; }
    .timeline-legend { gap: 7px 11px; font-size: 0.63rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
/* Öffentliche, login-geschützte energyLOG-Ansicht */
.account-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
    margin: 0 0 14px;
    color: var(--muted);
    font-size: 0.9rem;
}

.account-bar a,
.account-bar button {
    color: var(--text);
    background: transparent;
    border: 0;
    padding: 4px 0;
    font: inherit;
    text-decoration: none;
    cursor: pointer;
}

.account-bar form { margin: 0; }

.auth-screen {
    min-height: 100vh;
    margin: 0;
    padding: 24px;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at top, #10244d 0, #03102a 56%, #020817 100%);
    color: var(--text);
}

.auth-card,
.admin-card {
    width: min(100%, 460px);
    padding: 28px;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: var(--card);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.admin-card { width: min(100%, 780px); }
.auth-card .brand-mark { margin-bottom: 16px; }
.auth-card h1, .admin-card h1 { margin: 0 0 8px; }
.auth-card > p { color: var(--muted); margin: 0 0 22px; }

.auth-stack { display: grid; gap: 16px; }
.auth-stack label { display: grid; gap: 7px; font-weight: 650; color: var(--muted); }
.auth-stack input:not([type="checkbox"]) {
    width: 100%; box-sizing: border-box; border-radius: 12px; border: 1px solid var(--border);
    background: rgba(1, 9, 28, 0.72); color: var(--text); padding: 12px 13px; font: inherit;
}
.auth-stack .check-row { display: flex; align-items: center; gap: 9px; }

.primary-button, .secondary-button {
    display: inline-flex; justify-content: center; align-items: center; border-radius: 12px;
    padding: 11px 16px; border: 1px solid transparent; font: inherit; font-weight: 750;
    text-decoration: none; cursor: pointer;
}
.primary-button { color: #07101f; background: #ffc91a; }
.secondary-button { color: var(--text); background: transparent; border-color: var(--border); }
.secondary-button.danger { color: #ffb1b1; border-color: rgba(255, 90, 90, 0.35); }
.notice { margin: 16px 0; padding: 12px 14px; border-radius: 12px; background: rgba(131, 186, 255, 0.12); }
.notice.error { background: rgba(255, 90, 90, 0.13); color: #ffb1b1; }
.notice.success { background: rgba(101, 224, 137, 0.13); color: #9ff0b5; }
.admin-heading, .user-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.admin-section { margin-top: 26px; }
.admin-section h2 { font-size: 1.05rem; }
.user-list { display: grid; gap: 10px; }
.user-actions { display: flex; align-items: center; gap: 8px; }
.user-actions form { margin: 0; }
.user-row { padding: 12px; border: 1px solid var(--border); border-radius: 14px; }
.user-row > div:first-child { display: grid; gap: 4px; }
.user-row span { color: var(--muted); font-size: 0.88rem; }

@media (max-width: 620px) {
    .auth-screen { padding: 12px; }
    .auth-card, .admin-card { padding: 20px; border-radius: 20px; }
    .user-row { align-items: flex-start; flex-direction: column; }
}
