:root {
  --bg-primary: #0b0f19;
  --bg-secondary: #131b2e;
  --bg-card: #1e293b;
  --bg-card-hover: #27354d;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-orange: #f59e0b;
  --accent-red: #ef4444;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-radius: 16px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  padding-top: var(--safe-area-top);
  padding-bottom: calc(var(--safe-area-bottom) + 20px);
  overflow-x: hidden;
  user-select: none;
}

/* CARDS & CONTAINERS */
.app-container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 18px;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

/* HEADER */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  border-radius: 12px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.header-logo-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.auth-logo-img {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.app-header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* BADGES */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-disconnected {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-connected {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-info {
  background: rgba(6, 182, 212, 0.2);
  color: #67e8f9;
  border: 1px solid rgba(6, 182, 212, 0.4);
}

/* BUTTONS */
.btn {
  border: none;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: #334155;
  color: #f1f5f9;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-ble {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
  border-radius: 8px;
}

/* LIVE STATS */
.live-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.stat-box {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.1;
  color: #ffffff;
}

.stat-value .unit {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-left: 4px;
  font-weight: 500;
}

.stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.progress-bar-bg {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-top: 8px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  border-radius: 4px;
  transition: width 0.4s ease;
}

/* TABS */
.tab-nav {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: var(--bg-secondary);
  padding: 6px;
  border-radius: 14px;
  gap: 6px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.tab-icon {
  font-size: 1.2rem;
}

/* FILTERS & CONTROLS */
.filter-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-group {
  display: flex;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 10px;
}

.btn-filter {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
}

.btn-filter.active {
  background: var(--accent-blue);
  color: white;
}

.select-row {
  display: flex;
  gap: 10px;
}

.form-select, .form-control {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: white;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.95rem;
  outline: none;
}

.form-select:focus, .form-control:focus {
  border-color: var(--accent-blue);
}

.summary-banner {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
}

/* CHARTS */
.chart-card {
  position: relative;
  min-height: 280px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* REICHWEITE & LADELISTE */
.formula-box {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--accent-cyan);
  overflow-x: auto;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.charge-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.charge-item {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 14px;
  border-left: 4px solid var(--accent-green);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.charge-info h5 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 3px;
}

.charge-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.charge-metric {
  text-align: right;
}

.metric-efficiency {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--accent-cyan);
}

.metric-days {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* FORMS & DEBUG */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-grid label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.btn-row {
  display: flex;
  gap: 10px;
}

.debug-console {
  background: #000000;
  color: #38bdf8;
  font-family: monospace;
  font-size: 0.75rem;
  padding: 10px;
  border-radius: 8px;
  max-height: 180px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* OVERLAY / AUTH GUARD */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 9999;
}

.auth-card, .modal-card {
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.auth-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.input-group input {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: white;
  padding: 14px;
  border-radius: 12px;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 2px;
  font-weight: 700;
  outline: none;
}

.input-group input:focus {
  border-color: var(--accent-blue);
}

.auth-info {
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.error-msg {
  color: var(--accent-red);
  font-size: 0.85rem;
  margin-top: 10px;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }

/* REICHWEITE KPI GRID */
.reichweite-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.rw-stat {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}

.rw-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.rw-val {
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
}

.rw-val small {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.text-accent-cyan {
  color: var(--accent-cyan) !important;
}

.text-accent-green {
  color: var(--accent-green) !important;
}

