:root {
  --bg: #0f1216;
  --bg2: #232a33;
  --surface: #171c22;
  --border: #262d36;
  --text: #e6eaef;
  --muted: #8a94a3;
  --accent: #19ae9a;
  --muted-accent: #88a4d8;
  --danger: #ff5c6c;
  --warning: #f0a63c;
  --success: #4fbf7b;
  --radius: 10px;
  --page-max: 1400px;
  --page-max-wide: 2000px;

  /* Sidebar decoration. The mark is a flat silhouette with no theme-neutral
     colour of its own, so it ships as two files rather than being recoloured:
     `filter` cannot turn black into white without also eating the alpha edges,
     and `mask-image` would drop the shape on the older Safari we still see.
     Dark is the default: `data-theme` is unset until the application route
     applies the OS preference, so the un-attributed state has to resolve to
     the same theme as `:root`. */
  --nav-decoration: url("/assets/Rectangle_2_white.svg");

  /* Risk ramp (dashboard bars). `--risk-none` is not an absence of styling: an
     unenriched part is a real bucket, and grey is what says "nobody has told us
     yet" rather than "no risk". The green matches `.badge.status-approved` so
     one severity vocabulary runs through the whole app. */
  --risk-low: #3fb950;
  --risk-medium: #d9a441;
  --risk-high: var(--danger);
  --risk-none: var(--muted);

  /* StepChart series (dataviz categorical slots 1-5, dark steps) and chrome. */
  --chart-1: #3987e5;
  --chart-2: #d95926;
  --chart-3: #199e70;
  --chart-4: #c98500;
  --chart-5: #d55181;
  --chart-grid: #262d36;
  --chart-tick: #8a94a3;
}

/*
 * Light theme. The application route sets `<html data-theme>` from the OS
 * `prefers-color-scheme` (and follows its changes), so a single attribute
 * override is enough.
 */
:root[data-theme="light"] {
  --bg: #f7f8fa;
  --bg2: #c0c1c2;
  --surface: #fff;
  --border: #d8dde5;
  --text: #1a1f26;
  --muted: #5c6672;
  --accent: #19ae9a;
  --danger: #ff5c6c;
  --warning: #f0a63c;
  --success: #4fbf7b;

  /* Only the amber needs restating: at full saturation it disappears into a
     white surface, while the green and the theme-derived red carry over. */
  --risk-medium: #b8791a;

  /* StepChart: the same slots darkened to >= 3:1 on the light surface. */
  --chart-1: #2a78d6;
  --chart-2: #d2561f;
  --chart-3: #0f8a5f;
  --chart-4: #9c6800;
  --chart-5: #c23f77;
  --chart-grid: #d8dde5;
  --chart-tick: #5c6672;

  /* The black cut of the mark; the white one in `:root` would vanish here. */
  --nav-decoration: url("/assets/Rectangle_2.svg");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* App shell: vertical nav sidebar + scrolling content column. */
.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.app-content {
  flex: 1;
  min-width: 0;
}

.nav {
  /* Anchored, not scrolled away with the page: `.app-shell` is the containing
     block and grows past the viewport, so the sidebar travels to `top: 0` and
     stays. `b32578d` traded this for `relative` so the decoration below would
     paint (sticky makes a stacking context, which hid it at `z-index: -1`);
     the decoration now sits at a positive z-index, so both hold. */
  position: sticky;
  top: 0;

  /* That stacking context also TRAPS the sidebar's own overlays: the command
     palette (`z-index: 100`) and the notification panel (`z-index: 50`) only
     rank against their siblings in here, while the sidebar as a whole entered
     the page at `z-index: auto` — so any positioned element later in the DOM
     painted over them (`.supply-chain-map.card` is `position: relative` for its
     pins, and covered the open search). The whole sidebar has to rank above the
     content; page-level modals stay above it at 90/100.

     Layers: 20 sidebar + its overlays · 90 import dialog · 100 Z2 dialog, toasts. */
  z-index: 20;
  flex: 0 0 15rem;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  height: 100vh;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  font-size: 45px;
  line-height: 0.9;
  text-transform: uppercase;
  font-weight: 800;
  height: 95px;
  display: flex;
  align-items: center;
}

.nav-links {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-links .nav-divider-after {
  padding-bottom: 0.4rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border);
}

.nav-links .nav-section-label {
  padding: 0.4rem 0.6rem 0.2rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Pushed to the bottom of the sidebar. */
.nav-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Signed-in account, next to sign-out; long addresses wrap instead of widening the sidebar. */
.nav-user {
  max-width: 100%;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

/* Narrow viewports: fall back to a horizontal bar that wraps. */
@media (width <= 48rem) {
  .app-shell {
    flex-direction: column;
    align-items: stretch;
  }

  .nav {
    position: static;
    flex: none;
    flex-flow: row wrap;
    align-items: center;
    height: auto;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .nav-links {
    flex-flow: row wrap;
    gap: 0.3rem;
  }

  .nav-links .nav-divider-after {
    padding: 0 0.3rem 0 0;
    margin: 0;
    border-bottom: none;
    border-right: 1px solid var(--border);
  }

  .nav-footer {
    margin-top: 0;
    margin-left: auto;
    flex-direction: row;
    align-items: center;
  }
}

.container {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 2rem 1.25rem;
}

/* Pages whose main content is a wide data table opt out of the reading-width
   cap by marking their root section `.page-wide`. `main.container` lives in
   `application.gts` and wraps every route, so the cap cannot be lifted there
   without stretching the login card and the forms too; `:has()` lets the
   container react to the page instead of the page reaching upwards.

   The child combinator is load-bearing. `.component-risk-alert` on the
   dashboard holds a `.data-table` inside a card, so a loose `:has(.data-table)`
   would widen the dashboard as well — `> .page-wide` matches only a root that
   asked for it. */
.container:has(> .page-wide) {
  max-width: var(--page-max-wide);
}

h1 {
  font-size: 1.8rem;
  margin: 0 0 2.25rem;
}

.card {
  max-width: 480px;
  margin: 2rem auto;
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.login-card {
  h1 {
    text-align: center;
  }

  .forgot-password {
    margin-top: 0;
  }
}

.smaller-fontsize {
  font-size: 0.85rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input {
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  width: 100%;
}

input:focus {
  outline: none;
  border-color: var(--accent);
}

button {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

form button {
  margin-top: 0.5rem;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.primary-ghost {
  background: none;
  color: var(--text);
  border: 1px solid var(--accent);
  font-weight: normal;
}

.link {
  background: none;
  color: var(--accent);
  padding: 0.3rem 0.5rem;
  font-weight: 500;
}

.link[aria-pressed="true"] {
  color: var(--text);
  font-weight: 700;
  text-decoration: underline;
}

.link.danger {
  color: var(--danger);
}

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

.row.between {
  justify-content: space-between;
}

.create {
  margin: 1rem 0 1.5rem;
}

.create input {
  flex: 1;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

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

/*
 * Projects list rows are two lines: the name (and archive badge) on the line
 * the eye reads, then a muted meta line — part count, description, last
 * import — dot-separated. `.list-item` stays a flex row so the actions keep
 * their place on the right; only its left cell stacks.
 */
.projects .project-main {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.projects .project-title-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.projects .project-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
  font-size: 0.85rem;
}

.projects .project-meta > * + *::before {
  content: "·";
  margin-right: 0.4rem;
}

/*
 * `/projects/:id` header. The shared `.row` centres its children, which drops
 * the Update button into the middle of a header that is now three lines tall
 * (title, description, meta). The action belongs beside the heading itself.
 */
.project > header {
  align-items: flex-start;
}

/*
 * `/projects/:id` — the project's own description, directly under the title and
 * above the part-count/last-import line, introduced by a label on its own line.
 *
 * The label is muted metadata; the description under it is body colour, because
 * it is text the operator wrote rather than something the app says about the
 * row. The text is deliberately NOT clamped to a measure: a description can run
 * to a paragraph, and the header column is where it gets the full width to do
 * it in. `pre-line` keeps the line breaks typed into the textarea, the only
 * formatting a plain-text field can carry.
 */
.project-description-label {
  margin: 0.5rem 0 0.15rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.project-description {
  margin: 0 0 0.5rem;
  white-space: pre-line;
}

/* The header's text column claims the row's remaining width, so a long
   description wraps against the page edge rather than against the Update
   button's shrink-to-fit share of a `.row`. */
.project > header > div {
  flex: 1;
  min-width: 0;
}

/* The name and description fields in the BoM upload / project update dialog.
   Both labels are already flex columns (see the global `label` rule); only the
   textarea needs the input styling it does not inherit. */
.project-name-field,
.bom-description {
  margin-bottom: 0.75rem;
}

.bom-description textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

/* Status badges (workflow states, see docs/workflows.md). Muted palette:
   each state tints the surface via color-mix so both themes work. */
.badge {
  display: inline-block;
  padding: 0 0.55em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge.status-draft {
  color: var(--muted);
}

.badge.status-submitted {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.badge.status-approved {
  color: #3fb950;
  border-color: color-mix(in srgb, #3fb950 45%, var(--border));
  background: color-mix(in srgb, #3fb950 12%, var(--surface));
}

.badge.status-rejected {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
}

.badge.status-ordered {
  color: #b07cf7;
  border-color: color-mix(in srgb, #b07cf7 45%, var(--border));
  background: color-mix(in srgb, #b07cf7 12%, var(--surface));
}

.badge.status-received {
  color: #2fbf9f;
  border-color: color-mix(in srgb, #2fbf9f 45%, var(--border));
  background: color-mix(in srgb, #2fbf9f 12%, var(--surface));
}

.badge.status-closed {
  color: var(--muted);
  background: color-mix(in srgb, var(--muted) 12%, var(--surface));
}

.empty {
  padding: 1.5rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.error {
  margin: 0;
  padding: 0.6rem 0.75rem;
  background: rgb(255 92 108 / 12%);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 0.9rem;
}

a {
  color: var(--accent);

  .muted & {
    color: var(--muted-accent);
  }
}

/* ---- import mapping ---- */
.import-mapping {
  width: 100%;
  border-collapse: collapse;
}

.import-mapping th,
.import-mapping td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e3e3e8;
}

.import-mapping thead {
  background-color: color-mix(in srgb, var(--accent) 16%, transparent);
}

.search-trigger,
select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

/* ---- data table ---- */
.data-table-scroll {
  overflow-x: auto;
  margin-bottom: 1rem;
}

.data-table table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 0.4rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid #e3e3e8;
  white-space: nowrap;
}

.data-table-filters th {
  font-weight: 400;
}

.import-mapping tbody th {
  font-weight: normal;
}

.data-table thead th {
  font-weight: 600;
}

.z2-part-detail .data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.z2-part-detail .data-table th,
.z2-part-detail .data-table td {
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.z2-part-detail .data-table th {
  color: var(--muted);
  font-weight: 600;
}

.data-table tbody tr:nth-child(2n-1) {
  background-color: var(--border);
}

/* Row activation (DataTable `@onRowClick`). Below the zebra rule on purpose so
   the hover tint wins on both stripes. The <tr> deliberately carries no
   tabindex/role — the primary cell's `.cell-link` button is the keyboard and
   screenreader target, so the row stays a plain table row to assistive tech. */
.data-table tbody tr.is-clickable {
  cursor: pointer;
}

.data-table tbody tr.is-clickable:hover {
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
}

/* A cell that reads as text but activates like a button. Bold, like
   `dashboard-summary.gts`'s `.dashboard-mpn` — this is always the row's
   identifier column (see ColumnDef.primary), so it should lead the same way. */
.cell-link {
  font: inherit;
  font-weight: 600;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
}

.cell-link:hover,
.cell-link:focus-visible {
  color: var(--accent);
  text-decoration: underline;
}

/* An identifier's companion field (e.g. manufacturer beside an MPN) — see
   ColumnDef.secondary. Matches `dashboard-summary.gts`'s `.dashboard-mfr`. */
.cell-secondary {
  color: var(--muted);
  font-size: 0.85rem;
}

/* The dashboard's own summary tables sit in a narrow grid card, not a full-width
   page — `.data-table`'s default `white-space: nowrap` (right, for a page-width
   table) would force these into a horizontal scrollbar instead. Letting cells
   wrap keeps every column visible without one, the same trade its old
   flexible-grid rows made. */
.dashboard-panel .data-table th,
.dashboard-panel .data-table td {
  padding: 0.4rem 0.35rem;
  white-space: normal;
}

/* Only cell content (an MPN, a manufacturer) breaks mid-word if it must —
   headers stay short, known strings and read better wrapping at a space than
   splitting one open. */
.dashboard-panel .data-table td {
  overflow-wrap: anywhere;
}

.data-table-sort {
  font: inherit;
  font-weight: 600;
  padding: 0;
}

.data-table-filters input,
.data-table-filters select {
  width: 100%;
  min-width: 5rem;
  font-size: 0.85rem;
  padding: 0.2rem 0.35rem;
}

.data-table-range {
  display: flex;
  gap: 0.25rem;
}

.data-table-range input {
  min-width: 4rem;
}

/* A two-input filter must not be the thing that sizes its column. Two halves at
   4rem plus the gap ask for 8.25rem, while a single text filter asks for 5rem —
   so every number/money column came out ~65% wider than a text one for no
   reason anyone chose. These halves share the column instead (`flex: 1 1 0`),
   and their floor adds up to the 5rem a text filter already costs. The spin
   buttons go with them: ~1rem of chrome each, on a field nobody steps.

   Date ranges keep the 4rem above — a date input has an intrinsic width
   (dd.mm.yyyy plus the picker icon) and clips rather than shrinks. */
.data-table-range input[type="number"] {
  flex: 0 0 auto;
  width: 2.4rem;
  min-width: 0;
  appearance: textfield;
}

.data-table-range input[type="number"]::-webkit-outer-spin-button,
.data-table-range input[type="number"]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.data-table tbody.is-loading {
  opacity: 0.5;
}

.data-table-toolbar {
  margin-bottom: 0.5rem;
}

.data-table-toolbar-filters {
  flex: 1 1 18rem;
}

.data-table-search {
  max-width: 18rem;
}

/* Shown only while filters or the search narrow the rows. */
.data-table-filter-summary {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.2rem 0.1rem 0.6rem;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border));
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Separates groups of toolbar actions, e.g. data in (imports) from data out (exports). */
.data-table-toolbar-divider {
  width: 1px;
  height: 1.5rem;
  background: var(--border);
}

/* Checkbox and text on one line: the global `label` is a column and `input`
   is full width, which stacked the box above its label. */
.data-table-toggle {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
  cursor: pointer;

  input {
    width: auto;
    margin: 0;
  }
}

.data-table-menu {
  position: relative;
}

.data-table-menu summary {
  cursor: pointer;
}

.data-table-menu-panel {
  position: absolute;
  right: 0;
  z-index: 10;
  margin: 0.25rem 0 0;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid #e3e3e8;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgb(0 0 0 / 8%);
  min-width: 14rem;
}

.data-table-menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.data-table-reset {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e3e3e8;
  width: 100%;
  text-align: left;
}

.data-table-menu li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.15rem 0;
}

/* Checkbox before the column name, on one line: the global `label` is a
   column and `input` is full width, which stacked the box above the name. */
.data-table-menu label {
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;

  input[type="checkbox"] {
    width: auto;
    margin: 0;
  }
}

.data-table-move {
  display: flex;
  gap: 0.25rem;
}

.data-table-footer {
  margin-top: 0.5rem;
}

/* Toasts */
.toast-stack {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  max-width: 24rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 10px rgb(0 0 0 / 35%);
}

.toast-success {
  border-color: #3fb950;
}

.toast-error {
  border-color: var(--danger);
}

.toast-info {
  border-color: var(--accent);
}

.toast-dismiss {
  border: none;
  background: none;
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  margin-left: auto;
}

/* Email-verification banner (soft gate) */
.verify-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 1.25rem;
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 0.9rem;
}

.verify-banner button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.verify-banner-dismiss {
  margin-left: auto;
  border: none;
  background: none;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.25rem;
}

/* Notification bell */
.notification-bell {
  position: relative;
}

.notification-bell summary {
  cursor: pointer;
  list-style: none;
}

.notification-bell .badge {
  background: var(--danger);
  color: var(--bg);
  border-radius: 999px;
  font-size: 0.7rem;
  padding: 0 0.4em;
  vertical-align: top;
}

.notification-panel {
  position: absolute;
  right: 0;
  min-width: 20rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 10px rgb(0 0 0 / 35%);
  padding: 0.5rem;
  z-index: 50;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 20rem;
  overflow-y: auto;
}

.notification-item {
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  color: var(--text);
  font-weight: 400;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
}

.notification-item.unread {
  font-weight: 600;
}

/* Visually hidden but available to assistive tech (live regions, hidden inputs). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.file-upload .dropzone {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.file-upload .dropzone.dragging {
  border-color: var(--accent, #4a90d9);
  background: color-mix(in srgb, var(--accent, #4a90d9) 8%, var(--surface));
}

.file-upload .dropzone-hint {
  margin: 0;
}

.file-upload .hint {
  flex-basis: 100%;
  margin: 0.25rem 0 0;
  font-size: 0.85em;
}

.file-upload .upload-tasks {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.file-upload .upload-task {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.file-upload .upload-task .filename {
  font-weight: 600;
}

.file-upload .upload-task.error .error {
  color: var(--danger, #c0392b);
}

.file-upload .upload-task.success .success {
  color: var(--success, #2e7d32);
}

/* Global search (command palette, see components/command-palette.gts) */

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.search-trigger kbd {
  padding: 0 0.3rem;
  margin-left: 0.25rem;
  font-size: 0.8em;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
}

.command-palette-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 10vh;
  background: rgb(0 0 0 / 45%);
}

.command-palette {
  width: min(560px, 92vw);
  max-height: 70vh;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
}

/* Search bar row: input, then the close button pinned to its right. The button
   is LAST in the DOM so `focusTrap` hands the caret to the input on open (see
   command-palette.gts) — the position is purely this flex row's doing. */
.command-palette-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.command-palette-input {
  flex: 1;

  /* Flex items floor at their content width; without this the placeholder
     would push the close button off the dialog on a narrow viewport. */
  min-width: 0;
  padding: 0.5rem 0.65rem;
  font: inherit;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}

/* Matches `.toast-dismiss`, the app's compact glyph-button idiom: the `×` is
   decorative, so the accessible name comes from `aria-label`. */
.command-palette-close {
  padding: 0 0.25rem;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.command-palette-close:hover {
  color: var(--text);
}

.palette-hint,
.palette-empty {
  margin: 0.6rem 0.25rem 0.1rem;
}

.palette-heading {
  margin-top: 0.6rem;
  padding: 0 0.35rem 0.2rem;
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.palette-option {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
}

.palette-option.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
}

.palette-secondary {
  font-size: 0.9em;
}

/* Import and Z2 preview dialogs */

.import-dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  background: rgb(0 0 0 / 45%);
}

.import-dialog {
  width: min(900px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
}

.table-scroll {
  overflow-x: auto;
}

/*
 * Add/edit part dialog. Shares the import dialog's backdrop, but is sized for five
 * fields rather than a table: two columns pair the identity fields (MPN,
 * manufacturer) and the classification fields (category, lifecycle), and the
 * actions sit on their own line under a rule so they never share a row with a
 * field. One column below 32rem.
 */
.part-form-dialog {
  width: min(36rem, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);

  h2 {
    margin: 0 0 1.25rem;
    font-size: 1.2rem;
  }
}

.part-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.25rem 1rem;

  /* The form-level error spans the grid instead of taking a field's cell. */
  > [role="alert"] {
    grid-column: 1 / -1;
  }

  input,
  select {
    width: 100%;
    box-sizing: border-box;
  }

  @media (width <= 32rem) {
    grid-template-columns: 1fr;
  }
}

.part-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Dark text on the accent: white on #19ae9a falls short of 4.5:1. */
button.primary {
  background: var(--accent);
  color: #0f1216;
}

/* Z2 part detail dialog: sits above the preview, so z-index higher */

/*
 * StepChart (part market history). Colour tokens (`--chart-*`) live in the
 * `:root` blocks at the top of this file.
 */
.step-chart {
  position: relative;
}

.step-chart-focus {
  border-radius: var(--radius);
}

.step-chart-focus:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/*
 * The viewBox is 560 user units wide; capping the rendered width at 560px keeps
 * the SVG text at its authored size (1 unit = 1px) instead of scaling with the
 * container.
 */
.step-chart-focus svg {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
}

.step-chart-grid {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.step-chart-tick {
  fill: var(--chart-tick);
  font-size: 10px;
}

.step-chart-cursor {
  stroke: var(--chart-tick);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.step-chart-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.step-chart-line[data-emphasis="true"] {
  stroke-width: 2.5;
}

.step-chart-line-0 {
  stroke: var(--chart-1);
}

.step-chart-line-1 {
  stroke: var(--chart-2);
}

.step-chart-line-2 {
  stroke: var(--chart-3);
}

.step-chart-line-3 {
  stroke: var(--chart-4);
}

.step-chart-line-4 {
  stroke: var(--chart-5);
}

.step-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0.4rem 0 0;
  padding: 0;
  list-style: none;
  color: var(--text);
  font-size: 0.8rem;
}

.step-chart-legend li,
.step-chart-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.step-chart .step-chart-swatch {
  flex: none;
  width: 1rem;
  height: 0.25rem;
  overflow: visible;
}

.step-chart-tooltip {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.8rem;
}

.z2-part-detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 5vh;
  background: rgb(0 0 0 / 45%);
}

.z2-part-detail {
  /* Wider than the preview dialog: the width is what buys the third column. */
  width: min(1180px, 94vw);
  max-height: 85vh;
  overflow-y: auto;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 40px rgb(0 0 0 / 35%);
}

/*
 * The detail dialog's category flow.
 *
 * `columns` rather than `grid`: the ten categories differ wildly in height —
 * Sustainability is one row, Risk is nine — and a grid aligns every row to its
 * tallest cell, leaving holes. Multi-column fills the space instead.
 *
 * `column-width` (via the shorthand) rather than `column-count`: the COUNT then
 * follows the available width — one column on a phone, three on a wide monitor —
 * so there is no breakpoint to keep in sync with the dialog's own width.
 */

.z2-part-detail-sections {
  columns: 20rem;
  column-gap: 1.25rem;
}

/*
 * Each category becomes a bordered card, and the border is structural rather
 * than decorative: once categories sit side by side, vertical position no longer
 * tells the reader which category a field belongs to. The card edge is what
 * carries that. `break-inside` keeps a heading from being stranded at the foot
 * of one column with its fields at the head of the next.
 */

.z2-part-detail-sections > section {
  break-inside: avoid;
  margin: 0 0 1.25rem;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.z2-part-detail-sections > section > h3 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

/*
 * A table's own caption — the vendor key it came from, humanised. Needed only
 * when a section carries more than one table (`Exemptions` and
 * `REACHAffectedSubstances` under one `ComplianceDetails` heading); sits small
 * and muted so it reads as a sub-label rather than competing with the section
 * heading above it.
 */

.z2-part-detail-sections h4 {
  margin: 0.6rem 0 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

/*
 * A section carrying a table runs the full dialog width. A nine-column change-notice
 * table is unreadable in a 320px column, and `column-span` is the multi-column
 * mechanism for exactly this — no breakpoint, no second layout.
 */

.z2-part-detail-sections > section.vendor-section-wide {
  column-span: all;
}

/* The default-5-rows toggle under a vendor table; sits between the table and
   the (independent) server-cap notice, so it reads as "reveal more of what's
   already delivered" rather than as part of that notice. */
.z2-part-detail .vendor-table-toggle {
  display: block;
  margin: 0.35rem 0;
  font-size: 0.85rem;
}

.z2-part-detail dl {
  margin: 0;
}

/* Label above value, matching the `label` treatment used by the app's forms. */

.z2-part-detail dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.z2-part-detail dd {
  /* An MPN or a datasheet URL must wrap rather than widen its column. */
  margin: 0.1rem 0 0.6rem;
  overflow-wrap: anywhere;
}

.z2-part-detail dd:last-child {
  margin-bottom: 0;
}

.z2-part-detail .risk-dot {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  border-width: 0.1em;
  border-style: solid;
  background: var(--surface);
  color: var(--muted);
}

.z2-part-detail .risk-dot-low {
  background: green;
  border-color: darkgreen;
}

.z2-part-detail .risk-dot-medium {
  background: yellow;
  border-color: orange;
}

.z2-part-detail .risk-dot-high {
  background: red;
  border-color: red;
}

.z2-part-detail .risk-dot-critical {
  background: darkred;
  border-color: darkred;
}

/*
 * A si-factor insight, stacked: risk + type on a small meta line, the name as
 * the line the eye reads, the informant as a muted footnote. One row of four
 * inline fields does not fit the 20rem section column.
 */
.z2-part-detail .si-factor-insight {
  flex-direction: column;
  align-items: stretch;
  gap: 0.3rem;
  padding: 0.6rem 0.75rem;
}

.z2-part-detail .si-factor-insight-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
}

.z2-part-detail .si-factor-insight-risk {
  font-weight: 600;
}

.z2-part-detail .si-factor-insight-name {
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.z2-part-detail .si-factor-insight-informant {
  font-size: 0.8rem;
}

/*
 * A compliance value that is not a clean pass. Colour is the fast signal, but
 * never the only one: the template renders a "(needs review)" marker inside the
 * same element, so the flag survives greyscale, colour blindness and a screen
 * reader. The tint matches `.badge.status-rejected` so a flagged verdict reads
 * the same everywhere in the app.
 */

.z2-part-detail .compliance-flag {
  font-weight: 600;
  color: var(--danger);
}

.z2-part-detail .compliance-flag [data-test-detail-flag] {
  margin-inline-start: 0.4rem;
  font-size: 0.85em;
  font-weight: 400;
  white-space: nowrap;
}

/* Deep-link landing flash (utils/highlight.ts adds/removes the class) */

@keyframes highlight-flash {
  0% {
    background-color: color-mix(in srgb, var(--accent) 35%, transparent);
  }

  100% {
    background-color: transparent;
  }
}

.highlight-flash {
  animation: highlight-flash 1.6s ease-out;
}

/* ---- dashboard ---- */

/*
 * The four panels are peers, not a hierarchy: the page answers one question —
 * "what needs attention?" — and risk, lifecycle, EOL and high-risk are four
 * readings of it. `auto-fit` over a `minmax` track lets the column COUNT follow
 * the viewport (one on a phone, two on a laptop, three on a wide monitor) with
 * no breakpoint to keep in sync, the same reasoning as
 * `.z2-part-detail-sections` above.
 */

.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  align-items: start;
  gap: 1rem;
}

/* The route renders two `.dashboard` sections back to back (see
   templates/dashboard.gts); without this the second one touches the first. */
.dashboard + .dashboard {
  margin-top: 2rem;
}

/* Heading, headline count and empty state speak for the page, not for a column.
 *
 * The two rows of the si-factor dashboard span too, but each says so in its own
 * rule below (`.risk-cards`, `.next`) — repeating them here as
 * `.dashboard > .risk-cards` would out-specify those rules and trip
 * `no-descending-specificity`. */

.dashboard > h1,
.dashboard > .empty {
  grid-column: 1 / -1;
}

/* The grid's own gap already spaces the heading; the global `h1` margin would double it. */

.dashboard > h1 {
  margin-bottom: 0;
}

/*
 * Risk and lifecycle read together as one distribution story, so they stack in
 * a narrow left column instead of competing for a track in the `.dashboard`
 * auto-fit grid; the eol-soon/high-risk tables get the rest of the row, which
 * is more width than a single `minmax(20rem, 1fr)` track ever gave them. Below
 * `60rem` there is no "rest of the row" to give — both columns collapse to one,
 * same breakpoint logic as the auto-fit grid above, just made explicit because
 * a two-track template can't fall back to `auto-fit` on its own.
 */

.dashboard-groups {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(18rem, 22rem) minmax(24rem, 1fr);
  align-items: start;
  gap: 1rem;
}

.dashboard-stat-group,
.dashboard-table-group {
  display: grid;
  min-width: 0;
  gap: 1rem;
}

@media (width <= 60rem) {
  .dashboard-groups {
    grid-template-columns: 1fr;
  }
}

.dashboard-panel {
  /* A grid item's automatic minimum width is its content's min-content size
     (CSS Grid §6.6) — for a <table> that can exceed the `minmax(20rem, …)`
     track, pushing `auto-fit` to give this panel more than its fair share (or
     drop to fewer columns) depending on exactly how wide its rows happen to
     be. `min-width: 0` hands sizing back to the track; `.data-table-scroll`'s
     own overflow-x handles anything the panel still can't fit. */
  min-width: 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.dashboard-panel h2 {
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--muted);
}

.dashboard-bars {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
  gap: 0.4rem;
}

/*
 * Label, rail, count. The count sits in its own fixed track rather than after
 * the rail, so the numbers line up down the panel and the bars all start and
 * end at the same x — a distribution you can read by shape, not by measuring.
 */

/* A bar is an `<a>` on the dashboard and a `<button>` on a project page, where
   the drill-down filters the BoM table in place instead of navigating (see
   `Bar` in dashboard-summary.gts). Both must be the same object on screen, so
   the button branch only undoes the UA's own button chrome. */
.dashboard-bar a,
.dashboard-bar button {
  display: grid;
  grid-template-columns: minmax(5rem, 9rem) 1fr 2.5rem;
  align-items: center;
  gap: 0.75rem;
  padding: 0.3rem 0.35rem;
  border-radius: 6px;
  color: var(--text);
  text-decoration: none;
}

.dashboard-bar button {
  width: 100%;
  font: inherit;
  text-align: left;
  background: none;
  border: 0;
  cursor: pointer;
}

.dashboard-bar a:hover,
.dashboard-bar button:hover {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.dashboard a:focus-visible,
.dashboard button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.dashboard-bar-label {
  font-size: 0.85rem;
}

/*
 * The rail is always drawn, the fill only as wide as its share, so a bucket
 * holding nothing reads as an empty rail rather than as a missing row —
 * "none at this level" is an answer the dashboard owes the reader.
 */

.dashboard-bar-track {
  height: 0.5rem;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 22%, transparent);
}

.dashboard-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--risk-none);
}

/*
 * Colour is the fast signal but never the only one: each bar carries its label
 * and its count as text, so the ramp survives greyscale, colour blindness and a
 * screen reader — the same posture as `.compliance-flag` above.
 *
 * Lifecycle borrows the risk ramp deliberately. NRND is the warning, EOL is the
 * one to act on, and OBSOLETE falls through to grey because it is a past-tense
 * fact rather than a live risk — as does `unenriched`, for the opposite reason.
 */

.dashboard-bar-fill[data-level="LOW"],
.dashboard-bar-fill[data-level="ACTIVE"] {
  background: var(--risk-low);
}

.dashboard-bar-fill[data-level="MEDIUM"],
.dashboard-bar-fill[data-level="NRND"] {
  background: var(--risk-medium);
}

.dashboard-bar-fill[data-level="HIGH"],
.dashboard-bar-fill[data-level="EOL"] {
  background: var(--risk-high);
}

.dashboard-bar-fill[data-level="OBSOLETE"] {
  background: #8c0303;
}

.dashboard-bar-count {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/*
 * Borrows the risk ramp from the bars above, as a tinted chip rather than a
 * solid fill — a row is not a measurement, so a full-strength block would shout
 * over the MPN next to it. The level is spelled out inside, so the colour is
 * reinforcement and never the carrier (same posture as `.dashboard-bar-fill`).
 * Shared by the dashboard's own hand-rolled `.data-table` markup (see
 * `dashboard-summary.gts`) and by any `ColumnDef.riskLevel` column in the
 * generic `DataTable` — one risk-severity look for the whole app.
 */

.risk-tag {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--text);
  background: color-mix(in srgb, var(--risk-none) 30%, transparent);
}

.risk-tag[data-level="LOW"] {
  background: color-mix(in srgb, var(--risk-low) 30%, transparent);
}

.risk-tag[data-level="MEDIUM"] {
  background: color-mix(in srgb, var(--risk-medium) 30%, transparent);
}

.risk-tag[data-level="HIGH"] {
  background: color-mix(in srgb, var(--risk-high) 30%, transparent);
}

/* Same link-or-button duality as `.dashboard-bar` above: the class carries the
   shared shape, the `button` rule strips the UA chrome and restores the link
   colour the base `a` rule would have given it. */
.dashboard-view-all {
  display: inline-block;
  margin-top: 0.7rem;
  font-size: 0.85rem;
}

button.dashboard-view-all {
  padding: 0;
  font-family: inherit;
  color: var(--accent);
  background: none;
  border: 0;
  cursor: pointer;
}

.dashboard-no-rows {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

/* ---- nav sidebar overrides (kept last: they specialise the base `a` and
   `.notification-panel` rules above) ---- */

/* Two independently written dashboards met here in the origin/main merge;
   ordering this ahead of `.dashboard-bar a:hover` would mean interleaving
   the nav and dashboard blocks. Revisit when the two pages are unified. */
/* stylelint-disable-next-line no-descending-specificity */
.nav-links a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}

.nav-links a:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.nav-links a.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

/* The bell panel anchors right in a wide bar; in the sidebar it opens rightwards. */
.nav .notification-panel {
  right: auto;
  left: 0;
}

/* A dashboard section's heading (plus optional description), read as one unit
   above its content; the grid gap spaces the unit from that content, so the
   children drop their own margins. */
.dashboard-section-header {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;

  > * {
    margin: 0;
  }
}

.risk-cards {
  /* A whole row of the page, not a panel ranked beside the summary's four —
     `.dashboard` is an `auto-fit` grid shared with `DashboardSummary`, and
     without this the cards are squeezed into one `minmax(20rem, 1fr)` track. */
  grid-column: 1 / -1;

  /* display: grid;
  grid-template-columns: repeat(3, 1fr); */
  display: flex;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  flex-wrap: wrap;

  /* Error/truncation notes take their own line instead of a card slot. */
  > p {
    flex-basis: 100%;
  }
}

.risk-card {
  display: flex;
  flex-direction: row;
  gap: 0.35rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);

  /* Cards share the row equally and fill the container; below ~14rem each
     they wrap, and the wrapped ones stretch across their line. */
  flex: 1 1 14rem;
  justify-content: space-between;

  span {
    font-size: 16px;
  }

  @media (width <= 30rem) {
    width: 100%;
  }
}

.risk-card.risk-high {
  border-left-color: var(--danger);
}

.risk-card.risk-medium {
  border-left-color: var(--warning);
}

.risk-card.risk-low {
  border-left-color: var(--success);
}

.risk-count {
  font-size: 30px;
  font-weight: 500;
  line-height: normal;
}

.risk-left {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  justify-content: flex-end;
}

/* Font Awesome Light icons (fa-icon.gts): filled paths, sized to the text they sit in. */
.fa-icon {
  flex: none;
  inline-size: 1em;
  block-size: 1em;
  fill: currentcolor;
}

.risk-icon {
  width: 10rem;
}

/* 2.4rem is the 512-unit glyph height the earlier 3rem-wide, 640-unit SVGs drew, so the size holds. */
.risk-icon svg {
  inline-size: auto;
  block-size: 2.4rem;

  .risk-card.risk-low & {
    fill: var(--success);
  }

  .risk-card.risk-medium & {
    fill: var(--warning);
  }

  .risk-card.risk-high & {
    fill: var(--danger);
  }

  .risk-card.total & {
    fill: var(--muted);
  }
}

@media (width <= 40rem) {
  .risk-cards {
    grid-template-columns: 1fr;
  }
}

.si-decoration-1 {
  position: absolute;
  bottom: 15%;
  transform: rotate(270deg);
  filter: opacity(0.3);

  /* An empty box has no intrinsic size, so the square has to be stated on both
     axes — as an `<img>` the 206x206 viewBox supplied the width from `height`
     alone. Painting it as a background rather than an `<img>` is what lets the
     light/dark swap stay a token: only the used file is ever fetched. */
  width: 13rem;
  height: 13rem;
  background: var(--nav-decoration) no-repeat center / contain;
  z-index: 1;

  /* Decorative (`aria-hidden`), and it sits ABOVE the nav links at this z-index
     — so it must not take part in hit-testing, or it swallows every click on
     the entries it happens to cover. Which entries those are follows the
     viewport height, so the symptom moves around. */
  pointer-events: none;

  @media (width <= 48rem) {
    display: none;
  }
}

.component-risk-alert.card {
  max-width: none;
  margin-left: 0;

  /* Heading and description read as one unit: the card's flex `gap` separates
     them from the table, so their own margins are zeroed (flex items do not
     collapse margins, which doubled the space). */
  .component-risk-alert-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;

    > * {
      margin: 0;
    }
  }

  .data-table {
    .data-table-filters,
    .data-table-toolbar,
    .data-table-footer {
      display: none;
    }
  }

  @media (width <= 70rem) {
    width: 100%;
  }
}

.supply-chain-map.card {
  max-width: 100%;
  width: fit-content;
  margin-left: 0;
  position: relative;

  /* Diagonal watermark across the map. Above the pin labels (10), below the
     sidebar (20), and click-through so the pins stay usable. */
  .draft-stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 11;
    padding: 0.2rem 1.5rem;
    border: 3px solid var(--muted);
    border-radius: var(--radius);
    color: var(--muted);
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.6;
    transform: translate(-50%, -50%) rotate(-20deg);
    pointer-events: none;
  }

  h3 {
    margin-top: 0;
  }

  /* Width-led, not height-led: the map is 913.9 x 402.89, so a bare
     `height: 300px` asks for 681px and simply overflows the card — and the
     page — wherever the row is narrower. `max-height` keeps 300px as the cap
     on a roomy viewport while the aspect ratio drives the shrink below it. */

  img {
    width: 100%;
    height: auto;
    max-height: 300px;
  }

  .label {
    background: #424242c4;
    padding: 0.5rem;
    width: max-content;
    border-radius: var(--radius);
    color: white;
    position: absolute;
    bottom: 0.25rem;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    z-index: 10;
  }

  .pin-red,
  .pin-red-2,
  .pin-yellow {
    height: 20px;
    width: 20px;
    position: absolute;
    border-radius: 50%;

    &:hover {
      .label {
        display: block;
      }
    }
  }

  .pin-red {
    background-color: var(--danger);
    right: 31%;
    top: 53%;
  }

  .pin-red-2 {
    background-color: var(--danger);
    right: 22%;
    top: 50%;
  }

  .pin-yellow {
    background-color: var(--warning);
    left: 17%;
    top: 42%;
  }
}

/* Separates the Overall Risk section from the SI Factor cards above; this was
   `.next`'s own top margin before the heading sat between them. */
.next-header {
  margin-top: 2.5rem;
}

.next {
  /* Spans for the same reason as `.risk-cards` above, and needs it more: in a
     single track the row is narrower than the map image, which then overflows
     the card and the page gutter. `.risk-cards` MUST keep its span too — a
     spanning item occupies every track, so `auto-fit` stops collapsing the
     empty ones and the cards would lose the width they have today. */
  grid-column: 1 / -1;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;

  /* 50:50 columns: the basis is half the row minus half the 2rem gap, so both
     fit on one line; `min-width: 0` lets the table and map shrink into it.
     Below 70rem each takes the full row. */
  .card {
    flex: 1 1 calc(50% - 1rem);
    min-width: 0;
    margin-top: 0;
    margin-bottom: 0;
    margin-right: 0;

    @media (width <= 70rem) {
      flex-basis: 100%;
    }
  }
}

/* A filtered column: accent border on its filter controls. Kept last because it
   outranks every plainer `input`/`select` rule above (no-descending-specificity). */
.data-table-filters .is-filtered input,
.data-table-filters .is-filtered select {
  border-color: var(--accent);
}

/*
 * Z2Data import preview. Wider than the plain import dialog: this table
 * compares a file against the catalog and needs the room. Cells stack a primary
 * value over a muted secondary one (`.cell-secondary`), so rows align to the top
 * and every column keeps its header on one line.
 */
.z2-preview {
  width: min(1200px, 95vw);
}

.import-dialog.z2-preview .z2-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;

  th,
  td {
    padding: 0.55rem 0.6rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
  }

  th {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
  }

  .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  .link {
    padding: 0;
  }
}

.import-dialog.z2-preview .z2-preview-select input[type="checkbox"] {
  width: auto;
  margin: 0.2rem 0 0;
}

/* MPN, then manufacturer · package, then at most two lines of description. */
.z2-preview-part {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 14rem;
  max-width: 24rem;
}

.z2-preview-mpn {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.z2-preview-description {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  font-size: 0.85rem;
}

.z2-preview-catalog,
.z2-preview-lifecycle {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  white-space: nowrap;
}

.z2-preview-tags {
  min-width: 8rem;
}

.z2-preview-actions {
  text-align: right;
  white-space: nowrap;
}
