@font-face {
  font-family: "Montserrat";
  src: url("/assets/fonts/Montserrat-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("/assets/fonts/Montserrat-Medium.otf") format("opentype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("/assets/fonts/Montserrat-SemiBold.otf") format("opentype");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("/assets/fonts/Montserrat-Bold.otf") format("opentype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --brand-ink: #111827;
  --brand-navy: #160f43;
  --brand-violet: #6d28d9;
  --brand-muted: #6b7280;
  --brand-magenta: #ed2b84;
  --brand-hover: #33216f;
  --surface: #ffffff;
  --page: #f5f6f8;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --text: #111827;
  --muted: #6b7280;
  --accent: #f3f4f6;
  --success: #147d64;
  --success-bg: #e7f6f0;
  --warning: #a86600;
  --warning-bg: #fff4d8;
  --danger: #b42345;
  --danger-bg: #ffe7ed;
  --focus: #6d28d9;
  --active-bg: rgba(109, 40, 217, 0.1);
  --button-secondary-hover: #fbfaff;
  --disabled-bg: #c9bfd9;
  --rail-initial-bg: #f1eef8;
  --soft-surface: #fbfaff;
  --neutral-bg: #f3f2f6;
  --progress-bg: #ede9f5;
  --group-bg: #f5f1fb;
  --drawer-backdrop: rgba(22, 15, 67, 0.24);
  --shadow: 0 12px 24px rgba(17, 24, 39, 0.08);
  color-scheme: light;
}

html.dark {
  --brand-ink: #f8fafc;
  --brand-navy: #cdbcf2;
  --brand-violet: #8b5cf6;
  --brand-muted: #94a3b8;
  --brand-magenta: #f472b6;
  --brand-hover: #7c3aed;
  --surface: #0f172a;
  --page: #020617;
  --line: #1e293b;
  --line-strong: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #1e293b;
  --success: #6ee7b7;
  --success-bg: rgba(20, 125, 100, 0.24);
  --warning: #fbbf24;
  --warning-bg: rgba(168, 102, 0, 0.26);
  --danger: #fb7185;
  --danger-bg: rgba(180, 35, 69, 0.26);
  --focus: #a78bfa;
  --active-bg: rgba(139, 92, 246, 0.18);
  --button-secondary-hover: #1e293b;
  --disabled-bg: #334155;
  --rail-initial-bg: #1e1b4b;
  --soft-surface: #111827;
  --neutral-bg: #1e293b;
  --progress-bg: #1e293b;
  --group-bg: rgba(139, 92, 246, 0.16);
  --drawer-backdrop: rgba(2, 6, 23, 0.72);
  --shadow: 0 18px 34px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Montserrat, Avenir, "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-page {
  min-height: 100vh;
  background: var(--surface);
  display: grid;
  grid-template-rows: 240px 1fr;
}

.auth-hero {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 5% 10%, rgba(237, 43, 132, 0.62), transparent 18%),
    radial-gradient(circle at 86% 82%, rgba(67, 47, 144, 0.7), transparent 22%),
    linear-gradient(110deg, #160f43 0%, #432f90 52%, #ed2b84 100%);
  color: white;
  display: flex;
  align-items: center;
  padding: 28px clamp(18px, 5vw, 80px);
}

.auth-hero::before,
.auth-hero::after {
  content: "";
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  width: 300px;
  height: 300px;
  transform: rotate(34deg);
}

.auth-hero::before {
  left: -80px;
  top: -70px;
}

.auth-hero::after {
  right: -130px;
  bottom: -140px;
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 24px;
  font-weight: 600;
  font-size: clamp(42px, 9vw, 92px);
  letter-spacing: 10px;
}

.brand-lockup img {
  width: auto;
  height: clamp(76px, 13vw, 132px);
}

.auth-panel {
  width: min(100%, 620px);
  padding: clamp(28px, 6vw, 72px) clamp(18px, 5vw, 80px);
}

.auth-panel h1 {
  margin: 0 0 16px;
  font-size: 26px;
  line-height: 1.2;
}

.auth-panel p {
  margin: 0 0 42px;
  color: var(--text);
  font-size: 18px;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
}

.field label {
  font-size: 14px;
  color: var(--text);
}

.input,
.select {
  width: 100%;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.16);
}

.password-field {
  position: relative;
}

.password-field .input {
  padding-right: 48px;
}

/* Searchable single-select (ANSI/ASQ Z1.4 sampling plan picker). */
.searchable-select {
  position: relative;
}

.searchable-options {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.searchable-option {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
}

.searchable-option:hover,
.searchable-option.active {
  background: var(--soft-surface);
}

.searchable-empty {
  padding: 8px 10px;
  color: var(--muted);
  font-size: 14px;
}

/* Headline output on Incoming Inspection rows: the computed sample size. */
.sample-size {
  font-weight: 700;
  font-size: 16px;
  color: var(--focus);
}

.icon-button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-muted);
  display: inline-grid;
  place-items: center;
}

.password-toggle {
  position: absolute;
  right: 4px;
  top: 4px;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  background: var(--brand-violet);
  color: white;
}

.button:hover {
  background: var(--brand-hover);
}

.button:disabled {
  cursor: not-allowed;
  background: var(--disabled-bg);
  color: rgba(255, 255, 255, 0.82);
}

.button.secondary {
  background: var(--surface);
  color: var(--brand-ink);
  border-color: var(--line);
}

.button.secondary:hover {
  background: var(--button-secondary-hover);
}

.button.magenta {
  background: var(--brand-magenta);
}

.button.magenta:hover {
  background: #cc1f6e;
}

.button.danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.button.danger:hover {
  filter: brightness(0.95);
}

/* Item-master approval lifecycle ladder (Lifecycle subtab). */
.lifecycle-ladder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.lifecycle-step {
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  background: var(--neutral-bg);
  color: var(--muted);
  white-space: nowrap;
}

.lifecycle-step.done {
  background: var(--success-bg);
  color: var(--success);
}

.lifecycle-step.current {
  background: var(--brand-magenta);
  color: #fff;
}

.lifecycle-arrow {
  color: var(--muted);
  font-size: 12px;
}

.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 28px;
}

.text-link {
  color: var(--brand-violet);
  text-decoration: none;
  font-size: 14px;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  background: var(--page);
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.sidebar-brand {
  min-height: 76px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  position: relative;
  font-weight: 700;
  color: var(--brand-ink);
}

.app-switcher-trigger {
  width: 100%;
  min-height: 56px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  text-align: left;
}

.app-switcher-trigger:hover,
.app-switcher-trigger:focus {
  background: var(--accent);
  outline: none;
}

.app-switcher-trigger img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-mark,
.app-switcher-trigger img.brand-mark {
  width: auto;
  height: 30px;
  flex: 0 0 auto;
}

.brand-wordmark {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1.5px;
  line-height: 1;
  white-space: nowrap;
}

.bw-fission {
  color: var(--brand-navy);
}

.bw-mfg {
  color: var(--brand-magenta);
}

.app-switcher-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.app-switcher-name {
  color: var(--brand-ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2.4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-switcher-meta {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
}

.app-switcher-menu {
  position: absolute;
  top: 76px;
  left: 12px;
  right: 12px;
  z-index: 20;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 8px;
}

.app-switcher-option {
  width: 100%;
  min-height: 58px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px;
  text-align: left;
  text-decoration: none;
}

.app-switcher-option:hover,
.app-switcher-option:focus,
.app-switcher-option.active {
  background: var(--active-bg);
  outline: none;
}

.app-switcher-option.active .rail-initial {
  background: var(--brand-violet);
  color: white;
}

.org-switcher {
  border-bottom: 1px solid var(--line);
  padding: 12px 12px;
}

.org-switcher-trigger {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  text-align: left;
}

.org-switcher-trigger:hover,
.org-switcher-trigger:focus {
  background: var(--accent);
  outline: none;
}

.org-initial {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--brand-violet);
  color: white;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.org-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--brand-violet);
  color: white;
  font-weight: 600;
  font-size: 13px;
  flex: 0 0 auto;
}

.avatar.magenta {
  background: var(--brand-magenta);
}

.sidebar-scroll {
  overflow: auto;
  padding: 14px 12px;
}

.sidebar-section {
  margin-bottom: 22px;
}

.sidebar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.7px;
  margin: 0 4px 10px;
  text-transform: uppercase;
}

.rail-button,
.nav-link {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  text-align: left;
  text-decoration: none;
  font-size: 14px;
  transition:
    background-color 150ms ease,
    color 150ms ease;
}

.rail-button.active,
.nav-link.active {
  color: var(--brand-violet);
  background: var(--active-bg);
  font-weight: 600;
}

.rail-button:hover,
.rail-button:focus,
.nav-link:hover,
.nav-link:focus {
  color: var(--text);
  background: var(--accent);
  outline: none;
}

.rail-initial {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  background: var(--rail-initial-bg);
  color: var(--brand-violet);
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}

.rail-button.active .rail-initial {
  background: var(--brand-violet);
  color: white;
}

.rail-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.rail-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-meta {
  color: var(--muted);
  font-size: 11px;
  margin-top: 2px;
}

.nav-stack {
  display: grid;
  gap: 4px;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: currentColor;
}

.button-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.switcher-icon,
.menu-check-icon {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex: 0 0 auto;
  margin-left: auto;
}

.menu-check-icon {
  color: var(--brand-violet);
}

.sidebar-search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  width: 14px;
  height: 14px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.sidebar-search {
  height: 32px;
  padding-left: 32px;
  background: var(--accent);
  font-size: 12px;
}

.organization-link {
  border-top: 1px solid var(--line);
  padding: 8px 12px;
}

.user-menu {
  border-top: 1px solid var(--line);
}

.user-menu-trigger {
  width: 100%;
  min-height: 54px;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  text-align: left;
}

.user-menu-trigger:hover,
.user-menu-trigger:focus {
  background: var(--accent);
  outline: none;
}

.user-menu-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--active-bg);
  color: var(--brand-violet);
  font-size: 12px;
}

.user-menu-panel {
  display: grid;
  gap: 4px;
  padding: 0 8px 12px;
}

.theme-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 14px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 8px;
  background: var(--accent);
  padding: 4px;
}

.theme-toggle-button {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: inline-grid;
  place-items: center;
  transition:
    background-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease;
}

.theme-toggle-button:hover,
.theme-toggle-button:focus {
  color: var(--text);
  outline: none;
}

.theme-toggle-button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(17, 24, 39, 0.14);
}

.theme-toggle-icon {
  width: 15px;
  height: 15px;
  color: currentColor;
}

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

.nav-link.danger:hover,
.nav-link.danger:focus {
  background: var(--danger-bg);
  color: var(--danger);
}

.content {
  min-width: 0;
}

.topbar {
  min-height: 116px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 22px 28px 16px;
}

.product-heading {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.product-heading h1 {
  font-size: 28px;
  line-height: 1.12;
  margin: 0;
  max-width: 390px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tabs {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: 18px;
  overflow: auto;
}

.tab {
  height: 44px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 0 18px;
  white-space: nowrap;
}

.tab.active {
  color: var(--brand-violet);
  border-color: var(--brand-violet);
}

.workspace {
  padding: 28px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.toolbar .input {
  max-width: 360px;
}

.segmented {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segment {
  height: 38px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 0 14px;
}

.segment:last-child {
  border-right: 0;
}

.segment.active {
  color: white;
  background: var(--brand-violet);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.callout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  margin-bottom: 22px;
  font-size: 14px;
}

.callout.warning {
  border-color: var(--warning);
  background: var(--warning-bg);
  color: var(--warning);
}

.callout.warning .table-link {
  margin-left: auto;
}

.metric-card,
.panel,
.row-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
  min-height: 122px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 12px;
  font-size: 34px;
  font-weight: 600;
  color: var(--brand-ink);
}

.metric-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-body {
  padding: 14px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--brand-muted);
  font-weight: 600;
  font-size: 14px;
  margin: 4px 0 12px;
}

.row-card {
  width: 100%;
  min-height: 86px;
  margin-bottom: 10px;
  padding: 14px 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  text-align: left;
  color: inherit;
}

.row-card:hover,
.row-card:focus {
  border-color: var(--brand-violet);
  box-shadow: 0 0 0 3px rgba(67, 47, 144, 0.1);
  outline: none;
}

.row-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.row-meta {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge {
  min-height: 24px;
  border-radius: 8px;
  padding: 4px 8px;
  background: var(--rail-initial-bg);
  color: var(--brand-violet);
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  color: var(--success);
  background: var(--success-bg);
}

.badge.warning {
  color: var(--warning);
  background: var(--warning-bg);
}

.badge.danger {
  color: var(--danger);
  background: var(--danger-bg);
}

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

.progress-line {
  height: 8px;
  border-radius: 999px;
  background: var(--progress-bg);
  overflow: hidden;
  margin-top: 14px;
}

.progress-line span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-violet), var(--brand-magenta));
}

.stack {
  display: grid;
  gap: 12px;
}

.mini-row {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.mini-row.linked-row {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
}

.mini-row:last-child {
  border-bottom: 0;
}

.mini-row-title {
  font-weight: 600;
  margin-bottom: 6px;
}

.mini-row p {
  color: var(--muted);
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.operational-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.page-heading-row {
  min-height: 84px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
}

.page-heading-row h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.page-heading-row p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.shared-nav {
  margin: 14px 18px 0;
  width: fit-content;
  max-width: calc(100% - 36px);
  overflow: auto;
}

.local-tabs {
  margin: 14px 18px;
  width: fit-content;
  max-width: calc(100% - 36px);
  overflow: auto;
}

.tracker-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  padding: 18px;
}

.tracker-metric {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--soft-surface);
}

.tracker-metric p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.tracker-metric strong {
  color: var(--brand-ink);
  font-size: 28px;
}

.dense-filters {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 220px) minmax(160px, 210px) auto;
  gap: 10px;
  padding: 0 18px 18px;
  align-items: center;
}

.data-table {
  width: calc(100% - 36px);
  margin: 0 18px 18px;
  border-collapse: collapse;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  display: table;
  background: var(--surface);
  font-size: 13px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--muted);
  background: var(--soft-surface);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

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

.group-row td {
  color: var(--brand-violet);
  background: var(--group-bg);
  font-weight: 600;
}

.table-link {
  color: var(--brand-ink);
  font-weight: 600;
  text-decoration: none;
}

.table-subtext {
  color: var(--muted);
  margin-top: 3px;
}

.training-list {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.training-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.training-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.training-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.pipe-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.pipe-meta span:not(:last-child)::after {
  content: "|";
  margin-left: 8px;
  color: var(--line-strong);
}

.service-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 18px;
}

.service-card,
.policy-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.service-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.service-card strong {
  display: block;
  color: var(--brand-ink);
  font-size: 26px;
  font-weight: 600;
}

.service-card span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding: 18px;
}

.library-section-heading {
  padding: 12px 18px 10px;
  border-top: 1px solid var(--line);
}

.service-overview-grid + .library-section-heading {
  border-top: 0;
  padding-top: 0;
}

.library-section-heading h3 {
  margin: 0 0 4px;
  color: var(--brand-ink);
  font-size: 15px;
}

.library-section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.policy-card-title {
  color: var(--brand-ink);
  font-weight: 600;
  margin-bottom: 8px;
}

.policy-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--drawer-backdrop);
  display: flex;
  justify-content: flex-end;
  z-index: 10;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--drawer-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 20;
}

.modal {
  width: min(100%, 520px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-header {
  flex: 0 0 auto;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  flex: 0 0 auto;
  padding: 16px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.po-total-label {
  margin-right: auto;
  font-size: 13px;
  color: var(--muted, inherit);
}

.po-total-label strong {
  font-size: 15px;
  color: inherit;
}

.po-lines {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.po-line {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.po-line .button {
  align-self: end;
}

@media (max-width: 720px) {
  .po-line {
    grid-template-columns: 1fr 1fr;
  }
}

.tracking-toggle {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.drawer {
  width: min(100%, 560px);
  height: 100vh;
  overflow: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.drawer-header {
  padding: 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.drawer-header h2 {
  margin: 0 0 10px;
  font-size: 22px;
}

.drawer-content {
  padding: 18px 22px 28px;
}

.detail-section {
  border-bottom: 1px solid var(--line);
  padding: 18px 0;
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.empty-state {
  padding: 34px;
  text-align: center;
  color: var(--muted);
}

.empty-state.compact {
  padding: 16px;
  text-align: left;
}

.policy-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.policy-detail-grid div,
.attachment-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.policy-detail-grid div {
  padding: 12px;
}

.policy-detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.policy-detail-grid strong {
  color: var(--text);
  font-size: 14px;
}

.attachment-list {
  display: grid;
  gap: 10px;
}

.attachment-row {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 12px;
}

.attachment-icon {
  width: 20px;
  height: 20px;
  color: var(--brand-violet);
}

.attachment-row p {
  margin: 4px 0 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: var(--muted);
}

.status-dot.success {
  background: var(--success);
}

.status-dot.warning {
  background: var(--warning);
}

.status-dot.danger {
  background: var(--danger);
}

.status-dot.violet {
  background: var(--brand-violet);
}

@media (max-width: 1040px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .app-switcher-copy,
  .app-switcher .switcher-icon,
  .org-copy,
  .org-switcher .switcher-icon,
  .user-menu .rail-title,
  .user-menu .switcher-icon,
  .theme-row,
  .rail-copy,
  .sidebar-label,
  .sidebar-search-wrap,
  .user-menu-panel {
    display: none;
  }

  .sidebar-brand {
    justify-content: center;
    padding: 22px 12px;
  }

  .app-switcher-trigger {
    justify-content: center;
    padding: 8px;
  }

  .app-switcher-menu {
    left: 72px;
    right: auto;
    top: 16px;
    width: 250px;
  }

  .org-switcher,
  .organization-link {
    padding: 10px;
  }

  .org-switcher-trigger,
  .user-menu-trigger,
  .rail-button,
  .nav-link {
    justify-content: center;
    padding: 10px;
  }

  .user-menu-identity {
    justify-content: center;
  }

  .user-menu {
    position: relative;
  }

  .user-menu-panel {
    position: absolute;
    left: 76px;
    bottom: 8px;
    z-index: 30;
    width: 250px;
    display: grid;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
    padding: 8px;
  }

  .user-menu-panel .nav-link {
    justify-content: flex-start;
    padding: 8px 12px;
  }

  .user-menu-panel .rail-copy {
    display: grid;
  }

  .user-menu-panel .rail-title {
    display: block;
  }

  .user-menu-panel .theme-row {
    display: flex;
  }

  .main-grid,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .dense-filters {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .auth-page {
    grid-template-rows: 170px 1fr;
  }

  .brand-lockup {
    font-size: 38px;
    letter-spacing: 5px;
  }

  .app-shell {
    display: block;
  }

  .sidebar {
    min-height: auto;
    grid-template-rows: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-scroll,
  .organization-link,
  .user-menu {
    display: none;
  }

  .topbar,
  .workspace {
    padding: 18px;
  }

  .topbar-row,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .metric-grid,
  .main-grid {
    grid-template-columns: 1fr;
  }

  .dense-filters {
    grid-template-columns: 1fr;
  }

  .page-heading-row,
  .training-card {
    align-items: stretch;
    flex-direction: column;
  }

  .data-table {
    display: block;
    overflow-x: auto;
  }
}

/* ----- Work-instruction images + operator measurement entry + PIN modal ----- */
.step-instructions {
  white-space: pre-line;
}
.step-image-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0;
}
.step-image {
  margin: 0;
}
.step-image img {
  max-width: 220px;
  max-height: 170px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: block;
  background: var(--soft-surface);
}
.step-image figcaption {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  max-width: 220px;
}
.measure-entry {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
  padding: 10px 12px;
  background: var(--soft-surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.measure-row {
  display: grid;
  grid-template-columns: 1fr 140px 88px;
  gap: 10px;
  align-items: center;
}
.measure-row label {
  font-size: 13px;
  color: var(--text);
}
.measure-row .req {
  color: var(--danger);
}
.measure-row [data-measure-verdict] {
  text-align: center;
  justify-self: stretch;
}
.pin-input {
  letter-spacing: 0.5em;
  font-size: 18px;
  text-align: center;
  max-width: 200px;
}
@media (max-width: 720px) {
  .measure-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ----- Work-instruction / BOM authoring controls ----- */
.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
  margin: 4px 0;
}
.checkbox-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--brand-violet);
}
[data-routing-row] input[type="file"] {
  font-size: 12px;
  color: var(--muted);
}
.step-image {
  position: relative;
}
.thumb-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--danger);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}
[data-step-measure-row],
[data-bom-row],
[data-routing-row] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: var(--soft-surface);
}

/* ----- Demand tracker (pegged order tree) ----- */
.clickable-row {
  cursor: pointer;
}
.clickable-row:hover {
  background: var(--soft-surface);
}
.tracker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}
.tracker-leaf-spacer {
  display: inline-block;
  width: 28px;
}
.tracker-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  color: inherit;
}
.tracker-label[disabled] {
  cursor: default;
}
.tracker-label:not([disabled]):hover .mini-row-title {
  color: var(--brand-magenta, #d6248f);
  text-decoration: underline;
}
.tracker-badges {
  margin-left: auto;
  align-items: center;
}

/* Small inline icon for in-table links (e.g. "View in DLM ↗") */
.inline-icon {
  width: 13px;
  height: 13px;
  vertical-align: -2px;
  stroke: currentColor;
}

/* Condensed BOM editor rows: one component per line */
.bom-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.bom-row .field {
  margin-bottom: 0;
}
.bom-row .bom-component {
  flex: 1 1 auto;
}
.bom-row .bom-qty {
  flex: 0 0 110px;
}
.bom-row .bom-uom {
  flex: 0 0 72px;
}
.bom-row .bom-uom-value {
  height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text);
}
.bom-row .bom-remove {
  flex: 0 0 auto;
}

/* Products multi-select (checkbox list) on part details / create */
.product-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  padding: 4px 0;
}
.product-picker .checkbox-row {
  margin: 0;
}
