:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel-border: #334155;
  --ink: #f8fafc;
  --muted: #94a3b8;
  --line: #334155;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --green: #22c55e;
  --red: #ef4444;
  --gold: #eab308;
  --shadow: 0 12px 35px rgba(0, 0, 0, .4);
  --radius: 16px;
}

* { box-sizing: border-box; }
body { 
  margin: 0; 
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; 
  background: var(--bg); 
  color: var(--ink); 
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.error-text { 
  color: #fca5a5; 
  background: #451a1a; 
  padding: 10px 12px; 
  border-radius: 10px; 
  margin-bottom: 12px;
}

.screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-screen { background: radial-gradient(circle at 50% 0%, #1e293b 0, var(--bg) 60%); }
.login-card { 
  width: min(430px, 100%); 
  background: var(--panel); 
  border: 1px solid var(--panel-border); 
  border-radius: 24px; 
  padding: 34px; 
  box-shadow: var(--shadow); 
  text-align: center; 
}

.login-logo { width: 110px; height: 110px; object-fit: contain; margin-bottom: 14px; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .13em; color: var(--primary); text-transform: uppercase; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: 28px; }
h2 { font-size: 28px; margin: 4px 0 6px; }
h3 { margin-bottom: 6px; }

.login-card form { text-align: left; margin-top: 24px; }
label { display: grid; gap: 7px; font-weight: 700; font-size: 13px; margin: 0 0 16px; }

input, textarea, select { 
  width: 100%; 
  border: 1px solid var(--panel-border); 
  border-radius: 12px; 
  padding: 12px 13px; 
  background: #0f172a; 
  color: var(--ink); 
  outline: none; 
  transition: .15s; 
}

input:focus, textarea:focus, select:focus { 
  border-color: var(--primary); 
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .25); 
}

button { border: 0; border-radius: 12px; padding: 11px 15px; font-weight: 800; transition: .15s; }
.primary { background: var(--primary); color: #fff; box-shadow: 0 4px 14px rgba(59, 130, 246, .3); }
.primary:hover { background: var(--primary-dark); }
.ghost { background: var(--panel); color: var(--ink); border: 1px solid var(--panel-border); }
.ghost:hover { background: #334155; }
.wide { width: 100%; }
.small { padding: 8px 11px; font-size: 12px; }

.security-note { margin: 18px 0 0; color: var(--muted); font-size: 12px; }

.app { min-height: 100vh; display: flex; flex-direction: column; }

/* HEADER */
.topbar { 
  position: sticky; 
  top: 0; 
  z-index: 20; 
  min-height: 76px; 
  background: rgba(30, 41, 59, .95); 
  backdrop-filter: blur(12px); 
  border-bottom: 1px solid var(--panel-border); 
  display: flex; 
  justify-content: center; 
  align-items: center; 
  padding: 8px 28px; 
  position: relative;
}

.brand-center { 
  display: flex; 
  align-items: center; 
  gap: 14px; 
}

.brand-text { 
  font-size: 18px; 
  font-weight: 900; 
  letter-spacing: 0.05em; 
  color: var(--ink); 
}

.header-logo { 
  width: 55px; 
  height: 55px; 
  object-fit: contain; 
  display: block; 
}

.account-area { 
  position: absolute; 
  right: 28px; 
  display: flex; 
  align-items: center; 
  gap: 10px; 
  color: var(--muted); 
  font-size: 12px; 
  font-weight: 400; 
}

/* NAVIGATION */
.nav-tabs { display: flex; justify-content: center; gap: 6px; padding: 12px 18px; background: #0f172a; border-bottom: 1px solid var(--panel-border); }
.nav-tab { background: transparent; color: var(--muted); border-radius: 10px; padding: 9px 14px; }
.nav-tab.active { background: var(--panel); color: var(--primary); font-weight: 900; border: 1px solid var(--panel-border); }

/* MAIN CONTENT */
.main-content { width: min(1240px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 70px; flex: 1; }
.view { display: none; }
.active-view { display: block; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.heading-actions { display: flex; gap: 10px; align-items: center; }
.active-toggle { background: var(--primary) !important; color: #fff !important; }

.search { width: min(270px, 45vw); }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--panel); border: 1px solid var(--panel-border); border-radius: 16px; padding: 17px 19px; box-shadow: var(--shadow); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 700; }
.stat-card strong { display: block; font-size: 26px; margin-top: 4px; color: var(--ink); }

.panel { background: var(--panel); border: 1px solid var(--panel-border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.padding-panel { padding: 24px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--panel-border); }
.panel-head h3 { margin: 0; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 20px; border-bottom: 1px solid var(--panel-border); text-align: left; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
td { font-size: 14px; }
tbody tr:hover { background: #26334d; }

.student-name { font-weight: 800; color: var(--ink); }
.points { font-size: 18px; font-weight: 900; }
.points.positive { color: var(--green); }
.points.negative { color: var(--red); }

.actions { display: flex; gap: 7px; flex-wrap: wrap; }
.icon-btn { min-width: 39px; height: 36px; padding: 0 11px; display: inline-grid; place-items: center; border: 1px solid var(--panel-border); background: #0f172a; color: var(--ink); border-radius: 10px; font-weight: 800; }
.icon-btn.plus { color: var(--green); border-color: rgba(34, 197, 94, .3); }
.icon-btn.minus { color: var(--red); border-color: rgba(239, 68, 68, .3); }
.icon-btn:hover { background: #334155; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty-icon { font-size: 36px; margin-bottom: 8px; }

/* MASSENPUNKTE GRID */
.mass-selection-head { display: flex; justify-content: space-between; align-items: center; margin: 24px 0 14px; border-top: 1px solid var(--panel-border); padding-top: 18px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; max-height: 320px; overflow-y: auto; padding: 4px; }
.checkbox-item { display: flex; align-items: center; gap: 10px; background: #0f172a; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--panel-border); cursor: pointer; }
.checkbox-item input { width: auto; }

/* RANGLISTE BADGES */
.rank-badge { font-weight: 900; font-size: 16px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: #0f172a; border: 1px solid var(--panel-border); }
.rank-1 { background: #854d0e; color: #fef08a; border-color: var(--gold); }
.rank-2 { background: #334155; color: #f1f5f9; border-color: #94a3b8; }
.rank-3 { background: #7c2d12; color: #ffedd5; border-color: #f97316; }

/* MANAGE */
.manage-list { display: grid; }
.manage-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--panel-border); }
.manage-row:last-child { border-bottom: 0; }
.status { font-size: 11px; color: var(--green); font-weight: 800; }
.status.inactive { color: var(--muted); }

/* SETTINGS */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.settings-card { padding: 22px; }
.settings-card h3 { margin-bottom: 4px; }
.settings-card button { margin: 8px 8px 0 0; }
.backup-note { margin-top: 14px; padding: 11px 12px; border-radius: 10px; background: #0f172a; color: var(--muted); font-size: 12px; line-height: 1.5; border: 1px solid var(--panel-border); }

/* MODALS */
.modal { border: 0; padding: 0; background: transparent; max-width: min(560px, calc(100% - 28px)); width: 100%; color: var(--ink); }
.modal::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); }
.modal-card { position: relative; background: var(--panel); border: 1px solid var(--panel-border); border-radius: 22px; padding: 28px; box-shadow: var(--shadow); }
.modal-close { position: absolute; right: 14px; top: 12px; width: 36px; height: 36px; border-radius: 10px; background: #0f172a; color: var(--ink); border: 1px solid var(--panel-border); font-size: 22px; }
.modal-icon { width: 44px; height: 44px; border-radius: 13px; background: #0f172a; color: var(--primary); display: grid; place-items: center; font-size: 21px; margin-bottom: 13px; border: 1px solid var(--panel-border); }
.modal-card h3 { font-size: 24px; margin: 4px 0 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* TOASTS */
#toast-root { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: grid; gap: 8px; }
.toast { background: var(--panel); color: #fff; padding: 12px 15px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px; border: 1px solid var(--panel-border); animation: toast-in .18s ease-out; }
.toast.error { background: #7f1d1d; border-color: #ef4444; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* FOOTER */
.app-footer { text-align: right; padding: 16px 28px; color: var(--muted); font-size: 12px; font-weight: 700; border-top: 1px solid var(--panel-border); background: var(--panel); }

@media (max-width: 800px) {
  .topbar { padding: 8px 14px; justify-content: space-between; }
  .brand-text { font-size: 14px; }
  .header-logo { width: 40px; height: 40px; }
  .account-area { position: static; }
  .nav-tabs { overflow-x: auto; justify-content: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
  .settings-grid, .form-grid { grid-template-columns: 1fr; }
}