/* ==========================================================================
   Hey Hoolo — Teacher workspace
   A dark navy rail for navigation, a warm light canvas for the operational
   work. Shared tokens come from ../tokens.css.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Legacy variable aliases.

   teacher.js writes these straight into inline styles (renderStudents uses
   `var(--warning)`, renderReview uses `var(--accent-primary)`), so they must
   stay defined. They simply forward to the shared Hey Hoolo tokens.
   -------------------------------------------------------------------------- */
:root {
  --accent-primary: var(--hh-blue);
  --accent-2: var(--hh-purple);
  --accent-grad: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  --success: var(--hh-mint);
  --warning: var(--hh-amber-bright);
  --danger: var(--hh-red);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--hh-font-ui);
}

body {
  background-color: var(--hh-canvas);
  background-image:
    radial-gradient(1000px 560px at 88% -12%, rgba(108, 75, 244, 0.12), transparent 62%),
    radial-gradient(760px 480px at 4% 106%, rgba(29, 95, 208, 0.09), transparent 60%);
  color: var(--hh-ink);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--hh-purple);
  text-underline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

.mt-4 {
  margin-top: 1.5rem;
}

.full-height {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* White work surfaces. The Teacher rail supplies the dark frame. */
.glass-card {
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius-md);
  box-shadow: var(--hh-shadow-sm);
}

.hh-owl-glyph {
  width: 100%;
  height: 100%;
  display: block;
  color: inherit;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
button {
  cursor: pointer;
  border: none;
  outline: none;
  font-family: var(--hh-font-ui);
  font-weight: 700;
  font-size: 0.86rem;
  border-radius: var(--hh-radius);
  transition: transform var(--hh-t-fast) var(--hh-ease), background var(--hh-t) var(--hh-ease),
    border-color var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease),
    filter var(--hh-t) var(--hh-ease);
  padding: 0.65rem 1.15rem;
  min-height: var(--hh-tap);
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: none;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  color: var(--hh-ink-on-accent);
  position: relative;
  box-shadow: var(--hh-shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
  box-shadow: var(--hh-shadow);
}

.btn-secondary {
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink-soft);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--hh-purple-soft);
  border-color: var(--hh-purple);
  color: var(--hh-purple);
}

.btn-outline {
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-purple);
}

.btn-outline:hover:not(:disabled) {
  background: var(--hh-purple-soft);
  border-color: var(--hh-purple);
}

.btn-text {
  background: transparent;
  color: var(--hh-ink-muted);
  padding: 0;
  min-height: auto;
  text-align: left;
  font-weight: 600;
}

.btn-text:hover:not(:disabled) {
  color: var(--hh-purple);
  transform: none;
}

.btn-danger {
  background: var(--hh-red);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-success {
  background: var(--hh-mint);
  color: #fff;
}

.btn-success:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-warning {
  background: var(--hh-amber-bright);
  color: #2a1a00;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  min-height: 34px;
  font-size: 0.78rem;
  border-radius: var(--hh-radius-sm);
}

.approve-btn {
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Views
   -------------------------------------------------------------------------- */
.view-container {
  min-height: 100vh;
  display: flex;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
#login-view {
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem;
}

.login-wrap {
  width: 100%;
  max-width: 430px;
}

.login-box {
  width: 100%;
  padding: 2.2rem;
  text-align: center;
  box-shadow: var(--hh-shadow-md);
}

.login-box__brand {
  margin-bottom: 1.4rem;
}

.login-box__descriptor {
  margin: 0.55rem 0 0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--hh-purple);
}

.login-box h3 {
  margin-bottom: 0.45rem;
  font-family: var(--hh-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.login-box p {
  color: var(--hh-ink-muted);
  margin-bottom: 1.6rem;
  font-size: 0.92rem;
}

.login-box__foot {
  margin: 1.6rem 0 0;
  padding-top: 1.1rem;
  border-top: 1px solid var(--hh-line);
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.login-box__foot a {
  color: var(--hh-ink-muted);
  text-decoration: none;
}

.login-box__foot a:hover {
  color: var(--hh-purple);
  text-decoration: underline;
}

.step-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  margin-bottom: 0.5rem;
  font-weight: 700;
  color: var(--hh-ink) !important;
}

.step-badge {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--hh-purple-soft);
  color: var(--hh-purple);
  font-size: 0.72rem;
  font-weight: 800;
}

.form-group {
  text-align: left;
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--hh-ink-soft);
}

.form-group input {
  width: 100%;
  padding: 0.75rem 0.85rem;
  min-height: var(--hh-tap);
  border-radius: var(--hh-radius);
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink);
  font-family: var(--hh-font-ui);
  font-size: 0.92rem;
  transition: border-color var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease);
}

.form-group input:focus {
  border-color: var(--hh-purple);
  box-shadow: 0 0 0 4px var(--hh-purple-ring);
  outline: none;
}

#login-btn,
#mfa-btn,
#enroll-btn {
  width: 100%;
  padding: 0.85rem;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

#mfa-cancel {
  width: 100%;
  margin-top: 0.6rem;
  text-align: center;
  display: flex;
  justify-content: center;
}

.error-msg {
  color: var(--hh-red);
  font-size: 0.86rem;
  font-weight: 600;
  margin-top: 1rem;
  padding: 0.6rem 0.75rem;
  background: var(--hh-red-soft);
  border-radius: var(--hh-radius);
  text-align: left;
}

.error-msg:empty {
  display: none;
}

.loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: hh-spin 900ms linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

@keyframes hh-spin {
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.secret-box {
  display: block;
  font-family: var(--hh-font-mono);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
  background: var(--hh-surface-sunk);
  border: 1px dashed var(--hh-purple);
  border-radius: var(--hh-radius);
  padding: 0.75rem 0.9rem;
  margin: 0.7rem 0;
  overflow-wrap: anywhere;
  user-select: all;
  text-align: left;
}

/* --------------------------------------------------------------------------
   Brand
   -------------------------------------------------------------------------- */
.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}

.logo-container.sm {
  justify-content: flex-start;
}

.logo-icon {
  width: 42px;
  height: 42px;
  padding: 7px;
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-deep) 100%);
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
}

.logo-text h2 {
  font-family: var(--hh-font-display);
  font-size: 1.06rem;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.workspace-label {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--hh-navy-ink-muted);
}

/* ==========================================================================
   DASHBOARD RAIL (persistent dark navy on desktop)
   ========================================================================== */
.sidebar {
  width: 274px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--hh-navy-900) 0%, var(--hh-navy-800) 100%);
  color: var(--hh-navy-ink);
  padding: 1.35rem 0.9rem 1rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 70;
}

.sidebar__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.9rem;
}

.logo-text h2 {
  color: #fff;
}

.sidebar__close {
  display: none;
  margin-left: auto;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--hh-navy-line);
  color: var(--hh-navy-ink-muted);
}

.sidebar__close svg {
  width: 20px;
  height: 20px;
}

.sidebar__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-menu {
  list-style: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  min-height: var(--hh-tap);
  border-radius: var(--hh-radius);
  color: var(--hh-navy-ink-muted);
  cursor: pointer;
  transition: background var(--hh-t) var(--hh-ease), color var(--hh-t) var(--hh-ease);
  font-size: 0.9rem;
  font-weight: 600;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-strong) 100%);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.badge {
  margin-left: auto;
  background: var(--hh-red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.14rem 0.5rem;
  border-radius: var(--hh-radius-pill);
  min-width: 1.4rem;
  text-align: center;
}

.nav-item.active .badge {
  background: rgba(255, 255, 255, 0.95);
  color: var(--hh-purple-deep);
}

.sidebar__foot {
  margin-top: auto;
  padding-top: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* Healthy system status pinned to the bottom of the rail. */
.sidebar__foot .status-indicator {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--hh-navy-ink);
  background: rgba(15, 157, 118, 0.16);
  border: 1px solid rgba(15, 157, 118, 0.4);
  padding: 0.5rem 0.75rem;
  border-radius: var(--hh-radius);
}

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

.dot.healthy {
  background: #34d399;
  box-shadow: 0 0 8px #34d399;
}

.dot.degraded {
  background: var(--hh-amber-bright);
  box-shadow: 0 0 8px var(--hh-amber-bright);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--hh-navy-line);
}

.avatar {
  width: 40px;
  height: 40px;
  background: linear-gradient(140deg, var(--hh-purple) 0%, var(--hh-purple-deep) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0.1rem;
}

.user-info span {
  font-size: 0.86rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info button {
  font-size: 0.78rem;
  color: var(--hh-navy-ink-muted);
  padding: 0;
  min-height: auto;
}

.user-info button:hover {
  color: #fff;
  transform: none;
}

.sidebar-scrim {
  display: none;
}

/* ==========================================================================
   MAIN
   ========================================================================== */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 1.7rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  overflow-y: auto;
}

.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.top-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-header__menu {
  display: none;
  min-width: var(--hh-tap);
  min-height: var(--hh-tap);
  padding: 0;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink-soft);
}

.top-header__menu svg {
  width: 22px;
  height: 22px;
}

.top-header__menu:hover {
  background: var(--hh-purple-soft);
  color: var(--hh-purple);
}

.top-header h1 {
  font-family: var(--hh-font-display);
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--hh-ink);
}

.workspace-chip {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--hh-ink-soft);
  box-shadow: var(--hh-shadow-xs);
}

/* ==========================================================================
   METRICS
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 1rem;
}

.metric-card {
  position: relative;
  padding: 1.2rem 1.25rem;
  overflow: hidden;
  transition: transform var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease);
}

.metric-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
}

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

.metric-card--purple::before {
  background: var(--hh-purple);
}

.metric-card--blue::before {
  background: var(--hh-blue);
}

.metric-card--amber::before {
  background: var(--hh-amber-bright);
}

.metric-card--mint::before {
  background: var(--hh-mint);
}

.metric-card.warning {
  background: var(--hh-amber-soft);
  border-color: rgba(180, 83, 9, 0.3);
}

.metric-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--hh-ink-muted);
  margin-bottom: 0.5rem;
}

.metric-value {
  font-family: var(--hh-font-display);
  font-size: 2.15rem;
  font-weight: 900;
  line-height: 1.1;
  margin-bottom: 0.35rem;
  letter-spacing: -0.03em;
  color: var(--hh-ink);
}

.metric-trend,
.metric-status,
.metric-action {
  font-size: 0.8rem;
  font-weight: 600;
}

.metric-trend.positive {
  color: var(--hh-mint-strong);
}

.metric-action {
  color: var(--hh-amber);
}

.metric-status {
  color: var(--hh-ink-muted);
}

/* ==========================================================================
   OVERVIEW LOWER — chart + insight, side by side
   ========================================================================== */
.overview-lower {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 1rem;
  flex: 1;
  min-height: 0;
}

.chart-container {
  padding: 1.3rem;
  display: flex;
  flex-direction: column;
  min-height: 320px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.card-head h3,
.insight-card h3 {
  font-family: var(--hh-font-display);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.012em;
}

.card-head__note {
  font-size: 0.78rem;
  color: var(--hh-ink-muted);
}

.chart-frame {
  position: relative;
  flex: 1;
  min-height: 250px;
}

.insight-card {
  padding: 1.3rem;
  background: linear-gradient(160deg, var(--hh-purple-soft) 0%, var(--hh-surface) 62%);
}

.insight-list {
  list-style: none;
  margin-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.insight-list li {
  display: flex;
  gap: 0.6rem;
  font-size: 0.87rem;
  line-height: 1.6;
  color: var(--hh-ink-soft);
}

.insight-list__dot {
  width: 8px;
  height: 8px;
  margin-top: 0.5rem;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--hh-purple);
}

/* ==========================================================================
   PANELS
   ========================================================================== */
.content-panel {
  flex: 1;
  display: none;
  min-height: 0;
}

.content-panel.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel-header {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--hh-line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.panel-header__titles {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.panel-header__tools {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.panel-header h3 {
  font-family: var(--hh-font-display);
  font-size: 1.05rem;
  font-weight: 800;
}

.panel-header .subtitle {
  color: var(--hh-ink-muted);
  font-size: 0.85rem;
  font-weight: 500;
}

.search-input {
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink);
  padding: 0.6rem 1rem;
  min-height: var(--hh-tap);
  border-radius: var(--hh-radius-pill);
  width: 250px;
  max-width: 100%;
  font-size: 0.86rem;
  font-family: var(--hh-font-ui);
  transition: border-color var(--hh-t) var(--hh-ease), box-shadow var(--hh-t) var(--hh-ease);
}

.search-input:focus {
  border-color: var(--hh-purple);
  box-shadow: 0 0 0 4px var(--hh-purple-ring);
  outline: none;
}

.search-empty {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--hh-ink-muted);
}

.queue-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--hh-radius-pill);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.queue-chip__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.queue-chip--amber {
  background: var(--hh-amber-soft);
  color: var(--hh-amber);
  border: 1px solid rgba(180, 83, 9, 0.28);
}

.queue-chip--amber .queue-chip__dot {
  background: var(--hh-amber-bright);
}

.queue-chip--blue {
  background: var(--hh-blue-soft);
  color: var(--hh-blue);
  border: 1px solid rgba(29, 95, 208, 0.26);
}

.queue-chip--blue .queue-chip__dot {
  background: var(--hh-blue-bright);
}

.queue-chip--mint {
  background: var(--hh-mint-soft);
  color: var(--hh-mint-strong);
  border: 1px solid var(--hh-mint-ring);
}

.queue-chip--mint .queue-chip__dot {
  background: var(--hh-mint);
}

/* ==========================================================================
   TABLES — horizontal scroll on small screens, never clipped
   ========================================================================== */
.table-container {
  flex: 1;
  overflow-x: auto;
  overflow-y: auto;
  padding: 0 1.4rem;
}

.data-table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--hh-surface);
  padding: 0.85rem 0.6rem;
  color: var(--hh-ink-muted);
  font-weight: 700;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  border-bottom: 1px solid var(--hh-line-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 0.6rem;
  border-bottom: 1px solid var(--hh-line);
  font-size: 0.87rem;
  vertical-align: middle;
  color: var(--hh-ink-soft);
}

.data-table tbody tr:hover td {
  background: var(--hh-surface-sunk);
}

.data-table td:first-child {
  font-weight: 700;
  color: var(--hh-ink);
}

/* renderStudents() sets an inline background, so keep readable contrast. */
.data-table .badge {
  display: inline-block;
  background: var(--hh-amber-bright);
  color: #2a1a00;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--hh-radius-pill);
  white-space: nowrap;
}

/* ==========================================================================
   FLAGGED LIST
   ========================================================================== */
.flagged-list {
  padding: 1.3rem 1.4rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.flag-item {
  background: var(--hh-amber-soft);
  border: 1px solid rgba(180, 83, 9, 0.28);
  border-left: 4px solid var(--hh-amber-bright);
  border-radius: var(--hh-radius);
  padding: 1.1rem 1.2rem;
}

.flag-header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
  color: var(--hh-ink-muted);
}

.flag-content {
  font-size: 0.93rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: var(--hh-ink);
  overflow-wrap: anywhere;
}

.flag-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  color: var(--hh-ink-muted);
  text-align: center;
  padding: 2rem 1rem;
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
  color: var(--hh-mint);
}

/* ==========================================================================
   REVIEW QUEUE
   ========================================================================== */
.review-list {
  padding: 1.3rem 1.4rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-item {
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line-strong);
  border-left: 4px solid var(--hh-blue-bright);
  border-radius: var(--hh-radius);
  padding: 1.1rem 1.2rem;
}

.review-header {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.7rem;
  font-size: 0.8rem;
  color: var(--hh-ink-muted);
}

.review-question {
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 0.7rem;
  color: var(--hh-ink);
}

.review-answer {
  font-size: 0.89rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  color: var(--hh-ink-soft);
  background: var(--hh-surface);
  border: 1px solid var(--hh-line);
  padding: 0.85rem;
  border-radius: var(--hh-radius);
}

/* ---------- Markdown in the AI answer under review ----------
   Mirrors the .message-bubble rules in ../styles.css so an answer reads the
   same in the review queue as it does in the student's chat. */
.review-answer p {
  margin: 0.5em 0;
}

.review-answer p:first-child {
  margin-top: 0;
}

.review-answer p:last-child {
  margin-bottom: 0;
}

.review-answer strong {
  font-weight: 700;
}

.review-answer em {
  font-style: italic;
}

.review-answer code {
  font-family: var(--hh-font-mono);
  font-size: 0.86em;
  background: var(--hh-surface-sunk);
  padding: 0.14em 0.4em;
  border-radius: 5px;
  border: 1px solid var(--hh-line);
}

.review-answer pre {
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius-sm);
  padding: 0.7rem;
  overflow-x: auto;
  font-family: var(--hh-font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
}

.review-answer pre code {
  background: none;
  padding: 0;
  border: none;
  font-size: inherit;
}

.review-answer ul,
.review-answer ol {
  margin: 0.5em 0;
  padding-left: 1.35rem;
}

.review-answer li {
  margin: 0.25em 0;
}

.review-answer blockquote {
  border-left: 3px solid var(--hh-purple);
  padding-left: 0.8rem;
  margin: 0.5em 0;
  color: var(--hh-ink-muted);
  font-style: italic;
}

.review-answer h1,
.review-answer h2,
.review-answer h3,
.review-answer h4,
.review-answer h5,
.review-answer h6 {
  margin: 0.7em 0 0.35em;
  font-family: var(--hh-font-display);
  font-weight: 800;
  line-height: 1.3;
}

.review-answer h1 { font-size: 1.24em; }
.review-answer h2 { font-size: 1.14em; }
.review-answer h3 { font-size: 1.05em; }

.review-answer hr {
  border: none;
  border-top: 1px solid var(--hh-line);
  margin: 0.85em 0;
}

.review-answer a {
  color: var(--hh-purple);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.review-answer a:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 3px;
}

.review-answer img {
  max-width: 100%;
  height: auto;
  border-radius: var(--hh-radius-sm);
  border: 1px solid var(--hh-line);
  margin: 0.35em 0;
}

/* Scroll wide tables rather than overflowing the review card. */
.review-answer table {
  border-collapse: collapse;
  margin: 0.6em 0;
  font-size: 0.92em;
  display: block;
  max-width: 100%;
  overflow-x: auto;
}

.review-answer th,
.review-answer td {
  border: 1px solid var(--hh-line);
  padding: 0.35em 0.6em;
  text-align: left;
}

.review-answer th {
  background: var(--hh-surface-sunk);
  font-weight: 700;
}

.review-answer del {
  opacity: 0.75;
}

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

.review-actions textarea {
  flex: 1;
  min-width: 200px;
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  color: var(--hh-ink);
  padding: 0.65rem;
  border-radius: var(--hh-radius);
  resize: vertical;
  min-height: 62px;
  font-family: var(--hh-font-ui);
  font-size: 0.86rem;
}

.review-actions textarea:focus {
  border-color: var(--hh-purple);
  box-shadow: 0 0 0 4px var(--hh-purple-ring);
  outline: none;
}

/* ==========================================================================
   LMS
   ========================================================================== */
.lms-grid {
  padding: 1.3rem 1.4rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.lms-card {
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.lms-card.connected {
  background: var(--hh-mint-soft);
  border-color: rgba(15, 157, 118, 0.3);
}

.lms-header {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.85rem;
}

.lms-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--hh-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.05rem;
  flex-shrink: 0;
  color: #fff;
}

.canvas-icon {
  background: #e72429;
}

.gc-icon {
  background: #1fa463;
}

.lms-header h4 {
  flex: 1;
  font-family: var(--hh-font-display);
  font-size: 1rem;
  font-weight: 800;
}

.badge.success {
  background: var(--hh-mint);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--hh-radius-pill);
  white-space: nowrap;
}

.badge.neutral {
  background: var(--hh-line);
  color: var(--hh-ink-soft);
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.2rem 0.6rem;
  border-radius: var(--hh-radius-pill);
  white-space: nowrap;
}

.lms-details {
  flex: 1;
  font-size: 0.86rem;
  color: var(--hh-ink-soft);
  margin-bottom: 1.1rem;
}

.lms-details p {
  margin-bottom: 0.4rem;
}

.lms-action {
  align-self: flex-start;
}

.lms-inline-note {
  margin-top: 0.8rem;
  padding: 0.6rem 0.75rem;
  background: var(--hh-blue-soft);
  border: 1px solid rgba(29, 95, 208, 0.26);
  border-radius: var(--hh-radius-sm);
  font-size: 0.79rem;
  line-height: 1.55;
  color: var(--hh-ink-soft);
}

.lms-note {
  margin: 0 1.4rem 1.3rem;
  padding: 0.8rem 0.9rem;
  background: var(--hh-surface-sunk);
  border: 1px solid var(--hh-line);
  border-radius: var(--hh-radius);
  font-size: 0.82rem;
  line-height: 1.6;
  color: var(--hh-ink-muted);
}

/* ==========================================================================
   COOKIE CONSENT
   ========================================================================== */
.cookie-consent {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 32px));
  z-index: 1000;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-radius: var(--hh-radius-md);
  background: var(--hh-surface);
  border: 1px solid var(--hh-line-strong);
  box-shadow: var(--hh-shadow-lg);
}

.cookie-consent[hidden] {
  display: none;
}

.cookie-consent-text {
  flex: 1 1 360px;
}

.cookie-consent-text p {
  margin: 0;
  color: var(--hh-ink-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.cookie-consent-text a {
  color: var(--hh-purple);
  text-decoration: none;
}

.cookie-consent-text a:hover {
  text-decoration: underline;
}

.cookie-consent-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Reserve room for the fixed consent banner so it never traps page content. */
body:has(#cookie-consent:not([hidden])) .main-content {
  padding-bottom: calc(2.5rem + 150px);
}

/* ==========================================================================
   RESPONSIVE — 1280 / 768 / 390
   ========================================================================== */
@media (max-width: 1180px) {
  .overview-lower {
    grid-template-columns: minmax(0, 1fr);
  }

  .insight-card {
    order: 2;
  }
}

@media (max-width: 1024px) {
  /* Rail becomes a drawer. */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: 100vh;
    width: min(84vw, 290px);
    transform: translateX(-100%);
    transition: transform var(--hh-t-slow) var(--hh-ease);
    box-shadow: var(--hh-shadow-lg);
  }

  .sidebar.is-open {
    transform: none;
  }

  .sidebar__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(22, 19, 56, 0.45);
    backdrop-filter: blur(2px);
  }

  .sidebar-scrim[hidden] {
    display: none;
  }

  .top-header__menu {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  body.hh-drawer-open {
    overflow: hidden;
  }
}

@media (max-width: 720px) {
  .main-content {
    padding: 1rem 0.9rem 2rem;
  }

  .top-header {
    align-items: center;
  }

  .workspace-chip {
    display: none;
  }

  .panel-header {
    flex-direction: column;
    align-items: stretch;
  }

  .panel-header__tools {
    flex-direction: column;
    align-items: stretch;
  }

  .search-input {
    width: 100%;
  }

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

  .metric-value {
    font-size: 1.7rem;
  }

  .lms-grid,
  .flagged-list,
  .review-list {
    padding: 1rem;
  }

  .lms-note {
    margin: 0 1rem 1rem;
  }

  .review-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .review-actions button {
    width: 100%;
  }

  .chart-container {
    min-height: 260px;
    padding: 1rem;
  }

  .login-box {
    padding: 1.7rem 1.3rem;
  }

  .cookie-consent {
    flex-direction: column;
    align-items: stretch;
  }

  .cookie-consent-actions button {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .flag-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .flag-actions button {
    width: 100%;
  }

  .table-container {
    padding: 0 0.9rem;
  }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  .sidebar {
    transition: none;
  }

  button:hover:not(:disabled),
  .metric-card:hover {
    transform: none !important;
  }

  .loader {
    animation: none !important;
  }
}
