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

:root {
  --accent: #c4622d;
  --accent-bg: #f8ede6;
  --bg0: #f5f5f5;
  --bg1: #ffffff;
  --bg2: #f9f9f9;
  --border: #e8e8e8;
  --border2: #d0d0d0;
  --text1: #1a1a1a;
  --text2: #555555;
  --text3: #999999;
  --success: #2e7d32;
  --success-bg: #e8f5e9;
  --warning: #e65100;
  --warning-bg: #fff3e0;
  --danger: #c62828;
  --danger-bg: #fce8e8;
  --info: #1565c0;
  --info-bg: #e3f2fd;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg0);
  color: var(--text1);
  font-size: 14px;
  line-height: 1.5;
}

/* ── LAYOUT ──────────────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: var(--bg1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.sidebar-logo-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text3);
  padding: 12px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  transition: background .12s, color .12s;
  border-radius: 0;
}

.nav-item:hover { background: var(--bg2); color: var(--text1); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; border-right: 2px solid var(--accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.main {
  margin-left: 220px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--bg1);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text1);
}

.content {
  padding: 28px;
  flex: 1;
}

/* ── KOMPONENTEN ──────────────────────────────────────────── */
.card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text1);
}

.card-body { padding: 20px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text1);
  line-height: 1;
}

.kpi-label {
  font-size: 12px;
  color: var(--text3);
  margin-top: 6px;
}

.kpi-delta {
  font-size: 11px;
  color: var(--success);
  margin-top: 4px;
}

/* Tabelle */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text3);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text1);
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg2); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-default { background: var(--bg2); color: var(--text3); border: 1px solid var(--border); }
.badge-free { background: #e8f5e9; color: #1b5e20; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--bg1);
  color: var(--text1);
  transition: all .12s;
  white-space: nowrap;
}

.btn:hover { background: var(--bg2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; background: var(--accent); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #e57373; }
.btn-success { background: var(--success-bg); color: var(--success); border-color: #81c784; }
.btn-xs { padding: 4px 10px; font-size: 11px; border-radius: 5px; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text1);
  background: var(--bg1);
  outline: none;
  transition: border-color .12s;
}
.form-control:focus { border-color: var(--accent); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg1);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.16);
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 15px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text3); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  animation: slideIn .2s ease;
  box-shadow: var(--shadow);
  max-width: 320px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Spinner */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Auth screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg0);
  padding: 20px;
}

.auth-card {
  background: var(--bg1);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.auth-logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 28px;
}

/* Hilfs */
.hidden { display: none !important; }
.text-muted { color: var(--text3); font-size: 12px; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }

/* MRR Chart */
.mrr-bars {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 80px;
  padding-top: 8px;
}

.mrr-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
}

.mrr-bar-fill {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  opacity: 0.8;
  min-height: 4px;
  transition: height .3s ease;
}

.mrr-bar-label {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
}

/* Toggle */
.toggle {
  width: 40px; height: 22px;
  background: var(--border2);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 2px; left: 2px;
  transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 20px; }
