@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ─── CSS VARIABLES ────────────────────────────────────────────────────────── */
:root {
  --primary:       #5B50F0;
  --primary-light: #EEEEFF;
  --primary-dark:  #4338CA;
  --success:       #10B981;
  --success-light: #ECFDF5;
  --warning:       #F59E0B;
  --warning-light: #FFFBEB;
  --danger:        #EF4444;
  --danger-light:  #FEF2F2;
  --bg:            #F4F6FA;
  --card:          #FFFFFF;
  --border:        #E4E9F0;
  --text:          #18202F;
  --text-muted:    #64748B;
  --text-light:    #9AAAB8;
  --shadow-sm:     0 1px 4px rgba(0,0,0,0.07);
  --shadow:        0 4px 16px rgba(0,0,0,0.09);
  --shadow-lg:     0 10px 36px rgba(0,0,0,0.13);
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     18px;
  --m1: #EF4444;
  --m2: #F97316;
  --m3: #EAB308;
  --m4: #84CC16;
  --m5: #10B981;
  --header-h: 96px;
}

/* ─── RESET ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: 15px; }
a { color: var(--primary); text-decoration: none; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100vh; }

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  background: linear-gradient(135deg, #5B50F0 0%, #4338CA 100%);
  box-shadow: 0 2px 20px rgba(67,56,202,0.28);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.brand-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.countdown-badge {
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  background: rgba(255,255,255,0.15);
  padding: 4px 12px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid rgba(255,255,255,0.2);
}

/* ─── TAB NAV ───────────────────────────────────────────────────────────────── */
.tab-nav {
  display: flex;
  padding: 0 16px;
  gap: 4px;
}

.tab-btn {
  flex: 1;
  padding: 8px 10px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.65);
  font-size: 13px;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.1px;
}

.tab-btn:hover { color: rgba(255,255,255,0.9); }

.tab-btn.active {
  color: #fff;
  border-bottom-color: rgba(255,255,255,0.9);
  font-weight: 600;
}

/* ─── ROLLOVER BAR ──────────────────────────────────────────────────────────── */
.rollover-bar {
  position: fixed;
  top: var(--header-h);
  left: 0; right: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--warning);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
}

.rollover-bar.hidden { display: none; }

.rollover-icon { font-size: 16px; }

.rollover-dismiss {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  line-height: 1;
  opacity: 0.8;
}

.rollover-dismiss:hover { opacity: 1; }

.rollover-countdown {
  margin-left: auto;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.rollover-countdown-svg {
  width: 20px;
  height: 20px;
  transform: rotate(-90deg);
}

.rollover-countdown-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.36);
  stroke-width: 4;
}

.rollover-countdown-progress {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 94.2;
  stroke-dashoffset: 0;
}

.rollover-countdown.is-running .rollover-countdown-progress {
  animation: rollover-countdown-drain 5s linear forwards;
}

@keyframes rollover-countdown-drain {
  to { stroke-dashoffset: 94.2; }
}

/* ─── MAIN ──────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-top: var(--header-h);
  padding: 28px 24px;
  max-width: 1100px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}

.main.with-banner { margin-top: calc(var(--header-h) + 42px); }

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 60px;
}

/* ─── CARDS ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 22px 24px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
  margin-bottom: 14px;
  letter-spacing: -0.2px;
}

/* ─── TODAY VIEW ─────────────────────────────────────────────────────────────── */
.today-header {
  margin-bottom: 20px;
}

.today-date {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

.today-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.progress-section {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

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

.progress-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.progress-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.progress-bar-wrap {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.progress-bar-fill.done { background: var(--success); }

/* ─── TASK CARD ─────────────────────────────────────────────────────────────── */
.task-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
  position: relative;
}

.task-card:hover { box-shadow: var(--shadow); }

.task-card.status-done {
  border-color: #A7F3D0;
  background: #F0FDF9;
}

.task-card.status-skipped {
  border-color: var(--border);
  background: #F8FAFC;
  opacity: 0.75;
}

.task-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 10px;
}

.task-block-num {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.task-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.task-chapter {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.task-chapter.done-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.task-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.task-undo {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

.task-undo:hover { color: var(--text); }

.rolled-over-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--warning);
  background: var(--warning-light);
  border: 1px solid #FDE68A;
  padding: 2px 7px;
  border-radius: 20px;
}

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
}

.badge-subject {
  color: #fff;
}

.badge-mastery {
  color: #fff;
  font-size: 11px;
}

.badge-duration {
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 500;
}

/* ─── MASTERY STARS ─────────────────────────────────────────────────────────── */
.mastery-stars {
  display: inline-flex;
  gap: 2px;
  align-items: center;
}

.star {
  font-size: 16px;
  cursor: pointer;
  transition: transform 0.1s;
  line-height: 1;
}

.star:hover { transform: scale(1.2); }
.star.filled { color: #F59E0B; }
.star.empty  { color: #D1D5DB; }

/* clickable stars in forms */
.star-input { cursor: pointer; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: background 0.14s, box-shadow 0.14s, transform 0.1s;
  white-space: nowrap;
  letter-spacing: 0.1px;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.55; pointer-events: none; }

.btn-primary   { background: var(--primary); color: #fff; box-shadow: 0 1px 4px rgba(91,80,240,0.25); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 3px 10px rgba(91,80,240,0.3); }

.btn-success   { background: var(--success); color: #fff; box-shadow: 0 1px 4px rgba(16,185,129,0.2); }
.btn-success:hover { background: #0DA271; }

.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #DC2626; }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--bg); border-color: #C8D3DF; }

.btn-warning  { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #D97706; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  padding: 6px 10px;
}
.btn-ghost:hover { background: var(--primary-light); }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 11.5px; border-radius: 6px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.empty-text {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 20px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── STATS STRIP ─────────────────────────────────────────────────────────────── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, transform 0.15s;
}

.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-value {
  font-size: 28px;
  font-weight: 750;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 5px;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ─── PLANNING VIEW ──────────────────────────────────────────────────────────── */
.week-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.week-label {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.day-row {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s;
}

.day-row:hover { box-shadow: var(--shadow); }

.day-row-header {
  display: flex;
  align-items: center;
  padding: 13px 18px;
  cursor: pointer;
  gap: 12px;
  user-select: none;
  transition: background 0.15s;
}

.day-row-header:hover { background: #FAFBFD; }

.day-row-header.today-row { background: var(--primary-light); }

.day-label {
  font-weight: 650;
  font-size: 14px;
  min-width: 120px;
  letter-spacing: -0.1px;
}

.day-row-header.today-row .day-label { color: var(--primary); }

.day-status-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}

.day-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-chip.done-chip { opacity: 0.6; text-decoration: line-through; }

.day-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.day-count {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.day-done-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
}

.day-overdue-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--danger);
}

.day-expand-icon {
  font-size: 12px;
  color: var(--text-light);
  transition: transform 0.2s;
}

.day-expand-icon.open { transform: rotate(180deg); }

.day-body {
  display: none;
  padding: 0 16px 12px;
  border-top: 1px solid var(--border);
}

.day-body.open { display: block; }

.day-task-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg);
  font-size: 13.5px;
}

.day-task-row:last-child { border-bottom: none; }

.day-task-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 36px;
}

.day-task-chapter {
  flex: 1;
  font-weight: 500;
}

.day-task-status {
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.status-pending  { background: var(--bg);          color: var(--text-muted); }
.status-done     { background: var(--success-light); color: var(--success); }
.status-skipped  { background: #F1F5F9;             color: var(--text-muted); }
.status-overdue  { background: var(--danger-light);  color: var(--danger); }

.day-task-actions { display: flex; gap: 4px; flex-shrink: 0; flex-wrap: wrap; margin-left: auto; }

.block-time-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.block-time-modified {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.badge-time {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.badge-time-modified {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.break-row {
  background: rgba(251, 191, 36, 0.06);
  border-radius: var(--radius-sm);
  padding-left: 6px;
  padding-right: 6px;
}

.homework-plan-row {
  background: rgba(14, 165, 233, 0.06);
  border-radius: var(--radius-sm);
  padding-left: 6px;
  padding-right: 6px;
}

.drag-handle {
  cursor: grab;
  color: var(--text-muted);
  font-size: 14px;
  flex-shrink: 0;
  opacity: 0.4;
  user-select: none;
  pointer-events: none;
}
.day-task-row[draggable="true"]:hover .drag-handle { opacity: 0.8; }

.day-task-row[draggable="true"] { cursor: default; }
.day-task-row.dragging {
  opacity: 0.4;
  background: var(--bg);
}
.day-task-row.drag-over {
  border-top: 2px solid var(--primary);
  margin-top: -2px;
}

.break-badge {
  font-size: 12.5px;
  font-weight: 600;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 10px;
  border-radius: 20px;
  flex: 1;
}

.break-chip {
  background: #fef3c7 !important;
  color: #92400e !important;
}

.no-study-day {
  padding: 12px 16px;
  color: var(--text-light);
  font-size: 13.5px;
  font-style: italic;
}

/* ─── CHAPTERS VIEW ──────────────────────────────────────────────────────────── */
.chapters-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.chapters-toolbar .spacer { flex: 1; }

.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
}

.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.chapter-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.chapter-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}

.chapter-table th:hover { color: var(--text); }
.chapter-table th.sort-asc::after  { content: ' ▲'; font-size: 10px; }
.chapter-table th.sort-desc::after { content: ' ▼'; font-size: 10px; }

.chapter-table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.chapter-table tr:last-child td { border-bottom: none; }
.chapter-table tr:hover td { background: #FAFBFD; }
.chapter-table .chapter-row[draggable="true"] { cursor: default; }
.chapter-table .chapter-row.dragging td {
  opacity: 0.45;
  background: var(--bg);
}
.chapter-table .chapter-row.drag-over td {
  box-shadow: inset 0 2px 0 var(--primary);
}

.chapter-name-cell {
  font-weight: 500;
}

.chapter-notes-cell {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
  white-space: nowrap;
}

.actions-col {
  width: 160px;
  min-width: 160px;
  text-align: right !important;
}

.chapter-actions .btn {
  padding: 4px 6px;
  min-width: 28px;
  justify-content: center;
}

.chapter-actions .btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.mastery-bar-wrap {
  width: 80px;
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  display: inline-block;
}

.mastery-bar-fill {
  height: 100%;
  border-radius: 99px;
}

/* ─── SETTINGS VIEW ──────────────────────────────────────────────────────────── */
.settings-inner-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.settings-inner-tab {
  padding: 8px 14px;
  border: none;
  background: transparent;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.settings-inner-tab:hover { color: var(--text); }

.settings-inner-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.settings-panel { display: none; }
.settings-panel.active { display: block; }

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 140px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font-size: 14.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,80,240,0.12);
}

.form-input-sm {
  padding: 7px 10px;
  font-size: 14px;
  text-align: center;
  width: 70px;
}

.days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.day-block-input {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.day-block-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

.settings-warning {
  background: var(--warning-light);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: #92400E;
  margin-top: 12px;
}

.settings-info {
  background: var(--primary-light);
  border: 1px solid #C7D2FE;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13.5px;
  color: #3730A3;
  margin-top: 12px;
}

.capacity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-size: 13.5px;
}

.danger-zone {
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  padding: 16px 18px;
  background: #FFF5F5;
}

.danger-zone-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 8px;
}

/* ─── INVOICES TABLE ─────────────────────────────────────────────────────────── */
.invoices-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.invoices-table thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  padding: 0 10px 10px 0;
  border-bottom: 1px solid var(--border);
}

.invoices-table tbody td {
  padding: 10px 10px 10px 0;
  border-bottom: 1px solid var(--bg);
  vertical-align: middle;
}

.invoices-table tbody tr:last-child td { border-bottom: none; }

.invoices-table .text-right { text-align: right; padding-right: 0; }

/* ─── SUBSCRIPTION BADGE & DETAILS ──────────────────────────────────────────── */
.badge-success {
  background: #D1FAE5;
  color: #065F46;
}

.badge-warning {
  background: #FEF3C7;
  color: #92400E;
}

.subscription-details {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin: 0;
  font-size: 13.5px;
}

.subscription-details dt {
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

.subscription-details dd {
  margin: 0;
  font-weight: 600;
  color: var(--text);
}

.subscription-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.subscription-actions-hint {
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ─── MODAL ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,0.18);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.modal-box.modal-box-wide { max-width: 760px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.modal-close-btn {
  background: var(--bg);
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  padding: 2px 7px;
  line-height: 1.4;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.modal-close-btn:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 22px 24px;
}

.modal-body .form-group {
  margin-bottom: 16px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}

.modal-footer-wrap {
  flex-wrap: wrap;
}

.modal-footer-wrap .btn {
  flex-shrink: 0;
}

/* star rating in form */
.star-rating-input {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.star-rating-input .star {
  font-size: 24px;
}

.mastery-description {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 4px;
  min-height: 18px;
}

/* ─── SECTION HEADER ────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.planning-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.planning-status-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  background: #F8FAFC;
}

.planning-status-card.is-success {
  background: linear-gradient(135deg, var(--success), #059669);
  border-color: #10B981;
  color: #fff;
}

.planning-status-card.is-pending {
  background: var(--primary-light);
  border-color: #C7D2FE;
  color: #3730A3;
}

.planning-status-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  opacity: 0.85;
  margin-bottom: 4px;
}

.planning-status-text {
  font-size: 13px;
  font-weight: 600;
}

/* ─── WEEKLY HOMEWORK ───────────────────────────────────────────────────────── */
.homework-week-card { margin-bottom: 14px; }

.homework-week-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.homework-subject-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.homework-subject-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.homework-subject-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.homework-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #E2E8F0;
  padding: 8px 0;
}

.homework-subject-group .homework-item:first-of-type {
  border-top: none;
  padding-top: 0;
}

.homework-item-main {
  flex: 1;
  min-width: 0;
}

.homework-item-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}

.homework-item-meta {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.homework-subtasks {
  margin-top: 5px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.homework-subtask-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.homework-subtask {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 0;
  text-align: left;
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
}

.homework-subtask:hover { color: var(--text); }

.homework-subtask-parent {
  cursor: default;
  color: var(--text);
  font-weight: 600;
}

.homework-subtasks-children {
  margin-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.homework-subtask-child {
  font-size: 12.5px;
}

.homework-subtask.is-done {
  color: var(--text-light);
}

.homework-subtask-label {
  color: inherit;
}

.homework-subtask-label.is-done {
  color: var(--text-light);
  text-decoration: line-through;
}

.homework-subtask-meta {
  margin-left: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.homework-subtask-time,
.homework-subtask-date,
.homework-range-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent);
  padding: 1px 6px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
  text-decoration: none;
}

.homework-subtask-time,
.homework-subtask-date {
  margin-left: 0;
}

.homework-range-badge {
  margin-left: 8px;
  vertical-align: middle;
}

.homework-subtask-check {
  font-size: 13px;
  line-height: 1;
}

.homework-item-side {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.homework-item-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.homework-item.is-done .homework-item-title {
  color: var(--text-light);
  text-decoration: line-through;
}

.homework-item-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.homework-collapse-toggle {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.homework-collapse-toggle:hover { color: var(--primary); }

.homework-item.is-collapsed .homework-item-body { display: none; }
.homework-item.is-collapsed .homework-item-actions { display: none; }

/* ─── CONGRATULATIONS BANNER ─────────────────────────────────────────────────── */
.congrats-banner {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff;
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  margin-bottom: 20px;
}

.congrats-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.congrats-text {
  font-size: 14px;
  opacity: 0.9;
}

/* ─── PLANNING CAP WARNING ───────────────────────────────────────────────────── */
.cap-bar {
  height: 10px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
  margin-top: 8px;
}

.cap-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--success);
  transition: width 0.4s;
}

.cap-fill.over { background: var(--danger); }
.cap-fill.near { background: var(--warning); }

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */

/* ── Tablet (≤ 768px) ── */
@media (max-width: 768px) {
  .subject-grid { grid-template-columns: 1fr; }
  .stats-strip  { grid-template-columns: repeat(2, 1fr); }
  .modal-box.modal-box-wide { max-width: 100%; }
}

/* ── Grote telefoon / kleine tablet (≤ 600px) ── */
@media (max-width: 600px) {
  :root { --header-h: 84px; }

  /* Header */
  .header-inner { padding: 8px 12px 6px; }
  .brand-name   { font-size: 16px; }
  .countdown-badge { font-size: 11.5px; padding: 3px 9px; }

  /* Countdown badge: hide on small phones to save header space */
  .countdown-badge { display: none; }

  /* Nav tabs */
  .tab-nav { padding: 0 6px; }
  .tab-btn { font-size: 12.5px; padding: 8px 6px; }

  /* Main */
  .main { padding: 12px; }

  /* Stats */
  .stats-strip { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-value  { font-size: 22px; }

  /* Week-nav: stack label on its own line */
  .week-nav {
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }
  .week-label { order: -1; width: 100%; text-align: center; }

  /* Planning status */
  .planning-status-grid { grid-template-columns: 1fr; }
  .homework-week-header { flex-direction: column; align-items: stretch; }
  .homework-item { flex-direction: column; align-items: stretch; }
  .homework-item-side { justify-content: flex-start; }

  /* Day row */
  .day-label { min-width: 80px; font-size: 13.5px; }
  .day-status-chips { display: none; } /* too cramped on mobile */
  .day-task-row { flex-wrap: wrap; gap: 6px; }
  .day-task-actions { margin-left: auto; }

  /* Days-grid in settings */
  .days-grid          { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .form-input-sm      { width: 52px; padding: 6px 4px; font-size: 13px; }
  .day-block-label    { font-size: 11px; }

  /* Chapter table: hide less important columns */
  .chapter-table th:nth-child(4),
  .chapter-table td:nth-child(4),
  .chapter-table th:nth-child(5),
  .chapter-table td:nth-child(5) { display: none; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* Modal */
  .modal-overlay { padding: 10px; align-items: flex-end; }
  .modal-box     { max-height: 92vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .subject-file-modal-meta  { grid-template-columns: 1fr; }
  .subject-file-preview-frame { height: 240px; }

  /* Forms */
  .form-row  { gap: 10px; }
  .form-group { min-width: 0; }

  /* Dropdowns / selects */
  .filter-select { width: 100%; max-width: 240px; }

  /* Vakken toolbar */
  .vakken-toolbar { flex-wrap: wrap; }
  .vakken-toolbar .spacer { display: none; }

  /* Buttons – ensure tap targets are big enough */
  .btn    { min-height: 40px; }
  .btn-sm { min-height: 34px; }
}

/* ── Kleine telefoon (≤ 390px) ── */
@media (max-width: 390px) {
  .main { padding: 10px; }

  /* Days-grid: 2 rows of 4 for Ma–Zo */
  .days-grid { grid-template-columns: repeat(4, 1fr); gap: 4px; }

  /* Stack form rows vertically */
  .form-row { flex-direction: column; align-items: stretch; }
  .form-group { min-width: 0; width: 100%; }

  /* Stats in 2 columns, smaller */
  .stats-strip { gap: 6px; }
  .stat-value  { font-size: 20px; }
  .stat-label  { font-size: 11px; }

  /* Smaller card padding */
  .card { padding: 14px; }

  /* Preset buttons in settings wrap */
  .form-row.mt-12 { flex-direction: row; flex-wrap: wrap; }

  /* Login box: less horizontal padding on tiny screens */
  .login-box { padding: 28px 20px; }
}

/* ─── VAKKEN VIEW ────────────────────────────────────────────────────────────── */
.vakken-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.subject-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.subject-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.18s, transform 0.18s;
}

.subject-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.subject-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  color: #fff;
}

.subject-card-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subject-card-name::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.65);
  border-radius: 50%;
  flex-shrink: 0;
}

.subject-card-actions {
  display: flex;
  gap: 4px;
}

.subject-card-action {
  background: rgba(255,255,255,0.18);
  border: none;
  color: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13px;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s;
}

.subject-card-action:hover { background: rgba(255,255,255,0.35); }

.subject-card-body {
  padding: 16px 18px;
}

.subject-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.subject-stat-row strong { color: var(--text); font-weight: 600; }

.subject-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin: 8px 0 12px;
}

.subject-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.4s ease;
}

.subject-next-block {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.subject-files-section {
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 2px;
}

.subject-files-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subject-files-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.subject-files-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 228px;
  overflow-y: scroll;
  overflow-x: hidden;
  scrollbar-gutter: stable both-edges;
  -webkit-overflow-scrolling: touch;
}

.subject-files-list.files-page-list {
  max-height: none;
}

.subject-file-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.subject-file-link {
  width: 100%;
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.subject-file-link:hover {
  background: #F1F5F9;
  border-color: #CBD5E1;
}

.subject-file-delete {
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 7px 8px;
}

.subject-file-name {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subject-file-meta {
  flex-shrink: 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.subject-files-empty {
  font-size: 12.5px;
  color: var(--text-light);
  padding: 2px 0;
}

.subject-file-modal-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.subject-file-modal-meta strong { color: var(--text); }

.subject-file-preview-wrap {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #F8FAFC;
  padding: 10px;
}

.subject-file-preview-nav {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
}

.subject-file-preview-nav .subject-file-preview-wrap {
  margin-top: 0;
}

.subject-file-preview-nav-btn {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  width: 38px;
  height: 38px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.subject-file-preview-nav-btn:hover:not(:disabled) {
  background: #EEF2FF;
}

.subject-file-preview-nav-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.subject-file-preview-counter {
  margin-top: 8px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}

.subject-file-viewer-minimal .subject-file-preview-nav {
  margin-top: 0;
}

.subject-file-viewer-minimal .subject-file-preview-wrap {
  padding: 6px;
}

.subject-file-viewer-minimal .subject-file-preview-image {
  max-height: 72vh;
}

.subject-file-preview-image,
.subject-file-preview-video {
  display: block;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.subject-file-preview-audio {
  width: 100%;
}

.subject-file-preview-frame {
  width: 100%;
  height: 400px;
  border: 0;
  border-radius: var(--radius-sm);
  background: #fff;
}

.subject-file-preview-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 26px 10px;
}

.subject-card-footer {
  border-top: 1px solid var(--border);
  padding: 10px 16px;
}

/* ─── ARCHIVED SUBJECTS ──────────────────────────────────────────────────────── */
.subject-card-archived {
  opacity: 0.72;
  filter: grayscale(30%);
}

.subject-card-archived:hover {
  opacity: 1;
  filter: none;
}

/* ─── COLOR SWATCHES (subject modal) ──────────────────────────────────────────── */
.color-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.3);
  transform: scale(1.1);
}

/* ─── PLANNING FILTER BAR ────────────────────────────────────────────────────── */
.plan-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.plan-filter-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.plan-filter-active {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  color: #fff;
}

.plan-filter-clear {
  background: rgba(255,255,255,0.25);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ─── TODAY SUBJECT GROUP ────────────────────────────────────────────────────── */
.subject-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
}

.subject-group-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.subject-group-label {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.subject-group-count {
  font-size: 12px;
  color: var(--text-light);
  margin-left: auto;
}

/* ─── RESPONSIVE (vakken) ────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .subject-grid { grid-template-columns: 1fr; }
}

/* ─── SUBJECT DETAIL VIEW ───────────────────────────────────────────────────── */
.subject-detail-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0 4px;
  margin-bottom: 14px;
}
.subject-detail-back:hover { color: var(--primary); }

.subject-detail-header {
  border-radius: var(--radius);
  padding: 20px 22px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.subject-detail-title {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.subject-detail-subtitle {
  font-size: 13px;
  opacity: 0.85;
  margin-top: 4px;
}

/* ─── EXAM LIST (subject detail) ─────────────────────────────────────────────── */
.exam-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.exam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.exam-item[draggable="true"] { cursor: default; }
.exam-item.dragging {
  opacity: 0.4;
  background: var(--bg);
}
.exam-item.drag-over {
  border-top: 2px solid var(--primary);
  margin-top: -2px;
}

.exam-item-name { flex: 1; font-weight: 500; }
.exam-item-duration { font-size: 12.5px; color: var(--text-muted); white-space: nowrap; }

.exam-item-done {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  padding: 2px 8px;
  border-radius: 20px;
}

.exam-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
}
.exam-delete:hover { color: var(--danger); background: var(--danger-light); }

.exam-none {
  font-size: 13.5px;
  color: var(--text-light);
  font-style: italic;
  padding: 8px 0;
}

.exam-photos-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  padding: 10px;
  margin-bottom: 10px;
}

.exam-photos-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.exam-photos-title {
  font-size: 13px;
  color: var(--text);
}

.exam-photos-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.exam-photos-toggle-icon {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform .15s ease;
}

.exam-photos-toggle[aria-expanded="true"] .exam-photos-toggle-icon {
  transform: rotate(180deg);
}

.made-test-body {
  margin-top: 4px;
}

.made-test-carousel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.made-test-carousel-track {
  min-width: 0;
}

.made-test-carousel-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-weight: 700;
}

.made-test-carousel-btn:hover {
  background: #F1F5F9;
}

.made-test-slide {
  display: none;
}

.made-test-slide.is-active {
  display: block;
}

.made-test-slide-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

.exam-photo-files-list {
  margin-top: 0;
  max-height: 190px;
}

/* ─── PARTS MANAGEMENT (chapter modal) ──────────────────────────────────────── */
.parts-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.parts-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.parts-info {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

.parts-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  min-height: 10px;
}

.part-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.part-item-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 20px;
}

.part-item-name { flex: 1; }

.part-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.part-input-row input { flex: 1; }

/* ─── EXAM TASK CARD ─────────────────────────────────────────────────────────── */
.task-card.exam-task {
  border-left: 4px solid var(--warning);
}

.exam-task-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #92400E;
  background: var(--warning-light);
  border: 1px solid #FDE68A;
  padding: 2px 8px;
  border-radius: 20px;
}

.task-card.video-task {
  border-left: 4px solid #7C3AED;
}

.video-task-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #4C1D95;
  background: #EDE9FE;
  border: 1px solid #C4B5FD;
  padding: 2px 8px;
  border-radius: 20px;
}

.task-part-label {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 2px 0 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* exam chip in planning */
.day-chip.exam-chip  { background: var(--warning); }
.day-chip.video-chip { background: #7C3AED; color: #fff; }

/* ─── CHAPTER LIST (subject detail) ─────────────────────────────────────────── */
.chapter-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 14px;
}
.chapter-list-item[draggable="true"] { cursor: default; }
.chapter-list-item.dragging {
  opacity: 0.4;
  background: var(--bg);
}
.chapter-list-item.drag-over {
  border-top: 2px solid var(--primary);
  margin-top: -2px;
}

.chapter-list-name { flex: 1; font-weight: 500; }
.chapter-list-parts { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* ─── STUDY ORDER TOGGLE ─────────────────────────────────────────────────────── */
.study-order-toggle {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.study-order-option {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--card);
  transition: border-color 0.15s, background 0.15s;
  text-align: left;
}

.study-order-option:hover { border-color: var(--primary); }

.study-order-option.selected {
  border-color: var(--primary);
  background: var(--primary-light);
}

.study-order-option input[type="radio"] { margin-top: 2px; flex-shrink: 0; }

.study-order-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.study-order-desc {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
  line-height: 1.4;
}

/* ─── UTILITIES ──────────────────────────────────────────────────────────────── */
.hidden   { display: none !important; }
.mt-8     { margin-top: 8px; }
.mt-12    { margin-top: 12px; }
.mt-16    { margin-top: 16px; }
.text-muted { color: var(--text-muted); font-size: 13px; }
.text-danger { color: var(--danger); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── LOGIN SCHERM ───────────────────────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.login-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.10);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
}

.login-brand img {
  width: 28px;
  height: 28px;
}

.login-title {
  font-size: 26px;
  line-height: 1.1;
  margin-bottom: 8px;
  color: var(--text);
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.login-error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
  padding: 8px 12px;
  background: var(--danger-light);
  border-radius: 8px;
}

.login-toggle-btn {
  width: 100%;
  margin-top: 12px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

.login-toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ─── CHAT ───────────────────────────────────────────────────────────────────── */

.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-h) - 2rem);
  gap: 0;
  overflow: hidden;
}

.chat-sidebar {
  width: 300px;
  min-width: 260px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-right: 1px solid var(--border);
  border-radius: var(--radius) 0 0 var(--radius);
  overflow: hidden;
}

.chat-sidebar-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-search-wrap {
  position: relative;
}

.chat-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

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

.chat-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 50;
  max-height: 200px;
  overflow-y: auto;
}

.chat-search-results.hidden {
  display: none;
}

.chat-search-item {
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

.chat-search-item:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

.chat-search-item--empty {
  color: var(--text-muted);
  cursor: default;
}

.chat-search-item--empty:hover {
  background: transparent;
  color: var(--text-muted);
}

.chat-conv-list {
  flex: 1;
  overflow-y: auto;
}

.chat-conversation-item {
  padding: 12px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.chat-conversation-item:hover {
  background: var(--bg);
}

.chat-conversation-item.active {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}

.chat-conv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-conv-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-conv-time {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.chat-conv-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.chat-conv-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-unread-badge {
  flex-shrink: 0;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 0 var(--radius) var(--radius) 0;
  overflow: hidden;
  min-width: 0;
}

.chat-main-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-back-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  line-height: 1;
  display: none;
}

.chat-back-btn:hover {
  background: var(--border);
  color: var(--text);
}

.chat-main-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-bubble {
  max-width: 70%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-bubble--self {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-bubble--other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble-text {
  display: inline-block;
  padding: 8px 12px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-bubble--self .chat-bubble-text {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble--other .chat-bubble-text {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-bubble-time {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  line-height: 1.4;
  transition: border-color 0.15s;
  overflow-y: hidden;
}

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

.chat-send-btn {
  flex-shrink: 0;
  align-self: flex-end;
  padding: 8px 18px;
  font-size: 13px;
}

.chat-empty-state {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 32px 16px;
  line-height: 1.6;
}

.chat-empty-state--main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* Mobiel: sidebar verbergen als gesprek open is */
@media (max-width: 640px) {
  .chat-layout {
    height: calc(100vh - var(--header-h));
    border-radius: 0;
  }

  .chat-sidebar {
    border-radius: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .chat-main {
    border-radius: 0;
    display: none;
  }

  .chat-layout.chat-conv-open .chat-sidebar {
    display: none;
  }

  .chat-layout.chat-conv-open .chat-main {
    display: flex;
  }

  .chat-back-btn {
    display: inline-flex;
  }
}
