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

:root {
  --bg: #0b0d13;
  --bg2: #111420;
  --card: #161a26;
  --card-hover: #1c2133;
  --border: #242940;
  --primary: #6c63ff;
  --primary-light: #8b83ff;
  --green: #22c55e;
  --green-bg: rgba(34,197,94,0.1);
  --red: #ef4444;
  --red-bg: rgba(239,68,68,0.1);
  --yellow: #f59e0b;
  --yellow-bg: rgba(245,158,11,0.1);
  --orange: #f97316;
  --orange-bg: rgba(249,115,22,0.1);
  --blue: #3b82f6;
  --text: #e8eaf0;
  --text-dim: #6b7194;
  --radius: 14px;
  --radius-lg: 20px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========== NAVBAR ========== */
.navbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 12px;
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
}

.nav-center { flex: 0 0 auto; }

.logo {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

/* View Toggle (Einfach / Erweitert) */
.view-toggle {
  display: flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  position: relative;
}

.view-toggle-btn {
  padding: 7px 18px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s;
  position: relative;
  z-index: 1;
}

.view-toggle-btn.active {
  color: #fff;
  background: var(--primary);
}

/* Student Pills */
.student-pills {
  display: flex;
  gap: 6px;
}

.pill-btn {
  padding: 8px 20px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 20px rgba(108,99,255,0.3);
}

.pill-btn:hover:not(.active) {
  border-color: var(--primary-light);
  color: var(--text);
}

/* ========== DASHBOARD ========== */
.dashboard {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ========================================
   SIMPLE VIEW
   ======================================== */

/* Hero Card */
.simple-hero {
  margin-bottom: 32px;
}

.hero-card {
  background: linear-gradient(135deg, var(--card) 0%, #1a1f30 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
}

.hero-name {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 8px;
  font-weight: 500;
}

.hero-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 8px;
}

.hero-grade {
  font-size: 4.5rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.hero-label {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.hero-week {
  font-size: 1rem;
  color: var(--text-dim);
}

.hero-week strong {
  font-weight: 700;
}

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.hero-stat {
  text-align: center;
}

.hero-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Section Titles */
.simple-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.simple-section {
  margin-bottom: 32px;
}

/* Today's Status */
.simple-today-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}

.today-item:hover {
  background: var(--card-hover);
}

.today-subject {
  font-size: 1rem;
  font-weight: 600;
}

.today-rating {
  display: flex;
  align-items: center;
  gap: 8px;
}

.today-emoji {
  font-size: 1.5rem;
}

.today-grade-num {
  font-size: 1.1rem;
  font-weight: 700;
}

.today-pending {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
}

/* Subject Overview Cards */
.simple-subjects {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}

.subject-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s;
}

.subject-card:hover {
  background: var(--card-hover);
}

.subject-name {
  font-size: 1rem;
  font-weight: 600;
}

.subject-count {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.subject-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
}

/* Recent Timeline */
.simple-timeline {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.timeline-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: background 0.15s;
}

.timeline-item:hover {
  background: var(--card-hover);
}

.timeline-emoji {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.timeline-info {
  flex: 1;
  min-width: 0;
}

.timeline-subject {
  font-size: 1rem;
  font-weight: 600;
}

.timeline-date {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.timeline-comment {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-style: italic;
}

.timeline-grade {
  font-size: 1.3rem;
  font-weight: 800;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
}

/* Simple No Data */
.simple-empty {
  text-align: center;
  padding: 32px;
  color: var(--text-dim);
  font-size: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

/* ========================================
   EXTENDED VIEW
   ======================================== */

/* Compare Section */
.compare-section {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.compare-vs {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dim);
  padding: 0 8px;
}

.compare-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.compare-card .compare-name {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.compare-card .compare-grade {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}

.compare-card .compare-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.compare-card .compare-week {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.compare-card .compare-week span {
  font-weight: 600;
}

/* KPI Row */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

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

.kpi-card .kpi-label {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.kpi-card .kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1;
}

.kpi-card .kpi-sub {
  font-size: 0.82rem;
  margin-top: 6px;
  color: var(--text-dim);
}

.kpi-card .kpi-sub .up { color: var(--green); }
.kpi-card .kpi-sub .down { color: var(--red); }
.kpi-card .kpi-sub .neutral { color: var(--yellow); }

/* Charts */
.charts-row {
  margin-bottom: 24px;
  display: grid;
  gap: 14px;
}

.charts-row.two-col {
  grid-template-columns: 1fr 1fr;
}

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.chart-card.wide {
  grid-column: 1 / -1;
}

.chart-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

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

.chart-header h3 {
  margin-bottom: 0;
}

.chart-controls {
  display: flex;
  gap: 6px;
}

.chip {
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Tables */
.table-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.table-section h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

tbody tr:hover {
  background: rgba(108,99,255,0.04);
}

/* Grade Badges */
.grade-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
}

.grade-1 { background: var(--green-bg); color: var(--green); }
.grade-2 { background: rgba(34,197,94,0.07); color: #6ee7a0; }
.grade-3 { background: var(--yellow-bg); color: var(--yellow); }
.grade-4 { background: var(--orange-bg); color: var(--orange); }
.grade-5 { background: var(--red-bg); color: var(--red); }
.grade-6 { background: rgba(239,68,68,0.15); color: #f87171; }

.trend-up { color: var(--green); }
.trend-down { color: var(--red); }
.trend-flat { color: var(--text-dim); }

/* Grade colors */
.grade-color-1 { color: var(--green); }
.grade-color-2 { color: #6ee7a0; }
.grade-color-3 { color: var(--yellow); }
.grade-color-4 { color: var(--orange); }
.grade-color-5 { color: var(--red); }
.grade-color-6 { color: #f87171; }

/* Media buttons */
.media-btn {
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 6px;
  margin: 0 2px;
  transition: all 0.15s;
}

.media-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.media-btn.disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* Media Modal */
.media-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.media-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.9);
}

.media-modal-content {
  position: relative;
  background: var(--card);
  border-radius: 16px;
  padding: 24px;
  width: 90%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  z-index: 1;
}

.media-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 4px 8px;
  z-index: 2;
}

.media-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.media-tab {
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}

.media-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.media-pane img {
  width: 100%;
  border-radius: 10px;
}

.media-info {
  text-align: center;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 0.88rem;
}

/* Comment in recent table */
.comment-text {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
  font-style: italic;
}

/* Goals */
.goals-section { margin-bottom: 24px; }
.goals-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.goals-controls select, .goals-controls input {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: #fff;
  font-size: 0.9rem;
}
.goal-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.goal-info { flex: 1; min-width: 0; }
.goal-info strong { display: block; font-size: 0.95rem; }
.goal-info span { font-size: 0.8rem; color: var(--text-dim); }
.goal-bar { width: 120px; height: 8px; background: var(--bg2); border-radius: 4px; overflow: hidden; }
.goal-fill { height: 100%; border-radius: 4px; transition: width 0.5s; }
.goal-badge { font-size: 0.8rem; }
.goal-del { background: none; border: none; cursor: pointer; font-size: 1rem; padding: 4px; }

/* Export Section */
.export-section {
  text-align: center;
  padding: 16px 0 32px;
}

/* Buttons */
.btn-green {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-green:hover {
  background: #16a34a;
}

/* Loading / No Data */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
}

.no-data {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* PIN Overlay */
.pin-overlay { position:fixed;inset:0;background:rgba(10,10,20,0.95);z-index:9999;display:flex;align-items:center;justify-content:center; }
.pin-box { background:#1a1a2e;padding:2.5rem;border-radius:20px;text-align:center;max-width:320px;width:90%; }
.pin-box h2 { margin:0 0 8px;font-size:1.5rem; }
.pin-box p { color:#8b8fa3;margin:0 0 1.5rem; }
.pin-input { width:100%;padding:16px;font-size:2rem;text-align:center;letter-spacing:12px;background:#0d0d1a;border:2px solid #2a2a4a;border-radius:12px;color:#fff;outline:none; }
.pin-input:focus { border-color:#6c63ff; }
.pin-btn { width:100%;padding:14px;margin-top:1rem;background:#6c63ff;color:#fff;border:none;border-radius:12px;font-size:1.1rem;font-weight:600;cursor:pointer; }
.pin-btn:hover { background:#5a52e0; }
.pin-error { color:#ef4444;margin-top:12px;font-weight:600; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  .navbar {
    flex-wrap: wrap;
    padding: 10px 14px;
    gap: 8px;
  }
  .nav-left { order: 1; }
  .nav-right { order: 2; }
  .nav-center { order: 3; width: 100%; justify-content: center; }
  .view-toggle { width: 100%; }
  .view-toggle-btn { flex: 1; text-align: center; }

  .dashboard { padding: 16px; }
  .charts-row.two-col { grid-template-columns: 1fr; }
  .compare-section { grid-template-columns: 1fr; gap: 8px; }
  .compare-vs { display: none; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }

  .simple-subjects { grid-template-columns: 1fr; }

  .hero-card { padding: 28px 20px; }
  .hero-grade { font-size: 3.5rem; }
  .hero-emoji { font-size: 3rem; }
  .hero-stats { gap: 20px; }
  .hero-stats { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .pill-btn { padding: 7px 14px; font-size: 0.85rem; }
  .kpi-row { grid-template-columns: 1fr 1fr; gap: 8px; }
  .hero-stats { gap: 16px; }
}

/* ============================
   Edit / Delete Rating Styles
   ============================ */
.edit-btn:hover { background: rgba(108,99,255,0.15) !important; }
.delete-btn:hover { background: rgba(239,68,68,0.15) !important; }

.actions-cell {
  display: flex;
  gap: 4px;
  align-items: center;
}

.timeline-actions {
  display: flex;
  gap: 2px;
  margin-left: auto;
  margin-right: 8px;
  opacity: 0;
  transition: opacity 0.2s;
}

.timeline-item:hover .timeline-actions { opacity: 1; }

.timeline-action-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s;
}

.timeline-action-btn:hover { background: rgba(108,99,255,0.15); border-color: var(--primary); }
.timeline-action-btn.delete:hover { background: rgba(239,68,68,0.15); border-color: var(--red); }

/* Edit Modal */
.edit-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
}

.edit-modal-content {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 90%;
  max-width: 440px;
  z-index: 1;
}

.edit-modal-content h3 {
  font-size: 1.1rem;
  margin-bottom: 20px;
  color: var(--text);
}

.edit-form label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 6px;
  margin-top: 14px;
}

.edit-form label:first-of-type { margin-top: 0; }

.edit-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.edit-input:focus { border-color: var(--primary); }

.edit-rating-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.edit-rating-row input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
}

.edit-rating-display {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 24px;
  text-align: center;
}

.edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn-cancel {
  padding: 10px 20px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover { border-color: var(--text-dim); color: var(--text); }
