:root {
  --font-base: "Inter", "Roboto", "Manrope", "Segoe UI", sans-serif;
  --color-bg: #eff2f6;
  --color-surface: #ffffff;
  --color-surface-alt: #f8fafc;
  --color-border: #d5dae1;
  --color-divider: #e5e7eb;
  --color-text: #1f2433;
  --color-muted: #4f5d6f;
  --color-subtle: #6b778a;
  --color-primary: #1b2e4b;
  --color-primary-strong: #13223a;
  --color-topbar: #101725;
  --color-field-bg: #f9fafc;
  --color-accent: #028152;
  --color-accent-strong: #007248;
  --color-success: #179143;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --shadow-quiet: 0 1px 2px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 4px 16px rgba(15, 23, 42, 0.08);
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-base);
  font-size: 16px;
  line-height: 1.5;
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  color-scheme: light;
}

main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

a {
  color: var(--color-primary);
}

.topbar {
  background: var(--color-topbar);
  color: #f4f6fb;
  padding: 0 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.25);
}

.topbar-inner {
  width: min(1240px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: 64px;
  padding: 0.75rem 0;
}

.topbar-primary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  transition: background 160ms ease;
}

.brand-mark:hover {
  background: rgba(255, 255, 255, 0.08);
}

.brand-logo {
  display: block;
  height: 42px;
  width: auto;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  line-height: 1.1;
}

.brand-title {
  font-weight: 600;
  letter-spacing: 0.02em;
}

.brand-subtitle {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244, 246, 251, 0.7);
}

.brand-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  letter-spacing: 0.08em;
}

.topbar-panel {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.topbar-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logout-form {
  margin: 0;
}

.topbar-meta-slot {
  margin-left: 0;
  font-size: 0.88rem;
  color: rgba(244, 246, 251, 0.85);
}

.topbar a {
  color: #e7ecf5;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.85rem 0.35rem 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.user-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.user-name {
  font-weight: 600;
}

.user-role {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(244, 246, 251, 0.7);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-3) var(--space-2) var(--space-4);
}

h1,
h2,
h3 {
  font-weight: 600;
  margin: 0 0 0.25rem;
  color: var(--color-primary-strong);
}

p {
  margin: 0 0 0.75rem;
}

.hint {
  color: var(--color-subtle);
  font-size: 0.9rem;
}

.muted {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  box-shadow: var(--shadow-quiet);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.card:hover {
  border-color: rgba(27, 46, 75, 0.35);
  box-shadow: var(--shadow-soft);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  flex-wrap: wrap;
}

.aoi-dashboard-header {
  align-items: center;
}

.dashboard-heading {
  flex: 0 1 auto;
}

.dashboard-search {
  flex: 1 1 260px;
  display: flex;
  justify-content: center;
  width: 100%;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
}

.dashboard-search input {
  max-width: 360px;
}

.dashboard-date-filter {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.dashboard-date-filter .icon-btn {
  width: 36px;
  height: 36px;
  padding: 0;
}

.date-display {
  min-width: 140px;
  justify-content: center;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, monospace;
}

.date-hidden-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.temp-visible-input {
  /* Temporary class for making date input briefly visible for showPicker */
  pointer-events: auto;
}

.date-display.date-disabled {
  opacity: 0.6;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-1);
  margin-bottom: var(--space-2);
}

.report-summary-item {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  box-shadow: var(--shadow-quiet);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.report-summary-item .label {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-summary-item strong {
  font-size: 1.25rem;
}

.aoi-dashboard-header .dashboard-actions {
  margin-left: auto;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .dashboard-search {
    justify-content: flex-start;
  }
  .aoi-dashboard-header .dashboard-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media (max-width: 768px) {
  #aoi-dashboard-card {
    overflow-x: auto;
  }
  #aoi-dashboard-table {
    font-size: 0.88rem;
    min-width: 520px;
  }
  #aoi-dashboard-table th,
  #aoi-dashboard-table td {
    padding: 0.5rem 0.45rem;
  }
  #aoi-dashboard-table th.col-customer,
  #aoi-dashboard-table td.col-customer,
  #aoi-dashboard-table th.col-boards,
  #aoi-dashboard-table td.col-boards {
    display: none;
  }
}

.dashboard-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-2);
}

.dashboard-tile {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  background: var(--color-surface-alt);
  box-shadow: var(--shadow-quiet);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-height: 150px;
}

.dashboard-tile h3 {
  margin: 0;
  color: var(--color-primary-strong);
}

.dashboard-tile-actions {
  margin-top: auto;
  display: flex;
  justify-content: flex-end;
}

.module-section {
  margin-top: var(--space-2);
}

.portal-hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
}

.portal-user {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.submission-success {
  text-align: center;
  padding: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  align-items: center;
}

.submission-success .success-icon {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  background: rgba(2, 129, 82, 0.1);
  color: var(--color-accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  box-shadow: inset 0 0 0 1px rgba(2, 129, 82, 0.2);
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-2);
}

.module-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  display: flex;
  flex-direction: column;
  padding: var(--space-2);
  min-height: 220px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
  position: relative;
}

.module-card:hover {
  border-color: rgba(27, 46, 75, 0.35);
  box-shadow: var(--shadow-soft);
}

.module-card-production {
  border-color: rgba(43, 99, 240, 0.35);
  box-shadow: 0 2px 18px rgba(43, 99, 240, 0.08);
}

.module-card-production .module-eyebrow {
  color: #2b63f0;
}

.module-card-inspection {
  border-color: rgba(2, 129, 82, 0.35);
  box-shadow: 0 4px 12px rgba(2, 129, 82, 0.08);
}

.module-card-inspection .module-eyebrow {
  color: #028152;
}

.module-card-logistics {
  border-color: rgba(240, 145, 53, 0.35);
  box-shadow: 0 4px 12px rgba(240, 145, 53, 0.12);
}

.module-card-logistics .module-eyebrow {
  color: #f09135;
}

.module-card-rework {
  border-color: rgba(239, 68, 68, 0.35);
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.12);
}

.module-card-rework .module-eyebrow {
  color: #b91c1c;
}

.module-card-body {
  flex: 1;
}

.module-card h3 {
  margin: 0;
  color: var(--color-primary-strong);
}

.module-card p {
  margin-bottom: 0.35rem;
}


.module-launch {
  margin-top: auto;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid rgba(27, 46, 75, 0.15);
  background: rgba(255, 255, 255, 0.7);
  color: var(--color-primary);
  transition: background 180ms ease, transform 120ms ease, box-shadow 180ms ease;
}

.module-card-production .module-launch {
  border-color: rgba(43, 99, 240, 0.25);
  background: rgba(43, 99, 240, 0.08);
  color: #1f3bad;
}

.module-card-inspection .module-launch {
  border-color: rgba(2, 129, 82, 0.25);
  background: rgba(2, 129, 82, 0.1);
  color: #046b45;
}

.module-card-logistics .module-launch {
  border-color: rgba(240, 145, 53, 0.3);
  background: rgba(240, 145, 53, 0.12);
  color: #a45300;
}

.module-card-rework .module-launch {
  border-color: rgba(185, 28, 28, 0.35);
  background: rgba(239, 68, 68, 0.12);
  color: #872014;
}
.module-launch span {
  font-size: 1.1rem;
}

.module-launch:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.module-launch:active {
  transform: translateY(0);
}

.module-launch-ghost {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--color-primary);
}

.module-card-accent {
  background: linear-gradient(135deg, rgba(27, 46, 75, 0.07), rgba(2, 129, 82, 0.08));
  border-color: rgba(2, 129, 82, 0.25);
}

.module-eyebrow {
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--color-subtle);
  margin-bottom: 0.3rem;
}

.module-launch span {
  font-size: 1.1rem;
}

.module-launch:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.module-launch:active {
  transform: translateY(0);
}

.module-launch-ghost {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.4);
  color: var(--color-primary);
}

@media (max-width: 720px) {
  .portal-hero {
    flex-direction: column;
    align-items: flex-start;
  }
  .portal-user {
    text-align: left;
  }
}

.dashboard-card-full {
  position: fixed;
  inset: 0;
  margin: 0;
  border-radius: 0;
  z-index: 1000;
  overflow: auto;
}

.history-cell {
  min-width: 260px;
  text-align: left;
}

.history-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.history-chart {
  flex: 1 1 220px;
}

.history-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.history-delta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}

.history-delta-arrow {
  font-size: 1rem;
  line-height: 1;
}

.history-delta.delta-up {
  color: var(--color-success);
}

.history-delta.delta-down {
  color: var(--color-danger);
}

.history-delta.delta-flat {
  color: var(--color-subtle);
}

.history-empty {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--color-subtle);
  font-style: italic;
}

.history-prototype-tag {
  display: inline-flex;
  margin-top: 0.3rem;
}

.prototype-tag {
  font-weight: 700;
  color: #ff7b7b;
  letter-spacing: 0.08em;
}
label {
  display: block;
  margin: 0.5rem 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-primary-strong);
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 1rem;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  background: var(--color-field-bg);
  color: var(--color-text);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

select option {
  color: #0f172a;
  background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 168, 107, 0.25);
  outline: none;
}

.field {
  margin: 0.6rem 0;
}

.signature {
  margin-left: 0.5rem;
  font-weight: 600;
  color: var(--color-success);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: 0.5rem;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--color-accent);
  color: #fff;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 60ms ease, background 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.btn-small {
  padding: 0.3rem 0.65rem;
  font-size: 0.82rem;
}

.btn:hover,
button:hover {
  background: var(--color-accent-strong);
}

.btn:active,
button:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: rgba(27, 46, 75, 0.35);
}

.btn-secondary:hover {
  background: rgba(27, 46, 75, 0.06);
}

.btn-ghost {
  background: rgba(0, 0, 0, 0);
  color: var(--color-muted);
  border-color: transparent;
}

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

.nav li {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
}

.table-wrapper {
  border-radius: var(--radius-md);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  box-shadow: var(--shadow-quiet);
}

th,
td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-divider);
  text-align: left;
}

thead th {
  background-color: var(--color-surface);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--color-muted);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 0 rgba(229, 231, 235, 0.9);
}

tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

tbody tr:hover {
  background: #edf1f5;
}

.fk-cell {
  position: relative;
  vertical-align: middle;
}

.fk-value {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.fk-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.3rem;
  height: 1.3rem;
  border: 1px solid var(--color-primary);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--color-primary);
  background: rgba(27, 46, 75, 0.08);
}

.fk-tooltip {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-width: 320px;
  max-height: 240px;
  overflow: auto;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-soft);
  z-index: 5;
}

.fk-cell:hover .fk-tooltip,
.fk-cell:focus-within .fk-tooltip {
  display: block;
}

.fk-tooltip-title {
  margin: 0 0 0.35rem;
  font-weight: 600;
  color: var(--color-primary-strong);
  font-size: 0.85rem;
}

.fk-tooltip-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.82rem;
}

.fk-tooltip-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.2rem 0;
  border-top: 1px solid var(--color-divider);
}

.fk-tooltip-list li:first-child {
  border-top: none;
}

.hidden {
  display: none;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr;
  gap: var(--space-2);
  align-items: start;
}

@media (max-width: 960px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
}

.alert-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--color-danger);
}

.alert-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--color-success);
}

.progress {
  position: relative;
  width: 100%;
  height: 8px;
  border-radius: var(--radius-xs);
  background: #e2e8f0;
  overflow: hidden;
}

.progress-cell {
  min-width: 180px;
}

.progress .bar {
  position: absolute;
  inset: 0;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
  transition: width 200ms ease;
}

.spark path {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
}

.spark path.spark-bridge {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 2;
  stroke-dasharray: 4 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark path.spark-line {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spark-dot {
  fill: var(--color-primary);
  opacity: 0.85;
}

.spark-current {
  fill: var(--color-accent);
  stroke: var(--color-surface);
  stroke-width: 1.5;
}

.spark .axis {
  stroke: var(--color-divider);
  stroke-width: 1;
}

.report-shift {
  margin-top: var(--space-2);
}

.report-shift h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.report-job {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  box-shadow: var(--shadow-quiet);
  margin-bottom: var(--space-1);
}

.report-job-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.report-job-body {
  margin-left: 1.25rem;
  border-left: 2px solid var(--color-border);
  padding-left: 1rem;
}

.report-job-table-wrapper {
  margin: 0;
}

.report-job-table thead th {
  background: rgba(15, 23, 42, 0.04);
  font-size: 0.75rem;
}

.report-job-table td,
.report-job-table th {
  padding: 0.45rem 0.75rem;
  text-align: center;
}

.report-job-table td {
  vertical-align: middle;
}

.report-job-table td:nth-child(5),
.report-job-table td:nth-child(6) {
  white-space: nowrap;
}

.report-job-table td.history-cell {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  padding-right: 0.75rem;
}

.report-job-table td.history-cell svg {
  flex-shrink: 0;
}

.delta-indicator {
  font-size: 0.75rem;
  font-weight: 600;
}

.delta-indicator.delta-up {
  color: var(--color-success);
}

.delta-indicator.delta-down {
  color: var(--color-danger);
}

.delta-indicator.delta-flat {
  color: var(--color-muted);
}

.defect-summary-block {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.defect-summary-block h5 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}

.defect-bars {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.defect-bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.defect-bar-label {
  min-width: 120px;
  color: var(--color-muted);
}

.defect-bar-track {
  flex: 1;
  height: 8px;
  background: var(--color-border);
  border-radius: 999px;
  position: relative;
  overflow: hidden;
}

.defect-bar-fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-accent), var(--color-primary));
}

.defect-bar-qty {
  font-size: 0.75rem;
  color: var(--color-subtle);
  min-width: 36px;
  text-align: right;
}

.report-appendix {
  margin-top: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.job-analysis {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  background: var(--color-surface);
  box-shadow: var(--shadow-quiet);
}

.job-analysis h4 {
  margin: 0 0 0.35rem;
}

.analysis-additional {
  margin-top: 0.75rem;
}

.analysis-additional pre {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  white-space: pre-wrap;
  font-size: 0.85rem;
}

.table-subtext {
  font-size: 0.8rem;
  color: var(--color-subtle);
}

.top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: rgba(244, 246, 251, 0.85);
  width: 100%;
}

.top-meta-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-meta-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.tenant-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.topbar-user {
  font-weight: 500;
}

.hint-inline {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-left: 0.35rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--color-accent);
}

.topbar-btn {
  height: 36px;
}

.logout-form .topbar-btn {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.3);
}

.logout-form .topbar-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.topbar-btn-placeholder {
  width: 120px;
  height: 36px;
  display: inline-flex;
}

@media (max-width: 960px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .topbar-panel {
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
  }

  .topbar-badges,
  .topbar-actions {
    width: 100%;
    justify-content: center;
    align-items: center;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0.75rem 1rem;
  }

  .brand-logo {
    height: 36px;
  }

  .brand-badge {
    font-size: 0.7rem;
  }

  .topbar-actions,
  .topbar-badges {
    gap: 0.5rem;
  }

  .topbar-actions .btn,
  .topbar-actions .topbar-btn,
  .topbar-actions .logout-form,
  .topbar-actions form {
    width: 100%;
  }

  .topbar-actions button {
    width: 100%;
  }
}


@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
.table-scroll {
  overflow: auto;
  max-height: 360px;
  border: 1px solid var(--color-border);
}

.flash-list {
  list-style: none;
  margin: 0 0 var(--space-2);
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.95rem;
  box-shadow: var(--shadow-quiet);
}

.flash-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--color-success);
}

.flash-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--color-danger);
}

.flash-info {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-alt);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.badge-info {
  border-color: rgba(27, 46, 75, 0.4);
  background: rgba(27, 46, 75, 0.08);
  color: var(--color-primary);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-top: var(--space-1);
}

.form-grid input,
.form-grid select,
.form-grid textarea {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-field-bg);
  font-family: inherit;
  font-size: 1rem;
}

.form-grid button {
  justify-self: flex-start;
  margin-top: var(--space-1);
}

.wizard-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.wizard-panels {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: minmax(340px, 1.1fr) minmax(280px, 1fr);
  align-items: start;
}

@media (max-width: 880px) {
  .wizard-panels {
    grid-template-columns: 1fr;
  }
}

.wizard-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.wizard-fieldset {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-alt);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.wizard-fieldset legend {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.25rem;
}

.wizard-fieldset .checkbox {
  align-items: flex-start;
}

.wizard-fieldset .checkbox span {
  flex: 1;
}

.wizard-option-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.wizard-option {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: flex-start;
}

.wizard-option input[type="radio"],
.wizard-option input[type="checkbox"] {
  margin-top: 0.35rem;
}

.wizard-option-body {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.wizard-option-title {
  font-weight: 600;
}

.wizard-nested-fields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-left: 1.5rem;
}

.wizard-hint {
  color: var(--color-subtle);
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: var(--space-1);
}

.role-choices {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.role-choices legend {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.checkbox-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.checkbox input[type="checkbox"] {
  width: auto;
  height: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
  font-size: 0.95rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-divider);
  text-align: left;
  white-space: nowrap;
  max-width: none;
}

.data-table th:last-child,
.data-table td:last-child {
  text-align: right;
  width: 180px;
  white-space: normal;
}

.data-table input,
.data-table select,
.data-table textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.45rem 0.55rem;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  background: var(--color-field-bg);
  font: inherit;
  white-space: normal;
}

.data-table input[type="checkbox"] {
  width: auto;
  height: auto;
  margin: 0 auto;
  display: block;
}

.data-table .checkbox-cell {
  text-align: center;
  width: 90px;
}

.data-table tbody tr:nth-child(even) {
  background: var(--color-surface-alt);
}

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

.list li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-divider);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.list li:last-child {
  border-bottom: none;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: var(--space-2);
  align-items: flex-start;
}

@media (max-width: 960px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
}

.admin-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2);
}

.sidebar-title {
  margin-bottom: 0.5rem;
}

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

.table-list a {
  display: block;
  padding: 0.45rem 0.6rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--color-primary);
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease;
}

.table-list li.active a {
  background: rgba(27, 46, 75, 0.1);
  border-color: rgba(27, 46, 75, 0.25);
  font-weight: 600;
}

.table-list a:hover {
  background: rgba(27, 46, 75, 0.08);
  border-color: rgba(27, 46, 75, 0.15);
}

.sidebar-summary {
  border-top: 1px solid var(--color-divider);
  padding-top: var(--space-1);
}

.admin-content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.admin-table-scroll {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  overflow-x: hidden;
  min-width: 0;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.nested-card {
  background: var(--color-surface-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

.actions-cell {
  width: 120px;
  min-width: 120px;
  text-align: center;
}

.mono-cell {
  font-family: "JetBrains Mono", "Fira Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  word-break: normal;
}

.fk-cell-value {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.fk-cell-trigger {
  border: none;
  background: transparent;
  padding: 0.15rem;
  margin-left: 0.3rem;
  border-radius: var(--radius-xs);
  color: var(--color-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background 120ms ease, color 120ms ease;
}

.fk-cell-trigger:hover,
.fk-cell-trigger:focus-visible {
  background: rgba(27, 46, 75, 0.12);
  color: var(--color-primary);
}

.fk-cell-trigger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(27, 46, 75, 0.35);
}

.fk-cell-indicator {
  font-size: 0.85rem;
}

.table-row-scroll {
  display: block;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  min-width: 0;
}

.table-row-scroll::-webkit-scrollbar {
  height: 8px;
}

.table-row-scroll::-webkit-scrollbar-thumb {
  background: rgba(31, 36, 51, 0.35);
  border-radius: var(--radius-xs);
}

.fk-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 20000;
}

.fk-preview-overlay.is-visible {
  display: flex;
}

.fk-preview-dialog {
  width: min(960px, 100%);
  max-width: 90vw;
  max-height: 90vh;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  overflow: hidden;
}

.fk-preview-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.fk-preview-eyebrow {
  margin: 0;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-subtle);
}

.fk-preview-close {
  border: none;
  background: transparent;
  color: var(--color-primary);
  font-size: 1.5rem;
  line-height: 1;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.fk-preview-close:hover,
.fk-preview-close:focus-visible {
  background: rgba(27, 46, 75, 0.08);
}

.fk-preview-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.fk-preview-status {
  margin: 0;
}

.fk-preview-table-container {
  margin: 0;
}

.fk-preview-table-container.hidden {
  display: none;
}

.fk-preview-scroll {
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.fk-preview-table {
  margin: 0;
  min-width: 600px;
}

.btn-danger {
  background: var(--color-danger);
  border-color: rgba(239, 68, 68, 0.6);
}

.btn-danger:hover {
  background: #dc2626;
}

.pipelines-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.inline-form {
  display: inline;
  margin-right: 0.5rem;
}

.hidden {
  display: none !important;
}

.dual-field {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
  align-items: end;
}

.dual-field-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dual-field-divider {
  text-align: center;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--color-subtle);
}

.dual-field-note {
  grid-column: 1 / -1;
  margin: 0;
}

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

.operations-column {
  border: 1px dashed rgba(27, 46, 75, 0.3);
  border-radius: var(--radius-sm);
  padding: var(--space-1);
  background: rgba(255, 255, 255, 0.6);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.operations-column-header {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--color-subtle);
}

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

.operations-selected-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(27, 46, 75, 0.2);
  background: rgba(27, 46, 75, 0.05);
  font-size: 0.9rem;
}

.operations-controls {
  display: inline-flex;
  gap: 0.25rem;
}

.btn-icon {
  border: none;
  background: rgba(27, 46, 75, 0.08);
  color: var(--color-primary-strong);
  border-radius: var(--radius-xs);
  width: 1.8rem;
  height: 1.8rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-icon:hover {
  background: rgba(27, 46, 75, 0.15);
}

.operations-available {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.operation-chip {
  border: 1px solid rgba(27, 46, 75, 0.2);
  background: rgba(27, 46, 75, 0.05);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--color-primary-strong);
}

.operation-chip:hover {
  background: rgba(27, 46, 75, 0.12);
}

.btn.is-disabled,
.btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

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

/* --- Modern report layout --- */
.report-layout {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.report-form-pane,
.report-preview-pane {
  flex: 1;
  min-width: 0;
}

.report-form-pane {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.report-preview-pane {
  max-width: 420px;
  position: sticky;
  top: 96px;
}

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

.form-grid-two > label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-full-width {
  grid-column: 1 / -1;
}

.report-preview {
  background: radial-gradient(circle at top, rgba(15, 23, 42, 0.08), transparent),
    var(--color-surface);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  overflow: hidden;
}

.preview-watermark {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: repeating-linear-gradient(
      45deg,
      #0f172a,
      #0f172a 6px,
      transparent 6px,
      transparent 18px
    ),
    repeating-linear-gradient(
      -45deg,
      #0f172a,
      #0f172a 6px,
      transparent 6px,
      transparent 18px
    );
}

.preview-card {
  background: rgba(255, 255, 255, 0.92);
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: var(--space-2);
  box-shadow: var(--shadow-quiet);
  position: relative;
}

.preview-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-subtle);
}

.preview-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
  font-size: 0.92rem;
}

.preview-meta-grid span {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  color: var(--color-subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.preview-meta-grid strong {
  font-size: 1.05rem;
  color: var(--color-primary-strong);
}

.flow-stepper {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0;
  margin: 0;
  list-style: none;
}

.flow-step {
  flex: 1;
  min-width: 120px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(15, 23, 42, 0.2);
  padding: 0.65rem 0.8rem;
  text-align: left;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.flow-step::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(15, 23, 42, 0.4);
  display: inline-block;
}

.flow-step[data-complete="true"] {
  border-color: rgba(23, 145, 67, 0.6);
  background: rgba(23, 145, 67, 0.08);
  color: var(--color-success);
}

.flow-step[data-complete="true"]::before {
  background: var(--color-success);
  border-color: var(--color-success);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.metric-card strong {
  font-size: 1.35rem;
  font-weight: 600;
}

.metric-bar {
  height: 8px;
  width: 100%;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.metric-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #00a76f, #1b2e4b);
  transition: width 160ms ease;
}

.operations-flow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.operations-flow span {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.operations-flow span[data-active="true"] {
  background: rgba(27, 46, 75, 0.12);
  border-color: rgba(27, 46, 75, 0.25);
  font-weight: 600;
}

.preview-stamp {
  position: absolute;
  top: 24px;
  right: 24px;
  padding: 0.35rem 0.75rem;
  border: 2px solid rgba(27, 46, 75, 0.35);
  border-radius: 4px;
  font-size: 0.78rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: rgba(27, 46, 75, 0.7);
  transform: rotate(-5deg) scale(0.9);
  opacity: 0;
  transition: transform 200ms ease, opacity 200ms ease;
}

.preview-stamp.is-visible {
  opacity: 1;
  transform: rotate(-5deg) scale(1);
}

.preview-defect-wheel {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.defect-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  font-size: 0.8rem;
}

.defect-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.75);
}

.validation-note {
  border-left: 3px solid var(--color-warning);
  padding: 0.65rem;
  background: rgba(245, 158, 11, 0.08);
  font-size: 0.88rem;
  color: var(--color-warning);
}

@media (max-width: 1100px) {
  .report-layout {
    flex-direction: column;
  }
  .report-preview-pane {
    position: relative;
    top: 0;
    max-width: none;
    width: 100%;
  }
}

.shipping-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .shipping-grid {
    grid-template-columns: 1fr;
  }
}

.shipping-form-card .form-section {
  margin-bottom: 1.5rem;
}

.job-meta {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  background: var(--color-surface-alt);
  min-height: 88px;
}

.shipping-form.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-top: 0;
}

.shipping-form.form-grid > * {
  width: 100%;
}

.shipping-form .button-row {
  justify-content: flex-start;
  margin-top: 0;
}

.shipping-section-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.section-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  background: var(--color-surface);
  box-shadow: var(--shadow-quiet);
}

.section-card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-card header h3 {
  margin: 0;
}

.section-card header .hint {
  margin: 0.25rem 0 0;
}

.section-card .section-body {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  font-size: 0.78rem;
  padding: 0.1rem 0.65rem;
  color: var(--color-text-muted);
  background: var(--color-surface-alt);
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.chip-active {
  border-color: var(--color-accent);
  color: var(--color-accent-strong);
  background: rgba(2, 129, 82, 0.08);
}

.shipping-optional header {
  flex-wrap: wrap;
}

.shipping-optional .section-body {
  gap: 1.5rem;
}

.optional-sections {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.optional-panel {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.optional-panel:first-child {
  border-top: 0;
  padding-top: 0;
}

.optional-panel-head {
  margin-bottom: 0.75rem;
}

.optional-panel-head h4 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text);
}

.optional-panel-head .hint {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.optional-panel textarea {
  width: 100%;
}

.tracking-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tracking-entry {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.4rem;
}

.tracking-entry input {
  width: 100%;
}

.shipping-closeout {
  border-top: 1px solid var(--color-border);
  padding-top: 1rem;
}

.close-confirm {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: rgba(255, 184, 0, 0.08);
  border-radius: var(--radius-sm);
}

.close-confirm[hidden] {
  display: none;
}

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

.timeline-item {
  padding-left: 1.2rem;
  position: relative;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4rem;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-primary);
}

.timeline-title {
  font-weight: 600;
  margin: 0;
}

.badge-success {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.15);
  color: var(--color-success);
}

/* Dashboard filter layout */
.dashboard-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.25rem;
}

.dashboard-filters label {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(15, 23, 42, 0.8);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.dashboard-filters select,
.dashboard-filters input[type="date"] {
  width: 100%;
  border-radius: 0.5rem;
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 0.45rem 0.6rem;
  font-size: 0.9rem;
}

.filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  padding: 0.2rem 0.75rem;
  font-size: 0.8rem;
  background: rgba(99, 102, 241, 0.08);
  color: rgba(15, 23, 42, 0.7);
}

.live-stage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.live-stage-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.live-stage-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.live-stage-card h3 {
  font-size: 1.8rem;
  margin: 0;
}

.live-stage-meta {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.live-stage-chart {
  height: 120px;
}

.live-stage-card.status-red {
  border-color: rgba(239, 68, 68, 0.3);
}

.live-stage-card.status-yellow {
  border-color: rgba(245, 158, 11, 0.3);
}

.live-stage-card.status-green {
  border-color: rgba(16, 185, 129, 0.35);
}

.live-stage-card.status-idle {
  opacity: 0.85;
}

.alert-pill {
  display: inline-flex;
  padding: 0.2rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.75rem;
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.live-lower-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-top: 1.25rem;
}

@media (max-width: 992px) {
  .live-lower-grid {
    grid-template-columns: 1fr;
  }
}

.live-panel {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  padding: 1rem;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.01);
}

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

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

.live-defect-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.25rem;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.08);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

.badge-yellow {
  background: rgba(245, 158, 11, 0.18);
  color: #92400e;
}

.quality-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.quality-chart-block {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: #fff;
}

.delta {
  font-size: 0.8rem;
  font-weight: 600;
}

.delta-up {
  color: #10b981;
}

.delta-down {
  color: #ef4444;
}

.defects-chart-block {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 1rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: #fff;
}

.defects-chart-block.dual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.heatmap-wrapper {
  overflow-x: auto;
}

#defects-heatmap {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

#defects-heatmap th,
#defects-heatmap td {
  border: 1px solid rgba(15, 23, 42, 0.08);
  padding: 0.2rem;
  text-align: center;
}

#defects-heatmap td {
  background: rgba(46, 144, 250, var(--heatmap-alpha, 0.05));
}

.defects-breakdowns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.defects-breakdowns article {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: #fff;
}

.defects-breakdowns ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.defects-breakdowns li {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

/* Live Production Dashboard */
.live-dashboard__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.live-dashboard__header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dashboard-card.live-dashboard {
  position: relative;
  overflow: visible;
}

.live-filter-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-alt);
  margin-bottom: 1.5rem;
}

.live-filter-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.live-filter-field label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
}

.live-filter-field__control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  padding: 0.4rem 0.75rem;
}

.live-filter-field__control svg {
  width: 22px;
  height: 22px;
  color: var(--color-primary);
  flex-shrink: 0;
}

.live-filter-field select {
  border: none;
  background: transparent;
  width: 100%;
  font-size: 0.95rem;
  padding: 0.25rem 0;
}

.live-filter-field select:focus {
  outline: none;
}

.live-filter-field select[multiple] {
  min-height: 120px;
}

.live-filter-field__summary {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: 0;
}

.live-custom-range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.live-kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.kpi-card {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: #fff;
  box-shadow: var(--shadow-quiet);
}

.kpi-card h3 {
  margin: 0;
  font-size: 1.6rem;
}

.kpi-card span {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.live-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.live-chart {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 1rem;
  background: #fff;
}

.chart-wrapper {
  height: 300px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.station-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.station-card {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: #fff;
  box-shadow: var(--shadow-quiet);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.station-card header {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.station-card__yield {
  font-size: 1.2rem;
  font-weight: 600;
}

.station-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.station-card dl div {
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  text-align: center;
}

.station-card footer {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.station-card--green {
  border-color: rgba(23, 145, 67, 0.4);
}

.station-card--yellow {
  border-color: rgba(245, 158, 11, 0.5);
}

.station-card--red {
  border-color: rgba(239, 68, 68, 0.5);
}

.live-bottom-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

@media (max-width: 1024px) {
  .live-bottom-grid {
    grid-template-columns: 1fr;
  }
}

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

.alert-row {
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}

.alert-row__meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
}

.alert-row--critical {
  border-color: rgba(239, 68, 68, 0.6);
}

.alert-row--high {
  border-color: rgba(245, 158, 11, 0.6);
}

.alert-row--medium {
  border-color: rgba(14, 165, 233, 0.4);
}
