/* ===================================================================
   ECTS & German Grade Analyser - Bespoke Orange & White Design System
   Created for Prospective Indian Students by MPR (Rahul Babu M P)
   =================================================================== */

:root {
  /* Core Orange Palette - Warm, Energetic, Professional */
  --primary: #ea580c;           /* Deep Warm Orange */
  --primary-hover: #c2410c;     /* Darker Orange on hover */
  --primary-light: #f97316;     /* Vivid Tangerine */
  --primary-subtle: #fff7ed;    /* Soft Orange Tint */
  --primary-border: #fed7aa;    /* Warm Orange Border */
  --primary-text: #9a3412;     /* High-contrast readable orange text */
  --primary-glow: rgba(234, 88, 12, 0.22);

  /* Light Theme Canvas (Orange & White) */
  --bg-app: #fcfaf8;
  --bg-card: #ffffff;
  --bg-card-subtle: #faf5f0;
  --bg-card-hover: #ffffff;
  --bg-input: #ffffff;
  --bg-modal: #ffffff;

  --border-light: #f3eae0;
  --border-medium: #e5ded5;
  --border-focus: #ea580c;

  --text-main: #1c1917;         /* Deep Warm Charcoal */
  --text-muted: #78716c;        /* Warm Gray */
  --text-subtle: #a8a29e;
  --text-inverse: #ffffff;

  --amber: #d97706;
  --amber-subtle: #fef3c7;
  --rose: #dc2626;
  --rose-subtle: #fee2e2;

  --yt-red: #ff0000;
  --yt-red-subtle: #ffe4e6;

  /* Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(120, 53, 15, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(120, 53, 15, 0.08), 0 1px 2px -1px rgba(120, 53, 15, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(120, 53, 15, 0.08), 0 2px 6px -2px rgba(120, 53, 15, 0.04);
  --shadow-lg: 0 12px 24px -4px rgba(120, 53, 15, 0.12), 0 4px 8px -3px rgba(120, 53, 15, 0.04);
  --shadow-orange-glow: 0 4px 20px rgba(234, 88, 12, 0.28);

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --radius-full: 9999px;

  /* Fonts */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Monaco, Consolas, monospace;

  /* Layout */
  --max-width: 1260px;
}

/* ===================================================================
   Dark Theme (Charcoal & Glowing Orange)
   =================================================================== */
body.theme-dark {
  --bg-app: #121214;
  --bg-card: #1c1b1f;
  --bg-card-subtle: #27252b;
  --bg-card-hover: #222026;
  --bg-input: #232228;
  --bg-modal: #1c1b1f;

  --border-light: #2d2b33;
  --border-medium: #3d3b45;
  --border-focus: #f97316;

  --text-main: #fafaf9;
  --text-muted: #a8a29e;
  --text-subtle: #78716c;
  --text-inverse: #121214;

  --primary: #f97316;
  --primary-hover: #ea580c;
  --primary-subtle: rgba(249, 115, 22, 0.15);
  --primary-border: rgba(249, 115, 22, 0.35);
  --primary-text: #fdba74;
  --primary-glow: rgba(249, 115, 22, 0.3);

  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 14px 28px rgba(0, 0, 0, 0.65);
  --shadow-orange-glow: 0 4px 25px rgba(249, 115, 22, 0.35);
}

/* ===================================================================
   Base & Reset
   =================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Keyframe Animations */
@keyframes fadeInSlideUp {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(234, 88, 12, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(234, 88, 12, 0);
  }
}

@keyframes ytPulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
}

/* Typography utilities */
.font-mono { font-family: var(--font-mono); }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-bold { font-weight: 700; }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--rose) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-orange { color: var(--primary); }
.text-charcoal { color: var(--text-main); }
.text-amber { color: var(--amber); }
.p-0 { padding: 0 !important; }

.bg-orange-subtle {
  background-color: var(--primary-subtle);
  color: var(--primary);
}

/* ===================================================================
   Header
   =================================================================== */
.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-xs);
  transition: all 0.2s ease;
}

.header-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, #ff8533 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px var(--primary-glow);
  transition: transform 0.2s ease;
}

.brand-icon:hover {
  transform: rotate(-3deg) scale(1.05);
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--text-main);
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.brand-subtitle strong {
  color: var(--primary);
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* Theme toggle */
.theme-light .sun-icon { display: none; }
.theme-light .moon-icon { display: block; }
.theme-dark .sun-icon { display: block; }
.theme-dark .moon-icon { display: none; }

/* ===================================================================
   Buttons & Badges
   =================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #f97316 100%);
  color: #ffffff;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary) 100%);
  box-shadow: 0 4px 14px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-secondary:hover {
  background: var(--bg-card-subtle);
  border-color: var(--primary-border);
  color: var(--primary);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border-medium);
}

.btn-outline:hover {
  background: var(--bg-card-subtle);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-card-subtle);
  color: var(--text-main);
}

.btn-icon {
  padding: 0.55rem;
  border-radius: var(--radius-md);
  width: 38px;
  height: 38px;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.45rem 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-xs {
  font-size: 0.74rem;
  padding: 0.28rem 0.55rem;
  border-radius: var(--radius-sm);
}

/* YouTube Button */
.btn-youtube {
  background: #ff0000;
  color: #ffffff !important;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(255, 0, 0, 0.25);
  animation: ytPulse 3s infinite ease-in-out;
}

.btn-youtube:hover {
  background: #cc0000;
  box-shadow: 0 4px 14px rgba(255, 0, 0, 0.4);
  transform: translateY(-1px);
}

/* Creator Profile Button */
.btn-creator {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.35rem 0.75rem;
}

.btn-creator:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  color: var(--primary);
}

.creator-nav-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--primary);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.22rem 0.6rem;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
}

.badge-accent {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-primary {
  background: var(--primary);
  color: #ffffff;
}

.badge-orange {
  background: var(--primary-subtle);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-neutral {
  background: var(--bg-card-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}

/* Clean Numeric German Grade Badge (No word labels) */
.grade-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-medium);
  color: var(--text-main);
  min-width: 58px;
}

.grade-num-badge.badge-top {
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* ===================================================================
   Main Layout & Cards
   =================================================================== */
.main-container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3.5rem 1.5rem;
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  overflow: hidden;
}

.card:hover {
  border-color: var(--border-medium);
}

.card-header {
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: var(--bg-card);
}

.card-header-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 0.75rem;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.card-body {
  padding: 1.25rem 1.35rem;
}

/* ===================================================================
   Top Config Grid (2 Columns)
   =================================================================== */
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}

.form-group {
  margin-bottom: 1.15rem;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.info-tag {
  font-size: 0.7rem;
  color: var(--primary);
  background: var(--primary-subtle);
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
}

/* Duration segmented control */
.duration-segmented-control {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.35rem;
  background: var(--bg-card-subtle);
  padding: 0.3rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

.segment-btn {
  background: transparent;
  border: 1px solid transparent;
  padding: 0.55rem 0.25rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
}

.segment-btn .subtext {
  font-size: 0.65rem;
  font-weight: 500;
  opacity: 0.8;
}

.segment-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.6);
}

body.theme-dark .segment-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.segment-btn.active {
  background: var(--bg-card);
  color: var(--primary);
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

/* Label with quick presets */
.label-with-presets {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.45rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.label-with-presets .form-label {
  margin-bottom: 0;
}

.quick-chips {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.chip-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.chip-btn {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary-border);
}

/* Input fields */
.form-input, .form-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  transition: all 0.18s ease;
}

.form-input:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-with-affix {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-affix .form-input {
  padding-right: 4.5rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}

.input-affix {
  position: absolute;
  right: 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

.input-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

/* Formula Preview Box */
.formula-preview-box {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-top: 0.85rem;
}

.formula-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.formula-title {
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--primary-text);
  letter-spacing: 0.04em;
}

.formula-equation {
  font-size: 0.82rem;
  color: var(--text-main);
  background: var(--bg-card);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary-border);
  margin: 0.35rem 0;
  overflow-x: auto;
  white-space: nowrap;
}

.formula-meta {
  font-size: 0.73rem;
  color: var(--text-muted);
}

/* Radio toggle group */
.radio-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.radio-toggle-label {
  cursor: pointer;
}

.radio-toggle-label input[type="radio"] {
  display: none;
}

.toggle-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.radio-toggle-label:hover .toggle-pill {
  color: var(--text-main);
  border-color: var(--border-medium);
}

.radio-toggle-label input[type="radio"]:checked + .toggle-pill {
  background: var(--primary-subtle);
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-xs);
}

/* Scale specs pills */
.scale-specs-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.spec-pill {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.spec-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.spec-val {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Bavarian Formula Box */
.bavarian-formula-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.95rem;
}

.bavarian-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tum-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
}

.tum-link:hover {
  text-decoration: underline;
}

.bavarian-math {
  font-size: 0.78rem;
  color: var(--text-main);
  background: var(--bg-card);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  margin: 0.3rem 0 0.45rem 0;
  overflow-x: auto;
  white-space: nowrap;
}

/* ===================================================================
   KPI Summary Banner
   =================================================================== */
.summary-kpi-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary-border);
}

.kpi-card.highlight-card {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--primary-subtle) 100%);
  border-color: var(--primary-border);
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.12);
}

.kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.kpi-title {
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi-main-val {
  font-size: 1.95rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.025em;
  line-height: 1.1;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
}

.kpi-subtext {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-family: var(--font-sans);
}

.kpi-target-val {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
}

.kpi-footer-text {
  font-size: 0.73rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 0.6rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, #ff8533 100%);
  border-radius: var(--radius-full);
  transition: width 0.35s ease;
}

/* ===================================================================
   Builder & Groups Section
   =================================================================== */
.builder-section {
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.builder-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.section-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.builder-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.groups-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Empty State Banner */
.empty-state-card {
  background: var(--bg-card);
  border: 2px dashed var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 3rem 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.85rem;
  animation: fadeInSlideUp 0.3s ease-out;
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary-subtle);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.empty-state-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.5;
}

/* Group Card */
.group-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  overflow: hidden;
  animation: fadeInSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.group-card:hover {
  border-color: var(--primary-border);
}

/* Group Header: Cleaned up to show ONLY title and course count */
.group-card-header {
  padding: 0.95rem 1.25rem;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.group-title-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.group-color-tag {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.group-title-input {
  background: transparent;
  border: 1px solid transparent;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-main);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  width: 100%;
  max-width: 380px;
}

.group-title-input:hover {
  background: var(--bg-card);
  border-color: var(--border-medium);
}

.group-title-input:focus {
  background: var(--bg-card);
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.group-header-right {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.group-count-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.data-table th {
  background: var(--bg-card);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background: var(--bg-card-subtle);
}

/* Inputs inside Course Rows */
.table-input {
  width: 100%;
  padding: 0.45rem 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  transition: all 0.15s ease;
}

.table-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.table-input.font-mono {
  font-family: var(--font-mono);
}

.table-input-number {
  max-width: 85px;
  text-align: right;
  font-weight: 600;
}

.table-select {
  padding: 0.45rem 0.65rem;
  background: var(--bg-input);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  max-width: 110px;
}

.table-select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Distinct Column-Aligned Group Subtotal Row */
.group-subtotal-row td {
  background: var(--primary-subtle);
  border-top: 2px solid var(--primary-border);
  border-bottom: none;
  color: var(--text-main);
  padding: 0.75rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.group-subtotal-title {
  color: var(--primary-text);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.group-footer-actions {
  padding: 0.75rem 1.25rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ===================================================================
   Master Unified Table
   =================================================================== */
.master-table-section {
  overflow: hidden;
}

.master-header {
  justify-content: space-between;
  flex-wrap: wrap;
}

.master-header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.master-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.master-table th {
  background: var(--bg-card-subtle);
}

.master-group-header-row td {
  background: var(--bg-card-subtle);
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text-main);
  padding: 0.65rem 1rem;
  border-top: 2px solid var(--border-light);
  border-bottom: 1px solid var(--border-medium);
}

.master-subtotal-row td {
  background: var(--primary-subtle);
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--primary-text);
  border-bottom: 2px solid var(--primary-border);
}

.master-grandtotal-row td {
  background: linear-gradient(135deg, var(--primary) 0%, #ff8533 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 0.95rem;
  padding: 1rem 1rem;
  border: none;
}

.master-grandtotal-row .grade-num-badge {
  background: #ffffff;
  color: var(--primary);
  border: none;
}

/* ===================================================================
   Methodology & Guide Notes
   =================================================================== */
.methodology-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.method-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.45rem;
}

.method-p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 0.65rem;
}

.math-callout {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary-text);
  margin: 0.5rem 0;
}

/* ===================================================================
   Modals
   =================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(28, 25, 23, 0.65);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-modal);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-dialog-compact {
  max-width: 520px;
}

@keyframes modalPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

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

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
}

.modal-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background: var(--bg-card);
}

.modal-two-col {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.grade-mapping-table-wrap {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  max-height: 220px;
  overflow-y: auto;
}

.mapping-table th {
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
}

.mapping-table td {
  padding: 0.4rem 0.75rem;
}

/* Creator Profile Card in About Modal */
.creator-profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--primary-subtle);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-lg);
}

.creator-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  box-shadow: 0 4px 10px var(--primary-glow);
}

.creator-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-main);
}

.creator-handle {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
}

.creator-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.about-text {
  font-size: 0.85rem;
  color: var(--text-main);
  line-height: 1.6;
}

.youtube-spotlight-box {
  background: #fff5f5;
  border: 1.5px solid #fed7d7;
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

body.theme-dark .youtube-spotlight-box {
  background: rgba(255, 0, 0, 0.08);
  border-color: rgba(255, 0, 0, 0.3);
}

.yt-box-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #c53030;
}

body.theme-dark .yt-box-title {
  color: #ff8080;
}

.yt-box-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.creator-links-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.creator-link-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s ease;
}

.creator-link-pill:hover {
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  color: var(--primary);
}

/* Tester Box inside Modal */
.tester-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
}

.tester-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.tester-slider-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.form-range {
  flex: 1;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ===================================================================
   Toast Notifications
   =================================================================== */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1c1917;
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  font-weight: 700;
  z-index: 1000;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-left: 4px solid var(--primary);
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ===================================================================
   Footer
   =================================================================== */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
  padding: 1.5rem 1.5rem;
  margin-top: auto;
}

.footer-container {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.footer-title {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-main);
}

.footer-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.footer-creator-link {
  color: var(--primary);
  text-decoration: none;
}

.footer-creator-link:hover {
  text-decoration: underline;
}

.footer-social-links {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.footer-icon-link {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  text-decoration: none;
}

.footer-icon-link:hover {
  color: var(--primary);
  background: var(--primary-subtle);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}

.footer-icon-link.yt-link:hover {
  color: #ff0000;
  border-color: rgba(255, 0, 0, 0.3);
  background: #ffe4e6;
}

/* ===================================================================
   Offscreen PDF Export & Print Styles
   =================================================================== */
.pdf-print-container {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 700px;
  max-width: 700px;
  z-index: -99999;
  background: #ffffff;
  pointer-events: none;
  overflow: visible;
}

@media print {
  body {
    background: #ffffff !important;
    color: #1c1917 !important;
    font-size: 11pt !important;
  }

  .app-header,
  .toast,
  .modal-overlay,
  .btn,
  .btn-icon,
  .group-actions,
  .course-actions,
  .add-course-btn,
  .creator-nav-avatar,
  .theme-toggle,
  .footer-social-links,
  .app-footer {
    display: none !important;
  }

  .main-container {
    padding: 0 !important;
    max-width: 100% !important;
  }

  .card {
    box-shadow: none !important;
    border: 1px solid #d1d5db !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  table {
    page-break-inside: auto;
    width: 100% !important;
  }

  tr {
    page-break-inside: avoid !important;
    break-inside: avoid !important;
  }

  thead {
    display: table-header-group !important;
  }

  tfoot {
    display: table-footer-group !important;
  }
}

/* ===================================================================
   Responsive Breakpoints
   =================================================================== */
@media (max-width: 1024px) {
  .config-grid {
    grid-template-columns: 1fr;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .methodology-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  html {
    font-size: 14px;
  }

  .header-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .duration-segmented-control {
    grid-template-columns: repeat(3, 1fr);
  }

  .radio-toggle-group {
    grid-template-columns: 1fr;
  }

  .scale-specs-row {
    grid-template-columns: 1fr;
  }

  .creator-links-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-container {
    flex-direction: column;
    align-items: flex-start;
  }
}
