/* ============================================
   ClassCheck - Assessment Table Styles
   Dark Mode Design System
   ============================================ */

/* Sticky header heights for proper stacking */
:root {
  --topbar-height: 56px;
  --class-header-height: 80px;
  --preset-bar-height: 42px;
  --category-legend-height: 0px; /* Only adds when legend is present */
}

.class-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
}

.class-page-content {
  display: flex;
  flex-direction: column;
  background: var(--bg-base);
  min-width: 0;
  flex: 1;
}

/* ============================================
   Class Header
   ============================================ */

.class-header {
  background: var(--bg-elevated);
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: var(--topbar-height);
  z-index: 90;
  gap: 1rem;
  flex-wrap: wrap;
}

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

.back-btn {
  font-size: 1.5rem;
  text-decoration: none;
  color: var(--text-tertiary);
  padding: 0.25rem 0.5rem;
  transition: color 0.15s;
}

.back-btn:hover {
  color: var(--accent);
}

.class-info h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.class-info .class-meta {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
}

.header-right {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-undo {
  background: var(--yellow-bg);
  color: var(--yellow-mid);
  border: 1px solid rgba(234, 179, 8, 0.3);
}

.btn-undo:hover:not(:disabled) {
  background: rgba(234, 179, 8, 0.25);
}

.btn-undo:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   Table Container
   ============================================ */

.table-container {
  overflow: auto;
  padding: 0 1rem 1rem 1rem;
  position: relative;
  flex: 1;
}

.assessment-table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-elevated);
  border-radius: 0;
  border: 1px solid var(--border-subtle);
  border-top: none;
  font-size: 0.875rem;
}

/* First column sticky - applied directly to ensure it works */
.assessment-table th:first-child,
.assessment-table td:first-child {
  position: -webkit-sticky;
  position: sticky;
  left: 0;
  z-index: 5;
  box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.15);
}

/* Cover any gap to the left of sticky column */
.assessment-table th:first-child::before,
.assessment-table td:first-child::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1rem;
  width: 1rem;
  background: inherit;
}

.assessment-table th:first-child {
  z-index: 20;
  background: var(--bg-surface);
}

.assessment-table tbody td:first-child {
  background: var(--bg-elevated);
}

.assessment-table tbody tr:nth-child(even) td:first-child {
  background: var(--bg-surface);
}

.assessment-table tbody tr:hover td:first-child {
  background: var(--bg-hover);
}

/* ============================================
   Table Header
   ============================================ */

.assessment-table thead th {
  background: var(--bg-surface);
  color: var(--text-secondary);
  font-weight: 500;
  padding: 0.75rem 0.5rem;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: normal;
  min-width: 60px;
  max-width: 120px;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-transform: uppercase;
  font-size: 0.6875rem;
  letter-spacing: 0.05em;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.assessment-table thead th:first-child {
  text-align: left;
  min-width: 150px;
  text-transform: none;
  font-size: 0.8125rem;
  letter-spacing: normal;
  /* Sticky both horizontally and vertically (corner cell) */
  left: 0;
  z-index: 20;
  box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.15);
}

.col-header {
  /* position: relative is inherited from thead th sticky context */
}

.col-header-content {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: center;
  gap: 0.125rem;
}

.col-name {
  font-weight: 600;
  color: var(--text-primary);
  text-transform: none;
  font-size: 0.8125rem;
  letter-spacing: normal;
  line-height: 1.2;
  min-width: 0;
  max-width: 80px;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}

.col-date {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  font-weight: 400;
}

.col-notes-icon {
  font-size: 0.65rem;
  opacity: 0.5;
  cursor: help;
  position: relative;
}

.col-header:hover .col-notes-icon {
  opacity: 0.8;
}

.col-notes-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface, #fff);
  color: var(--text-color, #333);
  border: 1px solid var(--border-color, #ccc);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 400;
  white-space: pre-wrap;
  max-width: 220px;
  min-width: 100px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  pointer-events: none;
  line-height: 1.4;
}

/* When header has colored background, reduce intensity with overlay */
/* Note: sticky already establishes positioning context for ::before */

.col-header[style*="background-color:"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  opacity: 0.85;
  pointer-events: none;
}

[data-theme="light"] .col-header[style*="background-color:"]::before {
  opacity: 0.88;
}

.col-header[style*="background-color:"] .col-header-content {
  position: relative;
  z-index: 1;
}

.col-header[style*="background-color:"] .col-name,
.col-header[style*="background-color:"] .col-date {
  color: var(--text-primary);
}

.col-header[style*="background-color:"] .col-date {
  opacity: 0.6;
}

.col-menu-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  line-height: 1;
  opacity: 0;
  transition: all 0.15s;
  border-radius: 4px;
  z-index: 2;
}

.col-header:hover .col-menu-btn {
  opacity: 1;
}

.col-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* Column header drag and drop */
.col-header[draggable="true"] {
  cursor: grab;
}

.col-header[draggable="true"]:active {
  cursor: grabbing;
}

.col-header.dragging {
  opacity: 0.5;
}

.col-header.drag-over {
  border-left: 3px solid var(--accent);
}

/* ============================================
   Sticky Name Column
   ============================================ */

.sticky-col {
  position: -webkit-sticky;
  position: sticky;
  left: 0 !important;
  z-index: 5;
  background: var(--bg-elevated);
  /* Shadow to indicate scrollable content */
  box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.15);
}

/* CSS custom properties for sticky column widths */
:root {
  --student-col-width: 150px;
  --sticky-col-width: 80px;
  --weighted-avg-width: 60px;
}

.student-col {
  padding: 0.625rem 0.75rem;
  font-weight: 500;
  border-right: 1px solid var(--border-subtle);
  min-width: 120px;
  max-width: 180px;
  width: var(--student-col-width);
  color: var(--text-primary);
}

/* ============================================
   Sticky Data Columns (pinned after name)
   ============================================ */

.col-sticky {
  position: -webkit-sticky;
  position: sticky;
  z-index: 4;
  background: var(--bg-elevated);
}

/* Header sticky columns need higher z-index */
th.col-sticky {
  z-index: 19;
  background: var(--bg-surface);
}

/* Dynamic left positioning for sticky columns (shifted right by weighted-avg width) */
.col-sticky[data-sticky-index="0"] {
  left: calc(var(--student-col-width) + var(--weighted-avg-width));
}

.col-sticky[data-sticky-index="1"] {
  left: calc(var(--student-col-width) + var(--weighted-avg-width) + var(--sticky-col-0-width, var(--sticky-col-width)));
}

.col-sticky[data-sticky-index="2"] {
  left: calc(var(--student-col-width) + var(--weighted-avg-width) + var(--sticky-col-0-width, var(--sticky-col-width)) + var(--sticky-col-1-width, var(--sticky-col-width)));
}

/* Shadow on last sticky column */
.col-sticky.last-sticky {
  box-shadow: 2px 0 4px -2px rgba(0, 0, 0, 0.15);
}

/* Sticky indicator icon */
.sticky-indicator {
  color: var(--accent);
  font-size: 0.6rem;
  margin-left: 0.25rem;
  opacity: 0.8;
}

/* Alternating row backgrounds for sticky columns */
.assessment-table tbody tr:nth-child(even) td.col-sticky {
  background: var(--bg-surface);
}

.assessment-table tbody tr:hover td.col-sticky {
  background: var(--bg-hover);
}

/* Stats row sticky cell */
.stats-row td.col-sticky {
  background: var(--bg-surface);
}

.student-col-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.student-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.name-settings-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 0.875rem;
  opacity: 0.6;
  transition: all 0.15s;
  border-radius: 4px;
}

.name-settings-btn:hover {
  color: var(--accent);
  opacity: 1;
}

.sort-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.125rem 0.25rem;
  font-size: 0.625rem;
  opacity: 0.6;
  transition: all 0.15s;
  border-radius: 4px;
  line-height: 1;
}

.sort-btn:hover {
  color: var(--accent);
  opacity: 1;
}

.sort-btn .sort-arrow {
  display: inline-block;
  transition: transform 0.15s;
}

.sort-btn.desc .sort-arrow {
  transform: rotate(180deg);
}

.name-display-menu {
  position: fixed;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 180px;
  overflow: hidden;
  padding: 0.25rem;
}

.name-display-menu button {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.name-display-menu button:hover {
  background: var(--bg-hover);
}

.name-display-menu button.active {
  background: var(--accent-muted);
  color: var(--accent);
}

.name-display-menu .menu-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 0.375rem 0;
}

.name-display-menu .menu-section-label {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.375rem 1rem 0.25rem;
  font-weight: 500;
}

.student-menu-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0;
  transition: all 0.15s;
  border-radius: 4px;
}

tr:hover .student-menu-btn {
  opacity: 1;
}

.student-menu-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

/* ============================================
   Table Body
   ============================================ */

.assessment-table tbody tr {
  transition: background 0.1s;
}

.assessment-table tbody tr:nth-child(even) {
  background: var(--bg-surface);
}

.assessment-table tbody tr:nth-child(even) .sticky-col {
  background: var(--bg-surface);
}

.assessment-table tbody tr:hover {
  background: var(--bg-hover);
}

.assessment-table tbody tr:hover .sticky-col {
  background: var(--bg-hover);
}

/* Active row (keyboard navigation / cell focus) */
.assessment-table tbody tr.row-active {
  background: var(--bg-hover);
}
.assessment-table tbody tr.row-active .sticky-col {
  background: var(--bg-hover);
}
.assessment-table tbody tr.row-active td:first-child {
  background: var(--bg-hover);
}
.assessment-table tbody tr.row-active td.col-sticky {
  background: var(--bg-hover);
}
.assessment-table tbody tr.row-active td.weighted-avg-cell {
  background: var(--bg-hover) !important;
}

/* Suppress hover highlight when a row is keyboard-active */
.assessment-table tbody:has(.row-active) tr:hover {
  background: inherit;
}
.assessment-table tbody:has(.row-active) tr:hover td:first-child {
  background: inherit;
}
.assessment-table tbody:has(.row-active) tr:hover .sticky-col {
  background: inherit;
}
.assessment-table tbody:has(.row-active) tr:hover td.col-sticky {
  background: inherit;
}
.assessment-table tbody:has(.row-active) tr:hover td.weighted-avg-cell {
  background: inherit !important;
}

/* Re-apply hover on the active row itself */
.assessment-table tbody tr.row-active:hover {
  background: var(--bg-hover);
}

/* ============================================
   Assessment Cells - Grade Colors (Muted BG + Colored Text)
   ============================================ */

.assessment-cell {
  text-align: center;
  padding: 0.5rem;
  cursor: pointer;
  user-select: none;
  border: 1px solid var(--border-subtle);
  box-shadow: none;
  transition: all 0.1s;
  min-width: 50px;
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

/* Handle long values in cells */
.assessment-cell .cell-value {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 60px;
}

.assessment-cell:hover {
  background: var(--bg-hover);
  border-color: var(--border-default);
}

.assessment-cell:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Grade color classes - small badge around the value */
.assessment-cell.green .cell-value,
.assessment-cell.lightgreen .cell-value,
.assessment-cell.yellow .cell-value,
.assessment-cell.orange .cell-value,
.assessment-cell.red .cell-value,
.assessment-cell.gray .cell-value,
.assessment-cell.lime .cell-value,
.assessment-cell.cyan .cell-value,
.assessment-cell.indigo .cell-value,
.assessment-cell.rose .cell-value,
.assessment-cell.amber .cell-value,
.assessment-cell.slate .cell-value,
.assessment-cell.emerald .cell-value {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
}

.assessment-cell.green .cell-value {
  background: var(--green-bg);
  color: var(--green-good);
}

.assessment-cell.lightgreen .cell-value {
  background: var(--lightgreen-bg);
  color: var(--lightgreen-good);
}

.assessment-cell.yellow .cell-value {
  background: var(--yellow-bg);
  color: var(--yellow-mid);
}

.assessment-cell.orange .cell-value {
  background: var(--orange-bg);
  color: var(--orange-warn);
}

.assessment-cell.red .cell-value {
  background: var(--red-bg);
  color: var(--red-bad);
}

.assessment-cell.gray .cell-value {
  background: var(--gray-bg);
  color: var(--gray-neutral);
}

.assessment-cell.lime .cell-value {
  background: var(--lime-bg);
  color: var(--lime-good);
}

.assessment-cell.cyan .cell-value {
  background: var(--cyan-bg);
  color: var(--cyan-good);
}

.assessment-cell.indigo .cell-value {
  background: var(--indigo-bg);
  color: var(--indigo-good);
}

.assessment-cell.rose .cell-value {
  background: var(--rose-bg);
  color: var(--rose-good);
}

.assessment-cell.amber .cell-value {
  background: var(--amber-bg);
  color: var(--amber-good);
}

.assessment-cell.slate .cell-value {
  background: var(--slate-bg);
  color: var(--slate-good);
}

.assessment-cell.emerald .cell-value {
  background: var(--emerald-bg);
  color: var(--emerald-good);
}

/* Column header color - subtle tinted background */
.assessment-cell.has-header-color {
  background: color-mix(in srgb, var(--header-color) 12%, var(--bg-elevated)) !important;
}

[data-theme="light"] .assessment-cell.has-header-color {
  background: color-mix(in srgb, var(--header-color) 8%, var(--bg-elevated)) !important;
}

/* When cell has header color, give .cell-value a semi-transparent background for contrast */
.assessment-cell.has-header-color .cell-value:not(:empty) {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

/* Light mode: use white-based transparency */
[data-theme="light"] .assessment-cell.has-header-color .cell-value:not(:empty) {
  background: rgba(255, 255, 255, 0.55);
}

/* Grade colors for cells with header color - solid colored badges */
.assessment-cell.has-header-color.green .cell-value {
  background: #166534;
  color: #86efac;
}
.assessment-cell.has-header-color.lightgreen .cell-value {
  background: #15803d;
  color: #bbf7d0;
}
.assessment-cell.has-header-color.yellow .cell-value {
  background: #854d0e;
  color: #fde047;
}
.assessment-cell.has-header-color.orange .cell-value {
  background: #9a3412;
  color: #fdba74;
}
.assessment-cell.has-header-color.red .cell-value {
  background: #991b1b;
  color: #fca5a5;
}
.assessment-cell.has-header-color.gray .cell-value {
  background: #374151;
  color: #d1d5db;
}
.assessment-cell.has-header-color.lime .cell-value {
  background: #3f6212;
  color: #bef264;
}
.assessment-cell.has-header-color.cyan .cell-value {
  background: #155e75;
  color: #67e8f9;
}
.assessment-cell.has-header-color.indigo .cell-value {
  background: #3730a3;
  color: #a5b4fc;
}
.assessment-cell.has-header-color.rose .cell-value {
  background: #9f1239;
  color: #fda4af;
}
.assessment-cell.has-header-color.amber .cell-value {
  background: #92400e;
  color: #fcd34d;
}
.assessment-cell.has-header-color.slate .cell-value {
  background: #334155;
  color: #cbd5e1;
}
.assessment-cell.has-header-color.emerald .cell-value {
  background: #065f46;
  color: #6ee7b7;
}

/* Light mode overrides for grade colors with header */
[data-theme="light"] .assessment-cell.has-header-color.green .cell-value {
  background: #bbf7d0;
  color: #166534;
}
[data-theme="light"] .assessment-cell.has-header-color.lightgreen .cell-value {
  background: #dcfce7;
  color: #15803d;
}
[data-theme="light"] .assessment-cell.has-header-color.yellow .cell-value {
  background: #fef08a;
  color: #854d0e;
}
[data-theme="light"] .assessment-cell.has-header-color.orange .cell-value {
  background: #fed7aa;
  color: #9a3412;
}
[data-theme="light"] .assessment-cell.has-header-color.red .cell-value {
  background: #fecaca;
  color: #991b1b;
}
[data-theme="light"] .assessment-cell.has-header-color.gray .cell-value {
  background: #e5e7eb;
  color: #374151;
}
[data-theme="light"] .assessment-cell.has-header-color.lime .cell-value {
  background: #d9f99d;
  color: #3f6212;
}
[data-theme="light"] .assessment-cell.has-header-color.cyan .cell-value {
  background: #a5f3fc;
  color: #155e75;
}
[data-theme="light"] .assessment-cell.has-header-color.indigo .cell-value {
  background: #c7d2fe;
  color: #3730a3;
}
[data-theme="light"] .assessment-cell.has-header-color.rose .cell-value {
  background: #fecdd3;
  color: #9f1239;
}
[data-theme="light"] .assessment-cell.has-header-color.amber .cell-value {
  background: #fde68a;
  color: #92400e;
}
[data-theme="light"] .assessment-cell.has-header-color.slate .cell-value {
  background: #e2e8f0;
  color: #334155;
}
[data-theme="light"] .assessment-cell.has-header-color.emerald .cell-value {
  background: #a7f3d0;
  color: #065f46;
}

/* Cell with notes indicator */
.assessment-cell {
  position: relative;
}

.assessment-cell.has-notes::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* ============================================
   Empty States
   ============================================ */

.empty-header {
  padding: 1rem;
}

.empty-message {
  text-align: center;
  color: var(--text-tertiary);
  padding: 2rem;
}

/* Override student-col constraints when showing empty message */
.empty-message.student-col {
  max-width: none;
  width: auto;
  display: table-cell;
  text-align: center;
  justify-content: center;
}

.empty-message a {
  color: var(--accent);
}

.empty-message a:hover {
  text-decoration: underline;
}

/* ============================================
   Status Bar
   ============================================ */

.status-bar {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  padding: 0.5rem 1.5rem;
  display: flex;
  gap: 2rem;
  font-size: 0.8125rem;
  border-top: 1px solid var(--border-subtle);
}

.status-hint {
  opacity: 0.5;
  font-size: 0.75rem;
}

#saveStatus {
  margin-left: auto;
  color: var(--text-tertiary);
}

/* ============================================
   Attendance Summary in Status Bar
   ============================================ */

.attendance-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.attendance-label {
  font-weight: 500;
  color: var(--text-tertiary);
}

.attendance-rate {
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
}

.attendance-rate.good {
  background: var(--green-bg);
  color: var(--green-good);
}

.attendance-rate.warn {
  background: var(--yellow-bg);
  color: var(--yellow-mid);
}

.attendance-rate.bad {
  background: var(--red-bg);
  color: var(--red-bad);
}

.attendance-detail {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  cursor: help;
}

/* ============================================
   Context Menu
   ============================================ */

.context-menu {
  position: fixed;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  min-width: 140px;
  overflow: hidden;
  padding: 0.25rem;
}

.context-menu button {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  text-align: left;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  transition: background 0.1s;
}

.context-menu button:hover {
  background: var(--bg-hover);
}

.context-menu button.danger {
  color: var(--red-bad);
}

.context-menu button.danger:hover {
  background: var(--red-bg);
}

/* ============================================
   Responsive - Mobile
   ============================================ */

@media (max-width: 768px) {
  .class-header {
    padding: 0.75rem 1rem;
    flex-direction: column;
    gap: 0.75rem;
  }

  .header-left {
    width: 100%;
    display: flex;
    align-items: center;
  }

  .class-info h1 {
    font-size: 1rem;
  }

  .header-right {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .header-right .btn {
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
  }

  .header-right .mobile-hide {
    display: none;
  }

  .table-container {
    padding: 0 0.5rem 0.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .assessment-table {
    font-size: 0.8125rem;
  }

  .assessment-table thead th {
    padding: 0.5rem 0.25rem;
    font-size: 0.6875rem;
    min-width: 45px;
  }

  .student-col {
    min-width: 70px;
    max-width: 90px;
    width: 80px;
    padding: 0.4rem 0.5rem;
    font-size: 0.75rem;
  }

  /* Mobile sticky column adjustments */
  :root {
    --student-col-width: 80px;
    --sticky-col-width: 50px;
  }

  .col-sticky[data-sticky-index="0"] {
    left: calc(80px + var(--weighted-avg-width));
  }

  .col-sticky[data-sticky-index="1"] {
    left: calc(80px + var(--weighted-avg-width) + var(--sticky-col-0-width, 50px));
  }

  .col-sticky[data-sticky-index="2"] {
    left: calc(80px + var(--weighted-avg-width) + var(--sticky-col-0-width, 50px) + var(--sticky-col-1-width, 50px));
  }

  .student-name {
    font-size: 0.75rem;
  }

  .assessment-cell {
    min-width: 35px;
    padding: 0.4rem 0.2rem;
    font-size: 0.8125rem;
  }

  .col-date {
    display: none;
  }

  .col-menu-btn {
    opacity: 1;
    padding: 0.5rem;
    font-size: 1.1rem;
  }

  .student-menu-btn {
    opacity: 1;
  }

  .status-bar {
    padding: 0.25rem 0.75rem;
    gap: 0.5rem 1rem;
    font-size: 0.6875rem;
    flex-wrap: wrap;
  }

  .status-hint {
    display: none;
  }

  .attendance-summary {
    padding: 0.125rem 0.5rem;
  }

  .attendance-detail {
    display: none;
  }

  .context-menu {
    min-width: 160px;
  }

  .context-menu button {
    padding: 0.875rem 1rem;
    font-size: 0.9375rem;
  }
}

/* ============================================
   Modal Sizes
   ============================================ */

.modal-sm .modal-content {
  max-width: 360px;
}

/* ============================================
   Notes Indicator
   ============================================ */

.notes-indicator {
  margin-left: 0.4rem;
  font-size: 0.8em;
  opacity: 0.5;
  cursor: default;
  vertical-align: middle;
}

.notes-indicator:hover {
  opacity: 0.8;
}

/* ============================================
   Bold Columns (Important columns)
   ============================================ */

.col-header.col-bold .col-name {
  font-weight: 700;
  color: var(--accent);
}

.col-header.col-bold {
  border-bottom: 2px solid var(--accent);
}

/* ============================================
   Color Picker
   ============================================ */

.color-picker-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.color-picker-row input[type="color"] {
  width: 50px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--bg-surface);
}

.color-picker-row input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 2px;
}

.color-picker-row input[type="color"]::-webkit-color-swatch {
  border-radius: 3px;
  border: none;
}

/* ============================================
   Checkbox in Forms
   ============================================ */

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
  vertical-align: middle;
  cursor: pointer;
  accent-color: var(--accent);
}

.form-group label:has(input[type="checkbox"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-weight: normal;
  color: var(--text-primary);
}

/* ============================================
   Preset Quick-Add Bar
   ============================================ */

.preset-quick-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  position: sticky;
  top: calc(var(--topbar-height) + var(--class-header-height));
  z-index: 80;
}

.preset-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  color: var(--text-primary);
}

.preset-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Preset buttons with column color */
.preset-btn.has-preset-color {
  background: color-mix(in srgb, var(--preset-color) 15%, var(--bg-elevated));
  border-color: color-mix(in srgb, var(--preset-color) 30%, var(--border-subtle));
}

.preset-btn.has-preset-color:hover {
  background: color-mix(in srgb, var(--preset-color) 35%, var(--bg-elevated));
  border-color: var(--preset-color);
}

[data-theme="light"] .preset-btn.has-preset-color {
  background: color-mix(in srgb, var(--preset-color) 12%, var(--bg-elevated));
}

[data-theme="light"] .preset-btn.has-preset-color:hover {
  background: color-mix(in srgb, var(--preset-color) 25%, var(--bg-elevated));
}

.preset-btn.dragging {
  opacity: 0.5;
}

.preset-btn.drag-over {
  border-color: var(--accent);
  transform: scale(1.05);
}

.preset-btn-custom {
  background: transparent;
  border-style: dashed;
}

@media (max-width: 768px) {
  .preset-quick-bar {
    padding: 0.5rem;
    gap: 0.375rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .preset-btn {
    padding: 0.375rem 0.625rem;
    font-size: 0.75rem;
  }
}

/* ============================================
   Category Weights Legend
   ============================================ */

/* Compact toolbar (replaces old button row + weights legend) */
.compact-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-secondary);
  flex-wrap: wrap;
  position: sticky;
  top: calc(var(--topbar-height) + var(--class-header-height) + var(--preset-bar-height));
  z-index: 70;
}

.compact-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  flex-wrap: wrap;
}

.compact-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.compact-toolbar .legend-label {
  color: var(--text-tertiary);
  font-weight: 500;
}

.compact-toolbar .legend-item {
  color: var(--text-primary);
}

.compact-toolbar .legend-info-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 0 0.125rem;
  line-height: 1;
}

.compact-toolbar .legend-info-btn:hover {
  color: var(--accent);
}

/* Toolbar text-buttons */
.tb-link {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.2rem 0.375rem;
  border-radius: 3px;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  line-height: 1.2;
}

.tb-link:hover {
  color: var(--accent);
  background: var(--bg-hover);
}

.tb-link:disabled {
  opacity: 0.35;
  cursor: default;
}

.tb-link:disabled:hover {
  background: none;
  color: var(--text-secondary);
}

.tb-sep {
  color: var(--text-tertiary);
  opacity: 0.4;
  user-select: none;
}

.tb-hidden-btn {
  color: var(--accent);
  font-weight: 500;
}

/* Toolbar dropdown */
.tb-dropdown {
  position: relative;
  display: inline-block;
}

.tb-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 200;
  min-width: 140px;
  padding: 0.25rem 0;
}

.tb-dropdown-menu.show {
  display: block;
}

.tb-dropdown-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-primary);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.tb-dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Category weight info tooltip */
.category-weight-tooltip {
  position: fixed;
  z-index: 1000;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 1rem;
  max-width: 350px;
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  line-height: 1.5;
}

.category-weight-tooltip h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9375rem;
  color: var(--text-primary);
}

.category-weight-tooltip p {
  margin: 0 0 0.5rem 0;
  color: var(--text-secondary);
}

.category-weight-tooltip .tooltip-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

/* ============================================
   Mobile Preset Toggle + Toolbar Overflow
   ============================================ */

/* Preset toggle button — hidden on desktop, shown on mobile */
.preset-toggle-mobile {
  display: none;
  padding: 0.5rem 1rem;
  background: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--accent, #5D4C9A);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  position: sticky;
  top: calc(var(--topbar-height) + var(--class-header-height));
  z-index: 80;
}

.preset-toggle-mobile:hover {
  background: var(--bg-hover);
}

/* Toolbar overflow button — hidden on desktop */
.tb-overflow-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.125rem 0.5rem;
  line-height: 1;
  white-space: nowrap;
}

.tb-overflow-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

/* Overflow items container — inline on desktop, dropdown on mobile */
.tb-overflow-items {
  display: contents;
}

@media (max-width: 768px) {
  .compact-toolbar {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    gap: 0.25rem;
  }

  .compact-toolbar-right .tb-sep { display: none; }

  /* Hide preset bar by default on mobile, toggled by JS */
  .preset-quick-bar {
    display: none;
  }

  .preset-quick-bar.mobile-visible {
    display: flex;
  }

  .preset-toggle-mobile {
    display: block;
  }

  /* Toolbar overflow: show "..." button, hide secondary items */
  .tb-overflow-btn {
    display: inline-block;
  }

  .tb-overflow-items {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 200;
    min-width: 160px;
    padding: 0.375rem 0;
    flex-direction: column;
  }

  .tb-overflow-items.show {
    display: flex;
  }

  .tb-overflow-items .tb-link,
  .tb-overflow-items .tb-dropdown,
  .tb-overflow-items .tb-classroom-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    white-space: nowrap;
  }

  .tb-overflow-items .tb-sep {
    display: none;
  }

  .compact-toolbar-right {
    position: relative;
  }

  /* Category breakdown starts collapsed on mobile */
  .category-breakdown-bar.mobile-collapsed .breakdown-items {
    display: none;
  }

  .category-breakdown-bar.mobile-collapsed .breakdown-toggle {
    transform: rotate(-90deg);
  }
}

/* ============================================
   Header Collapse Button
   ============================================ */

.header-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 24px;
  background: var(--bg-surface);
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0;
  transition: background 0.15s;
  position: sticky;
  top: 0;
  z-index: 65;
}

.header-collapse-btn:hover {
  background: var(--bg-hover);
  color: var(--text-secondary);
}

.collapse-arrow {
  line-height: 1;
}

/* Collapsed state */
.header-collapsed .topbar {
  display: none !important;
}

/* On mobile, keep topbar visible when collapsed (hamburger needs to stay accessible) */
@media (max-width: 768px) {
  .header-collapsed .topbar {
    display: block !important;
  }

  .header-collapsed .compact-toolbar,
  .header-collapsed .preset-quick-bar,
  .header-collapsed #semesterSelectorWrapper,
  .header-collapsed #categoryBreakdownBar {
    display: none !important;
  }

  .header-collapsed .header-collapse-btn {
    top: auto;
  }
}

.header-collapsed .preset-quick-bar {
  top: 0;
}

.header-collapsed .compact-toolbar {
  top: var(--preset-bar-height);
}

.header-collapsed .alert {
  display: none !important;
}

.header-collapsed .header-collapse-btn {
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-collapsed .table-container {
  overflow: auto;
}

/* ============================================
   Hidden Columns Button
   ============================================ */

.btn-show-hidden {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--yellow-bg);
  color: var(--yellow-mid);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-show-hidden:hover {
  background: rgba(234, 179, 8, 0.25);
}

/* ============================================
   Multi-Select Columns
   ============================================ */

.col-header.column-selected {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background-color: var(--accent-muted) !important;
}

.btn-hide-selected {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-hide-selected:hover {
  background: var(--accent);
  color: white;
}

/* ============================================
   Reverse Columns Button
   ============================================ */

.btn-reverse-columns {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  font-size: 1.1rem;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-reverse-columns:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-reverse-columns.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================
   Transpose Button
   ============================================ */

.btn-transpose {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.25rem 0.5rem;
  font-size: 1.1rem;
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-transpose:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-transpose.active {
  background: var(--accent-muted);
  color: var(--accent);
  border-color: var(--accent);
}

/* ============================================
   Transposed Table View
   ============================================ */

.table-transposed .assessment-table {
  /* Reset normal table behavior */
}

.table-transposed .transposed-wrapper {
  overflow: auto;
  max-height: calc(100vh - var(--topbar-height) - var(--class-header-height) - var(--preset-bar-height) - 60px);
}

.table-transposed .transposed-table {
  border-collapse: collapse;
  width: auto;
}

.table-transposed .transposed-table th,
.table-transposed .transposed-table td {
  border: 1px solid var(--border-default);
  padding: 0.5rem;
  text-align: center;
  min-width: 60px;
}

.table-transposed .transposed-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-surface);
  z-index: 10;
  font-weight: 600;
  white-space: nowrap;
}

.table-transposed .transposed-table tbody th {
  position: sticky;
  left: 0;
  background: var(--bg-surface);
  z-index: 5;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
}

.table-transposed .transposed-table thead th:first-child {
  position: sticky;
  left: 0;
  top: 0;
  z-index: 15;
  background: var(--bg-surface);
}

.table-transposed .transposed-cell {
  cursor: pointer;
  transition: all 0.1s;
  position: relative;
  border: 1px solid var(--border-subtle);
}

.table-transposed .transposed-cell:hover {
  border-color: var(--border-default);
  background: var(--bg-hover);
}

.table-transposed .transposed-cell:focus {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  box-shadow: 0 0 0 3px rgba(93, 76, 154, 0.3);
}

/* Column header color for transposed cells - subtle tinted background */
.table-transposed .transposed-cell.has-header-color {
  background: color-mix(in srgb, var(--header-color) 12%, var(--bg-elevated)) !important;
}

[data-theme="light"] .table-transposed .transposed-cell.has-header-color {
  background: color-mix(in srgb, var(--header-color) 8%, var(--bg-elevated)) !important;
}

/* Value badge in transposed cells with header color */
.table-transposed .transposed-cell.has-header-color .cell-value:not(:empty) {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .table-transposed .transposed-cell.has-header-color .cell-value:not(:empty) {
  background: rgba(255, 255, 255, 0.55);
}

/* Grade colors for transposed cells */
.table-transposed .transposed-cell.green .cell-value,
.table-transposed .transposed-cell.lightgreen .cell-value,
.table-transposed .transposed-cell.yellow .cell-value,
.table-transposed .transposed-cell.orange .cell-value,
.table-transposed .transposed-cell.red .cell-value,
.table-transposed .transposed-cell.gray .cell-value,
.table-transposed .transposed-cell.lime .cell-value,
.table-transposed .transposed-cell.cyan .cell-value,
.table-transposed .transposed-cell.indigo .cell-value,
.table-transposed .transposed-cell.rose .cell-value,
.table-transposed .transposed-cell.amber .cell-value,
.table-transposed .transposed-cell.slate .cell-value,
.table-transposed .transposed-cell.emerald .cell-value {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
}

.table-transposed .transposed-cell.green .cell-value {
  background: var(--green-bg);
  color: var(--green-good);
}
.table-transposed .transposed-cell.lightgreen .cell-value {
  background: var(--lightgreen-bg);
  color: var(--lightgreen-good);
}
.table-transposed .transposed-cell.yellow .cell-value {
  background: var(--yellow-bg);
  color: var(--yellow-mid);
}
.table-transposed .transposed-cell.orange .cell-value {
  background: var(--orange-bg);
  color: var(--orange-warn);
}
.table-transposed .transposed-cell.red .cell-value {
  background: var(--red-bg);
  color: var(--red-bad);
}
.table-transposed .transposed-cell.gray .cell-value {
  background: var(--gray-bg);
  color: var(--gray-neutral);
}
.table-transposed .transposed-cell.lime .cell-value {
  background: var(--lime-bg);
  color: var(--lime-good);
}
.table-transposed .transposed-cell.cyan .cell-value {
  background: var(--cyan-bg);
  color: var(--cyan-good);
}
.table-transposed .transposed-cell.indigo .cell-value {
  background: var(--indigo-bg);
  color: var(--indigo-good);
}
.table-transposed .transposed-cell.rose .cell-value {
  background: var(--rose-bg);
  color: var(--rose-good);
}
.table-transposed .transposed-cell.amber .cell-value {
  background: var(--amber-bg);
  color: var(--amber-good);
}
.table-transposed .transposed-cell.slate .cell-value {
  background: var(--slate-bg);
  color: var(--slate-good);
}
.table-transposed .transposed-cell.emerald .cell-value {
  background: var(--emerald-bg);
  color: var(--emerald-good);
}

/* Grade colors for transposed cells with header color - solid badges */
.table-transposed .transposed-cell.has-header-color.green .cell-value {
  background: #166534;
  color: #86efac;
}
.table-transposed .transposed-cell.has-header-color.lightgreen .cell-value {
  background: #15803d;
  color: #bbf7d0;
}
.table-transposed .transposed-cell.has-header-color.yellow .cell-value {
  background: #854d0e;
  color: #fde047;
}
.table-transposed .transposed-cell.has-header-color.orange .cell-value {
  background: #9a3412;
  color: #fdba74;
}
.table-transposed .transposed-cell.has-header-color.red .cell-value {
  background: #991b1b;
  color: #fca5a5;
}
.table-transposed .transposed-cell.has-header-color.gray .cell-value {
  background: #374151;
  color: #d1d5db;
}
.table-transposed .transposed-cell.has-header-color.lime .cell-value {
  background: #3f6212;
  color: #bef264;
}
.table-transposed .transposed-cell.has-header-color.cyan .cell-value {
  background: #155e75;
  color: #67e8f9;
}
.table-transposed .transposed-cell.has-header-color.indigo .cell-value {
  background: #3730a3;
  color: #a5b4fc;
}
.table-transposed .transposed-cell.has-header-color.rose .cell-value {
  background: #9f1239;
  color: #fda4af;
}
.table-transposed .transposed-cell.has-header-color.amber .cell-value {
  background: #92400e;
  color: #fcd34d;
}
.table-transposed .transposed-cell.has-header-color.slate .cell-value {
  background: #334155;
  color: #cbd5e1;
}
.table-transposed .transposed-cell.has-header-color.emerald .cell-value {
  background: #065f46;
  color: #6ee7b7;
}

/* Light mode overrides for transposed cells with header color */
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.green .cell-value {
  background: #bbf7d0;
  color: #166534;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.lightgreen .cell-value {
  background: #dcfce7;
  color: #15803d;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.yellow .cell-value {
  background: #fef08a;
  color: #854d0e;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.orange .cell-value {
  background: #fed7aa;
  color: #9a3412;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.red .cell-value {
  background: #fecaca;
  color: #991b1b;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.gray .cell-value {
  background: #e5e7eb;
  color: #374151;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.lime .cell-value {
  background: #d9f99d;
  color: #3f6212;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.cyan .cell-value {
  background: #a5f3fc;
  color: #155e75;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.indigo .cell-value {
  background: #c7d2fe;
  color: #3730a3;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.rose .cell-value {
  background: #fecdd3;
  color: #9f1239;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.amber .cell-value {
  background: #fde68a;
  color: #92400e;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.slate .cell-value {
  background: #e2e8f0;
  color: #334155;
}
[data-theme="light"] .table-transposed .transposed-cell.has-header-color.emerald .cell-value {
  background: #a7f3d0;
  color: #065f46;
}

.table-transposed th.transposed-row-header {
  padding-right: 2rem;
}

/* Reduce intensity of colored row headers in transposed view */
/* Note: sticky already establishes positioning context for ::before */

.table-transposed th.transposed-row-header[style*="background-color"]::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-surface);
  opacity: 0.85;
  pointer-events: none;
}

[data-theme="light"] .table-transposed th.transposed-row-header[style*="background-color"]::before {
  opacity: 0.88;
}

.table-transposed th.transposed-row-header > span {
  position: relative;
  z-index: 1;
}

.table-transposed th.transposed-row-header .transposed-menu-btn {
  position: absolute;
  right: 0.25rem;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
}

.table-transposed .transposed-menu-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  font-size: 1rem;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.table-transposed th.transposed-row-header:hover .transposed-menu-btn {
  opacity: 1;
}

.table-transposed .transposed-menu-btn:hover {
  color: var(--text-primary);
}

/* ============================================
   Counter Inline Controls (+/-)
   ============================================ */

.counter-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  width: 100%;
}

.counter-btn {
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.1s;
}

.counter-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.counter-minus:hover {
  background: var(--red-good, #ef4444);
  border-color: var(--red-good, #ef4444);
}

.counter-plus:hover {
  background: var(--green-good, #22c55e);
  border-color: var(--green-good, #22c55e);
}

.counter-val {
  font-weight: 600;
  font-size: 0.8125rem;
  min-width: 16px;
  text-align: center;
  color: var(--text-primary);
}

.counter-active {
  z-index: 2;
}

/* ============================================
   E2EE Status Indicator (Clickable)
   ============================================ */

.e2ee-status-clickable {
  cursor: pointer;
  transition: all 0.15s;
}

.e2ee-status-clickable:hover {
  background: var(--accent-muted) !important;
  color: var(--accent);
}

/* ============================================
   Column Statistics Row
   ============================================ */

.stats-row {
  background: var(--bg-surface);
  border-bottom: 2px solid var(--border-default);
}

.stats-row.collapsed {
  display: none;
}

.stats-label {
  background: var(--bg-surface) !important;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 500;
  text-align: center;
  padding: 0.375rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.stats-toggle {
  cursor: pointer;
  font-size: 0.625rem;
  opacity: 0.6;
  transition: all 0.15s;
  display: inline-block;
}

.stats-toggle:hover {
  opacity: 1;
  color: var(--accent);
}

.stats-row.collapsed + tbody .stats-toggle,
.stats-toggle.collapsed {
  transform: rotate(180deg);
}

.stats-text {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stats-cell {
  text-align: center;
  padding: 0.375rem 0.25rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
  min-width: 50px;
}

.stats-avg {
  display: block;
  font-weight: 600;
}

.stats-dist {
  display: flex;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
}

.stats-bar {
  width: 6px;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  max-height: 16px;
  opacity: 0.7;
}

.stats-bar.green { background: var(--green-good); }
.stats-bar.yellow { background: var(--yellow-mid); }
.stats-bar.orange { background: var(--orange-warn); }
.stats-bar.red { background: var(--red-bad); }
.stats-bar.gray { background: var(--gray-neutral); }

/* Stats cell clickable */
.stats-cell {
  cursor: pointer;
  transition: background 0.15s;
}

.stats-cell:hover {
  background: var(--bg-hover);
}

/* Responsive stats */
@media (max-width: 768px) {
  .stats-row {
    display: none;
  }
}

/* ============================================
   Grade Statistics Modal (Notenspiegel)
   ============================================ */

.grade-stats-modal {
  max-width: 520px;
}

.grade-stats-body {
  padding: 1.25rem 1.5rem;
}

.grade-stats-info {
  margin-bottom: 1.25rem;
}

.grade-stats-system {
  font-size: 0.8125rem;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-sm);
}

.grade-stats-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.grade-stats-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 0.875rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border-subtle);
}

.grade-stats-value {
  display: block;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.grade-stats-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}

.grade-stats-histogram h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin: 0 0 0.875rem 0;
  font-weight: 600;
}

.grade-histogram-chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 120px;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
}

.grade-histogram-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.grade-histogram-bar-inner {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  transition: height 0.3s ease;
  min-height: 4px;
}

.grade-histogram-bar-label {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.grade-histogram-bar-count {
  font-size: 0.6875rem;
  color: var(--text-tertiary);
  margin-top: 0.125rem;
}

/* Histogram bar colors */
.grade-histogram-bar-inner.grade-1,
.grade-histogram-bar-inner.grade-A,
.grade-histogram-bar-inner.grade-plus {
  background: var(--green-good);
}

.grade-histogram-bar-inner.grade-2,
.grade-histogram-bar-inner.grade-B {
  background: var(--green-good);
  opacity: 0.8;
}

.grade-histogram-bar-inner.grade-3,
.grade-histogram-bar-inner.grade-C,
.grade-histogram-bar-inner.grade-wave {
  background: var(--yellow-mid);
}

.grade-histogram-bar-inner.grade-4,
.grade-histogram-bar-inner.grade-D {
  background: var(--orange-warn);
}

.grade-histogram-bar-inner.grade-5,
.grade-histogram-bar-inner.grade-E,
.grade-histogram-bar-inner.grade-minus {
  background: var(--red-bad);
}

.grade-histogram-bar-inner.grade-6,
.grade-histogram-bar-inner.grade-F {
  background: var(--red-bad);
}

.grade-histogram-bar-inner.grade-check {
  background: var(--green-good);
}

.grade-histogram-bar-inner.grade-x {
  background: var(--red-bad);
}

.grade-histogram-bar-inner.grade-neutral {
  background: var(--accent);
}

.grade-histogram-bar-inner.grade-present {
  background: var(--green-good);
}

.grade-histogram-bar-inner.grade-late {
  background: var(--yellow-mid);
}

.grade-histogram-bar-inner.grade-excused {
  background: var(--gray-neutral);
}

.grade-histogram-bar-inner.grade-absent {
  background: var(--red-bad);
}

.grade-stats-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.grade-stats-count-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  background: var(--bg-surface);
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius-sm);
}

.grade-stats-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  background: var(--accent-muted);
  color: var(--accent);
  border-radius: 3px;
  padding: 0 0.25rem;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .grade-stats-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .grade-stats-modal {
    max-width: calc(100vw - 2rem);
  }

  .grade-histogram-chart {
    height: 100px;
  }
}

/* ============================================
   Keyboard Shortcuts Modal
   ============================================ */

.shortcuts-modal {
  max-width: 500px;
}

.shortcuts-body {
  padding: 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.shortcuts-section h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin: 0 0 0.5rem 0;
  font-weight: 600;
}

.shortcut-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.shortcut-row span {
  margin-left: auto;
  color: var(--text-primary);
}

.shortcut-row kbd {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-family: inherit;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  min-width: 1.5rem;
  text-align: center;
}

.btn-shortcuts {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--bg-hover);
  color: var(--text-tertiary);
  border: 1px solid var(--border-default);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-shortcuts:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--accent);
}

/* ============================================
   Locked Columns
   ============================================ */

.col-locked {
  position: relative;
}

.lock-indicator {
  font-size: 0.625rem;
  margin-left: 0.25rem;
  opacity: 0.7;
}

.col-locked .col-name {
  opacity: 0.8;
}

.cell-locked {
  cursor: not-allowed;
  opacity: 0.7;
}

.cell-locked:hover {
  background: inherit;
}

.cell-locked::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 4px,
    rgba(128, 128, 128, 0.05) 4px,
    rgba(128, 128, 128, 0.05) 8px
  );
  pointer-events: none;
}

/* Cell focused state - first click highlights, second click edits */
.cell-focused {
  outline: 2px solid var(--accent) !important;
  outline-offset: -2px;
  box-shadow: 0 0 0 3px rgba(93, 76, 154, 0.3);
}

.max-points-badge {
  font-size: 0.6875rem;
  font-weight: 400;
  color: var(--text-tertiary, #94a3b8);
  margin-left: 2px;
}

/* Weighted average column in table */
.weighted-avg-col {
  background: var(--bg-elevated);
  font-weight: 600;
  border-left: 2px solid var(--accent);
}

.weighted-avg-cell {
  background: var(--bg-elevated) !important;
  font-weight: 600;
  color: var(--accent);
  text-align: center;
  border-left: 2px solid var(--accent);
  position: sticky;
  left: var(--student-col-width);
  z-index: 5;
}

.weighted-avg-cell .weighted-avg-value {
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.weighted-avg-cell .avg-grade {
  font-size: 0.9rem;
  font-weight: 700;
}

.weighted-avg-cell .avg-pct {
  font-size: 0.65rem;
  opacity: 0.7;
}

.weighted-avg-header {
  background: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
  min-width: var(--weighted-avg-width);
  width: var(--weighted-avg-width);
  left: var(--student-col-width) !important;
  z-index: 21 !important;
}

.weighted-avg-header .col-name {
  color: #fff !important;
}

.weighted-avg-header .col-date {
  color: rgba(255, 255, 255, 0.8) !important;
  font-size: 0.625rem;
}

/* Alternating row backgrounds for weighted-avg cells */
.assessment-table tbody tr:nth-child(even) td.weighted-avg-cell {
  background: var(--bg-surface) !important;
}

.assessment-table tbody tr:hover td.weighted-avg-cell {
  background: var(--bg-hover) !important;
}

/* Stats row weighted average */
#classWeightedAvg {
  background: var(--bg-elevated) !important;
  border-left: 2px solid var(--accent);
}

/* Greyed-out Gesamtnote (weighting disabled) */
.weighted-avg-disabled {
  opacity: 0.4;
  cursor: help;
}

/* Pos/neg marking on overall grade */
.weighted-avg-cell.avg-negative {
  border-left: 3px solid var(--red-bad, #ef4444) !important;
}
.weighted-avg-cell.avg-negative .weighted-avg-value,
.weighted-avg-cell.avg-negative .avg-grade {
  color: var(--red-bad, #ef4444);
}

.weighted-avg-disabled.weighted-avg-header {
  background: var(--bg-surface) !important;
  color: var(--text-tertiary) !important;
  border-left-color: var(--border-subtle);
}

.weighted-avg-disabled.weighted-avg-header .col-name {
  color: var(--text-tertiary) !important;
}

.weighted-avg-disabled.weighted-avg-cell {
  border-left-color: var(--border-subtle);
}

/* Weighting warning state (total != 100%) */
.weighted-avg-warning {
  border-left-color: var(--yellow-mid) !important;
}

.weighted-avg-warning.weighted-avg-header {
  background: var(--yellow-bg) !important;
}

/* Gesamtnote info icon */
.weighted-avg-info {
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.7;
  margin-left: 0.25rem;
  pointer-events: auto;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.weighted-avg-info:hover {
  opacity: 1;
  color: var(--accent);
}

.weighted-avg-info:hover::after {
  content: 'Gewichtung in den Einstellungen aktivieren';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  white-space: nowrap;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  margin-top: 0.25rem;
}

/* ============================================
   Student History / Timeline Modal
   ============================================ */

.history-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.history-tab {
  flex: 1;
  padding: 0.875rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.history-tab:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
}

.history-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-primary);
}

.history-content {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0;
}

.history-list {
  display: flex;
  flex-direction: column;
}

.history-group {
  border-bottom: 1px solid var(--border-subtle);
}

.history-group:last-child {
  border-bottom: none;
}

.history-group-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  padding: 0.75rem 1rem 0.5rem;
  background: var(--bg-surface);
  position: sticky;
  top: 0;
  z-index: 1;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background 0.1s ease;
}

.history-item:last-child {
  border-bottom: none;
}

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

.history-item-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
  min-width: 0;
}

.history-item-value {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 0.375rem;
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Grade value colors */
.history-item-value.grade-positive,
.history-item-value.plus {
  background: rgba(34, 197, 94, 0.15);
  color: var(--green-good);
}

.history-item-value.grade-neutral,
.history-item-value.wave {
  background: rgba(234, 179, 8, 0.15);
  color: var(--yellow-mid);
}

.history-item-value.grade-negative,
.history-item-value.minus {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-bad);
}

.history-item-name {
  font-size: 0.9375rem;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.history-item-type {
  font-size: 0.75rem;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

.history-item-notes {
  font-size: 0.875rem;
  opacity: 0.7;
}

.history-item-note {
  width: 100%;
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--text-tertiary);
  margin-top: 0.25rem;
  padding-left: 2.75rem;
  line-height: 1.4;
}

/* Cell highlight animation for navigation */
@keyframes cellHighlight {
  0% {
    box-shadow: 0 0 0 3px var(--accent);
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}

.cell-highlight {
  animation: cellHighlight 2s ease-out forwards;
}

/* ============================================
   Row/Column Highlight on Student Name Click
   ============================================ */

.assessment-table tbody tr.row-highlighted {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 15px rgba(93, 76, 154, 0.4), inset 0 0 8px rgba(93, 76, 154, 0.1);
  position: relative;
  z-index: 2;
}

.assessment-table tbody tr.row-highlighted td {
  background: rgba(93, 76, 154, 0.08) !important;
}

.assessment-table tbody tr.row-highlighted td.sticky-col,
.assessment-table tbody tr.row-highlighted td:first-child {
  background: var(--accent-muted) !important;
}

/* Transposed view: highlight column */
.table-transposed .transposed-table thead th.col-highlighted,
.table-transposed .transposed-table tbody td.col-highlighted {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  box-shadow: 0 0 15px rgba(93, 76, 154, 0.4);
  background: rgba(93, 76, 154, 0.15) !important;
  position: relative;
  z-index: 2;
}

/* Clickable student name */
.student-name-clickable {
  cursor: pointer;
  transition: color 0.15s;
}

.student-name-clickable:hover {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 480px) {
  .history-tabs {
    flex-direction: column;
  }

  .history-tab {
    border-bottom: none;
    border-left: 2px solid transparent;
  }

  .history-tab.active {
    border-left-color: var(--accent);
    border-bottom: none;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .history-item-meta {
    width: 100%;
    justify-content: flex-start;
  }
}

/* ============================================
   Bulk Entry Mode
   ============================================ */
.bulk-entry-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 500;
  gap: 12px;
  position: sticky;
  top: calc(var(--topbar-height) + var(--class-header-height) + var(--preset-bar-height));
  z-index: 90;
}

.bulk-entry-bar button {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.bulk-entry-bar button:hover {
  background: rgba(255,255,255,0.35);
}

.bulk-entry-col {
  background: rgba(93, 76, 154, 0.12) !important;
}

[data-theme="light"] .bulk-entry-col {
  background: rgba(93, 76, 154, 0.08) !important;
}

.bulk-entry-current {
  outline: 2px solid var(--accent) !important;
  outline-offset: -2px;
  background: rgba(93, 76, 154, 0.25) !important;
}

[data-theme="light"] .bulk-entry-current {
  background: rgba(93, 76, 154, 0.15) !important;
}

/* ============================================
   Responsive - Tablet (max-width: 1024px)
   ============================================ */

@media (max-width: 1024px) {
  .assessment-cell {
    min-width: 48px;
    min-height: 44px;
    font-size: 0.95rem;
  }

  .assessment-cell .cell-value {
    max-width: 70px;
  }

  .student-col {
    min-width: 140px;
  }

  .context-menu button {
    min-height: 44px;
    font-size: 0.95rem;
  }

  .assessment-table thead th {
    font-size: 0.7rem;
  }
}

/* ============================================
   Responsive - Phone (max-width: 600px)
   ============================================ */

@media (max-width: 600px) {
  .assessment-cell {
    min-width: 44px;
    min-height: 44px;
  }

  .compact-toolbar {
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .compact-toolbar-right {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }

  .student-col {
    max-width: 100px;
  }

  .student-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100px;
    display: block;
  }

  .col-date {
    display: none;
  }

  .preset-quick-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================
   Weighting Banner (disabled state)
   ============================================ */

.weighting-banner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  border-left: 3px solid var(--text-tertiary);
  color: var(--text-secondary);
}

.weighting-banner-icon {
  font-size: 1rem;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.weighting-banner a {
  color: var(--accent);
  text-decoration: underline;
}

/* ============================================
   Category Breakdown Bar (S3)
   ============================================ */

.category-breakdown-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.375rem 1rem;
  font-size: 0.75rem;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: calc(var(--topbar-height) + var(--class-header-height) + var(--preset-bar-height) + 33px);
  z-index: 69;
  flex-wrap: wrap;
  cursor: pointer;
  user-select: none;
}

.category-breakdown-bar .breakdown-label {
  color: var(--text-tertiary);
  font-weight: 500;
  white-space: nowrap;
}

.category-breakdown-bar .breakdown-toggle {
  font-size: 0.625rem;
  color: var(--text-tertiary);
  transition: transform 0.15s;
}

.category-breakdown-bar.collapsed .breakdown-toggle {
  transform: rotate(-90deg);
}

.category-breakdown-bar.collapsed .breakdown-items {
  display: none;
}

.breakdown-items {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.category-avg {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  background: var(--bg-surface);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.category-avg .cat-name {
  color: var(--text-secondary);
}

.category-avg .cat-value {
  font-weight: 600;
  color: var(--accent);
}

.category-avg .cat-weight {
  color: var(--text-tertiary);
  font-size: 0.6875rem;
}

.category-avg .cat-sep {
  color: var(--text-tertiary);
  margin: 0 0.125rem;
}

@media (max-width: 768px) {
  .category-breakdown-bar {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
    gap: 0.375rem;
  }
}

.header-collapsed .category-breakdown-bar {
  top: calc(var(--preset-bar-height) + 33px);
}

/* ============================================
   Projection Badge (S4)
   ============================================ */


/* ============================================
   Mobile Grade Input Bar
   ============================================ */

.mobile-grade-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-elevated, #fff);
  border-top: 2px solid var(--accent, #5D4C9A);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
  border-radius: 16px 16px 0 0;
}

.mobile-grade-bar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.mobile-grade-bar-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.mobile-grade-bar-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
}

.mobile-grade-bar-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.mobile-grade-bar-buttons button {
  min-width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 2px solid var(--border-subtle, #ddd);
  background: var(--bg-surface, #f5f5f5);
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  flex: 1;
  max-width: 80px;
}

.mobile-grade-bar-buttons button:active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: scale(0.95);
}

.mobile-grade-bar-buttons button.grade-btn-active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.mobile-grade-bar-buttons button.grade-btn-clear {
  background: var(--bg-hover, #eee);
  color: var(--text-tertiary);
  font-size: 0.75rem;
}


