/* =============================================================
   deenja — Admin-Oberflaeche
   Farben und Bausteine kommen aus theme.css. Lag frueher als
   <style>-Block in admin.html; ausgelagert, damit die CSP ohne
   'unsafe-inline' fuer style-src auskommt.
   ============================================================= */

body { min-height: 100dvh; }

/* ---- Token-Schranke ---- */
#gate {
  display: flex;
  align-items: safe center;
  justify-content: center;
  min-height: 100dvh;
  padding: var(--sp-4);
}
#gate.hidden { display: none; }

.gate-box {
  width: 100%;
  max-width: 24rem;
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  box-shadow: var(--shadow-3);
  text-align: center;
}
.gate-box img { width: 3rem; height: 3rem; margin: 0 auto; }
.gate-box h1 { font-size: var(--fs-xl); }
.gate-box p  { color: var(--muted); font-size: var(--fs-sm); }

/* ---- Geruest ---- */
#app {
  display: none;
  max-width: 62rem;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-7);
}
#app.shown { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-title { display: flex; align-items: center; gap: var(--sp-3); }
.page-title img { width: 2.25rem; height: 2.25rem; }
.page-header h1 { font-size: var(--fs-xl); }
.page-header .sub { display: block; font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.header-actions { display: flex; gap: var(--sp-2); }

.card { margin-bottom: var(--sp-4); }
.card h2 {
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: var(--sp-4);
}
.card-note { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--sp-4); }

/* ---- Kennzahlen ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-1);
}
.stat-box .val {
  font-size: 1.75rem; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.stat-box .lbl { font-size: var(--fs-xs); color: var(--muted); margin-top: 0.25rem; }

/* ---- Verbrauchsbalken ---- */
.prog-wrap { margin-bottom: var(--sp-4); }
.prog-label {
  display: flex; justify-content: space-between;
  font-size: var(--fs-sm); color: var(--muted); margin-bottom: 0.4rem;
}
.prog-bar {
  height: 10px;
  background: var(--surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: var(--r-full);
  transition: width var(--dur-3) var(--ease), background var(--dur-2);
}
.prog-fill.warn   { background: var(--warn); }
.prog-fill.danger { background: var(--danger); }

/* ---- 30-Tage-Verlauf ---- */
.chart { display: flex; align-items: flex-end; gap: 3px; height: 4.5rem; margin-top: var(--sp-3); }
.chart-bar {
  flex: 1;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  opacity: 0.65;
  position: relative;
  transition: opacity var(--dur-1);
}
.chart-bar:hover { opacity: 1; }
.chart-bar[title]:hover::after {
  content: attr(title);
  position: absolute; bottom: 115%; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  padding: 2px 7px;
  font-size: var(--fs-2xs);
  white-space: nowrap;
  pointer-events: none;
  box-shadow: var(--shadow-2);
  z-index: 5;
}

/* ---- Einstellungen ---- */
.config-row {
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.config-row:last-of-type { border-bottom: none; }
.config-label { flex: 1; min-width: 12rem; }
.config-label span { display: block; font-size: var(--fs-base); }
.config-label small { color: var(--muted); font-size: var(--fs-xs); }
.config-input {
  width: 6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 0.4rem 0.6rem;
  font-size: var(--fs-base);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.config-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.config-input-wide { width: 15rem; text-align: left; }

.card-actions { display: flex; align-items: center; gap: var(--sp-4); margin-top: var(--sp-4); flex-wrap: wrap; }

/* Schalter: der Zustand steht als Wort daneben, nicht nur als Farbe —
   Rot/Gruen allein ist fuer Farbenblinde keine Auskunft. */
.toggle-btn {
  min-height: 2.25rem;
  padding: 0.35rem 0.9rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
.toggle-btn.on  { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.toggle-btn.off { background: var(--surface-2); }

/* ---- Sprachen ---- */
.lang-checkboxes { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.lang-check-btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  min-height: 2.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  cursor: pointer;
  font-size: var(--fs-sm);
  transition: background var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
.lang-check-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }

/* ---- Tabellen ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th {
  text-align: left;
  color: var(--muted);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--dur-1); }
tbody tr:hover { background: var(--hover-wash); }
.cell-actions { white-space: nowrap; display: flex; gap: 0.35rem; justify-content: flex-end; }

.token-code {
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  padding: 2px 6px;
  font-size: var(--fs-xs);
}
.copy-btn, .del-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: var(--r-xs);
  color: var(--muted);
  cursor: pointer;
  padding: 3px 7px;
  font-size: var(--fs-xs);
  transition: color var(--dur-1), background var(--dur-1), border-color var(--dur-1);
}
.copy-btn:hover { color: var(--text); border-color: var(--border); background: var(--hover-wash); }
.del-btn { font-size: var(--fs-md); }
.del-btn:hover { color: var(--danger); background: var(--danger-soft); }

.pending-count { margin-left: 0.6rem; vertical-align: middle; }
.empty-row td { color: var(--muted); text-align: center; padding: var(--sp-5); }

/* ---- Einladungen ---- */
.invite-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-bottom: var(--sp-4); }
.invite-form input, .invite-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 0.5rem 0.75rem;
  font-size: var(--fs-sm);
}
.invite-form input:focus, .invite-form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.invite-form input[type="text"] { flex: 1; min-width: 8rem; }

/* ---- Statusmeldungen ---- */
.status-msg { font-size: var(--fs-sm); color: var(--muted); min-height: 1.2em; }
.status-msg.ok  { color: var(--success); }
.status-msg.err { color: var(--danger); }

@media (max-width: 40rem) {
  #app { padding: var(--sp-4) var(--sp-3) var(--sp-6); }
  .card { padding: var(--sp-4); }
  .config-input-wide { width: 100%; }
}
