:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #21262d;
  --border:    rgba(255,255,255,0.08);
  --border-2:  rgba(255,255,255,0.14);
  --text:      #e6edf3;
  --muted:     #7d8590;
  --accent:    #3b82f6;
  --accent-h:  #60a5fa;
  --danger:    #f85149;
  --success:   #3fb950;
  --warning:   #d29922;
  --radius:    8px;
  --radius-lg: 14px;
  --sidebar-w: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; inset: 0 auto 0 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px; font-weight: 700;
}
.sidebar-logo .accent { color: var(--accent); }
.sidebar-logo small { display: block; font-size: 11px; font-weight: 400; color: var(--muted); margin-top: 2px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--muted); font-weight: 500;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}
.sidebar-nav a:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sidebar-nav a.active { color: var(--accent); border-left-color: var(--accent); background: rgba(59,130,246,0.08); }
.sidebar-nav .nav-icon { width: 18px; text-align: center; font-style: normal; }
.sidebar-nav .nav-sep { padding: 16px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); opacity: 0.6; }

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.sidebar-footer strong { color: var(--text); display: block; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex; flex-direction: column;
}

.topbar {
  background: var(--surface);
  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: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

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

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 700; }
.card-body { padding: 22px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-card .stat-val { font-size: 32px; font-weight: 800; letter-spacing: -1px; }
.stat-card .stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Tables ── */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th { padding: 10px 16px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); }
tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 50px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.badge-admin  { background: rgba(59,130,246,0.15);  color: #60a5fa; }
.badge-mod    { background: rgba(168,85,247,0.15);  color: #c084fc; }
.badge-member { background: rgba(125,133,144,0.15); color: var(--muted); }
.badge-pub    { background: rgba(63,185,80,0.15);   color: #3fb950; }
.badge-draft  { background: rgba(210,153,34,0.15);  color: #d29922; }
.badge-open   { background: rgba(59,130,246,0.15);  color: #60a5fa; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border-2); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: transparent; border-color: rgba(248,81,73,0.35); color: var(--danger); }
.btn-danger:hover { background: rgba(248,81,73,0.1); color: var(--danger); }
.btn-success { background: transparent; border-color: rgba(63,185,80,0.35); color: var(--success); }
.btn-success:hover { background: rgba(63,185,80,0.1); color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  transform: translateY(16px); transition: transform 0.2s;
}
.modal-backdrop.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; }
.modal-close:hover { color: var(--text); }

/* ── Alert ── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; border: 1px solid; }
.alert-error   { background: rgba(248,81,73,0.1);   border-color: rgba(248,81,73,0.3);  color: #fca5a5; }
.alert-success { background: rgba(63,185,80,0.1);   border-color: rgba(63,185,80,0.3);  color: #86efac; }
.alert-info    { background: rgba(59,130,246,0.1);  border-color: rgba(59,130,246,0.3); color: #93c5fd; }

/* ── Login page ── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-box {
  background: var(--surface);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%; max-width: 400px;
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .logo-main { font-size: 20px; font-weight: 800; }
.login-logo .logo-main .a { color: var(--accent); }
.login-logo small { font-size: 12px; color: var(--muted); }
.login-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-box .sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }
.totp-digits {
  display: flex; gap: 8px; justify-content: center; margin-bottom: 20px;
}
.totp-digits input {
  width: 44px; height: 52px;
  text-align: center; font-size: 22px; font-weight: 700;
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius); color: var(--text);
}
.totp-digits input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }

/* ── Gallery grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.gallery-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-item-overlay {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.2s;
}
.gallery-item:hover .gallery-item-overlay { opacity: 1; }

/* ── Drop zone ── */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(59,130,246,0.05);
}
.drop-zone .dz-icon { font-size: 36px; margin-bottom: 12px; }
.drop-zone h3 { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.drop-zone p  { font-size: 13px; color: var(--muted); }
.drop-zone input[type=file] { display: none; }

/* ── Progress ── */
.upload-progress { margin-top: 16px; }
.progress-item { margin-bottom: 8px; }
.progress-name { font-size: 12px; margin-bottom: 3px; display: flex; justify-content: space-between; }
.progress-bar-wrap { background: var(--bg); border-radius: 50px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 50px; transition: width 0.3s; }

/* ── 2FA Setup ── */
.qr-wrap { text-align: center; margin: 20px 0; }
.qr-wrap img { border: 8px solid #fff; border-radius: 8px; }
.secret-display {
  background: var(--bg); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 10px 14px;
  font-family: monospace; font-size: 16px; letter-spacing: 2px;
  text-align: center; color: var(--accent); margin: 12px 0;
}

/* ── Misc ── */
.tag {
  display: inline-flex; padding: 2px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
}
.empty-row td { text-align: center; padding: 40px; color: var(--muted); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #a855f7);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}

@media (max-width: 768px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0,0,0,0.5);
  }
  .sidebar.open { transform: translateX(0); }

  /* Overlay hinter der Sidebar */
  .sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 99;
  }
  .sidebar-overlay.open { display: block; }

  .main { margin-left: 0; }

  /* Hamburger-Button sichtbar machen */
  #menu-btn { display: inline-flex !important; }

  .topbar { padding: 0 16px; }
  .content { padding: 16px; }

  /* Sidebar-Footer besser lesbar */
  .sidebar-footer { padding: 16px 20px 24px; }
  .sidebar-footer strong { font-size: 14px; margin-bottom: 2px; }
}
