:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --green: #16a34a;
  --yellow: #d97706;
  --red: #dc2626;
  --grey: #9ca3af;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--accent); text-decoration: none; }

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 1rem .75rem;
}
.sidebar .brand { font-weight: 600; font-size: 1.05rem; padding: .25rem .5rem 1rem; }
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem; border-radius: .5rem; color: var(--ink);
}
.nav a:hover { background: var(--bg); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav svg { width: 18px; height: 18px; }

.sidebar .foot { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--line); }
.ampel { display: flex; align-items: center; gap: .55rem; padding: .5rem .6rem; }
.ampel .dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 12px; }
.ampel.green  .dot { background: var(--green); }
.ampel.yellow .dot { background: var(--yellow); }
.ampel.red    .dot { background: var(--red); }
.ampel.grey   .dot { background: var(--grey); }
.ampel .label { font-weight: 600; }
.ampel .detail { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.logout { margin-top: .25rem; }
.logout button {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  background: none; border: 0; color: var(--muted); cursor: pointer;
  padding: .5rem .6rem; border-radius: .5rem; font: inherit;
}
.logout button:hover { background: var(--bg); color: var(--ink); }
.logout svg { width: 16px; height: 16px; }

.main { flex: 1; padding: 1.5rem 2rem; min-width: 0; }
.main h1 { font-size: 1.4rem; margin: 0 0 1.25rem; }
.topbar { display: none; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: .75rem; padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card h2 { font-size: 1rem; margin: 0 0 .75rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.device-name { display: flex; align-items: center; gap: .5rem; }
.device-icon svg { width: 20px; height: 20px; flex-shrink: 0; }

.activity-filter { display: flex; align-items: center; gap: .6rem; }
.activity-filter select { padding: .4rem .5rem; border: 1px solid var(--line); border-radius: .5rem; font: inherit; }
.activity-type { display: flex; align-items: center; gap: .5rem; }
.activity-icon svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
#activity-sentinel td { text-align: center; padding: .75rem; }

.detail-back { margin: 0 0 .5rem; font-size: .9rem; }
.detail-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; color: var(--muted); margin: 0 0 1.25rem; }
.detail-meta .activity-icon svg { width: 18px; height: 18px; flex-shrink: 0; }
.metric-group + .metric-group { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--line); }
.metric-group h2 { font-size: .95rem; margin: 0 0 .7rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem 1.2rem; }
.metric { display: flex; flex-direction: column; gap: .1rem; }
.metric-label { color: var(--muted); font-size: .8rem; }
.metric-value { font-size: 1.05rem; font-weight: 600; }
.zones { display: flex; flex-direction: column; gap: .5rem; }
.zone-row { display: grid; grid-template-columns: minmax(90px, 1.2fr) 3fr auto auto; align-items: center; gap: .7rem; font-size: .85rem; }
.zone-name { color: var(--muted); }
.zone-bar { display: block; background: var(--bg); border-radius: .4rem; height: 14px; overflow: hidden; }
.zone-fill { display: block; background: var(--accent); height: 100%; }
.zone-time { text-align: right; font-variant-numeric: tabular-nums; }
.zone-pct { text-align: right; color: var(--muted); min-width: 3.5ch; font-variant-numeric: tabular-nums; }

.totals { display: flex; gap: 2.5rem; flex-wrap: wrap; }
.totals div strong { display: block; font-size: 1.5rem; }
.totals div span { color: var(--muted); font-size: .85rem; }

.badge { display: inline-block; padding: .1rem .55rem; border-radius: .75rem; font-size: .8rem; color: #fff; }
.badge.state-idle { background: #6b7280; }
.badge.state-running { background: var(--green); }
.badge.state-sleeping { background: var(--accent); }
.ok { color: var(--green); }
.fail { color: var(--red); }
.muted { color: var(--muted); }
.error-box { background: #fdecec; border: 1px solid #f5c2c0; color: #7f1d1d; padding: .9rem 1rem; border-radius: .6rem; margin-bottom: 1.25rem; }

.login-wrap { max-width: 340px; margin: 12vh auto; }
.login-wrap .card { text-align: left; }
.login-wrap label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.login-wrap input[type=password] { width: 100%; padding: .55rem .6rem; border: 1px solid var(--line); border-radius: .5rem; font: inherit; }
.login-wrap button { margin-top: .9rem; width: 100%; padding: .6rem; background: var(--accent); color: #fff; border: 0; border-radius: .5rem; font: inherit; cursor: pointer; }
.login-wrap .brand { display: flex; align-items: center; gap: .5rem; justify-content: center; font-weight: 600; margin-bottom: 1rem; }

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; flex: none; flex-direction: column; }
  .sidebar[x-data] .nav, .sidebar .foot { display: var(--nav-display, none); }
  .sidebar.open .nav, .sidebar.open .foot { display: flex; }
  .topbar { display: flex; align-items: center; gap: .5rem; }
}

.stack { display: flex; flex-direction: column; gap: 1rem; max-width: 460px; }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field > label { font-size: .85rem; color: var(--muted); }
.field input[type=number], .field input[type=text], .field input[type=date] {
  padding: .5rem .6rem; border: 1px solid var(--line); border-radius: .5rem; font: inherit; max-width: 260px;
}
.field-check label { display: flex; align-items: center; gap: .5rem; color: var(--ink); font-size: .95rem; }
.field-error { color: var(--red); font-size: .82rem; }
.stack button { align-self: flex-start; padding: .55rem 1.1rem; background: var(--accent); color: #fff; border: 0; border-radius: .5rem; font: inherit; cursor: pointer; }
.stack button:hover { filter: brightness(.95); }
.account-form { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-top: 1.1rem; }
.account-form:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.account-email { margin: 0; font-size: .9rem; }
.flash-ok { background: #e9f7ee; border: 1px solid #b7e0c4; color: #14532d; padding: .9rem 1rem; border-radius: .6rem; margin-bottom: 1.25rem; }

/* Scheibe 4c: Karte und Höhenprofil der Aktivitäts-Detailansicht */
.activity-map { height: 380px; border-radius: .5rem; position: relative; z-index: 0; }
.activity-map + .elevation { margin-top: 1rem; }
.elevation { display: block; width: 100%; height: 120px; }
.elevation-area { fill: var(--accent-soft); }
.elevation-line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.elevation-caption { margin: .4rem 0 0; font-size: .82rem; color: var(--muted); }

@media (max-width: 700px) {
  .activity-map { height: 260px; }
  .elevation { height: 90px; }
}
