/* ==========================================================================
   Components - the reusable surface vocabulary of the workspace.
   ========================================================================== */

/* --- Panel: a working plane, separated by hairline rather than shadow --- */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xs);
  min-width: 0;
}

.panel--flush {
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2) var(--sp-4);
  flex-wrap: wrap;
  min-height: 52px;
  padding: var(--sp-3) var(--sp-5);
  border-bottom: 1px solid var(--c-line-soft);
}

.panel__head > div:first-child {
  min-width: 0;
}

.panel__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tight);
  color: var(--c-ink-900);
  line-height: 1.3;
}

.panel__hint {
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  margin-top: 2px;
  line-height: var(--lh-snug);
}

.panel__body {
  padding: var(--sp-5);
}

.panel__body--tight {
  padding: var(--sp-4) var(--sp-5);
}

.panel__foot {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--c-line-soft);
  background: var(--c-surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.panel--quiet {
  background: var(--c-surface-2);
  box-shadow: none;
}

.panel--accent {
  border-color: var(--c-accent-line);
  background: var(--c-accent-soft);
}

/* A section label inside a panel: title + meta on one baseline. */
.section-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
  letter-spacing: var(--tracking-tight);
}

.section-label__meta {
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  color: var(--c-ink-500);
  font-variant-numeric: tabular-nums;
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  --btn-bg: var(--c-primary);
  --btn-fg: var(--c-white);
  --btn-bd: var(--c-primary);
  --btn-sh: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 1px 2px rgba(11, 19, 34, 0.14);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 var(--sp-3);
  height: var(--h-md);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-tight);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  box-shadow: var(--btn-sh);
  user-select: none;
  transition: background-color var(--dur-1) var(--ease-out),
    border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out);
}

.btn:hover:not(:disabled) {
  background: var(--c-primary-hover);
  border-color: var(--c-primary-hover);
  color: var(--btn-fg);
}

.btn:active:not(:disabled) {
  background: var(--c-primary-active);
  box-shadow: none;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.btn--secondary {
  --btn-bg: var(--c-surface);
  --btn-fg: var(--c-ink-800);
  --btn-bd: var(--c-line-strong);
  --btn-sh: 0 1px 1px rgba(11, 19, 34, 0.04);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--c-surface-2);
  border-color: var(--c-ink-300);
  color: var(--c-ink-900);
}

.btn--secondary:active:not(:disabled) {
  background: var(--c-surface-3);
}

.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--c-ink-600);
  --btn-bd: transparent;
  --btn-sh: none;
}

.btn--ghost:hover:not(:disabled) {
  background: var(--c-surface-3);
  border-color: transparent;
  color: var(--c-ink-900);
}

.btn--ghost:active:not(:disabled) {
  background: var(--c-ink-100);
}

.btn--danger {
  --btn-bg: var(--c-danger);
  --btn-bd: var(--c-danger);
}

.btn--danger:hover:not(:disabled) {
  background: var(--c-danger-hover);
  border-color: var(--c-danger-hover);
}

.btn--lg {
  height: var(--h-lg);
  padding: 0 var(--sp-4);
  font-size: var(--fs-base);
  gap: var(--sp-2);
}

.btn--sm {
  height: var(--h-sm);
  padding: 0 10px;
  font-size: var(--fs-xs);
  border-radius: var(--r-md);
  gap: 5px;
}

.btn--block {
  width: 100%;
}

.btn__icon,
.btn > svg {
  flex: none;
  width: 15px;
  height: 15px;
}

.btn--sm > svg {
  width: 13px;
  height: 13px;
}

.btn--secondary > svg,
.btn--ghost > svg {
  color: var(--c-ink-500);
}

.btn--secondary:hover:not(:disabled) > svg,
.btn--ghost:hover:not(:disabled) > svg {
  color: var(--c-ink-800);
}

/* --- Badges ------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  line-height: 1;
  border: 1px solid transparent;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.badge--neutral {
  background: var(--c-surface-3);
  color: var(--c-ink-600);
  border-color: var(--c-line);
}

.badge--success {
  background: var(--c-success-soft);
  color: var(--c-success);
  border-color: var(--c-success-line);
}

.badge--warning {
  background: var(--c-warning-soft);
  color: var(--c-warning);
  border-color: var(--c-warning-line);
}

.badge--danger {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  border-color: var(--c-danger-line);
}

.badge--info {
  background: var(--c-info-soft);
  color: var(--c-info);
  border-color: var(--c-info-line);
}

.badge--lg {
  height: 24px;
  padding: 0 var(--sp-2);
  font-size: var(--fs-xs);
}

/* A status dot that can precede badge text. */
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* Grade letter chip. Always paired with its range text, never colour alone. */
.grade-chip {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--c-white);
  background: var(--grade-1);
  box-shadow: inset 0 0 0 1px rgba(11, 19, 34, 0.06);
  flex: none;
}

.grade-chip[data-tone="light"] {
  color: var(--c-ink-900);
}

.grade-chip--lg {
  min-width: 34px;
  height: 24px;
  font-size: var(--fs-xs);
}

/* Grade transition: "B  →  B-" set in one typographic unit. */
.grade-move {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.grade-move__arrow {
  display: inline-flex;
  color: var(--c-ink-300);
}

/* --- Forms -------------------------------------------------------------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-700);
}

.field__req {
  color: var(--c-danger);
  margin-left: 2px;
}

.field__hint {
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  line-height: var(--lh-snug);
}

.field__error {
  display: none;
  align-items: flex-start;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-danger);
  line-height: var(--lh-snug);
}

.field[data-invalid="true"] .field__error {
  display: flex;
}

.field[data-invalid="true"] .input {
  border-color: var(--c-danger);
  background: var(--c-danger-soft);
}

.input {
  width: 100%;
  height: var(--h-md);
  padding: 0 10px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: var(--fs-sm);
  color: var(--c-ink-900);
  box-shadow: 0 1px 1px rgba(11, 19, 34, 0.03);
  transition: border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.input::placeholder {
  color: var(--c-ink-400);
}

.input:hover:not(:disabled) {
  border-color: var(--c-ink-300);
}

.input:focus {
  outline: none;
  border-color: var(--c-focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c-focus) 18%, transparent);
}

.input:disabled {
  background: var(--c-surface-2);
  color: var(--c-ink-400);
  cursor: not-allowed;
}

select.input {
  appearance: none;
  padding-right: var(--sp-8);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23636d80' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

.input--num {
  font-variant-numeric: tabular-nums;
  text-align: right;
  padding-inline: var(--sp-2);
  font-weight: var(--fw-semibold);
}

.search {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.search > svg {
  position: absolute;
  left: 10px;
  color: var(--c-ink-400);
  pointer-events: none;
}

.search .input {
  padding-left: 31px;
  width: 232px;
}

.checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: var(--fs-sm);
  color: var(--c-ink-700);
  line-height: var(--lh-snug);
}

.checkbox input {
  flex: none;
  width: 15px;
  height: 15px;
  margin: 2px 0 0;
  accent-color: var(--c-primary);
  cursor: pointer;
}

.checkbox__title {
  font-weight: var(--fw-medium);
  color: var(--c-ink-900);
}

.checkbox__hint {
  display: block;
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
}

/* --- Upload ------------------------------------------------------------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-4);
  min-height: 300px;
  padding: var(--sp-10) var(--sp-8);
  text-align: center;
  border-radius: var(--r-lg);
  /* A fine 6/5 dash drawn with gradients: crisper than a dashed border. */
  background:
    repeating-linear-gradient(90deg, var(--c-ink-200) 0 5px, transparent 5px 9px) top / 100% 1px no-repeat,
    repeating-linear-gradient(90deg, var(--c-ink-200) 0 5px, transparent 5px 9px) bottom / 100% 1px no-repeat,
    repeating-linear-gradient(180deg, var(--c-ink-200) 0 5px, transparent 5px 9px) left / 1px 100% no-repeat,
    repeating-linear-gradient(180deg, var(--c-ink-200) 0 5px, transparent 5px 9px) right / 1px 100% no-repeat,
    var(--c-surface-2);
  transition: background-color var(--dur-2) var(--ease-out),
    box-shadow var(--dur-2) var(--ease-out);
}

/* A faint measuring grid: the drop area reads as an instrument's bed. */
.dropzone::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background-image:
    linear-gradient(var(--c-line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-line-soft) 1px, transparent 1px);
  background-size: 24px 24px;
  background-position: center;
  mask-image: radial-gradient(60% 70% at 50% 45%, #000 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(60% 70% at 50% 45%, #000 0%, transparent 100%);
  opacity: 0.8;
  pointer-events: none;
  transition: opacity var(--dur-2) var(--ease-out);
}

.dropzone > * {
  position: relative;
}

.dropzone:hover {
  box-shadow: inset 0 0 0 1px var(--c-line);
}

.dropzone[data-dragging="true"] {
  background: var(--c-primary-soft);
  box-shadow: inset 0 0 0 1.5px var(--c-primary);
}

.dropzone[data-dragging="true"]::before {
  opacity: 0.25;
}

.dropzone[data-dragging="true"] .dropzone__icon {
  color: var(--c-white);
  background: var(--c-primary);
  border-color: var(--c-primary);
  transform: translateY(-2px);
}

.dropzone:focus-within:has(:focus-visible) {
  box-shadow: inset 0 0 0 1px var(--c-line-strong);
}

.dropzone__icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  color: var(--c-primary);
  box-shadow: var(--sh-sm), 0 6px 14px -8px rgba(28, 74, 134, 0.35);
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out),
    transform var(--dur-2) var(--ease-out);
}

.dropzone__title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tighter);
  color: var(--c-ink-900);
}

.dropzone__sub {
  margin-top: 4px;
  font-size: var(--fs-sm);
  color: var(--c-ink-500);
  max-width: 44ch;
  margin-inline: auto;
}

.dropzone__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.dropzone__formats {
  display: flex;
  gap: 6px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
}

.dropzone__formats .badge {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--c-surface);
}

.dropzone__formats-note {
  flex-basis: 100%;
  margin-top: 2px;
  font-size: var(--fs-xs);
  color: var(--c-ink-400);
}

/* File state: one quiet line that names what was read. */
.filechip {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3) 10px var(--sp-4);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--sh-xs);
  min-width: 0;
  animation: rise-in var(--dur-3) var(--ease-out) both;
}

.filechip__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-md);
  background: var(--c-success-soft);
  color: var(--c-success);
  box-shadow: inset 0 0 0 1px var(--c-success-line);
}

.filechip__icon:not([data-state]) {
  background: var(--c-info-soft);
  color: var(--c-info);
  box-shadow: inset 0 0 0 1px var(--c-info-line);
}

.filechip__icon[data-state="error"] {
  background: var(--c-danger-soft);
  color: var(--c-danger);
  box-shadow: inset 0 0 0 1px var(--c-danger-line);
}

.filechip__icon[data-state="busy"] {
  background: var(--c-info-soft);
  color: var(--c-info);
  box-shadow: inset 0 0 0 1px var(--c-info-line);
}

.filechip__body {
  min-width: 0;
  flex: 1 1 auto;
}

.filechip__name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
}

.filechip__meta {
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  font-variant-numeric: tabular-nums;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Information rail (data health) -------------------------------------- */
.metric-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  overflow: hidden;
}

.metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--sp-3) var(--sp-4);
  min-width: 0;
}

.metric + .metric {
  border-left: 1px solid var(--c-line-soft);
}

.metric__value {
  order: -1;
  font-size: 1.25rem;
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
  letter-spacing: var(--tracking-tighter);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.metric__label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-700);
}

.metric__note {
  font-size: var(--fs-2xs);
  color: var(--c-ink-400);
}

.metric[data-tone="success"] .metric__value {
  color: var(--c-success);
}

.metric[data-tone="warning"] .metric__value {
  color: var(--c-warning);
}

.metric[data-tone="danger"] .metric__value {
  color: var(--c-danger);
}

.metric[data-tone="info"] .metric__value {
  color: var(--c-info);
}

/* --- Analytics rail ------------------------------------------------------ */
.stats {
  --stat-cols: 8;
  display: grid;
  grid-template-columns: repeat(var(--stat-cols), minmax(0, 1fr));
  gap: 1px;
  background: var(--c-line-soft);
  border: 1px solid var(--c-line);
  border-radius: var(--r-xl);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 14px var(--sp-4) var(--sp-3);
  background: var(--c-surface);
  min-width: 0;
}

.stat__label {
  order: -1;
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-500);
  white-space: nowrap;
}

.stat__value {
  margin-top: 6px;
  font-size: var(--fs-2xl);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-display);
  color: var(--c-ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
  white-space: nowrap;
}

.stat__value--text {
  font-size: 1.375rem;
}

.stat__unit {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-ink-400);
  margin-left: 2px;
}

.stat__note {
  margin-top: 5px;
  font-size: var(--fs-2xs);
  color: var(--c-ink-400);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat--accent .stat__value {
  color: var(--c-primary);
}

/* --- Course picker ------------------------------------------------------ */
.course-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
  gap: var(--sp-2);
}

.course-card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "name count"
    "meta meta";
  align-items: baseline;
  gap: 6px var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  box-shadow: var(--sh-xs);
  transition: border-color var(--dur-1) var(--ease-out),
    box-shadow var(--dur-1) var(--ease-out), background-color var(--dur-1) var(--ease-out);
}

.course-card:hover {
  border-color: var(--c-ink-300);
  box-shadow: var(--sh-sm);
}

.course-card[data-selected="true"] {
  border-color: var(--c-primary);
  box-shadow: inset 0 0 0 1px var(--c-primary), 0 1px 2px rgba(28, 74, 134, 0.12);
}

.course-card[data-selected="true"]::after {
  content: "";
  position: absolute;
  top: -1px;
  left: 14px;
  right: 14px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--c-primary);
}

.course-card__name {
  grid-area: name;
  font-size: var(--fs-md);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-tighter);
  color: var(--c-ink-900);
  overflow-wrap: anywhere;
}

.course-card__meta {
  display: contents;
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  font-variant-numeric: tabular-nums;
}

.course-card__meta > span:first-child {
  grid-area: count;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-700);
  white-space: nowrap;
}

.course-card__meta > span:not(:first-child) {
  grid-row: 2;
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  font-variant-numeric: tabular-nums;
}

.course-card__meta > span:nth-child(2) {
  grid-column: 1;
}

.course-card__meta > span:nth-child(3) {
  grid-column: 2;
  text-align: right;
}

.course-card__flag {
  grid-column: 1 / -1;
  grid-row: 3;
}

/* --- Tables ------------------------------------------------------------- */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}

.table-scroll {
  max-height: 440px;
  overflow: auto;
}

table.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  padding: 0 var(--sp-4);
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  letter-spacing: 0;
  color: var(--c-ink-500);
  background: color-mix(in srgb, var(--c-surface-2) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--c-line);
  white-space: nowrap;
}

table.data thead th[data-sortable="true"] {
  cursor: pointer;
  user-select: none;
  transition: color var(--dur-1) var(--ease-out);
}

table.data thead th[data-sortable="true"]:hover {
  color: var(--c-ink-900);
}

table.data thead th:focus-visible {
  outline-offset: -2px;
}

table.data thead th[aria-sort="ascending"],
table.data thead th[aria-sort="descending"] {
  color: var(--c-ink-900);
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

th.num .th-sort {
  flex-direction: row-reverse;
}

.th-sort__ind {
  display: inline-flex;
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease-out);
}

th[data-sortable="true"]:hover .th-sort__ind {
  opacity: 0.45;
}

th[aria-sort="ascending"] .th-sort__ind,
th[aria-sort="descending"] .th-sort__ind {
  opacity: 1;
  color: var(--c-primary);
}

table.data tbody td {
  height: 38px;
  padding: 7px var(--sp-4);
  border-bottom: 1px solid var(--c-line-soft);
  color: var(--c-ink-700);
  vertical-align: middle;
}

table.data tbody tr:last-child td {
  border-bottom: 0;
}

table.data tbody tr {
  transition: background-color var(--dur-1) var(--ease-out);
}

table.data tbody tr:hover {
  background: var(--c-surface-2);
}

table.data tbody tr[data-flagged="true"] {
  background: var(--c-accent-soft);
}

table.data tbody tr[data-flagged="true"] td:first-child {
  box-shadow: inset 2px 0 0 var(--c-accent);
}

table.data tbody tr[data-flagged="true"]:hover {
  background: #f8eddd;
}

td.num,
th.num,
table.data thead th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.issue-table th:first-child,
.issue-table td:first-child {
  width: 72px;
}

.issue-table td {
  vertical-align: top;
}

.cell-id {
  font-weight: var(--fw-medium);
  color: var(--c-ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.cell-strong {
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
  font-variant-numeric: tabular-nums;
}

.cell-muted {
  color: var(--c-ink-400);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
}

.row-marker {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--c-accent);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.table-foot {
  margin-top: var(--sp-3);
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
}

/* --- Notices: precise, tinted, never a red wall --------------------------- */
.notice {
  display: flex;
  gap: 10px;
  padding: var(--sp-3) 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  font-size: var(--fs-sm);
  line-height: var(--lh-snug);
  background: var(--c-surface);
  color: var(--c-ink-700);
}

.notice__icon {
  flex: none;
  margin-top: 1px;
}

.notice__icon svg {
  width: 16px;
  height: 16px;
}

.notice__title {
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
  display: block;
  margin-bottom: 2px;
}

.notice--success {
  background: var(--c-success-soft);
  border-color: var(--c-success-line);
  color: #1f5641;
}
.notice--success .notice__icon,
.notice--success .notice__title {
  color: var(--c-success);
}

.notice--warning {
  background: var(--c-warning-soft);
  border-color: var(--c-warning-line);
  color: #6d420c;
}
.notice--warning .notice__icon,
.notice--warning .notice__title {
  color: var(--c-warning);
}

.notice--danger {
  background: var(--c-danger-soft);
  border-color: var(--c-danger-line);
  color: #7a231b;
}
.notice--danger .notice__icon,
.notice--danger .notice__title {
  color: var(--c-danger);
}

.notice--info {
  background: var(--c-info-soft);
  border-color: var(--c-info-line);
  color: var(--c-brand-800);
}
.notice--info .notice__icon,
.notice--info .notice__title {
  color: var(--c-info);
}

.notice__body {
  min-width: 0;
  flex: 1 1 auto;
}

.notice ul {
  margin-top: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.notice li {
  position: relative;
  padding-left: 14px;
}

.notice li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.62em;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.45;
}

.notice--inline {
  padding: 0;
  border: 0;
  background: transparent;
}

.notice--inline .notice__title {
  display: inline;
  margin: 0 6px 0 0;
}

.notice--inline .notice__body > p {
  display: inline;
  color: var(--c-ink-500);
  font-size: var(--fs-sm);
}

/* --- Diagnostic: an error described as what, where and how to fix ------- */
.diagnostic {
  border: 1px solid var(--c-danger-line);
  border-radius: var(--r-xl);
  background: var(--c-surface);
  box-shadow: var(--sh-xs);
  overflow: hidden;
  animation: rise-in var(--dur-3) var(--ease-out) both;
}

.diagnostic__head {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 14px var(--sp-5);
  background: linear-gradient(var(--c-danger-soft), var(--c-danger-soft));
  border-bottom: 1px solid var(--c-danger-line);
}

.diagnostic__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-danger);
  box-shadow: inset 0 0 0 1px var(--c-danger-line);
}

.diagnostic__title {
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  color: var(--c-ink-900);
  letter-spacing: var(--tracking-tight);
}

.diagnostic__file {
  margin-top: 1px;
  font-size: var(--fs-xs);
  color: var(--c-ink-500);
  overflow-wrap: anywhere;
}

.diagnostic__grid {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px var(--sp-4);
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-sm);
}

.diagnostic__grid dt {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-500);
  padding-top: 1px;
}

.diagnostic__grid dd {
  color: var(--c-ink-800);
  min-width: 0;
  overflow-wrap: anywhere;
}

.diagnostic__headers {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.diagnostic__headers code,
.code-chip {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--c-surface-3);
  box-shadow: inset 0 0 0 1px var(--c-line);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-ink-800);
  white-space: nowrap;
}

.diagnostic__headers code[data-missing="true"] {
  background: var(--c-danger-soft);
  box-shadow: none;
  outline: 1px dashed color-mix(in srgb, var(--c-danger) 55%, transparent);
  outline-offset: -1px;
  color: var(--c-danger);
}

.diagnostic__headers code[data-missing="true"]::after {
  content: "missing";
  margin-left: 6px;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  opacity: 0.8;
}

.diagnostic__foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--c-line-soft);
  background: var(--c-surface-2);
}

/* --- Empty state -------------------------------------------------------- */
.empty {
  display: grid;
  place-items: center;
  gap: var(--sp-2);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
  color: var(--c-ink-500);
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 2px;
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
  box-shadow: inset 0 0 0 1px var(--c-line);
  color: var(--c-ink-400);
}

.empty__icon svg {
  width: 17px;
  height: 17px;
}

.empty__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--c-ink-800);
}

.empty__text {
  font-size: var(--fs-xs);
  max-width: 42ch;
  line-height: var(--lh-snug);
}

.empty--inline {
  padding: var(--sp-6) var(--sp-4);
}

/* --- Disclosure --------------------------------------------------------- */
.disclosure {
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  background: var(--c-surface);
  overflow: hidden;
}

.disclosure + .disclosure {
  margin-top: var(--sp-2);
}

/* Stacked disclosures read as one list with shared hairlines. */
.disclosure-group {
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--c-surface);
}

.disclosure-group > .disclosure {
  border: 0;
  border-radius: 0;
  margin: 0;
}

.disclosure-group > .disclosure + .disclosure {
  border-top: 1px solid var(--c-line-soft);
}

.disclosure__summary {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: var(--sp-2) 14px;
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-ink-800);
  user-select: none;
  transition: background-color var(--dur-1) var(--ease-out);
}

.disclosure__summary::-webkit-details-marker {
  display: none;
}

.disclosure__summary:hover {
  background: var(--c-surface-2);
}

.disclosure__summary:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: -2px;
}

.disclosure__chev {
  flex: none;
  display: inline-flex;
  color: var(--c-ink-400);
  transition: transform var(--dur-2) var(--ease-out);
}

.disclosure__chev svg {
  width: 13px;
  height: 13px;
}

.disclosure[open] > .disclosure__summary .disclosure__chev {
  transform: rotate(90deg);
}

.disclosure__count {
  margin-left: auto;
  min-width: 20px;
  height: 18px;
  padding: 0 5px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--r-sm);
  background: var(--c-surface-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-semibold);
  color: var(--c-ink-600);
  font-variant-numeric: tabular-nums;
}

.disclosure__body {
  padding: 14px;
  border-top: 1px solid var(--c-line-soft);
  background: var(--c-surface-2);
}

/* --- Definition list ---------------------------------------------------- */
.dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--sp-2) var(--sp-5);
  font-size: var(--fs-sm);
}

.dl dt {
  color: var(--c-ink-500);
  white-space: nowrap;
}

.dl dd {
  color: var(--c-ink-900);
  font-weight: var(--fw-medium);
  text-align: right;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.dl--stack {
  grid-template-columns: 1fr;
  gap: 0;
}

.dl--stack dt {
  font-size: var(--fs-2xs);
  font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
}

.dl--stack dd {
  text-align: left;
  margin-bottom: var(--sp-3);
}

/* --- Format guide table ------------------------------------------------- */
.spec-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.spec-table th {
  text-align: left;
  height: 30px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-ink-500);
  border-bottom: 1px solid var(--c-line);
}

.spec-table td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--c-line-soft);
  color: var(--c-ink-700);
  vertical-align: middle;
}

.spec-table tr:last-child td {
  border-bottom: 0;
}

.spec-table code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--c-surface);
  box-shadow: inset 0 0 0 1px var(--c-line);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  color: var(--c-ink-900);
  white-space: nowrap;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary {
  list-style: none;
}

details[open] > summary {
  color: var(--c-ink-900);
}

/* --- Spinner ------------------------------------------------------------ */
.spinner {
  width: 13px;
  height: 13px;
  flex: none;
  border: 1.5px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0.75;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Progress bar ------------------------------------------------------- */
.progress {
  height: 4px;
  border-radius: 2px;
  background: var(--c-ink-100);
  overflow: hidden;
}

.progress__bar {
  height: 100%;
  background: var(--c-primary);
  border-radius: inherit;
  transition: width var(--dur-3) var(--ease-out);
}

/* --- Toasts ------------------------------------------------------------- */
.toast-region {
  position: fixed;
  right: var(--sp-5);
  bottom: var(--sp-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  width: min(380px, calc(100vw - var(--sp-8)));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px var(--sp-3) 10px 14px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--c-ink-900);
  color: var(--c-ink-300);
  box-shadow: var(--sh-lg);
  font-size: var(--fs-xs);
  line-height: var(--lh-snug);
  pointer-events: auto;
  animation: toast-in var(--dur-3) var(--ease-out) both;
}

.toast[data-leaving="true"] {
  animation: toast-out var(--dur-2) var(--ease-in-out) both;
}

.toast__icon {
  flex: none;
  margin-top: 1px;
}

.toast__icon svg {
  width: 15px;
  height: 15px;
}

.toast__body {
  flex: 1 1 auto;
  min-width: 0;
}

.toast__title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-white);
  margin-bottom: 1px;
}

.toast--success .toast__icon {
  color: #7fd3ae;
}
.toast--danger .toast__icon {
  color: #f3a59c;
}
.toast--warning .toast__icon {
  color: #f0c77e;
}
.toast--info .toast__icon {
  color: #9dbbe6;
}

.toast__action {
  flex: none;
  align-self: center;
}

.toast__action button {
  height: 26px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--c-white);
  border-radius: var(--r-md);
  padding: 0 10px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition: background-color var(--dur-1) var(--ease-out);
}

.toast__action button:hover {
  background: rgba(255, 255, 255, 0.16);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(4px);
  }
}
