/* ============================================================
   Page header
   ============================================================ */

.older-jobs-control {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.older-jobs-control .btn { min-height: 44px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--geist-space-4x);
  padding-bottom: var(--geist-space-4x);
  border-bottom: 1px solid var(--hairline);
}

/* When a tab bar follows the header, the tabs' own border is the single
   divider — the header's would stack a second line beneath it. */
.page-header:has(+ .content-tabs) {
  padding-bottom: 0;
  border-bottom: 0;
}

.page-header > div:not(.page-actions) {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: var(--geist-space-2x);
}

.page-title {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: var(--text-xl);
  font-weight: 600;
  line-height: 32px;
  letter-spacing: -0.96px;
}

/* The title and its info control share one line, so the screen keeps a single
   label. Only rendered when the page has an explanation to disclose. */
.page-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--geist-space-2x);
}

.page-actions {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: flex-end;
  gap: var(--geist-space-2x);
}

.eyebrow {
  display: block;
  margin-bottom: var(--geist-space-2x);
  color: var(--ink-subtle);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: var(--leading-normal);
}

.text-muted {
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: 18px;
}

/* ============================================================
   Info tooltip
   ============================================================ */

.info-tip {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.info-tip-trigger {
  position: relative;
  display: inline-flex;
  width: 24px;
  height: 24px;
  padding: 0;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--ink-subtle);
  cursor: pointer;
}

.info-tip-trigger:hover { color: var(--ink); }

.info-tip-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.info-tip-icon {
  width: 16px;
  height: 16px;
}

/* Coarse pointers get the 44px target without widening the title line. */
@media (pointer: coarse) {
  .info-tip-trigger::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  .field input:not([type="checkbox"]):not([type="radio"]),
  .field select,
  .production-run-form input,
  .production-run-form select,
  #press-run-form input,
  #press-run-form select {
    min-height: 44px;
    font-size: var(--text-md);
  }

  .field input[type="checkbox"],
  .field input[type="radio"] {
    width: 24px;
    height: 24px;
  }
}

/* Floating layer: the panel is clipped by .visually-hidden while collapsed, so
   its copy stays available to a screen reader without being painted. */
.info-tip-panel {
  position: absolute;
  top: calc(100% + var(--geist-space));
  left: 0;
  z-index: var(--z-popover);
  width: max-content;
  max-width: min(280px, calc(100vw - var(--geist-space-8x)));
  padding: var(--geist-space-3x);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--ds-shadow-menu);
  animation: popover-in var(--ds-motion-popover-duration) var(--ds-motion-popover-timing);
}

.info-tip-text {
  margin: 0;
  color: var(--ink);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}

/* ============================================================
   KPI card (shared/_kpi_card)
   ============================================================ */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-3);
  align-items: stretch;
}

.kpi-card {
  position: relative;
  display: flex;
  min-width: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--ds-shadow-border);
}

.kpi-card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  min-height: 44px;
  padding: var(--space-4);
  border-radius: inherit;
  color: inherit;
  text-decoration: none;
  transition: background-color var(--duration) var(--ease);
}

a.kpi-card-body:hover { background: var(--surface-hover); }
a.kpi-card-body:focus-visible { outline: none; box-shadow: var(--ds-focus-ring); }

.kpi-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  min-height: 20px;
}

/* The ⓘ button is absolutely placed in the corner, outside the link. */
.kpi-card.has-tooltip .kpi-card-head { padding-right: 28px; }
.kpi-card > .info-tip { position: absolute; top: var(--space-3); right: var(--space-3); }
.kpi-card .info-tip-panel { left: auto; right: 0; }

/* A long badge wraps under the label instead of covering it. */
.kpi-card-label {
  flex: 1 1 8rem;
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  line-height: 20px;
  color: var(--ink-muted);
}

.kpi-card-badge { flex-shrink: 0; }

.kpi-card-figure {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  min-width: 0;
  overflow: hidden;
}

.kpi-card-value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: var(--font-weight-semibold);
  line-height: 32px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  white-space: nowrap;
}

.kpi-card-value--exact { display: none; }

.kpi-card-unit,
.kpi-card-delta,
.kpi-card-context {
  font-size: var(--text-sm);
  line-height: 18px;
  color: var(--ink-muted);
}

.kpi-card-unit { white-space: nowrap; }
.kpi-card-delta { font-variant-numeric: tabular-nums; }

.kpi-card-sparkline {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: auto;
  overflow: hidden;
}

.kpi-card-sparkline > div,
.kpi-card-sparkline canvas {
  display: block;
  width: 100% !important;
  height: 28px !important;
}

@media (prefers-reduced-motion: reduce) {
  .kpi-card-body { transition: none; }
}

/* Print: exact numbers, no canvas-only sparklines. */
@media print {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card { min-height: 0; break-inside: avoid; }
  .kpi-card-value { white-space: normal; }
  .kpi-card-sparkline,
  .kpi-card > .info-tip { display: none !important; }
  .kpi-card-value--compact { display: none; }
  .kpi-card-value--exact { display: inline; }
  /* The exact print value already names its unit. */
  .kpi-card-value--exact + .kpi-card-unit { display: none; }
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: var(--geist-space-2x);
  padding: 0 var(--geist-space-3x);
  border: 0;
  border-radius: var(--geist-radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--duration) var(--ease),
              color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease),
              opacity var(--duration) var(--ease),
              transform var(--duration) var(--ease);
}

.btn:hover {
  background: var(--ds-gray-100);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
}

.btn:active {
  background: var(--ds-gray-200);
}

.btn:focus-visible,
.link-button:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-border), var(--ds-focus-ring);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn[aria-busy="true"],
.btn.is-loading {
  opacity: 0.7;
  cursor: progress;
  pointer-events: none;
}

.btn[aria-busy="true"]::before,
.btn.is-loading::before {
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: var(--radius-full);
  content: "";
  animation: button-spin 0.8s linear infinite;
}

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

.btn svg,
.btn .icon,
.btn-icon svg,
.btn-icon .nav-item-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--contrast);
  box-shadow: none;
  color: var(--on-contrast);
}

.btn-primary:hover {
  background: var(--contrast-hover);
  box-shadow: none;
  color: var(--on-contrast);
}

.btn-primary:active {
  background: var(--contrast-hover);
}

.btn-primary:focus-visible,
.btn-danger:focus-visible,
.btn-critical:focus-visible,
.btn-warning:focus-visible,
.btn-nominal:focus-visible,
.btn-ghost:focus-visible,
.link-button:focus-visible {
  box-shadow: var(--ds-focus-ring);
}

.btn-secondary,
.btn-outline {
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
}

.btn-secondary:hover,
.btn-outline:hover {
  background: var(--ds-gray-100);
  box-shadow: var(--ds-shadow-border);
}

.btn-ghost,
.link-button {
  background: transparent;
  box-shadow: none;
  color: var(--ink-muted);
}

.btn-ghost:hover,
.link-button:hover {
  background: var(--ds-gray-alpha-100);
  box-shadow: none;
  color: var(--ink);
}

.btn-danger,
.btn-critical {
  background: var(--ds-red-800);
  box-shadow: none;
  color: #ffffff;
}

.btn-danger:hover,
.btn-critical:hover {
  background: var(--danger-hover);
  box-shadow: none;
  color: #ffffff;
}

.btn-nominal {
  background: var(--success);
  box-shadow: none;
  color: var(--on-success);
}

.btn-warning {
  background: var(--ds-amber-800);
  box-shadow: none;
  color: var(--ds-black);
}

.btn-icon {
  width: 36px;
  min-width: 36px;
  padding: var(--geist-space-2x);
  background: transparent;
  box-shadow: none;
  color: var(--ink-muted);
}

.btn-icon:hover {
  background: var(--ds-gray-alpha-100);
  box-shadow: none;
  color: var(--ink);
}

.btn-sm {
  height: 32px;
  padding: 0 var(--geist-space-3x);
  gap: var(--geist-space);
  font-size: var(--text-base);
  line-height: 20px;
}

.btn-xs {
  height: 32px;
  padding: 0 var(--geist-space-3x);
  gap: var(--geist-space);
  font-size: var(--text-base);
  line-height: 20px;
}

.btn-lg {
  height: 40px;
  padding: 0 var(--geist-space-3x);
  font-size: var(--text-md);
  line-height: 20px;
  border-radius: 8px;
}

.btn-icon.btn-sm { width: 32px; min-width: 32px; }
.btn-icon.btn-lg { width: 40px; min-width: 40px; }

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

form.button_to {
  display: inline-flex;
  margin: 0;
}

/* The "⋯" overflow menu (shared/_action_menu). */
.action-menu { position: relative; }
.action-menu > summary { list-style: none; cursor: pointer; box-shadow: var(--ds-shadow-border); }
.action-menu > summary::-webkit-details-marker { display: none; }

.action-menu-list {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 11rem;
  padding: var(--space-1);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--ds-shadow-border), 0 4px 12px rgb(0 0 0 / 12%);
}

.action-menu-item {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-xs);
  color: var(--ink);
  font-size: var(--text-base);
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
}

.action-menu-item:hover,
.action-menu-item:focus-visible { background: var(--surface-muted); }
.action-menu-item.is-danger { color: var(--ds-red-900); }

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

/* ============================================================
   Badges and status dots
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--geist-space-2x);
  min-height: 20px;
  padding: 2px var(--geist-space-3x);
  border: 0;
  border-radius: var(--radius-full);
  background: var(--surface-muted);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 16px;
  white-space: nowrap;
}

.badge-neutral {
  background: var(--surface-muted);
  color: var(--ink-muted);
}

.badge-primary,
.badge.\61 ccent,
.badge-info {
  background: var(--info-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 35%, transparent);
  color: var(--link);
}

.badge-nominal,
.badge-available,
.badge-success {
  background: var(--success-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 35%, transparent);
  color: var(--warning);
}

.badge-critical,
.badge-sold,
.badge-danger {
  background: var(--error-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--error) 35%, transparent);
  color: var(--error);
}

.badge-sm {
  min-height: 16px;
  padding: 1px 7px;
  font-size: var(--text-xs);
  line-height: 16px;
}

.badge-solid.badge-primary,
.badge-solid.badge-info { background: var(--ds-blue-700); box-shadow: none; color: #ffffff; }
.badge-solid.badge-nominal,
.badge-solid.badge-success { background: var(--ds-green-700); box-shadow: none; color: #ffffff; }
.badge-solid.badge-warning { background: var(--ds-amber-700); box-shadow: none; color: var(--ds-black); }
.badge-solid.badge-critical,
.badge-solid.badge-danger { background: var(--ds-red-700); box-shadow: none; color: #ffffff; }

.status-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--ink-subtle);
}

.status-dot.is-ok,
.status-dot.signal-nominal { background: var(--success); }
.status-dot.is-warn,
.status-dot.signal-warning { background: var(--warning); }
.status-dot.is-error,
.status-dot.signal-critical { background: var(--error); }
.status-dot.is-running,
.status-dot.signal-info {
  background: var(--info);
  animation: pulse-dot 1.4s var(--ease) infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

@media (prefers-reduced-motion: reduce) {
  .btn[aria-busy="true"]::before,
  .btn.is-loading::before,
  .autocomplete-results,
  .info-tip-panel,
  .status-dot.is-running,
  .status-dot.signal-info { animation: none; }
}

/* ============================================================
   Forms
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--geist-space-2x);
  margin-bottom: var(--geist-space-4x);
}

.field-error {
  color: var(--error);
  font-size: var(--text-sm);
  margin-top: var(--space-1);
}

.field input:not([type="checkbox"]):not([type="radio"])[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  box-shadow: 0 0 0 1px var(--ds-red-700);
}

[hidden] { display: none !important; }

/* Required fields: an asterisk after the label of any field whose control is
   required (also after a rejected submit, when Rails wraps both in
   .field_with_errors), or that carries .is-required (autocomplete pickers, whose visible
   input is not the submitted one). Forms render shared/_required_legend. */
.field:has(:is(input, select, textarea):required) > label::after,
.field:has(:is(input, select, textarea):required) > .field_with_errors > label::after,
.field.is-required > label::after,
.field.is-required > .field_with_errors > label::after {
  content: " *";
  color: var(--ds-red-700);
}

.form-required-legend {
  grid-column: 1 / -1;
  margin-bottom: var(--geist-space-3x);
  color: var(--ink-muted);
  font-size: var(--text-sm);
}

.form-required-legend span { color: var(--ds-red-700); }

/* Short help under a field. */
.hint {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.field label,
.form-label,
.field-static-label {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: var(--leading-snug);
}

.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea,
.input,
.select,
.textarea,
.autocomplete-input,
.auth-form input,
.search-field input[type="text"],
.search-field input[type="search"] {
  width: 100%;
  max-width: 32rem;
  height: 36px;
  padding: 0 var(--geist-space-3x);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 20px;
  transition: border-color var(--duration) var(--ease),
              box-shadow var(--duration) var(--ease);
}

.field input::placeholder,
.field textarea::placeholder,
.input::placeholder,
.textarea::placeholder { color: var(--ink-muted); }

.field input:hover,
.field select:hover,
.field textarea:hover,
.input:hover,
.select:hover,
.textarea:hover,
.autocomplete-input:hover,
.auth-form input:hover { box-shadow: var(--ds-shadow-border); }

.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.autocomplete-input:focus-visible,
.auth-form input:focus-visible,
.filter-bar input:focus-visible,
.filter-bar select:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-border), var(--ds-focus-ring);
}

.field textarea,
.textarea {
  min-height: 90px;
  height: auto;
  padding-block: 8px;
  resize: vertical;
}

.field input[type="checkbox"],
.field input[type="radio"] {
  width: auto;
  max-width: none;
  align-self: flex-start;
}

.field_with_errors input,
.field_with_errors select,
.field_with_errors textarea {
  box-shadow: 0 0 0 1px var(--ds-red-700);
}

.field input:not([type="checkbox"]):not([type="radio"])[aria-invalid="true"]:focus,
.field input:not([type="checkbox"]):not([type="radio"])[aria-invalid="true"]:focus-visible,
.field select[aria-invalid="true"]:focus,
.field select[aria-invalid="true"]:focus-visible,
.field textarea[aria-invalid="true"]:focus,
.field textarea[aria-invalid="true"]:focus-visible,
.field_with_errors input:focus,
.field_with_errors input:focus-visible,
.field_with_errors select:focus,
.field_with_errors select:focus-visible,
.field_with_errors textarea:focus,
.field_with_errors textarea:focus-visible {
  box-shadow: 0 0 0 1px var(--ds-red-700), var(--ds-focus-ring);
}

.field_with_errors,
.field_with_errors + .field-error,
.field_with_errors + .help-text {
  color: var(--ds-red-900);
}

.compact-field { max-width: 220px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--geist-space-3x);
  padding-top: var(--geist-space-4x);
}

.form-stack {
  display: grid;
  gap: var(--geist-space-4x);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--geist-space-4x);
}

/* Grid gap owns the spacing inside a form grid. */
.form-grid .field { margin-bottom: 0; }

/* Shared entry forms keep sections in reading order while fields adapt within
   each section. Semantic span roles prevent supporting content from landing in
   a partial grid column. */
.entry-form {
  display: grid;
  width: 100%;
  max-width: 900px;
  gap: var(--geist-space-6x);
}

.entry-form-section,
.entry-form-fields {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--geist-space-4x);
}

.entry-form-section { margin: 0; }

.entry-form-section > legend,
.entry-form-section > .detail-list,
.entry-form-span,
.entry-form-errors,
.entry-form-note,
.entry-form-actions {
  grid-column: 1 / -1;
}

.entry-form .field {
  min-width: 0;
  margin-bottom: 0;
}

.entry-form-note { margin: 0; }

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

  .entry-form-section > legend,
  .entry-form-section > .detail-list,
  .entry-form-span,
  .entry-form-errors,
  .entry-form-note,
  .entry-form-actions { grid-column: auto; }
}

/* Inline checkbox row: the box sits beside its label with a real hit area,
   instead of a tiny control stranded under a stacked label. */
.field-check {
  flex-direction: row;
  align-items: center;
  gap: var(--geist-space-3x);
  min-height: 36px;
}

.field-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  align-self: center;
}

.field-check label {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

fieldset { margin-bottom: var(--geist-space-6x); }

legend {
  width: 100%;
  padding-bottom: var(--geist-space-2x);
  margin-bottom: var(--geist-space-3x);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
  font-size: var(--text-md);
  font-weight: 600;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--geist-space-2x);
}

/* A labeled filter: the label sits above its control (U3). */
.filter-bar .field { margin-bottom: 0; }

/* A checkbox filter keeps its label beside the box, level with the controls. */
.filter-bar .filter-check {
  display: flex;
  align-items: center;
  gap: var(--geist-space-2x);
  min-height: 36px;
}

.filter-bar .filter-check input { height: auto; box-shadow: none; }

.filter-bar .filter-check label {
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

/* Filtered results update in place; dim them while the next set loads. */
turbo-frame#results { display: block; }
turbo-frame#results[busy] { opacity: 0.6; }
.results-actions { margin-bottom: var(--space-3); }

.filter-bar input,
.filter-bar select {
  height: 36px;
  padding: 0 var(--geist-space-3x);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 20px;
}

/* ============================================================
   Alerts
   ============================================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--geist-space-3x);
  padding: var(--geist-space-3x) var(--geist-space-4x);
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-muted);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-size: var(--text-xs);
}

.alert-content { flex: 1; }
.alert-title { margin-bottom: var(--geist-space); font-weight: 600; }
.alert-description { color: var(--ink-muted); }

.alert-critical {
  background: var(--error-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--error) 45%, transparent);
  color: var(--ds-red-900);
}

.alert-warning {
  background: var(--warning-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--warning) 45%, transparent);
  color: var(--ds-amber-900);
}

.alert-nominal {
  background: var(--success-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--success) 45%, transparent);
  color: var(--ds-green-900);
}

.alert-info {
  background: var(--info-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--info) 45%, transparent);
  color: var(--ds-blue-900);
}

.alert-critical .alert-content,
.alert-warning .alert-content,
.alert-nominal .alert-content,
.alert-info .alert-content { color: var(--ink); }

.inventory-readiness .alert-content {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Shared list footer: "1–50 of 976" plus page links. */
.list-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--geist-space-4x);
  margin-top: var(--geist-space-3x);
}

.list-pagination nav.pagy { margin: 0; }

.list-pagination-count {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: 16px;
  font-variant-numeric: tabular-nums;
}

.inventory-attention-table td:first-child,
.inventory-attention-table td:last-child { font-weight: 600; }

.inventory-attention-table tr.is-selected td:first-child {
  box-shadow: inset 2px 0 0 var(--accent);
}

.inventory-snapshot-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-block: 1px solid var(--hairline);
}

.inventory-snapshot-metric {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-2);
  min-width: 0;
  padding: var(--space-4);
  border-inline-start: 1px solid var(--hairline);
}

.inventory-snapshot-metric:first-child { border-inline-start: 0; }
.inventory-snapshot-label { grid-column: 1 / -1; color: var(--ink-muted); font-size: var(--text-xs); line-height: 16px; }
.inventory-snapshot-value { font-family: var(--font-mono); font-size: var(--text-xl); font-weight: 500; line-height: 32px; font-variant-numeric: tabular-nums; }
.inventory-snapshot-unit { align-self: end; padding-bottom: 4px; color: var(--ink-muted); font-size: var(--text-xs); }
.inventory-snapshot-context { grid-column: 1 / -1; color: var(--ink-muted); font-size: var(--text-xs); line-height: 16px; }
.next-step-list { margin: var(--space-3) 0 0; padding-inline-start: var(--space-6); line-height: 2; }
.inventory-coverage { margin: 0; padding: var(--space-3) var(--space-4); border-radius: var(--radius); background: var(--surface-muted); color: var(--ink-muted); }

.inventory-activity-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-6); }
.inventory-activity-section { min-width: 0; }

@media (max-width: 1000px) {
  .inventory-snapshot-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .inventory-snapshot-metric, .inventory-snapshot-metric:first-child { border-block-start: 1px solid var(--hairline); }
  .inventory-activity-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  .inventory-snapshot-strip { grid-template-columns: minmax(0, 1fr); }
  .inventory-snapshot-metric { border-inline-start: 0; }
}

.cockpit-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--geist-space-3x);
}

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

.card,
.panel {
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
}

.card.is-raised,
.panel.is-raised {
  box-shadow: var(--ds-shadow-border-small);
}

.panel { padding: var(--geist-space-4x); }

.panel-heading,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--geist-space-3x);
  padding: var(--geist-space-3x) var(--geist-space-4x);
  border-bottom: 1px solid var(--hairline);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 500;
}

.panel > .panel-heading {
  margin: calc(var(--geist-space-4x) * -1) calc(var(--geist-space-4x) * -1) var(--geist-space-4x);
}

.card-header-title {
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
}

.card-body { flex: 1; padding: var(--geist-space-4x); }

.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--geist-space-2x);
  padding: var(--geist-space-2x) var(--geist-space-4x);
  border-top: 1px solid var(--hairline);
}

.detail-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  align-items: baseline;
  gap: var(--geist-space-2x) var(--geist-space-6x);
  margin: var(--geist-space-4x) 0;
}

.detail-list dt {
  color: var(--ink-subtle);
  font-size: var(--text-xs);
  font-weight: 500;
}

.detail-list dd {
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Tabs
   ============================================================ */

.tabs,
.content-tabs {
  width: 100%;
  min-width: 0;
  display: flex;
  border-bottom: 1px solid var(--hairline);
}

.content-tabs {
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.page-tab-head {
  display: flex;
  flex-direction: column;
  gap: var(--geist-space-4x);
}

.page-tab-head .page-title { margin: 0; }

.page-tab-head .page-header {
  padding-bottom: 0;
  border-bottom: 0;
}

.tab,
.local-navigation-area-link {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: var(--geist-space-2x);
  min-width: 48px;
  padding: var(--geist-space-3x) var(--geist-space-4x);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
  text-transform: none;
}

.tab:hover,
.local-navigation-area-link:hover { color: var(--ink); }

.tab:focus-visible,
.local-navigation-area-link:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.tab.is-active,
.local-navigation-area-link.is-active {
  border-bottom-color: var(--ds-gray-1000);
  color: var(--ds-gray-1000);
}

.tab .badge,
.tab .pill-count {
  min-height: 16px;
  padding: 1px var(--geist-space-2x);
  font-size: var(--text-xs);
}

/* ============================================================
   Local area navigation
   ============================================================ */

.local-navigation {
  position: relative;
  z-index: calc(var(--z-topbar) - 1);
  display: flex;
  width: 100%;
  max-width: 100%;
  align-items: center;
  gap: var(--geist-space-3x);
  box-shadow: inset 0 -1px var(--hairline);
}

.local-navigation-primary {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

/* Keep the full underline inside the horizontally scrolling tab row. */
.local-navigation-area-link { margin-bottom: 0; }

.local-navigation-back {
  padding: var(--geist-space-3x) 0;
  color: var(--ink-muted);
  font-size: var(--text-base);
  font-weight: 500;
  line-height: 20px;
  text-decoration: none;
  white-space: nowrap;
}

.local-navigation-back:hover { color: var(--ink); }

.local-navigation-back:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.local-navigation-menu {
  position: relative;
  min-width: 0;
  max-width: 100%;
}

.local-navigation-trigger {
  display: grid;
  height: 36px;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--geist-space-2x);
  padding: 0 var(--geist-space-3x);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 20px;
  cursor: pointer;
  list-style: none;
}

.local-navigation-trigger::-webkit-details-marker { display: none; }

.local-navigation-trigger:hover { background: var(--surface-hover); }

.local-navigation-trigger:focus-visible {
  outline: none;
  box-shadow: var(--ds-shadow-border), var(--ds-focus-ring);
}

.local-navigation-context {
  color: var(--ink-subtle);
  font-weight: 400;
}

.local-navigation-current {
  overflow: hidden;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.local-navigation-link:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.orders-mobile-navigation { display: none; }

@media (max-width: 672px) {
  .local-navigation {
    width: 100%;
    align-items: stretch;
  }
  .local-navigation-menu { min-width: 0; width: 100%; }
  .local-navigation-trigger,
  .local-navigation-link { min-height: 44px; }
}

@media (pointer: coarse) {
  .local-navigation-area-link,
  .local-navigation-trigger,
  .local-navigation-link { min-height: 44px; }
}

/* ============================================================
   Pagination (Pagy)
   ============================================================ */

nav.pagy {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--geist-space);
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  margin: var(--geist-space-6x) auto 0;
  font-family: "Geist Sans", var(--font-sans);
  font-size: var(--text-xs);
}

nav.pagy a,
nav.pagy span {
  display: inline-flex;
  min-width: 2rem;
  min-height: 2rem;
  align-items: center;
  justify-content: center;
  padding: var(--geist-space-2x) var(--geist-space-2x);
  border-radius: 6px;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  line-height: 1;
}

nav.pagy a[href]:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

nav.pagy a:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

nav.pagy .current,
nav.pagy a[aria-current="page"] {
  background: var(--surface-active);
  box-shadow: var(--ds-shadow-border);
  color: var(--ink);
  font-weight: 500;
}

nav.pagy .gap,
nav.pagy [aria-disabled]:not([aria-current]) {
  color: var(--ink-subtle);
}

nav.pagy a[aria-label="Previous"],
nav.pagy a[aria-label="Next"] {
  gap: var(--geist-space-2x);
  padding-inline: var(--geist-space-3x);
  box-shadow: var(--ds-shadow-border);
  background: var(--surface);
}

nav.pagy a[aria-disabled]:not([aria-current]):not(.gap) {
  background: var(--surface-hover);
}

nav.pagy svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.pagination-chevron-back {
  transform: rotate(180deg);
}

nav.pagy a[aria-label][href]:hover {
  background: var(--surface-hover);
}

nav.pagy a[aria-label]:focus-visible {
  box-shadow: var(--ds-focus-ring);
}

@media (pointer: coarse) {
  nav.pagy a { min-height: 2.75rem; }
}

/* ============================================================
   Sortable table headers
   ============================================================ */

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: var(--geist-space);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: none;
  text-transform: inherit;
  white-space: nowrap;
}

.sort-link:hover,
.sort-link.is-sorted { color: var(--ink); }
.sort-link.is-sorted { font-weight: 600; }

.sort-link:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

.sort-indicator {
  color: var(--ink-subtle);
  font-size: var(--text-xs);
}

/* ============================================================
   Autocomplete picker
   ============================================================ */

.autocomplete { position: relative; }
.autocomplete-input { width: 100%; }

.autocomplete-results {
  position: absolute;
  top: calc(100% + var(--geist-space));
  right: 0;
  left: 0;
  z-index: var(--z-popover);
  max-height: 16rem;
  padding: var(--geist-space);
  margin: 0;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--ds-shadow-menu);
  list-style: none;
  transform-origin: top;
  animation: popover-in var(--ds-motion-popover-duration) var(--ds-motion-popover-timing);
}

@keyframes popover-in {
  from { opacity: 0; transform: scale(var(--ds-motion-overlay-scale)); }
  to { opacity: 1; transform: scale(1); }
}

.autocomplete-option,
.autocomplete-empty {
  padding: var(--geist-space-2x) var(--geist-space-3x);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: var(--text-xs);
}

.autocomplete-option { cursor: pointer; }
.autocomplete-option:hover { background: var(--surface-hover); }
.autocomplete-option.is-active { background: var(--surface-active); }
.autocomplete-empty { color: var(--ink-muted); }

.autocomplete-option:focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

/* ============================================================
   Empty states and dividers
   ============================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--geist-space-10x) var(--geist-space-6x);
  color: var(--ink-muted);
  text-align: center;
}

.empty-state-compact {
  align-items: flex-start;
  padding: var(--geist-space-4x) 0;
  text-align: left;
}

.empty-state-compact .empty-state-title {
  font-size: var(--text-base);
}

.empty-state-icon {
  margin-bottom: var(--geist-space-4x);
  color: var(--ink-subtle);
}

.empty-state-title {
  margin-bottom: var(--geist-space-2x);
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: var(--text-lg);
  font-weight: 600;
}

.empty-state-description {
  max-width: 360px;
  margin-bottom: var(--geist-space-6x);
  color: var(--ink-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-normal);
}

.empty-state-bordered {
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--ds-shadow-border);
}

.divider {
  display: flex;
  width: 100%;
  height: 1px;
  align-items: center;
  margin: var(--geist-space-4x) 0;
  background: var(--hairline);
}

/* ============================================================
   Utilities
   ============================================================ */

.skip-link {
  position: absolute;
  top: var(--geist-space-2x);
  left: var(--geist-space-2x);
  z-index: 10000;
  padding: var(--geist-space-2x) var(--geist-space-3x);
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--canvas);
  font-size: var(--text-base);
  font-weight: 500;
  text-decoration: none;
  transform: translateY(-200%);
}

.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

@media (max-width: 720px) {
  .field input:not([type="checkbox"]):not([type="radio"]),
  .field select,
  .field textarea,
  .input,
  .select,
  .textarea,
  .autocomplete-input,
  .auth-form input,
  .search-field input,
  .filter-bar input,
  .filter-bar select,
  .ai-chat-input {
    font-size: var(--text-md);
  }

  .btn,
  .btn-icon,
  .icon-link,
  .ai-chat-icon-btn,
  .nav-item {
    min-height: 44px;
  }

  .btn-icon,
  .icon-link,
  .ai-chat-icon-btn {
    min-width: 44px;
  }
}

.sr-only,
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border-width: 0;
}

.no-print {
  /* Hidden by the shared print stylesheet. */
}

@media (max-width: 672px) {
  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .detail-list { grid-template-columns: 1fr; }
}
/* Printable equipment label; the SVG is generated locally and links only to
   an authenticated maintenance-request route. */
.qr-label {
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  width: min(100%, 28rem);
  margin-inline: auto;
  padding: var(--space-6);
  text-align: center;
  border: 2px solid var(--hairline-mid);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.qr-label h1,
.qr-label p { margin: 0; }

.qr-label svg {
  display: block;
  width: min(100%, 20rem);
  height: auto;
  background: #ffffff;
}
.directional-label-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
}

/* ============================================================
   Website request files: confidential drawings previewed inline
   ============================================================ */
.web-submission-file-list,
.web-submission-refused {
  list-style: none;
  margin: var(--geist-space-2x) 0;
  padding: 0;
}

.web-submission-file-list > li {
  margin-bottom: var(--geist-space-4x);
}

.file-preview {
  display: block;
  width: 100%;
  max-width: 64rem;
  height: 36rem;
  margin-top: var(--geist-space-2x);
  border: 1px solid var(--hairline-strong);
  background: #fff;
}

.file-preview-image {
  height: auto;
  max-height: 36rem;
  object-fit: contain;
}

@media print {
  .file-preview { display: none; }
}

/* A plain sentence with its technical reason behind an info button. */
.plain-note {
  display: flex;
  align-items: flex-start;
  gap: var(--geist-space-2x);
  margin-bottom: var(--geist-space-4x);
}

.plain-note p { margin: 0; }

.data-problem-details summary {
  cursor: pointer;
  color: var(--link);
  font-size: var(--text-xs);
}

.data-problem-details[open] p {
  max-height: 320px;
  overflow: auto;
  overflow-wrap: anywhere;
}

.report-fallback-note { margin-bottom: var(--geist-space-4x); }
