/*
 * Design-system components. Each block notes its Figma source; sizes, radii
 * and colours were measured on the Design System page and the three admin
 * screens. Template tags in core/templatetags/ui.py render most of them.
 */


/* ===================================================================== */
/* Buttons (Figma Button 1:297: Primary / Secondary / Ghost x md / lg)    */
/* ===================================================================== */

.btn {
  --btn-icon: 16px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--control-height);
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--text-primary);
  font: var(--type-button-m);
  letter-spacing: var(--track-button-m);
  white-space: nowrap;
  text-decoration: none;
  user-select: none;
  transition:
    background-color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    color var(--duration-fast) var(--ease-out),
    box-shadow var(--duration) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.btn .i {
  --i-size: var(--btn-icon);
}

.btn:active:not(:disabled):not([aria-disabled="true"]) {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  box-shadow: none;
  pointer-events: none;
}

.btn--primary {
  background: var(--brand-red);
  color: var(--base-white);
  box-shadow: var(--glow-red);
}

.btn--primary:hover {
  background: var(--brand-red-bright);
  /* A step up from the Figma-fitted --glow-red (0 7 26 -2, 52 %). */
  box-shadow: 0 10px 32px -2px rgb(229 37 44 / 0.62);
}

.btn--primary:active {
  background: color-mix(in srgb, var(--brand-red) 86%, var(--base-black));
}

.btn--secondary {
  border: 1px solid var(--border-strong);
  background: var(--overlay-secondary);
}

.btn--secondary:hover {
  border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-tertiary));
  background: rgb(255 255 255 / 0.07);
}

.btn--ghost:hover {
  background: var(--overlay-hover);
}

.btn--ghost:active {
  background: rgb(255 255 255 / 0.06);
}

/* Danger: destructive confirmations (same shape as secondary, red text). */
.btn--danger {
  border: 1px solid color-mix(in srgb, var(--brand-red) var(--alpha-ring), transparent);
  background: color-mix(in srgb, var(--brand-red) var(--alpha-chip), transparent);
  color: var(--brand-red-bright);
}

.btn--danger:hover {
  background: color-mix(in srgb, var(--brand-red) 22%, transparent);
}

.btn--lg {
  --btn-icon: 20px;
  gap: 10px;
  height: var(--control-height-lg);
  padding: 0 20px;
  border-radius: var(--radius-xl);
  font: var(--type-button-l);
  letter-spacing: var(--track-button-l);
}

.btn--sm {
  --btn-icon: 14px;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  font: var(--type-label-xs-strong);
}

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

/* Trailing arrow nudges on hover. */
.btn .btn__arrow {
  transition: transform var(--duration) var(--ease-out);
}

.btn:hover .btn__arrow {
  transform: translateX(2px);
}

/* Loading state: <button class="btn" aria-busy="true"> */
.btn[aria-busy="true"] {
  color: transparent;
  pointer-events: none;
}

.btn[aria-busy="true"]::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgb(255 255 255 / 0.35);
  border-top-color: var(--base-white);
  border-radius: 50%;
  animation: ts-spin 0.7s linear infinite;
}

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

/* Icon-only buttons (bell, row actions, close). */
.icon-btn {
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  flex: none;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-secondary);
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

.icon-btn .i {
  --i-size: 18px;
}

.icon-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.icon-btn[aria-expanded="true"] {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.icon-btn--ghost {
  border-color: transparent;
  background: transparent;
}

.icon-btn--ghost:hover {
  border-color: transparent;
  background: var(--overlay-hover);
}

.icon-btn--sm {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
}

.icon-btn--xs {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-secondary);
}

.icon-btn--muted {
  color: var(--text-tertiary);
}

.icon-btn--xs:hover {
  background: var(--overlay-hover);
  color: var(--text-primary);
}

.icon-btn--danger:hover {
  color: var(--brand-red-bright);
}

/* Notification dot (red, 8 px). */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--tone, var(--brand-red));
}

/* Neutral count chip ("12" next to a board column title). */
.count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 18px;
  padding: 0 7px;
  border-radius: var(--radius-full);
  background: var(--bg-raised);
  color: var(--text-secondary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
}

.dot--pulse {
  box-shadow: 0 0 0 0 rgb(229 37 44 / 0.6);
  animation: ts-pulse 2.4s var(--ease-out) infinite;
}

@keyframes ts-pulse {
  0% { box-shadow: 0 0 0 0 rgb(229 37 44 / 0.55); }
  70% { box-shadow: 0 0 0 6px rgb(229 37 44 / 0); }
  100% { box-shadow: 0 0 0 0 rgb(229 37 44 / 0); }
}

/* Keyboard hint ("Ctrl K"). */
.kbd {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  font: var(--type-mono-xs);
  letter-spacing: var(--track-mono-xs);
  white-space: nowrap;
}

/* ===================================================================== */
/* Pills, badges and chips                                               */
/* ===================================================================== */

/* Status Pill (1:338): 22 px, dot + label, tone at 13 %. */
.pill {
  --tone: var(--tone-gray);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 10px 0 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tone) var(--alpha-pill), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.pill--queued, .pill--planned, .pill--accepted, .pill--cancelled { --tone: var(--tone-gray); }
.pill--in_progress, .pill--active { --tone: var(--tone-blue); }
.pill--reporting { --tone: var(--tone-violet); }
.pill--retest { --tone: var(--tone-amber); }
.pill--done, .pill--fixed, .pill--completed { --tone: var(--tone-green); }
.pill--open, .pill--blocked { --tone: var(--tone-orange); }
.pill--overdue { --tone: var(--tone-red); }

/* Severity Badge (1:313): 24 px, square marker + label, tone at 14 %. */
.sev-badge {
  --tone: var(--tone-gray);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px 0 9px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
}

.sev-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 2px;
  background: currentColor;
}

.sev-badge--critical { --tone: var(--severity-critical); }
.sev-badge--high { --tone: var(--severity-high); }
.sev-badge--medium { --tone: var(--severity-medium); }
.sev-badge--low { --tone: var(--severity-low); }
.sev-badge--info { --tone: var(--severity-info); }

/* Severity count chips ("2 C  5 H  9 M  6 L"). */
.sev-counts {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sev-chip {
  --tone: var(--tone-gray);
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sev-chip--critical { --tone: var(--severity-critical); }
.sev-chip--high { --tone: var(--severity-high); }
.sev-chip--medium { --tone: var(--severity-medium); }
.sev-chip--low { --tone: var(--severity-low); }
.sev-chip--info { --tone: var(--severity-info); }

.sev-counts__chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.sev-counts__empty {
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

/* Delta pill on KPI cards ("+14", "9 active", "Needs attention"). */
.delta {
  --tone: var(--tone-green);
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
}

.delta--success { --tone: var(--tone-green); }
.delta--info { --tone: var(--tone-blue); }
.delta--warning { --tone: var(--tone-amber); }
.delta--danger { --tone: var(--tone-red); }
.delta--neutral { --tone: var(--tone-gray); }

/* Generic soft badge with an optional icon ("Encrypted at rest", "Client"). */
.badge {
  --tone: var(--tone-gray);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-full);
  background: color-mix(in srgb, var(--tone) var(--alpha-soft), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
}

.badge .i {
  --i-size: 14px;
}

.badge--sm {
  gap: 5px;
  height: 22px;
  padding: 0 9px;
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
}

.badge--sm .i {
  --i-size: 12px;
}

.badge--neutral {
  --tone: var(--tone-gray);
  color: var(--text-secondary);
}

/* Scope tag chip ("Web", "API", "Phishing"). */
.tag {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  background: var(--overlay-chip);
  color: var(--text-secondary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* File-type badge (PDF / DOC / XLS / ZIP). */
.file-badge {
  --tone: var(--tone-gray);
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
  color: var(--tone);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
}

.file-badge--lg {
  width: 36px;
  height: 40px;
}

.file-badge--pdf { --tone: var(--tone-red); }
.file-badge--doc, .file-badge--docx { --tone: var(--tone-blue); }
.file-badge--xls, .file-badge--xlsx { --tone: var(--tone-green); }
.file-badge--zip { --tone: var(--tone-amber); }

/* Letter tile ("K" for Kestrel Pay). */
.letter-tile {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-tile);
  background: var(--bg-raised);
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
  text-transform: uppercase;
}

.letter-tile--sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  font: var(--type-label-xs-strong);
}

/* Icon in a tinted square (KPI cards, empty states, list items). */
.icon-tile {
  --tone: var(--brand-red);
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--tone) var(--alpha-soft), transparent);
  color: var(--tone);
}

.icon-tile .i {
  --i-size: 18px;
}

.icon-tile--lg {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-xl);
}

.icon-tile--lg .i {
  --i-size: 22px;
}

/* ===================================================================== */
/* Avatars (Avatar 1:339)                                                */
/* ===================================================================== */

.avatar {
  --size: 32px;
  --tone: var(--tone-gray);
  position: relative;
  display: inline-grid;
  place-items: center;
  width: var(--size);
  height: var(--size);
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  background: color-mix(in srgb, var(--tone) var(--alpha-avatar), transparent);
  color: var(--text-primary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  text-transform: uppercase;
  user-select: none;
}

.avatar--red { --tone: var(--tone-red); }
.avatar--orange { --tone: var(--tone-orange); }
.avatar--amber { --tone: var(--tone-amber); }
.avatar--blue { --tone: var(--tone-blue); }
.avatar--violet { --tone: var(--tone-violet); }
.avatar--green { --tone: var(--tone-green); }
.avatar--slate { --tone: var(--tone-gray); }

/* Neutral variant (sidebar user card). */
.avatar--neutral {
  background: var(--bg-raised);
}

.avatar--24 { --size: 24px; font-size: 10px; line-height: 12px; }
.avatar--28 { --size: 28px; font-size: 11px; line-height: 14px; }
.avatar--40 { --size: 40px; font-size: 14px; line-height: 18px; }
.avatar--48 { --size: 48px; font: var(--type-label-m); }

/* "Unassigned": dashed ring with a plus. */
.avatar--empty {
  border-style: dashed;
  background: transparent;
  color: var(--text-tertiary);
}

.avatar--empty .i {
  --i-size: 12px;
}

.avatar-stack {
  display: inline-flex;
  align-items: center;
  isolation: isolate;
}

/* 4 px overlap, 2 px ring in the surface colour, first avatar on top. */
.avatar-stack .avatar {
  box-shadow: 0 0 0 2px var(--avatar-ring, var(--bg-surface));
}

.avatar-stack .avatar + .avatar {
  margin-left: -4px;
}

.avatar-stack .avatar:nth-child(1) { z-index: 6; }
.avatar-stack .avatar:nth-child(2) { z-index: 5; }
.avatar-stack .avatar:nth-child(3) { z-index: 4; }
.avatar-stack .avatar:nth-child(4) { z-index: 3; }
.avatar-stack .avatar:nth-child(5) { z-index: 2; }
.avatar-stack .avatar:nth-child(6) { z-index: 1; }

.card .avatar-stack {
  --avatar-ring: var(--bg-elevated);
}

.avatar-stack__more {
  background: var(--bg-raised);
  color: var(--text-secondary);
}

/* Person row: avatar + name (+ secondary line). */
.person {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.person__name {
  overflow: hidden;
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.person--muted .person__name {
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

/* ===================================================================== */
/* Cards and panels                                                      */
/* ===================================================================== */

.panel {
  min-width: 0;
  padding: 24px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  background: var(--bg-surface);
}

.panel--flush {
  padding: 0;
  overflow: hidden;
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.panel--flush > .panel__head {
  padding: 20px 24px;
}

.panel__head--top {
  align-items: flex-start;
}

.panel__titles {
  min-width: 0;
}

.panel__title {
  color: var(--text-primary);
  font: var(--type-h5);
  letter-spacing: var(--track-h5);
}

.panel__subtitle {
  margin-top: 4px;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

.panel__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.panel__body {
  margin-top: 20px;
}

.panel__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  min-height: 58px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

/* Smaller inner card (board cards, upload rows, sidebar cards). */
.card {
  padding: 15px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  background: var(--bg-elevated);
}

a.card,
.card--interactive {
  transition: border-color var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

a.card:hover,
.card--interactive:hover {
  border-color: var(--border-strong);
}

.card--danger {
  border-color: color-mix(in srgb, var(--brand-red) 55%, transparent);
}

/* ===================================================================== */
/* KPI card (1:341): label + icon tile, value, delta + caption           */
/* ===================================================================== */

.kpi {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 162px;
  padding: 20px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-2xl);
  background: var(--bg-surface);
}

a.kpi {
  transition: border-color var(--duration-fast) var(--ease-out);
}

a.kpi:hover {
  border-color: var(--border-strong);
}

.kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
}

.kpi__label {
  min-width: 0;
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
}

.kpi__value {
  margin-top: 13px; /* Figma places the value 13 px below the header and the footer 11 px below it */
  color: var(--text-primary);
  font: var(--type-data-xl);
  letter-spacing: var(--track-data-xl);
  white-space: nowrap;
}

.kpi__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
  margin-top: 11px;
}

.kpi__caption {
  min-width: 0;
  overflow: hidden;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--grid-gap);
}

@media (max-width: 1179px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 559px) {
  .kpi-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===================================================================== */
/* Progress bar (SVG: CSP-safe widths via attributes)                     */
/* ===================================================================== */

.progress {
  --tone: var(--tone-blue);
  display: block;
  width: 100%;
  height: 6px;
  overflow: visible;
}

.progress__track {
  fill: var(--bg-raised);
}

.progress__fill {
  fill: var(--tone);
}

.progress--blue { --tone: var(--tone-blue); }
.progress--violet { --tone: var(--tone-violet); }
.progress--amber { --tone: var(--tone-amber); }
.progress--red { --tone: var(--tone-red); }
.progress--green { --tone: var(--tone-green); }

.progress--5 { height: 5px; }

.progress-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.progress-row .progress {
  flex: 0 1 100px;
  min-width: 48px;
}

.progress-row__value {
  min-width: 32px;
  color: var(--text-secondary);
  font: var(--type-body-xs);
  line-height: 16px;
}

/* ===================================================================== */
/* Tables (Overview queue, Reports library)                              */
/* ===================================================================== */

.table-wrap {
  /* Phase 2 (page patterns): positioned, so absolutely positioned content in a
     cell (e.g. <th><span class="sr-only">Actions</span></th>) is clipped by
     this scroller instead of widening the page on phones. */
  position: relative;
  width: 100%;
  overflow-x: auto;
}

.table {
  --table-head-py: 10px;
  --table-cell-py: 13px;
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.table th,
.table td {
  padding: var(--table-cell-py) 0 var(--table-cell-py) 14px;
  vertical-align: middle;
}

.table th:first-child,
.table td:first-child {
  padding-left: 24px;
}

.table th:last-child,
.table td:last-child {
  padding-right: 24px;
}

.table thead th {
  padding-top: var(--table-head-py);
  padding-bottom: var(--table-head-py);
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--overlay-head);
  color: var(--text-tertiary);
  font: var(--type-eyebrow);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td {
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
}

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

.table tbody tr {
  transition: background-color var(--duration-fast) var(--ease-out);
}

.table tbody tr:hover {
  background: rgb(255 255 255 / 0.015);
}

.table--roomy {
  --table-head-py: 12px;
  --table-cell-py: 12px;
}

.table .num,
.table .col-num {
  font-variant-numeric: tabular-nums;
}

.table .col-actions {
  text-align: right;
  white-space: nowrap;
}

/* A single inline component in a cell becomes block-level, so it is centred
   in the row instead of sitting on the text baseline. */
.table td > :is(.pill, .badge, .sev-badge, .delta, .tag, .file-badge, .progress-row, .sev-counts, .person, .cell-actions, .kbd):only-child {
  display: flex;
  width: max-content;
  max-width: 100%;
}

.table td > :is(.avatar, .letter-tile):only-child {
  display: grid;
}

/* Table cell content helpers */
.cell-media {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cell-stack {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.cell-title {
  overflow: hidden;
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
  white-space: nowrap;
  text-overflow: ellipsis;
}

a.cell-title:hover,
.cell-title a:hover {
  color: var(--brand-red-bright);
}

.cell-sub {
  overflow: hidden;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cell-actions {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.cell-actions .icon-btn--xs {
  width: 18px;
  height: 18px;
  border-radius: 4px;
}

.cell-actions .i {
  --i-size: 18px;
}

.is-overdue {
  color: var(--brand-red) !important;
}

/* ===================================================================== */
/* Forms (Reports "Upload details")                                      */
/* ===================================================================== */

.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 640px) {
  .form-grid--2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

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

.field__label {
  color: var(--text-secondary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
}

/* <fieldset class="field"><legend class="field__label">: a floated legend is an
   ordinary flex item, so it follows the field's 6 px gap like a <label>. */
fieldset.field > legend {
  float: left;
  width: 100%;
}

.field__label .req {
  color: var(--brand-red);
}

.field__help {
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

/* Django's password rules come as a <ul>. */
.field__help ul {
  margin: 2px 0 0;
  padding-left: 16px;
}

.field__help li + li {
  margin-top: 2px;
}

.field__error {
  display: flex;
  gap: 6px;
  color: var(--brand-red-bright);
  font: var(--type-body-xs);
}

.field__error .i {
  --i-size: 14px;
  margin-top: 1px;
}

.field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input,
.select select,
.textarea {
  width: 100%;
  height: var(--control-height);
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}

.textarea {
  height: auto;
  min-height: 104px;
  padding: 10px 12px;
  font: var(--type-body-s);
  letter-spacing: var(--track-body-s);
  line-height: 21px;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

.input:hover,
.select select:hover,
.textarea:hover {
  border-color: var(--border-strong);
}

.input:focus-visible,
.select select:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: color-mix(in srgb, var(--brand-red) 70%, var(--border-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-red) 22%, transparent);
}

.input:disabled,
.select select:disabled,
.textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.input[aria-invalid="true"],
.select select[aria-invalid="true"],
.textarea[aria-invalid="true"] {
  border-color: color-mix(in srgb, var(--brand-red) 70%, transparent);
}

.input[type="file"] {
  padding: 7px 8px;
  font: var(--type-body-xs);
}

.input[type="file"]::file-selector-button {
  height: 24px;
  margin-right: 10px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xs);
  background: var(--overlay-secondary);
  color: var(--text-primary);
  font: var(--type-label-xs-strong);
  cursor: pointer;
}

/* Control with a leading icon: icon at 13 px, text at 37 px. */
.control {
  position: relative;
  display: block;
  min-width: 0;
}

.control > .i {
  position: absolute;
  top: 50%;
  left: 13px;
  z-index: 1;
  color: var(--text-tertiary);
  transform: translateY(-50%);
  pointer-events: none;
}

.control > .input,
.control > .select select,
.control.select > select {
  padding-left: 36px;
}

/* Native select with the design's chevron. */
.select {
  position: relative;
  display: block;
  min-width: 0;
}

.select select {
  padding-right: 36px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.select select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.select::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 13px;
  width: 16px;
  height: 16px;
  background-color: var(--text-tertiary);
  -webkit-mask: url("../icons/chevron-down.685ae7f5d5b1.svg") center / contain no-repeat;
  mask: url("../icons/chevron-down.685ae7f5d5b1.svg") center / contain no-repeat;
  transform: translateY(-50%);
  pointer-events: none;
}

.select select[multiple] {
  height: auto;
  min-height: 120px;
  padding: 6px;
}

.select:has(select[multiple])::after {
  display: none;
}

.control--sm .input,
.control--sm.select select,
.select--sm select {
  height: var(--control-height-sm);
}

/* Filter buttons on the Targets board (36 px, 15 px icons). */
.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--control-height-sm);
  padding: 0 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  white-space: nowrap;
  transition: border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.filter-btn .i {
  --i-size: 15px;
  color: var(--text-tertiary);
}

.filter-btn:hover,
.filter-btn[aria-expanded="true"] {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.filter-btn--md {
  height: var(--control-height);
}

.filter-btn--md .i {
  --i-size: 16px;
}

/* Checkbox, radio and switch */
.check {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  cursor: pointer;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: none;
  margin: 1px 0 0;
  border: 1px solid var(--border-strong);
  border-radius: 5px;
  background: var(--bg-canvas);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
}

.check input[type="radio"] {
  border-radius: 50%;
}

.check input[type="checkbox"]::after {
  content: "";
  width: 14px;
  height: 14px;
  background-color: var(--base-white);
  -webkit-mask: url("../icons/check.ec39d9ae5f39.svg") center / contain no-repeat;
  mask: url("../icons/check.ec39d9ae5f39.svg") center / contain no-repeat;
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

.check input[type="radio"]::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--base-white);
  transform: scale(0);
  transition: transform var(--duration-fast) var(--ease-out);
}

.check input:checked {
  border-color: var(--brand-red);
  background: var(--brand-red);
}

.check input:checked::after {
  transform: none;
}

.check input:focus-visible {
  outline: 2px solid var(--brand-red-bright);
  outline-offset: 2px;
}

.check:hover input:not(:checked) {
  border-color: var(--text-tertiary);
}

.check__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check__hint {
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

.switch {
  position: relative;
  width: 36px;
  height: 20px;
  flex: none;
  margin: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-raised);
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease-out), border-color var(--duration) var(--ease-out);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition: transform var(--duration) var(--ease-out), background-color var(--duration) var(--ease-out);
}

.switch:checked {
  border-color: var(--brand-red);
  background: var(--brand-red);
}

.switch:checked::after {
  background: var(--base-white);
  transform: translateX(16px);
}

.switch:focus-visible {
  outline: 2px solid var(--brand-red-bright);
  outline-offset: 2px;
}

/* ===================================================================== */
/* Segmented control and tabs                                            */
/* (Board/List/Calendar, 12M/6M/30D, All/Internal/Shared, visibility)     */
/* ===================================================================== */

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 3px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-canvas);
}

.segmented__item {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 26px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

.segmented__item:hover {
  color: var(--text-secondary);
}

.segmented__item[aria-current="page"],
.segmented__item[aria-current="true"],
.segmented__item[aria-pressed="true"],
.segmented__item[aria-selected="true"],
.segmented__item.is-active,
.segmented__item:has(input:checked) {
  background: var(--bg-raised);
  color: var(--text-primary);
}

.segmented__item:has(input:focus-visible) {
  outline: 2px solid var(--brand-red-bright);
  outline-offset: 1px;
}

.segmented__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented__item .i {
  --i-size: 14px;
}

/* 40 px variant that fills its container (Upload details: Visibility). */
.segmented--block {
  display: flex;
  width: 100%;
  height: var(--control-height);
}

.segmented--block .segmented__item {
  flex: 1 1 0;
  height: 32px;
  border-radius: var(--radius-md);
}

/* ===================================================================== */
/* Dropdown menu                                                         */
/* ===================================================================== */

.dropdown {
  position: relative;
  display: inline-flex;
}

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: var(--z-dropdown);
  min-width: 220px;
  max-height: min(70vh, 420px);
  padding: 6px;
  overflow-y: auto;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--elevation-float);
  transform-origin: top right;
  animation: ts-pop var(--duration) var(--ease-out);
}

.menu[hidden] {
  display: none;
}

.menu--left {
  right: auto;
  left: 0;
  transform-origin: top left;
}

.menu--up {
  top: auto;
  bottom: calc(100% + 8px);
}

/* A row menu inside a .table-wrap floats above the scroller instead of being
   clipped by it; app.js sets top/left next to the toggle (final QA). */
.menu--floating {
  position: fixed;
  right: auto;
  bottom: auto;
}

@keyframes ts-pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.menu__label {
  padding: 8px 10px 6px;
  color: var(--text-tertiary);
  font: var(--type-eyebrow);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.menu__item .i {
  --i-size: 16px;
  color: var(--text-tertiary);
}

.menu__item:hover,
.menu__item:focus-visible,
.menu__item.is-active {
  outline: none;
  background: rgb(255 255 255 / 0.05);
  color: var(--text-primary);
}

.menu__item:hover .i,
.menu__item:focus-visible .i {
  color: var(--text-secondary);
}

.menu__item[aria-checked="true"]::after,
.menu__item[aria-current="true"]::after {
  content: "";
  width: 16px;
  height: 16px;
  margin-left: auto;
  background-color: var(--brand-red);
  -webkit-mask: url("../icons/check.ec39d9ae5f39.svg") center / contain no-repeat;
  mask: url("../icons/check.ec39d9ae5f39.svg") center / contain no-repeat;
}

.menu__item--danger,
.menu__item--danger .i {
  color: var(--brand-red-bright);
}

.menu__item--danger:hover,
.menu__item--danger:focus-visible {
  background: color-mix(in srgb, var(--brand-red) var(--alpha-chip), transparent);
  color: var(--brand-red-bright);
}

.menu__sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border-subtle);
}

.menu form {
  margin: 0;
}

/* ===================================================================== */
/* Modal dialog and confirm                                              */
/* ===================================================================== */

.modal {
  width: min(480px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  margin: auto;
  overflow: visible;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  background: var(--bg-elevated);
  box-shadow: var(--elevation-float);
}

.modal--lg {
  width: min(720px, calc(100vw - 32px));
}

.modal[open] {
  animation: ts-modal-in var(--duration-slow) var(--ease-out);
}

.modal::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@keyframes ts-modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.modal__inner {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 50px);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 0;
}

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

.modal__title {
  color: var(--text-primary);
  font: var(--type-h5);
  letter-spacing: var(--track-h5);
}

.modal__subtitle {
  margin-top: 4px;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

.modal__body {
  padding: 16px 24px 4px;
  overflow-y: auto;
  color: var(--text-secondary);
  font: var(--type-body-s);
  letter-spacing: var(--track-body-s);
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 24px 22px;
}

.modal--danger .icon-tile {
  --tone: var(--brand-red);
}

/* ===================================================================== */
/* Toasts (Django messages and TS.toast)                                 */
/* ===================================================================== */

.toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  width: min(420px, calc(100vw - 32px));
  pointer-events: none;
}

.toast {
  --tone: var(--tone-blue);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 12px 12px 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  background: var(--bg-raised);
  box-shadow: var(--elevation-float);
  pointer-events: auto;
  animation: ts-toast-in var(--duration-slow) var(--ease-out);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--duration) var(--ease-out), transform var(--duration) var(--ease-out);
}

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

.toast__icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--tone) var(--alpha-chip), transparent);
  color: var(--tone);
}

.toast__icon .i {
  --i-size: 14px;
}

.toast__text {
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
  color: var(--text-primary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  overflow-wrap: anywhere;
}

.toast--success { --tone: var(--tone-green); }
.toast--info { --tone: var(--tone-blue); }
.toast--warning { --tone: var(--tone-amber); }
.toast--danger, .toast--error { --tone: var(--tone-red); }

@media (max-width: 640px) {
  .toasts {
    right: 16px;
    bottom: 16px;
  }
}

/* ===================================================================== */
/* Tooltips                                                              */
/* ===================================================================== */

/* CSS-only: <button data-tooltip="Download">. Placement: data-tooltip-pos. */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: var(--z-dropdown);
  width: max-content;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  box-shadow: var(--elevation-float);
  color: var(--text-primary);
  font: var(--type-body-xs);
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
  white-space: normal;
  /* Phase 2 (page patterns): hidden tooltips are display:none, so a tooltip near
     the right edge never widens the page on phones; @starting-style below
     keeps the fade-in. */
  display: none;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 4px);
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out), visibility 0s linear var(--duration-fast);
  pointer-events: none;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  display: block;
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition-delay: 250ms, 250ms, 0s;
}

[data-tooltip-pos="bottom"]::after {
  top: calc(100% + 8px);
  bottom: auto;
}

[data-tooltip-pos="right"]::after {
  top: 50%;
  bottom: auto;
  left: calc(100% + 8px);
  transform: translate(4px, -50%);
}

[data-tooltip-pos="right"]:hover::after,
[data-tooltip-pos="right"]:focus-visible::after {
  transform: translate(0, -50%);
}

[data-tooltip-pos="left"]::after {
  top: 50%;
  right: calc(100% + 8px);
  bottom: auto;
  left: auto;
  transform: translate(-4px, -50%);
}

[data-tooltip-pos="left"]:hover::after,
[data-tooltip-pos="left"]:focus-visible::after {
  transform: translate(0, -50%);
}

/* Fade-in start for the display:none tooltips above (after the placement rules). */
@starting-style {
  [data-tooltip]:hover::after,
  [data-tooltip]:focus-visible::after {
    opacity: 0;
    transform: translate(-50%, 4px);
  }

  [data-tooltip-pos="right"]:hover::after,
  [data-tooltip-pos="right"]:focus-visible::after {
    transform: translate(4px, -50%);
  }

  [data-tooltip-pos="left"]:hover::after,
  [data-tooltip-pos="left"]:focus-visible::after {
    transform: translate(-4px, -50%);
  }
}

/* Floating card used by charts (Overview "November 2026" tooltip). */
.tooltip-card {
  min-width: 172px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--elevation-float);
  color: var(--text-secondary);
  font: var(--type-body-xs);
}

.tooltip-card__title {
  margin-bottom: 8px;
  color: var(--text-primary);
  font: var(--type-label-xs-strong);
}

/* ===================================================================== */
/* Pagination (Reports library)                                          */
/* ===================================================================== */

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
}

.page-btn {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  font-variant-numeric: tabular-nums;
  transition: border-color var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}

a.page-btn:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.page-btn[aria-current="page"] {
  border-color: color-mix(in srgb, var(--brand-red) var(--alpha-ring), transparent);
  background: color-mix(in srgb, var(--brand-red) var(--alpha-chip), transparent);
  color: var(--brand-red);
}

.page-btn--gap {
  border-color: var(--border-subtle);
  color: var(--text-tertiary);
}

.page-btn[aria-disabled="true"] {
  opacity: 0.4;
}

/* ===================================================================== */
/* Empty state                                                           */
/* ===================================================================== */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 440px;
  margin: 0 auto;
  padding: 48px 24px;
  text-align: center;
}

.empty__icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--brand-red) var(--alpha-chip), transparent);
  color: var(--brand-red);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--brand-red) 5%, transparent);
}

.empty__icon .i {
  --i-size: 24px;
}

.empty__title {
  margin-top: 20px;
  color: var(--text-primary);
  font: var(--type-h5);
  letter-spacing: var(--track-h5);
}

.empty__body {
  margin-top: 8px;
  color: var(--text-tertiary);
  text-wrap: pretty; /* no one-word widows (QA NIT-1) */
  font: var(--type-body-s);
  letter-spacing: var(--track-body-s);
}

.empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

/* ===================================================================== */
/* Alerts (inline messages, form errors)                                 */
/* ===================================================================== */

/* {% form_errors %} receives focus after a failed submit when no field can
   (non-field errors only); it is not a control, so no focus ring. */
.form-errors:focus {
  outline: none;
}

.alert {
  --tone: var(--tone-blue);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--tone) 10%, transparent);
  color: var(--text-primary);
  font: var(--type-body-s);
  letter-spacing: var(--track-body-s);
}

.alert > .i {
  --i-size: 16px;
  margin-top: 2px;
  color: var(--tone);
}

.alert__body > * + * {
  margin-top: 4px;
}

.alert--danger { --tone: var(--tone-red); }
.alert--warning { --tone: var(--tone-amber); }
.alert--success { --tone: var(--tone-green); }
.alert--info { --tone: var(--tone-blue); }

/* ===================================================================== */
/* Description list (detail pages)                                       */
/* ===================================================================== */

.meta-list {
  display: grid;
  grid-template-columns: minmax(120px, 180px) minmax(0, 1fr);
  gap: 12px 24px;
  margin: 0;
}

.meta-list dt {
  color: var(--text-tertiary);
  font: var(--type-label-xs-strong);
  letter-spacing: var(--track-label-xs-strong);
  padding-top: 2px;
}

.meta-list dd {
  min-width: 0;
  margin: 0;
  color: var(--text-primary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .meta-list {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .meta-list dd {
    margin-bottom: 10px;
  }
}

/* ===================================================================== */
/* Command palette (Ctrl/Cmd K)                                          */
/* ===================================================================== */

.palette {
  width: min(640px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 96px));
  margin: 12vh auto auto;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-2xl);
  background: var(--bg-elevated);
  box-shadow: var(--elevation-float), 0 0 0 1px rgb(0 0 0 / 0.2);
}

.palette[open] {
  display: flex;
  flex-direction: column;
  animation: ts-modal-in var(--duration) var(--ease-out);
}

.palette::backdrop {
  background: var(--scrim);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.palette__search {
  display: flex;
  flex: none;
  align-items: center;
  gap: 12px;
  height: 60px;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
}

.palette__search .i {
  --i-size: 18px;
}

.palette__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font: var(--type-body-m);
}

.palette__input::placeholder {
  color: var(--text-tertiary);
  opacity: 1;
}

.palette__input:focus-visible {
  outline: none;
}

.palette__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.palette__list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 8px;
  overflow-y: auto;
  list-style: none;
}

.palette__group {
  padding: 10px 10px 6px;
  color: var(--text-tertiary);
  font: var(--type-eyebrow);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.palette__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  cursor: pointer;
}

.palette__item[aria-selected="true"] {
  background: rgb(255 255 255 / 0.05);
  color: var(--text-primary);
}

.palette__item[aria-selected="true"] .palette__enter {
  opacity: 1;
}

.palette__item .icon-tile {
  --tone: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
}

.palette__item[aria-selected="true"] .icon-tile {
  --tone: var(--brand-red);
  background: color-mix(in srgb, var(--brand-red) var(--alpha-soft), transparent);
}

.palette__item .icon-tile .i {
  --i-size: 16px;
}

.palette__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.palette__title {
  overflow: hidden;
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.palette__sub {
  overflow: hidden;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
  white-space: nowrap;
  text-overflow: ellipsis;
}

.palette__enter {
  color: var(--text-tertiary);
  opacity: 0;
}

.palette__state {
  padding: 36px 24px 40px;
  color: var(--text-tertiary);
  font: var(--type-body-s);
  text-align: center;
}

.palette__foot {
  display: flex;
  flex: none;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

.palette__foot span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.palette__foot .kbd {
  height: 20px;
  padding: 0 5px;
  font-size: 11px;
}

.palette__foot a {
  margin-left: auto;
  color: var(--text-secondary);
}

.palette__foot a:hover {
  color: var(--text-primary);
}

/* ===================================================================== */
/* Notifications dropdown                                                */
/* ===================================================================== */

.notif {
  width: min(380px, calc(100vw - 32px));
  padding: 0;
}

.notif__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.notif__title {
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
}

.notif__list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.notif__item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
}

a.notif__item:hover,
a.notif__item:focus-visible {
  outline: none;
  background: rgb(255 255 255 / 0.05);
}

.notif__item .avatar {
  margin-top: 1px;
}

.notif__text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  font: var(--type-body-xs);
  line-height: 18px;
}

.notif__text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.notif__object {
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.notif__time {
  color: var(--text-tertiary);
}

.notif__empty {
  padding: 28px 20px 30px;
  color: var(--text-tertiary);
  font: var(--type-body-xs);
  text-align: center;
}

.notif__foot {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  font: var(--type-label-xs-strong);
  text-align: center;
}

.notif__foot a {
  color: var(--text-secondary);
}

.notif__foot a:hover {
  color: var(--text-primary);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-secondary);
  font: var(--type-label-xs-strong);
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text-primary);
}

/* ===================================================================== */
/* Small layout helpers                                                  */
/* ===================================================================== */

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap, var(--section-gap));
}

.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--cluster-gap, 8px);
}

.split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--section-gap);
}

@media (max-width: 1023px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.divider {
  height: 1px;
  background: var(--border-subtle);
}

.eyebrow {
  color: var(--text-tertiary);
  font: var(--type-eyebrow);
  letter-spacing: var(--track-eyebrow);
  text-transform: uppercase;
}

.muted {
  color: var(--text-tertiary);
}

.cluster--center {
  justify-content: center;
}

/* ===================================================================== */
/* Search results page (core/search_results.html)                        */
/* ===================================================================== */

.search-page__form {
  display: flex;
  gap: 12px;
  /* Full width like a list toolbar's search; Enter submits, the button is secondary (QA UX-1). */
  width: 100%;
}

.search-page__control {
  flex: 1 1 auto;
}

.result-list {
  margin: 0;
  padding: 0 0 8px;
  list-style: none;
}

.result-list__group {
  padding: 16px 24px 6px;
  border-top: 1px solid var(--border-subtle);
}

.result-list__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 24px;
  transition: background-color var(--duration-fast) var(--ease-out);
}

.result-list__item:hover,
.result-list__item:focus-visible {
  outline: none;
  background: rgb(255 255 255 / 0.03);
}

.result-list__item .icon-tile {
  --tone: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--bg-raised);
}

.result-list__item .icon-tile .i {
  --i-size: 16px;
}

.result-list__item .cell-stack {
  flex: 1 1 auto;
}

.result-list__arrow {
  color: var(--text-tertiary);
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--duration-fast) var(--ease-out), transform var(--duration-fast) var(--ease-out);
}

.result-list__item:hover .result-list__arrow,
.result-list__item:focus-visible .result-list__arrow {
  opacity: 1;
  transform: none;
}

@media (max-width: 560px) {
  .search-page__form {
    flex-direction: column;
  }
}

/* ===================================================================== */
/* Tone helpers (last, so they override each component's default tone). */
/* ===================================================================== */

.tone-red, .tone-critical, .tone-danger { --tone: var(--tone-red); }
.tone-orange, .tone-high { --tone: var(--tone-orange); }
.tone-amber, .tone-medium, .tone-warning { --tone: var(--tone-amber); }
.tone-blue, .tone-low, .tone-info { --tone: var(--tone-blue); }
.tone-gray, .tone-neutral { --tone: var(--tone-gray); }
.tone-green, .tone-success { --tone: var(--tone-green); }
.tone-violet { --tone: var(--tone-violet); }

/* ===================================================================== */
/* Language switchers (Phase 4 i18n, docs/architecture.md §17.3)          */
/* ===================================================================== */

/* Sidebar user card: avatar + name open the account menu. The closed state
   renders exactly like the plain user card (no padding, no border). */
.user-card__menu {
  position: relative;
  display: flex;
  flex: 0 1 auto;
  min-width: 0;
}

.user-card__toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.user-card__toggle::before {
  content: "";
  position: absolute;
  inset: -4px -6px;
  border-radius: var(--radius-md);
}

.user-card__toggle > * {
  position: relative;
}

.user-card__toggle:hover::before,
.user-card__toggle[aria-expanded="true"]::before {
  background: var(--overlay-hover);
}

.user-card__toggle:focus-visible {
  outline: none;
}

.user-card__toggle:focus-visible::before {
  box-shadow: var(--focus-ring);
}

.user-menu {
  min-width: 216px;
}

/* Auth pages: compact switcher under the card. */
.lang-switch {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  margin: 0;
}

.lang-switch__option {
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-tertiary);
  font: var(--type-label-s);
  letter-spacing: var(--track-label-s);
  cursor: pointer;
}

.lang-switch__option:hover,
.lang-switch__option:focus-visible {
  background: var(--overlay-secondary);
  color: var(--text-primary);
}

.lang-switch__option[aria-current="true"] {
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
}

/* Settings → Preferences: language radio cards. */
.lang-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

.lang-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 16px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--overlay-secondary);
  cursor: pointer;
}

.lang-card:hover {
  border-color: var(--border-strong);
}

.lang-card:has(input:checked) {
  border-color: var(--brand-red);
  background: color-mix(in srgb, var(--brand-red) var(--alpha-chip), transparent);
}

.lang-card:has(input:focus-visible) {
  box-shadow: var(--focus-ring);
}

.lang-card input {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  accent-color: var(--brand-red);
}

.lang-card__native {
  padding-right: 28px;
  color: var(--text-primary);
  font: var(--type-label-s-strong);
  letter-spacing: var(--track-label-s-strong);
}

.lang-card__english {
  color: var(--text-tertiary);
  font: var(--type-body-xs);
}

.lang-card__sample {
  margin-top: 8px;
  color: var(--text-secondary);
  font: var(--type-body-xs);
  font-variant-numeric: tabular-nums;
}

.lang-switch-form {
  margin: 0;
}

/* Phase 4 i18n: Uzbek and Russian labels run 20–40 % longer. On phones a segmented control that no longer fits
   scrolls sideways inside itself instead of widening the page (English always fits, so it is untouched). */
@media (max-width: 767px) {
  :root:not(:lang(en)) .segmented {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  :root:not(:lang(en)) .segmented__item {
    flex: none;
  }
}
