/* VoltLog – Mobile-First-Design */
:root {
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #6b7280;
  --line: #e5e8ec;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --accent-soft: #e7f6ec;
  --danger: #dc2626;
  --warn-bg: #fff7e6;
  --warn-line: #f2c14e;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --card: #1a1f26;
    --text: #e8eaed;
    --muted: #98a1ad;
    --line: #2a313a;
    --accent: #22c55e;
    --accent-soft: #14321f;
    --warn-bg: #2b2410;
    --warn-line: #8a6d1f;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.center { text-align: center; }
.spacer { flex: 1; }
.r { text-align: right; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card); border-bottom: 1px solid var(--line);
  padding: 10px 16px;
}
.brand { font-size: 1.05rem; }

/* Inhalt */
.content {
  max-width: 960px; margin: 0 auto;
  padding: 16px 14px calc(84px + env(safe-area-inset-bottom));
}
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.section-title { margin: 18px 0 10px; font-weight: 600; }

/* Tabbar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: .62rem; padding: 4px 2px; border-radius: 8px; }
.tabbar a .ico { font-size: 1.15rem; line-height: 1; }
.tabbar a.active { color: var(--accent); font-weight: 600; }
@media (min-width: 720px) {
  .tabbar a { flex-direction: row; gap: 6px; font-size: .85rem; }
  .tabbar a .ico { font-size: 1rem; }
}

/* Karten */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.row-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.row-actions-td { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }
.row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row-title { font-weight: 600; }
.row-actions { display: flex; gap: 6px; }
.empty { text-align: center; padding: 28px 14px; }
.err-code { font-size: 2.4rem; font-weight: 700; color: var(--muted); }

/* KPIs */
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 720px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
.kpi { display: flex; flex-direction: column; gap: 2px; margin-bottom: 0; }
.kpi-label { color: var(--muted); font-size: .8rem; }
.kpi-value { font-size: 1.15rem; font-weight: 700; }
.kpi-delta { font-size: .78rem; }
.kpi-delta.up { color: var(--accent); }
.kpi-delta.down { color: var(--danger); }

/* Filter */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; flex: 1; min-width: 100%; }
@media (min-width: 720px) { .filter-grid { grid-template-columns: repeat(3, 1fr); } }
.filter-actions { display: flex; gap: 8px; }
.list-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.sort-group { display: flex; gap: 6px; flex-wrap: wrap; }

/* Eingaben */
input, select, textarea {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 12px; width: 100%; min-height: 44px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type="date"], input[type="datetime-local"], input[type="time"] { min-width: 0; }
label { display: flex; flex-direction: column; gap: 5px; font-size: .88rem; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { color: var(--text); }
textarea { min-height: 0; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sub-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sub-fields[hidden] { display: none; }
.sub-label { margin-bottom: 8px; }
.sub-label[hidden] { display: none; }

/* Checkbox-Zeile (Kontrolliert) */
.check-line { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.check-line input { width: 20px; min-height: 20px; margin: 0; }

/* Abhaken-Button */
.check-btn {
  width: 38px; height: 38px; min-height: 38px; border-radius: 50%;
  border: 1.5px solid var(--line); background: transparent; color: var(--muted);
  font-size: 1.05rem; font-weight: 700; cursor: pointer; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.check-btn:hover { border-color: var(--accent); color: var(--accent); }
.check-btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.hint { color: var(--muted); font-size: .82rem; min-height: 1em; margin: 4px 0 10px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 10px; }
.seg-opt { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 10px; font-size: .9rem; cursor: pointer; color: var(--text); margin: 0; flex-direction: row; }
.seg-opt input { width: auto; min-height: 0; margin: 0; }
.seg-opt:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.form-card label, .form-card select, .form-card textarea { margin-bottom: 10px; }
.form-legend { margin: 16px 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.form-legend:first-child { margin-top: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 14px; }
.form-actions.wrap { flex-wrap: wrap; }
.form-actions form { display: flex; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 10px;
  padding: 11px 16px; min-height: 44px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn-secondary { background: var(--card); color: var(--text); border-color: var(--line); }
.btn-secondary:hover { background: var(--line); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn-small { padding: 7px 11px; min-height: 34px; font-size: .85rem; border-radius: 8px; }
.btn-block { flex: 1; width: 100%; }

/* Ladevorgang-Karten */
.sess-card { border-left: 4px solid var(--accent); }
.sess-card.is-open { border-left-color: var(--warn-line); background: var(--warn-bg); }
.sess-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.sess-ort { font-weight: 600; }
.sess-metrics { display: flex; flex-wrap: wrap; gap: 4px 8px; margin: 6px 0; }
.dot { width: 4px; height: 4px; border-radius: 50%; background: var(--muted); align-self: center; }
.sess-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.badge-warn { background: var(--warn-line); color: #3a2c00; }
.badge-ok { background: var(--accent-soft); color: var(--accent); }

/* Flashes */
.flash-stack { margin-bottom: 12px; }
.flash { border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; font-size: .92rem; border: 1px solid var(--line); }
.flash-success { background: var(--accent-soft); border-color: var(--accent); }
.flash-error { background: color-mix(in srgb, var(--danger) 12%, var(--card)); border-color: var(--danger); }
.flash-info { background: var(--card); }
.err-list { margin: 0; padding-left: 18px; }

/* Unvollständig- & Kontrolle-Widgets */
.widget-stack { display: flex; flex-direction: column; }
.warn-card { background: var(--warn-bg); border-color: var(--warn-line); }
.check-card { background: var(--accent-soft); }
.open-list, .check-list { list-style: none; margin: 10px 0 0; padding: 0; }
.open-list li, .check-list li { border-top: 1px solid var(--line); }
.open-list li:last-child, .check-list li:last-child { border-bottom: 1px solid var(--line); }
.open-list a { display: flex; justify-content: space-between; padding: 8px 2px; gap: 8px; }
.check-list li { display: flex; align-items: center; gap: 8px; }
.check-row-main { flex: 1; display: flex; justify-content: space-between; gap: 8px; padding: 8px 2px; }
.open-ort { font-weight: 600; }
.btn-link { color: var(--accent); font-weight: 600; }

/* Page actions */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--line); border-radius: 12px;
  padding: 32px 16px; text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
  color: var(--text);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: var(--accent-soft);
}
.upload-icon { font-size: 2.4rem; display: block; margin-bottom: 8px; }

/* Charts */
.grid-2 { display: grid; gap: 12px; }
.grid-3 { display: grid; gap: 12px; }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 52px 1fr 74px; align-items: center; gap: 8px; }
.bar-label { font-size: .78rem; color: var(--muted); }
.bar-track { background: var(--line); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 6px; background: var(--accent); }
.bar-fill.w { background: #3b82f6; }
.bar-value { font-size: .78rem; text-align: right; white-space: nowrap; }
.chart-wrap { display: grid; grid-template-columns: 46px 1fr; gap: 6px; align-items: center; }
.linechart { width: 100%; height: 130px; }
.linechart polyline, .linechart circle { vector-effect: non-scaling-stroke; }
.linechart circle { fill: var(--accent); }
.y-label { font-size: .72rem; color: var(--muted); text-align: center; }

/* Großer Verlaufs-Chart */
.chart-card h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.bigchart-wrap { width: 100%; }
.bigchart { width: 100%; height: auto; display: block; }
.bigchart .grid-line { stroke: var(--line); stroke-width: 1; }
.bigchart .axis-label { fill: var(--muted); font-size: 17px; font-family: inherit; }
.bigchart .tline { stroke: var(--accent); stroke-width: 2.5; opacity: .85; }
.bigchart .tl-dot { fill: var(--accent); opacity: .85; }
.bigchart .dt-on { fill: var(--accent); }
.bigchart .dt-off { fill: var(--muted); opacity: .55; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: .82rem; align-items: center; }
.lg-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.lg-dot.on { background: var(--accent); }
.lg-dot.off { background: var(--muted); opacity: .55; }
.lg-line { display: inline-block; width: 18px; height: 0; border-top: 2.5px solid var(--accent); opacity: .85; margin-right: 5px; vertical-align: 3px; }

/* Statistik-Strip unter Filter */
.stats-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 0 0 12px; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: .92rem; }

/* Tabellen */
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; padding: 4px; }
.table td { padding: 7px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.kv { width: 100%; font-size: .92rem; }
.kv td { padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv td:first-child { color: var(--muted); width: 110px; }

/* Login */
.login-wrap { min-height: 62vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 360px; text-align: center; }
.login-card label { text-align: left; }
.login-logo { font-size: 2.6rem; }
.login-card h1 { margin: 6px 0 0; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 8px 0 4px; }
