/* =========================================================================
   DIFF VIEW — developer-tool precision, left accent bars
   =========================================================================
   Diffs switch to JetBrains Mono to emphasize the "developer tool"
   character of the audit views. Additions use `tertiary-fixed`
   (#85f8c4) — a bright academic mint, sophisticated but unambiguous —
   with a soft vertical accent bar on the left edge instead of a
   border. Deletions use `error-container`.
   The left-bar pattern (box-shadow inset) avoids the No-Line rule
   violation that a real 1px border would introduce. */
.diff-eq {
  padding: 0.125rem 0.75rem;
  color: var(--md-sys-color-on-surface-variant);
  font: 400 0.8125rem/1.6 var(--md-sys-typescale-font-mono);
}
.diff-add {
  padding: 0.125rem 0.75rem;
  background: var(--md-sys-color-tertiary-fixed);
  color: var(--md-sys-color-on-tertiary-fixed);
  font: 500 0.8125rem/1.6 var(--md-sys-typescale-font-mono);
  box-shadow: inset 3px 0 0 0 var(--md-sys-color-tertiary);
}
.diff-del {
  padding: 0.125rem 0.75rem;
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  font: 500 0.8125rem/1.6 var(--md-sys-typescale-font-mono);
  text-decoration: line-through;
  box-shadow: inset 3px 0 0 0 var(--md-sys-color-error);
}

/* =========================================================================
   DASHBOARD
   =========================================================================
   Teacher-facing analytics layout. Maps the bento grid structure from
   the design mockup onto our existing M3 tokens (teal seed, no separate
   indigo/green palette) so it feels of-a-piece with the rest of the
   app. Uses CSS-only visualizations — conic-gradient for the donut,
   flex bars for the trend chart, no JS charting library. */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dashboard-header__filters {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* KPI row */
.dash-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dash-kpi {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
}
.dash-kpi--alert {
  background: color-mix(
    in srgb,
    var(--md-sys-color-error-container) 30%,
    var(--md-sys-color-surface-container-lowest)
  );
  border-color: color-mix(in srgb, var(--md-sys-color-error) 25%, transparent);
}
.dash-kpi__label {
  font: 700 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.dash-kpi--alert .dash-kpi__label {
  color: var(--md-sys-color-error);
}
.dash-kpi__value {
  font: 800 2.75rem/1.1 var(--md-sys-typescale-font-shell);
  letter-spacing: -0.02em;
  color: var(--md-sys-color-primary);
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.dash-kpi__unit {
  font: 500 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface-variant);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.dash-kpi--alert .dash-kpi__value {
  color: var(--md-sys-color-error);
}
.dash-kpi__sub {
  font: 400 0.8125rem/1.5 var(--md-sys-typescale-font-editorial);
  color: var(--md-sys-color-on-surface-variant);
  font-style: italic;
  margin-top: 0.5rem;
}
.dash-kpi__bar {
  margin-top: 0.75rem;
  height: 4px;
  width: 100%;
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
}
.dash-kpi__bar > div {
  height: 100%;
  background: var(--md-sys-color-primary);
  border-radius: inherit;
  transition: width var(--md-sys-motion-duration-medium) var(--md-sys-motion-easing-standard);
}

/* Bento row: trend chart + pattern donut */
.dash-bento {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.dash-card {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 1.75rem 2rem;
}
.dash-card--span-8 {
  grid-column: span 12;
}
.dash-card--span-4 {
  grid-column: span 12;
}
@media (min-width: 960px) {
  .dash-card--span-8 {
    grid-column: span 8;
  }
  .dash-card--span-4 {
    grid-column: span 4;
  }
}
.dash-card__title {
  font: 700 1.125rem/1.35 var(--md-sys-typescale-font-shell);
  color: var(--md-sys-color-on-surface);
  margin: 0 0 1.25rem;
}
.dash-card__subtitle {
  font: 400 0.9375rem/1.5 var(--md-sys-typescale-font-editorial);
  color: var(--md-sys-color-on-surface-variant);
  font-style: italic;
  margin: 0 0 1rem;
}

/* Trend chart — pure-CSS bars */
.dash-trend {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  height: 200px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
  padding-bottom: 0.25rem;
}
.dash-trend__bar {
  flex: 1;
  background: color-mix(in srgb, var(--md-sys-color-primary) 20%, transparent);
  border-radius: var(--md-sys-shape-corner-small) var(--md-sys-shape-corner-small) 0 0;
  position: relative;
  min-height: 4px;
  transition: background-color var(--md-sys-motion-duration-short)
    var(--md-sys-motion-easing-standard);
  cursor: default;
}
.dash-trend__bar:hover {
  background: color-mix(in srgb, var(--md-sys-color-primary) 45%, transparent);
}
.dash-trend__bar[data-alert="true"] {
  background: color-mix(in srgb, var(--md-sys-color-error) 30%, transparent);
}
.dash-trend__bar[data-alert="true"]:hover {
  background: color-mix(in srgb, var(--md-sys-color-error) 55%, transparent);
}
.dash-trend__tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-4px);
  background: var(--md-sys-color-on-surface);
  color: var(--md-sys-color-surface);
  font: 500 10px/16px var(--md-sys-typescale-font);
  padding: 2px 8px;
  border-radius: var(--md-sys-shape-corner-small);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 150ms var(--md-sys-motion-easing-standard);
  pointer-events: none;
}
.dash-trend__bar:hover .dash-trend__tooltip {
  opacity: 1;
}
.dash-trend__labels {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font: 700 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}
.dash-trend__labels span {
  flex: 1;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Pattern donut */
.dash-donut {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  margin: 1rem auto 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.dash-donut::before {
  content: "";
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: var(--md-sys-color-surface-container-lowest);
}
.dash-donut__center {
  position: relative;
  text-align: center;
  z-index: 1;
}
.dash-donut__value {
  display: block;
  font: 700 28px/32px var(--md-sys-typescale-font);
  color: var(--md-sys-color-on-surface);
}
.dash-donut__label {
  display: block;
  font: 700 10px/16px var(--md-sys-typescale-font);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
}
.dash-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.dash-legend li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font: 500 12px/16px var(--md-sys-typescale-font);
  color: var(--md-sys-color-on-surface);
}
.dash-legend__dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  vertical-align: middle;
}

/* Student portfolio table */
/* overflow: visible so the per-row 3-dot dropdown menu can extend
   beyond the table shell. The border-radius still clips the
   background but not positioned children. */
.dash-table-shell {
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-extra-large);
  overflow: visible;
  margin-bottom: 1.5rem;
}
.dash-table-shell > h5 {
  font: 700 1rem/1.4 var(--md-sys-typescale-font-shell);
  padding: 1.5rem 1.75rem 0.25rem;
  margin: 0;
}
.dash-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}
.dash-table th {
  background: var(--md-sys-color-surface-container-low);
  font: 700 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--md-sys-color-on-surface-variant);
  text-align: left;
  padding: 1rem 1.5rem;
}
.dash-table td {
  padding: 1.125rem 1.5rem;
  /* Zebra-striped tonal separation instead of bottom borders. */
  font: 500 0.875rem/1.5 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface);
  vertical-align: middle;
}
.dash-table tbody tr:nth-child(even) {
  background: var(--md-sys-color-surface-container-low);
}
.dash-table tbody tr:hover {
  background: color-mix(
    in srgb,
    var(--md-sys-color-primary) 5%,
    var(--md-sys-color-surface-container-lowest)
  );
}
.dash-table__row--clickable {
  cursor: pointer;
}
.dash-table__student {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.dash-table__avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--md-sys-shape-corner-full);
  background: var(--md-sys-gradient-primary);
  color: var(--md-sys-color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 0.75rem/1 var(--md-sys-typescale-font-shell);
  letter-spacing: 0;
  flex-shrink: 0;
}
.dash-table__name {
  font: 600 0.9375rem/1.4 var(--md-sys-typescale-font-shell);
}
.dash-table__id {
  font: 500 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface-variant);
}
.dash-table__score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  min-width: 60px;
}
.dash-table__score-bar {
  width: 64px;
  height: 4px;
  background: var(--md-sys-color-surface-container-highest);
  border-radius: var(--md-sys-shape-corner-full);
  overflow: hidden;
}
.dash-table__score-bar > div {
  height: 100%;
  background: var(--md-sys-color-primary);
  border-radius: inherit;
}
.dash-table__score-bar--alert > div {
  background: var(--md-sys-color-error);
}
.dash-table__pattern {
  display: inline-block;
  padding: 0.25rem 0.625rem;
  border-radius: var(--md-sys-shape-corner-small);
  font: 600 0.6875rem/1.2 var(--md-sys-typescale-font-label);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}
.dash-table__pattern--heavy_paste {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.dash-table__pattern--fluent {
  background: var(--md-sys-color-tertiary-fixed);
  color: var(--md-sys-color-on-tertiary-fixed);
}
.dash-table__pattern--natural {
  background: var(--md-sys-color-secondary-fixed);
  color: var(--md-sys-color-on-secondary-fixed);
}

/* 3-dot menu trigger + dropdown for per-row actions. */
.portfolio-menu-trigger {
  background: transparent;
  border: none;
  cursor: pointer;
  font: 700 1.25rem/1 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface-variant);
  padding: 0.25rem 0.5rem;
  border-radius: var(--md-sys-shape-corner-medium);
  letter-spacing: 0.1em;
  transition: background-color var(--md-sys-motion-duration-short)
    var(--md-sys-motion-easing-standard);
}
.portfolio-menu-trigger:hover {
  background: var(--md-sys-color-surface-container-high);
}
.portfolio-menu {
  position: fixed;
  z-index: 100;
  background: var(--md-sys-color-surface-container-lowest);
  border-radius: var(--md-sys-shape-corner-large);
  box-shadow: var(--md-sys-elevation-3);
  padding: 0.375rem 0;
  min-width: 160px;
}
.portfolio-menu__item {
  display: block;
  width: 100%;
  padding: 0.625rem 1rem;
  background: none;
  border: none;
  text-align: left;
  font: 500 0.8125rem/1.4 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--md-sys-motion-duration-short)
    var(--md-sys-motion-easing-standard);
}
.portfolio-menu__item:hover {
  background: var(--md-sys-color-surface-container-high);
  text-decoration: none;
}
.portfolio-menu__item-form {
  margin: 0;
  padding: 0;
}

/* Selection action bar. */
.dash-selection-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  background: var(--md-sys-color-primary-fixed);
  color: var(--md-sys-color-on-primary-fixed);
  border-radius: var(--md-sys-shape-corner-large) var(--md-sys-shape-corner-large) 0 0;
  font: 600 0.8125rem/1.4 var(--md-sys-typescale-font-label);
}

/* Active / Archived tabs */
.dash-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
}
.dash-tabs__tab {
  padding: 0.75rem 1.25rem;
  font: 600 0.8125rem/1.4 var(--md-sys-typescale-font-label);
  letter-spacing: 0.02em;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition:
    color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard),
    border-color var(--md-sys-motion-duration-short) var(--md-sys-motion-easing-standard);
}
.dash-tabs__tab:hover {
  color: var(--md-sys-color-on-surface);
  text-decoration: none;
}
.dash-tabs__tab.is-active {
  color: var(--md-sys-color-primary);
  border-bottom-color: var(--md-sys-color-primary);
}

/* Download modal — HTML <dialog> with Scholarly Lens ambient glow.
   showModal() puts the dialog in the top layer and should auto-center,
   but explicit margin + inset ensures centering even if an ancestor
   has overflow/position quirks. */
.download-modal {
  border: none;
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 0;
  max-width: 720px;
  width: 90vw;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
  box-shadow: var(--md-sys-elevation-3);
  /* Explicit centering for the top-layer <dialog>. */
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
}
.download-modal::backdrop {
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
}
.download-modal__content {
  padding: 2rem;
}
.download-modal__title {
  font: 700 1.25rem/1.3 var(--md-sys-typescale-font-shell);
  margin: 0 0 0.5rem;
}
.download-modal__desc {
  font: 400 0.9375rem/1.55 var(--md-sys-typescale-font-editorial);
  color: var(--md-sys-color-on-surface-variant);
  margin: 0 0 1.25rem;
}
.download-modal__checkbox {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font: 500 0.875rem/1.4 var(--md-sys-typescale-font-label);
  color: var(--md-sys-color-on-surface);
  cursor: pointer;
  padding: 0.75rem 0;
}
.download-modal__checkbox input[type="checkbox"] {
  accent-color: var(--md-sys-color-primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.download-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.5rem;
}

/* Bottom row — anomalies list + summary card */
.dash-footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}
@media (min-width: 960px) {
  .dash-footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}
.dash-anomaly-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.dash-anomaly-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: var(--md-sys-color-surface-container-lowest);
  padding: 1rem 1.25rem;
  border-radius: var(--md-sys-shape-corner-large);
}
.dash-anomaly-list__title {
  font: 600 0.9375rem/1.4 var(--md-sys-typescale-font-shell);
  color: var(--md-sys-color-on-surface);
  margin: 0;
}
.dash-anomaly-list__detail {
  font: 500 0.6875rem/1.4 var(--md-sys-typescale-font-label);
  letter-spacing: 0.01em;
  color: var(--md-sys-color-on-surface-variant);
  margin: 0.25rem 0 0;
}
.dash-summary-card {
  background: var(--md-sys-gradient-primary);
  color: var(--md-sys-color-on-primary);
  border-radius: var(--md-sys-shape-corner-extra-large);
  padding: 2rem 2.25rem;
  position: relative;
  overflow: hidden;
}
.dash-summary-card h5 {
  font: 800 1.5rem/1.3 var(--md-sys-typescale-font-shell);
  letter-spacing: -0.01em;
  margin: 0 0 1rem;
}
.dash-summary-card p {
  font: 400 1rem/1.6 var(--md-sys-typescale-font-editorial);
  font-style: italic;
  opacity: 0.9;
  margin: 0;
}

/* Review status chips */
.review-chip--accepted {
  background: var(--md-sys-color-tertiary-fixed);
  color: var(--md-sys-color-on-tertiary-fixed);
}
.review-chip--rejected {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
}
.review-chip--pending {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
}
