:root {
    color-scheme: light;
    --navy-950: #061522;
    --navy-900: #0a2035;
    --navy-800: #12314d;
    --ink: #102337;
    --muted: #627487;
    --line: #dce6ec;
    --surface: #ffffff;
    --surface-soft: #f3f7f8;
    --green: #0a9b75;
    --green-dark: #06765a;
    --green-soft: #e5f7f0;
    --blue: #1976d2;
    --blue-soft: #e8f2fd;
    --amber: #d67b0d;
    --danger: #bd3f4b;
    --shadow: 0 20px 55px rgba(9, 36, 57, .12);
    --radius-lg: 28px;
    --radius-md: 20px;
    --radius-sm: 12px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-soft); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--surface-soft); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(390px, .85fr) 1.15fr; background: var(--surface); }
.auth-panel { width: min(100%, 560px); margin: auto; padding: 64px; }
.brand-lockup, .topbar-brand { display: flex; align-items: center; gap: 16px; }
.brand-lockup h1 { margin: 2px 0 0; font-size: clamp(2rem, 4vw, 3rem); letter-spacing: -.055em; }
.brand-mark { display: grid; width: 64px; height: 64px; place-items: center; color: var(--navy-900); background: var(--green-soft); border-radius: 20px; }
.brand-mark svg { width: 38px; height: 38px; fill: currentColor; }
.brand-mark .brand-bolt { fill: var(--green); }
.brand-mark-small { width: 40px; height: 40px; border-radius: 13px; }
.brand-mark-small svg { width: 25px; height: 25px; }
.eyebrow, .panel-kicker { color: var(--green-dark); font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.auth-lead { max-width: 420px; margin: 34px 0 30px; color: var(--muted); font-size: 1.15rem; line-height: 1.65; }
.network-warning { margin: -12px 0 24px; padding: 12px 14px; color: #754407; background: #fff6df; border: 1px solid #f1d89b; border-radius: 11px; font-size: .84rem; line-height: 1.5; }
.stack-form { display: grid; gap: 18px; }
.stack-form label { display: grid; gap: 8px; color: var(--ink); font-size: .9rem; font-weight: 700; }
input, select { width: 100%; min-height: 50px; padding: 0 15px; color: var(--ink); background: #fff; border: 1px solid #cddae2; border-radius: 12px; outline: none; transition: border-color .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 4px rgba(10, 155, 117, .12); }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 18px; border: 0; border-radius: 12px; font-weight: 800; transition: transform .2s, box-shadow .2s, background .2s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button svg { width: 19px; height: 19px; fill: currentColor; }
.button-primary { color: #fff; background: var(--green); box-shadow: 0 10px 24px rgba(10, 155, 117, .22); }
.button-primary:hover { background: var(--green-dark); }
.button-secondary { color: var(--navy-900); background: #fff; border: 1px solid var(--line); box-shadow: 0 6px 18px rgba(9, 36, 57, .06); }
.button-ghost { color: var(--muted); background: transparent; }
.button-large { min-height: 54px; }
.button-loader { display: none; width: 18px; height: 18px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.is-loading .button-loader { display: inline-block; }
.form-error, .inline-warning { margin: 0; padding: 12px 14px; color: #8f2934; background: #fff0f1; border: 1px solid #ffd4d8; border-radius: 10px; font-size: .9rem; }
.privacy-note { display: flex; gap: 10px; margin-top: 25px; color: var(--muted); font-size: .82rem; line-height: 1.5; }
.privacy-note svg { flex: 0 0 20px; width: 20px; height: 20px; fill: var(--green); }
.auth-visual { position: relative; overflow: hidden; display: grid; place-items: center; min-height: 620px; background: radial-gradient(circle at 70% 20%, #1a476a 0, var(--navy-900) 38%, var(--navy-950) 78%); }
.auth-visual::after { content: ""; position: absolute; inset: auto -10% -35% 5%; height: 70%; background: linear-gradient(165deg, transparent 15%, rgba(54, 215, 167, .2)); border-radius: 50%; transform: rotate(-8deg); }
.sun { position: absolute; top: 13%; right: 15%; width: 160px; height: 160px; background: #44d4a8; border-radius: 50%; filter: blur(1px); box-shadow: 0 0 90px rgba(68, 212, 168, .38); }
.energy-orbit { position: absolute; border: 1px solid rgba(255,255,255,.15); border-radius: 50%; }
.orbit-one { width: 560px; height: 560px; }
.orbit-two { width: 760px; height: 760px; }
.visual-card { position: relative; z-index: 2; width: min(68%, 520px); padding: 40px; color: #fff; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.18); border-radius: 30px; box-shadow: 0 30px 80px rgba(0,0,0,.25); backdrop-filter: blur(18px); }
.visual-card span { display: block; color: #a8c5d8; font-size: .9rem; text-transform: uppercase; letter-spacing: .1em; }
.visual-card strong { display: block; margin: 8px 0 32px; font-size: clamp(2rem, 4vw, 3.2rem); }
.mini-bars { height: 150px; display: flex; align-items: end; gap: 10px; }
.mini-bars i { flex: 1; height: 30%; background: linear-gradient(#55ddb3, #0a9b75); border-radius: 8px 8px 3px 3px; opacity: .9; }
.mini-bars i:nth-child(2) { height: 45%; }.mini-bars i:nth-child(3) { height: 34%; }.mini-bars i:nth-child(4) { height: 68%; }.mini-bars i:nth-child(5) { height: 86%; }.mini-bars i:nth-child(6) { height: 62%; }.mini-bars i:nth-child(7) { height: 100%; }

.app-shell { min-height: 100vh; }
.topbar { min-height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 12px clamp(20px, 5vw, 72px); color: #fff; background: var(--navy-950); }
.topbar-brand { color: #fff; text-decoration: none; font-weight: 850; letter-spacing: -.02em; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.user-chip { max-width: 220px; overflow: hidden; padding: 8px 12px; color: #c9d7e0; font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; padding: 0; color: inherit; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.1); border-radius: 12px; }
.icon-button:hover { background: rgba(255,255,255,.16); }
.icon-button svg { width: 20px; height: 20px; fill: currentColor; }
.dashboard-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 72px; }
.dashboard-heading { display: flex; justify-content: space-between; gap: 30px; align-items: end; margin-bottom: 28px; }
.dashboard-heading h2 { margin: 6px 0; font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -.045em; }
.dashboard-heading p { margin: 0; color: var(--muted); }
.dashboard-controls { display: flex; align-items: end; gap: 12px; }
.point-switcher { display: grid; gap: 6px; min-width: 280px; color: var(--muted); font-size: .76rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.point-switcher select { min-height: 44px; }
.sync-notice { display: flex; align-items: center; gap: 10px; margin: 0 0 20px; padding: 12px 16px; color: #31536d; background: #e9f3f8; border-radius: 12px; font-size: .9rem; }
.pulse-dot { width: 9px; height: 9px; background: var(--blue); border-radius: 50%; animation: pulse 1.5s infinite; }
.overview-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 22px; }
.overview-grid.monitor-only { grid-template-columns: 1fr; }
.overview-grid.monitor-only .metric-stack { grid-template-columns: 1fr; }
.overview-grid.monitor-only .metric-card { min-height: 190px; }
.panel { background: var(--surface); border: 1px solid rgba(197, 213, 222, .75); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.battery-card { padding: clamp(24px, 4vw, 40px); }
.panel-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-heading h3, .insight-panel h3 { margin: 5px 0 0; font-size: 1.35rem; }
.status-badge { padding: 7px 10px; color: var(--green-dark); background: var(--green-soft); border-radius: 999px; font-size: .78rem; font-weight: 800; }
.battery-layout { min-height: 270px; display: flex; align-items: center; justify-content: space-around; gap: 30px; }
.battery-gauge { position: relative; width: min(210px, 46%); aspect-ratio: 1; }
.battery-gauge svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.battery-gauge circle { fill: none; stroke-width: 14; }
.gauge-track { stroke: #e7eff2; }
.gauge-progress { stroke: var(--green); stroke-linecap: round; stroke-dasharray: 452.39; stroke-dashoffset: 452.39; transition: stroke-dashoffset .8s ease; }
.gauge-value { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.gauge-value strong { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.05em; }
.gauge-value span { color: var(--muted); font-size: .82rem; }
.battery-stats { min-width: 210px; margin: 0; }
.battery-stats div { display: flex; justify-content: space-between; gap: 25px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.battery-stats div:last-child { border: 0; }
.battery-stats dt { color: var(--muted); }
.battery-stats dd { margin: 0; font-weight: 850; text-align: right; }
.metric-stack { display: grid; gap: 22px; }
.metric-card { position: relative; min-height: 155px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 20px; padding: 26px; overflow: hidden; text-align: left; border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.metric-card::after { content: ""; position: absolute; width: 180px; height: 180px; right: -75px; top: -90px; border: 30px solid rgba(255,255,255,.28); border-radius: 50%; }
.metric-card:hover { transform: translateY(-3px); box-shadow: 0 24px 60px rgba(9,36,57,.17); }
.metric-card-green { color: #063d31; background: linear-gradient(135deg, #e1f8ef, #bcebdc); }
.metric-card-blue { color: #0d3d68; background: linear-gradient(135deg, #e6f2ff, #bedcf8); }
.metric-icon { width: 54px; height: 54px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 17px; }
.metric-card-blue .metric-icon { background: var(--blue); }
.metric-icon svg { width: 28px; height: 28px; fill: currentColor; }
.metric-copy { display: grid; gap: 4px; }
.metric-label { font-size: .87rem; font-weight: 800; }
.metric-copy strong { font-size: clamp(1.7rem, 4vw, 2.35rem); letter-spacing: -.05em; }
.metric-copy small { opacity: .68; }
.metric-arrow { position: relative; z-index: 1; font-size: 1.6rem; }
.insight-panel { display: flex; align-items: center; gap: 20px; margin-top: 22px; padding: 24px 28px; }
.insight-panel p { margin: 6px 0 0; color: var(--muted); }
.insight-icon { width: 52px; height: 52px; flex: 0 0 52px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 17px; font-size: 1.4rem; font-weight: 900; }
.insight-panel.warning .insight-icon { background: var(--amber); }

.dialog { width: min(720px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; color: var(--ink); background: #fff; border: 0; border-radius: 24px; box-shadow: 0 34px 100px rgba(0,0,0,.34); }
.dialog::backdrop { background: rgba(4, 18, 30, .68); backdrop-filter: blur(5px); }
.dialog > * { margin-left: 30px; margin-right: 30px; }
.dialog > *:last-child { margin-bottom: 30px; }
.dialog-compact { width: min(620px, calc(100% - 32px)); }
.dialog-wide { width: min(1050px, calc(100% - 32px)); }
.dialog-header { position: sticky; z-index: 5; top: 0; display: flex; align-items: start; justify-content: space-between; gap: 20px; margin: 0; padding: 28px 30px 18px; background: #fff; }
.dialog-header h2 { margin: 5px 0 0; font-size: clamp(1.45rem, 4vw, 2.1rem); letter-spacing: -.04em; }
.dialog-close { color: var(--ink); background: var(--surface-soft); border-color: var(--line); font-size: 1.7rem; }
.dialog-lead { color: var(--muted); line-height: 1.6; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; justify-content: end; gap: 10px; }
.settings-list { display: grid; gap: 10px; margin-bottom: 18px; }
.settings-item { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 14px; }
.settings-item strong, .settings-item span { display: block; }
.settings-item span { margin-top: 3px; color: var(--muted); font-size: .84rem; }
.settings-item-actions { display: flex; gap: 6px; }
.mini-button { padding: 7px 10px; color: var(--navy-800); background: #fff; border: 1px solid var(--line); border-radius: 9px; font-weight: 800; }
.mini-button-danger { color: var(--danger); }
.settings-form { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.settings-form h3 { margin: 0; }
.period-tabs { display: flex; gap: 6px; padding: 5px; background: var(--surface-soft); border-radius: 14px; }
.period-tabs button { flex: 1; min-height: 42px; color: var(--muted); background: transparent; border: 0; border-radius: 10px; font-weight: 800; }
.period-tabs button.active { color: var(--navy-900); background: #fff; box-shadow: 0 5px 15px rgba(9,36,57,.08); }
.chart-toolbar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: 14px; margin-top: 22px; text-align: center; }
.chart-toolbar div { display: grid; gap: 4px; }
.chart-period { color: var(--muted); font-size: .88rem; }
.chart-toolbar strong { font-size: 1.65rem; letter-spacing: -.04em; }
.chart-maximum { color: var(--muted); font-size: .8rem; font-weight: 750; }
.period-arrow { width: 44px; height: 44px; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; font-size: 1.25rem; }
.period-arrow:disabled { cursor: not-allowed; opacity: .35; }
.chart-container { min-height: 330px; margin-top: 20px; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(#fff, #fbfdfd); }
.chart-container svg { display: block; min-width: 100%; height: 330px; }
.chart-grid { stroke: #e6eef2; stroke-width: 1; }
.chart-axis-label { fill: #748595; font-size: 11px; }
.chart-point { cursor: pointer; touch-action: pan-x; }
.chart-hit-target { fill: transparent; pointer-events: all; }
.chart-bar { pointer-events: none; fill: var(--green); opacity: .88; transition: opacity .15s; }
.chart-bar.import { fill: var(--blue); }
.chart-point:hover .chart-bar, .chart-point:focus .chart-bar { opacity: 1; outline: none; }
.chart-bar.future { cursor: default; fill: #e5ecef; }
.chart-loading { min-height: 330px; display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--muted); }
.spinner { width: 24px; height: 24px; border: 3px solid #d7e5eb; border-top-color: var(--green); border-radius: 50%; animation: spin .8s linear infinite; }
.chart-focus { min-height: 22px; color: var(--muted); font-size: .9rem; text-align: center; }
.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 14px 17px; color: #fff; background: var(--navy-900); border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: #922f39; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity: .4; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.15); } }

@media (max-width: 900px) {
    .auth-shell { grid-template-columns: 1fr; }
    .auth-panel { padding: 40px 28px; }
    .auth-visual { display: none; }
    .overview-grid { grid-template-columns: 1fr; }
    .metric-stack { grid-template-columns: 1fr 1fr; }
    .metric-card { min-height: 145px; grid-template-columns: auto 1fr; }
    .metric-arrow { display: none; }
}

@media (max-width: 680px) {
    .topbar { padding-inline: 16px; }
    .topbar-brand > span:last-child, .user-chip { display: none; }
    .dashboard-shell { width: min(100% - 24px, 1240px); padding-top: 32px; }
    .dashboard-heading { display: grid; align-items: stretch; }
    .dashboard-controls { display: grid; grid-template-columns: 1fr auto; }
    .point-switcher { min-width: 0; }
    .button-secondary span { display: none; }
    .point-switcher[hidden] + .button { width: 50px; justify-self: end; padding: 0; }
    .battery-layout { flex-direction: column; padding-top: 20px; }
    .battery-gauge { width: 190px; }
    .battery-stats { width: 100%; }
    .metric-stack { grid-template-columns: 1fr; }
    .metric-card { min-height: 130px; }
    .insight-panel { align-items: start; }
    .form-grid { grid-template-columns: 1fr; }
    .dialog { width: 100%; max-width: none; max-height: 94vh; margin: auto 0 0; border-radius: 24px 24px 0 0; }
    .dialog > * { margin-left: 20px; margin-right: 20px; }
    .dialog-header { padding: 22px 20px 15px; }
    .detail-heading { position: static; }
    .period-tabs { overflow-x: auto; }
    .period-tabs button { min-width: 70px; }
    .settings-item { align-items: start; flex-direction: column; }
    .chart-container { min-height: 300px; }
    .chart-container svg { height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
