*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green: #15803d;
  --green-pale: #f0fdf4;
  --green-border: #bbf7d0;
  --yellow: #fbbf24;
  --red: #dc2626;
  --text-primary: #111827;
  --text-secondary: #374151;
  --text-tertiary: #6b7280;
  --bg: #f3f4f6;
  --bg-secondary: #e5e7eb;
  --white: #ffffff;
  --border: rgba(0,0,0,.1);
  --radius: 14px;
  --radius-md: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100dvh;
}

/* ── App Shell ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

/* ── Header ── */
header {
  background: var(--green);
  padding: 10px 20px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-left h1 { color: white; font-size: 18px; font-weight: 500; }
.header-left p  { color: rgba(255,255,255,.7); font-size: 12px; margin-top: 2px; }
.header-icon { width: 36px; height: 36px; flex-shrink: 0; }

/* ── Bottom Nav ── */
nav {
  background: var(--white);
  border-top: 0.5px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  padding: 10px 0 calc(18px + env(safe-area-inset-bottom));
}
nav button {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-tertiary);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
nav button i { font-size: 22px; }
nav button.active { color: var(--green); }

/* ── Main ── */
main {
  flex: 1;
  padding: 16px 16px calc(80px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  padding: 14px 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-tertiary);
  margin-bottom: 10px;
}

/* ── Status badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--green-pale);
  border-radius: 20px;
  padding: 4px 12px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
}
.status-badge span { font-size: 13px; color: var(--green); font-weight: 500; }

.status-badge.charging { background: #fef3c7; }
.status-badge.charging .status-dot { background: var(--yellow); animation: pulse 1.4s infinite; }
.status-badge.charging span { color: #92400e; }
.status-badge.offline { background: #f3f4f6; }
.status-badge.offline .status-dot { background: #9ca3af; }
.status-badge.offline span { color: var(--text-tertiary); }
.status-badge.error { background: #fee2e2; }
.status-badge.error .status-dot { background: var(--red); }
.status-badge.error span { color: var(--red); }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Power display ── */
.status-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.status-time { font-size: 12px; color: var(--text-tertiary); }
.power-row { display: flex; align-items: baseline; gap: 4px; margin-bottom: 4px; }
.power-val { font-size: 36px; font-weight: 500; color: var(--text-primary); }
.power-unit { font-size: 16px; color: var(--text-secondary); }
.power-sub { font-size: 12px; color: var(--text-tertiary); }

/* ── Session grid (Übersicht aktive Ladung) ── */
.session-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.session-cell { text-align: center; }
.session-cell .val { font-size: 16px; font-weight: 500; color: var(--text-primary); }
.session-cell .lbl { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Stats mini grid ── */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat-card { background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border); padding: 12px 14px; }
.stat-card .lbl { font-size: 11px; color: var(--text-tertiary); margin-bottom: 4px; }
.stat-card .val { font-size: 22px; font-weight: 500; color: var(--text-primary); }
.stat-card .sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }

/* ── Last session (on dashboard) ── */
.last-row { display: flex; justify-content: space-between; align-items: center; }
.last-info { font-size: 13px; color: var(--text-primary); }
.last-meta { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.last-kwh { font-size: 20px; font-weight: 500; color: var(--text-primary); text-align: right; }
.last-kwh-lbl { font-size: 11px; color: var(--text-tertiary); text-align: right; }

/* ── History ── */
.month-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 8px;
}
.month-total {
  background: var(--green-pale);
  border-radius: var(--radius-md);
  border: 0.5px solid var(--green-border);
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.month-total .lbl { font-size: 12px; color: var(--green); }
.month-total .val { font-size: 15px; font-weight: 500; color: var(--green); }
.history-item {
  background: var(--white);
  border-radius: var(--radius);
  border: 0.5px solid var(--border);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-left .date { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.history-left .meta { font-size: 11px; color: var(--text-tertiary); margin-top: 3px; }
.history-right { text-align: right; flex-shrink: 0; margin-left: 12px; }
.history-right .kwh { font-size: 18px; font-weight: 500; color: var(--text-primary); }
.history-right .unit { font-size: 11px; color: var(--text-tertiary); }

/* ── Stats bars ── */
.chart-card { background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border); padding: 14px 16px; margin-bottom: 12px; }
.chart-title { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }
.bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.bar-month { font-size: 11px; color: var(--text-secondary); width: 28px; text-align: right; flex-shrink: 0; }
.bar-wrap { flex: 1; background: var(--bg-secondary); border-radius: 3px; height: 18px; }
.bar-fill { background: var(--green); border-radius: 3px; height: 18px; display: flex; align-items: center; padding-left: 6px; min-width: 28px; }
.bar-fill span { font-size: 10px; color: white; white-space: nowrap; }
.bar-fill.dim { background: var(--green-border); }
.bar-fill.dim span { color: var(--green); }

/* ── Account ── */
.avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--green-pale);
  border: 2px solid var(--green);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
}
.avatar span { font-size: 22px; font-weight: 500; color: var(--green); }
.account-name { text-align: center; font-size: 16px; font-weight: 500; color: var(--text-primary); }
.account-we   { text-align: center; font-size: 12px; color: var(--text-tertiary); margin-top: 3px; margin-bottom: 20px; }
.section-label { font-size: 11px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.menu-card { background: var(--white); border-radius: var(--radius); border: 0.5px solid var(--border); margin-bottom: 12px; overflow: hidden; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 0.5px solid var(--border);
  cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }
.menu-item > i, .menu-item > svg { width: 20px; height: 20px; color: var(--text-secondary); flex-shrink: 0; }
.menu-item > i { font-size: 18px; }
.menu-item .text { flex: 1; }
.menu-item .text .title { font-size: 14px; color: var(--text-primary); }
.menu-item .text .sub { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.menu-item .chevron { font-size: 16px; color: var(--text-tertiary); }
.menu-item.danger > i { color: var(--red); }
.menu-item.danger .title { color: var(--red); }
.version { text-align: center; font-size: 11px; color: var(--text-tertiary); margin-top: 8px; }

/* ── Password form (inline in menu) ── */
.pw-form-wrap { padding: 12px 16px; border-top: 0.5px solid var(--border); display: none; }
.pw-form-wrap.open { display: block; }
.form-group { margin-bottom: 12px; }
label { display: block; font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin-bottom: 5px; text-transform: uppercase; letter-spacing: .04em; }
input[type=password], input[type=text] {
  width: 100%; padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 8px;
  font-size: .9rem; color: var(--text-primary);
  background: var(--white);
  outline: none;
}
input:focus { border-color: var(--green); }
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 16px; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; border: none;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--green); color: white; width: 100%; }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-secondary { background: var(--bg); color: var(--text-primary); border: 1px solid var(--border); }

/* ── Messages ── */
.error-msg { background: #fee2e2; color: var(--red); border-radius: 8px; padding: 9px 12px; font-size: .82rem; margin-bottom: 10px; display: none; }
.error-msg.show { display: block; }
.info-msg { background: var(--green-pale); color: var(--green); border-radius: 8px; padding: 9px 12px; font-size: .82rem; margin-bottom: 10px; display: none; }
.info-msg.show { display: block; }

/* ── Login ── */
#login-screen {
  min-height: 100dvh;
  background: var(--green);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
}
.login-logo { margin-bottom: 20px; }
.login-title { color: white; font-size: 22px; font-weight: 600; margin-bottom: 4px; }
.login-sub { color: rgba(255,255,255,.7); font-size: 13px; margin-bottom: 28px; }
.login-card { background: white; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 340px; }
.login-card select {
  width: 100%; padding: 10px 12px;
  border: 1px solid rgba(0,0,0,.15);
  border-radius: 8px; font-size: .9rem;
  color: var(--text-primary); background: white;
  appearance: none; -webkit-appearance: none; outline: none;
}
.login-card select:focus, .login-card input:focus { border-color: var(--green); }

/* ── Misc ── */
.spinner { width: 20px; height: 20px; border: 2px solid rgba(0,0,0,.1); border-top-color: var(--green); border-radius: 50%; animation: spin .7s linear infinite; margin: 32px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.load-more { text-align: center; margin-top: 4px; }
.load-more button { background: none; border: none; color: var(--green); font-size: 13px; font-weight: 500; padding: 10px; cursor: pointer; }
