/* BAP legacy database additions on top of the OMS shared stylesheet. */

:root {
  --bap-good: #15803d;
  --bap-warn: #b45309;
  --bap-info: #2563eb;
  --bap-tile-shadow: -3px 4px 8px rgba(0, 0, 0, 0.14), 0 5px 14px rgba(0, 0, 0, 0.18), 0 1px 0 rgba(255, 255, 255, 0.035) inset;
  --bap-tile-shadow-hover: -5px 7px 12px rgba(0, 0, 0, 0.18), 0 8px 18px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.045) inset;
}

/* Fix rail/content seam without pulling cards underneath the fixed nav rail. */
.bap-main {
  gap: 12px;
  position: relative;
  isolation: isolate;
}

.bap-main::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 24px;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(10, 14, 28, 0.94) 0%, rgba(16, 24, 42, 0.72) 56%, rgba(16, 24, 42, 0) 100%);
}

.bap-main > * {
  position: relative;
  z-index: 1;
}

.app-title-block {
  min-width: 0;
}

.brand-title strong {
  color: #fff;
  font-weight: 500;
}

.active-users-tracker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  max-width: 320px;
  padding: 3px 8px 3px 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: var(--r-pill);
  background: rgba(15, 28, 48, 0.72);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 5px 14px rgba(0, 0, 0, 0.18);
}

.active-users-count {
  color: rgba(226, 232, 240, 0.82);
  font-family: var(--font-head);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.active-users-tracker .active-users {
  gap: 4px;
  min-height: 28px;
  max-width: 176px;
  overflow: hidden;
}

.active-users-tracker .user-badge {
  position: relative;
  width: 28px;
  height: 28px;
  border-color: rgba(255, 255, 255, 0.32);
  background: #3a557a;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 400;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.active-users-tracker .user-badge::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 9px;
  height: 9px;
  border: 2px solid rgba(15, 28, 48, 0.95);
  border-radius: 50%;
  background: #22c55e;
}

.active-users-tracker .user-badge.more::after {
  display: none;
}

body:not(.dark-mode) .active-users-tracker {
  background: rgba(205, 220, 239, 0.82);
  border-color: rgba(20, 35, 58, 0.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset, 0 4px 12px rgba(15, 23, 42, 0.12);
}

body:not(.dark-mode) .active-users-count {
  color: #2f4565;
}

body:not(.dark-mode) .active-users-tracker .user-badge {
  border-color: rgba(20, 35, 58, 0.22);
  background: #e5eef9;
  color: #14233a;
}

body:not(.dark-mode) .active-users-tracker .user-badge::after {
  border-color: rgba(205, 220, 239, 0.98);
}

@media (max-width: 760px) {
  .active-users-tracker {
    gap: 4px;
    min-height: 30px;
    max-width: 112px;
    padding: 2px 5px;
  }

  .active-users-count {
    display: none;
  }

  .active-users-tracker .active-users {
    max-width: 92px;
  }

  .active-users-tracker .user-badge {
    width: 26px;
    height: 26px;
    font-size: 0.56rem;
  }
}

.bap-card {
  padding: 16px;
  box-shadow: var(--shadow);
}

.app-rail,
.bap-main,
.bap-main * {
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.24) transparent;
}

body.dark-mode .app-rail,
body.dark-mode .bap-main,
body.dark-mode .bap-main * {
  scrollbar-color: rgba(226, 232, 240, 0.18) transparent;
}

.app-rail::-webkit-scrollbar,
.bap-main::-webkit-scrollbar,
.bap-main *::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.app-rail::-webkit-scrollbar-track,
.bap-main::-webkit-scrollbar-track,
.bap-main *::-webkit-scrollbar-track {
  background: transparent;
}

.app-rail::-webkit-scrollbar-thumb,
.bap-main::-webkit-scrollbar-thumb,
.bap-main *::-webkit-scrollbar-thumb {
  min-height: 28px;
  border: 2px solid transparent;
  border-radius: 999px;
  background-color: rgba(100, 116, 139, 0.24);
  background-clip: content-box;
}

body.dark-mode .app-rail::-webkit-scrollbar-thumb,
body.dark-mode .bap-main::-webkit-scrollbar-thumb,
body.dark-mode .bap-main *::-webkit-scrollbar-thumb {
  background-color: rgba(226, 232, 240, 0.18);
}

.app-rail::-webkit-scrollbar-thumb:hover,
.bap-main::-webkit-scrollbar-thumb:hover,
.bap-main *::-webkit-scrollbar-thumb:hover {
  background-color: rgba(100, 116, 139, 0.38);
}

body.dark-mode .app-rail::-webkit-scrollbar-thumb:hover,
body.dark-mode .bap-main::-webkit-scrollbar-thumb:hover,
body.dark-mode .bap-main *::-webkit-scrollbar-thumb:hover {
  background-color: rgba(226, 232, 240, 0.32);
}

.app-rail::-webkit-scrollbar-corner,
.bap-main::-webkit-scrollbar-corner,
.bap-main *::-webkit-scrollbar-corner {
  background: transparent;
}

.tab-panel {
  display: none;
  min-height: 0;
  overflow: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab-panel.active > .card,
.tab-panel.active > .home-grid,
.tab-panel.active > .detail-grid,
.tab-panel.active > .results-grid {
  flex: 0 0 auto;
}

.home-landing {
  display: grid;
  gap: 12px;
  margin-left: 0;
  width: auto;
  padding: 0;
  overflow: visible;
}

.tab-panel:not(#homeTab) > .bap-card:first-child {
  position: relative;
  overflow: hidden;
  min-height: 116px;
  border: 1px solid rgba(244, 84, 35, 0.38);
  border-top: 3px solid var(--orange);
  color: #f8fafc;
  background:
    linear-gradient(90deg, rgba(8, 13, 28, 0.94) 0%, rgba(12, 21, 40, 0.86) 52%, rgba(10, 17, 32, 0.7) 100%),
    url('../assets/home-hero-bg-V3_0.jpg?v=20260612-home-bg-v2');
  background-size: cover;
  background-position: center 62%;
  background-repeat: no-repeat;
  box-shadow: -3px 5px 10px rgba(0, 0, 0, 0.14), 0 7px 18px rgba(0, 0, 0, 0.18);
}

.tab-panel:not(#homeTab) > .bap-card:first-child::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 116, 67, 0.11) 0%, rgba(255, 116, 67, 0) 48%);
  pointer-events: none;
}

.tab-panel:not(#homeTab) > .bap-card:first-child > * {
  position: relative;
  z-index: 1;
}

.tab-panel:not(#homeTab) > .bap-card:first-child .section-head h2,
.tab-panel:not(#homeTab) > .bap-card:first-child .section-head h3 {
  color: #fff;
}

.tab-panel:not(#homeTab) > .bap-card:first-child .subtle,
.tab-panel:not(#homeTab) > .bap-card:first-child .field-label {
  color: rgba(226, 232, 240, 0.78);
}

.tab-panel:not(#homeTab) > .bap-card:first-child input,
.tab-panel:not(#homeTab) > .bap-card:first-child select {
  background: rgba(26, 43, 70, 0.86);
  border-color: rgba(148, 163, 184, 0.42);
  border-bottom-color: rgba(148, 163, 184, 0.58);
  color: #f8fafc;
}

.tab-panel:not(#homeTab) > .bap-card:first-child input::placeholder {
  color: rgba(226, 232, 240, 0.54);
}

@media (min-width: 901px) and (max-width: 1180px) {
  .bap-main::before {
    width: 14px;
  }
}

@media (max-width: 900px) {
  .bap-main::before {
    display: none;
  }
}

.landing-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 170px;
  padding: 24px;
  border: 1px solid rgba(244, 84, 35, 0.38);
  border-top: 3px solid var(--orange);
  color: #f8fafc;
  background:
    linear-gradient(90deg, rgba(8, 13, 28, 0.94) 0%, rgba(12, 21, 40, 0.86) 48%, rgba(10, 17, 32, 0.68) 100%),
    url('../assets/home-hero-bg-V3_0.jpg?v=20260612-home-bg-v2');
  background-size: cover;
  background-position: center 62%;
  background-repeat: no-repeat;
  box-shadow: -3px 5px 10px rgba(0, 0, 0, 0.14), 0 7px 18px rgba(0, 0, 0, 0.18);
}

.landing-hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 116, 67, 0.12) 0%, rgba(255, 116, 67, 0) 44%);
  pointer-events: none;
}

.landing-hero > * {
  position: relative;
  z-index: 1;
}

.landing-copy {
  min-width: 0;
}

.landing-eyebrow,
.shortcut-kicker {
  color: var(--orange);
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.landing-hero h1 {
  margin: 7px 0 6px;
  color: #fff;
  font-family: var(--font-head);
  font-size: 1.05rem;
  line-height: 1.05;
  letter-spacing: 0;
}

.landing-lede {
  max-width: 760px;
  margin: 0;
  color: rgba(226, 232, 240, 0.82);
  line-height: 1.5;
}

.landing-hero-side {
  display: grid;
  gap: 12px;
  justify-items: end;
}

.landing-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.landing-metrics {
  margin-top: 0;
}

.landing-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow: visible;
}

.shortcut-card {
  display: grid;
  gap: 6px;
  min-height: 116px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(244, 84, 35, 0.38);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  box-shadow: var(--bap-tile-shadow);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  overflow: hidden;
}

.shortcut-card:hover,
.shortcut-card:focus-visible {
  border-color: var(--orange);
  border-left-color: var(--orange);
  background: linear-gradient(180deg, rgba(44, 61, 91, 0.96), rgba(32, 47, 76, 0.96));
  box-shadow: var(--bap-tile-shadow-hover);
  outline: none;
}

body:not(.dark-mode) .shortcut-card {
  border-color: rgba(20, 35, 58, 0.14);
  border-left-color: rgba(244, 84, 35, 0.44);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04)), var(--card-2);
  box-shadow: -3px 4px 8px rgba(20, 35, 58, 0.1), 0 5px 14px rgba(20, 35, 58, 0.1), 0 1px 0 rgba(255, 255, 255, 0.36) inset;
}

body:not(.dark-mode) .shortcut-card:hover,
body:not(.dark-mode) .shortcut-card:focus-visible {
  border-color: rgba(244, 84, 35, 0.72);
  border-left-color: var(--orange);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.08)), var(--card-3);
  box-shadow: -5px 7px 12px rgba(20, 35, 58, 0.13), 0 8px 18px rgba(20, 35, 58, 0.13), 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.shortcut-card strong {
  font-family: var(--font-head);
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.shortcut-card span:last-child {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.home-grid,
.detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  gap: 12px;
  min-height: 0;
}

.pr-detail-stack {
  grid-template-columns: minmax(0, 1fr);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow: visible;
}

.metric {
  position: relative;
  min-height: 96px;
  padding: 14px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-top: 3px solid var(--orange);
  box-shadow: var(--shadow);
}

body.dark-mode .metric,
body.dark-mode .bap-card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border-color: rgba(255, 255, 255, 0.08);
  border-top-color: rgba(244, 84, 35, 0.38);
  box-shadow: var(--bap-tile-shadow);
  overflow: hidden;
}

body.dark-mode .metric {
  border-radius: 16px;
}

.metric span {
  display: block;
}

.metric-label {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 8px;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.metric-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

.search-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) repeat(3, auto);
  gap: 8px;
  align-items: end;
}

.filters-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
  align-items: end;
}

.search-row .btn,
.filters-row .btn {
  white-space: nowrap;
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-head h2,
.section-head h3 {
  margin: 0;
  color: var(--text);
  font-family: var(--font-head);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.section-head h2 {
  font-size: 1.2rem;
}

.section-head h3 {
  font-size: 0.95rem;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  background: var(--card-2);
  color: var(--text-2);
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.good {
  color: var(--bap-good);
  border-color: rgba(21, 128, 61, 0.25);
  background: rgba(21, 128, 61, 0.08);
}

.status-pill.warn {
  color: var(--bap-warn);
  border-color: rgba(180, 83, 9, 0.28);
  background: rgba(180, 83, 9, 0.08);
}

.rail-group-wrap,
.rail-links {
  margin-top: 8px;
}

.rail-link {
  text-decoration: none;
}

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

.result-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-row,
.detail-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: var(--card-2);
}

.result-row:hover,
.detail-row:hover {
  border-color: var(--orange);
  background: var(--row-hover);
}

.result-title {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.result-meta {
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.detail-panel {
  border: 1px solid var(--line);
  background: var(--card);
  min-height: 160px;
  padding: 14px;
}

.detail-title {
  margin: 0 0 4px;
  color: var(--text);
  font-family: var(--font-head);
  font-size: 1.2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.detail-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.export-link {
  text-decoration: none;
}

.kv-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.pr-summary-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 6px;
  margin: 8px 0 10px;
}

.pr-summary-grid .pr-summary-kv {
  flex: 0 1 min(100%, var(--kv-width, 18ch));
  width: min(100%, var(--kv-width, 18ch));
  max-width: min(100%, var(--kv-width, 18ch));
  padding: 6px 8px;
}

.pr-summary-grid .kv-label {
  font-size: 0.56rem;
  letter-spacing: 0.08em;
}

.pr-summary-grid .kv-value {
  margin-top: 3px;
  line-height: 1.24;
}

.pr-summary-grid .table-action {
  max-width: 100%;
  justify-content: flex-start;
}

.detail-summary-section {
  margin-top: 14px;
}

.detail-summary-section .section-head {
  margin-bottom: 8px;
}

.detail-summary-section .kv-grid {
  margin-top: 0;
}

.kv {
  padding: 8px;
  background: var(--card-2);
  border: 1px solid var(--line);
  min-width: 0;
}

.kv-label {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.kv-value {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.inventory-summary {
  display: grid;
  gap: 3px;
  min-width: 190px;
  white-space: normal;
}

.inventory-summary-head,
.inventory-summary-row {
  display: grid;
  grid-template-columns: minmax(78px, 0.9fr) minmax(108px, 1.1fr);
  gap: 8px;
  align-items: baseline;
}

.inventory-summary-head {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.62rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.inventory-summary-row span:first-child {
  color: var(--muted);
  font-weight: 500;
}

.inventory-summary-row span:last-child {
  font-variant-numeric: tabular-nums;
}

.bom-master-panel {
  display: grid;
  gap: 10px;
}

.bom-item-id {
  color: #dc2626;
}

.bom-status {
  color: #047857;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

.bom-master-desc {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

.bom-master-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.costing-panel {
  padding: 10px;
  border: 1px solid var(--line);
  background: var(--card);
}

.legacy-section-title {
  margin: 0;
  color: #dc2626;
  font-family: var(--font-head);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: none;
}

.bom-cost-method {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}

.bom-cost-method strong {
  color: var(--text);
  font-size: 0.8rem;
}

.costing-wrap {
  max-height: 320px;
  margin-top: 0;
}

.costing-table td:first-child {
  font-weight: 800;
}

.image-section-head {
  margin-top: 14px;
}

.item-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 10px 0 14px;
}

.item-photo-card {
  display: grid;
  grid-template-rows: 124px auto;
  gap: 7px;
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  text-decoration: none;
}

.item-photo-card:hover {
  border-color: var(--orange);
  background: var(--row-hover);
}

.item-photo-card img {
  width: 100%;
  height: 124px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
}

.item-photo-card span {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap.compact {
  max-height: 56vh;
}

#prTable .table-wrap.compact {
  /* Sticky header, ten standard PR rows, and the wrapper borders. */
  max-height: min(424px, 56vh);
}

.table-wrap.detail-table {
  max-height: 320px;
  margin-top: 8px;
}

.sortable-head {
  appearance: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: left;
  text-transform: inherit;
  cursor: pointer;
}

.sortable-head:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.sort-mark {
  position: relative;
  flex: 0 0 8px;
  width: 8px;
  height: 12px;
  margin-bottom: 1px;
  color: currentColor;
  opacity: 0.72;
}

.sort-mark::before,
.sort-mark::after {
  content: '';
  position: absolute;
  left: 0;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  opacity: 0.34;
}

.sort-mark::before {
  top: 0;
  border-bottom: 5px solid currentColor;
}

.sort-mark::after {
  bottom: 0;
  border-top: 5px solid currentColor;
}

th[aria-sort="ascending"] .sort-mark::before,
th[aria-sort="descending"] .sort-mark::after {
  opacity: 1;
}

th[aria-sort="ascending"] .sort-mark::after,
th[aria-sort="descending"] .sort-mark::before {
  opacity: 0.16;
}

.doc-link {
  color: #1d4ed8;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}

.doc-link-list {
  display: grid;
  gap: 4px;
  min-width: 180px;
}

.doc-link-list .doc-link {
  display: block;
}

.table-action {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: #1d4ed8;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}

.table-action:hover,
.table-action:focus-visible {
  color: var(--orange);
  text-decoration: underline;
  outline: none;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  background: var(--card-2);
}

.pr-line-coverage {
  margin: 8px 0 10px;
  border-left: 4px solid var(--bap-warn);
  text-align: left;
}

.source-warning {
  border-left: 4px solid var(--bap-warn);
}

.source-good {
  border-left: 4px solid var(--bap-good);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.password-editor {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 8px;
  margin-top: 8px;
}

.admin-users-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 12px;
}

.admin-users-search-field {
  display: grid;
  gap: 4px;
  min-width: min(360px, 100%);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.admin-users-table-wrap {
  max-height: calc(100vh - 330px);
}

.users-table-lite {
  min-width: 1180px;
}

.users-table-lite th,
.users-table-lite td {
  vertical-align: top;
}

.users-table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-group-row td {
  background: var(--card-3);
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.inactive-user-row {
  opacity: 0.72;
}

.inactive-user-row td {
  background: rgba(148, 163, 184, 0.06);
}

.wide-table td {
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wide-table td.wrap-cell {
  white-space: normal;
  overflow-wrap: anywhere;
  max-width: 520px;
}

tr.selectable-row {
  cursor: pointer;
}

tr.selectable-row td:first-child {
  border-left: 3px solid transparent;
}

tr.selectable-row:hover,
tr.selectable-row:focus-within,
tr.selectable-row.selected-row {
  background: var(--row-hover);
}

tr.selectable-row.selected-row td:first-child {
  border-left-color: var(--orange);
}

.login-page-card {
  max-width: 420px;
  margin: 18px 24px 0;
}

.login-page-card .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#loginErr {
  color: var(--danger);
  margin-top: 8px;
}

@media (max-width: 1100px) {
  .home-grid,
  .detail-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .filters-row,
  .landing-shortcuts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .landing-hero {
    grid-template-columns: 1fr;
  }

  .landing-hero-side {
    justify-items: start;
  }

  .landing-links {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .home-landing {
    padding-left: 10px;
    padding-right: 10px;
  }

  .search-row,
  .filters-row,
  .metric-grid,
  .kv-grid,
  .bom-master-meta,
  .landing-shortcuts,
  .password-editor,
  .user-editor-grid {
    grid-template-columns: 1fr;
  }

  .landing-hero {
    min-height: 0;
    padding: 18px;
  }

  .landing-hero h1 {
    font-size: 1.05rem;
  }

  .auth-box {
    min-width: 0;
  }

  .login-page-card {
    margin: 12px;
  }

  .button-row {
    justify-content: flex-start;
  }
}

@media (max-width: 820px) {
  .app-rail .rail-group-wrap,
  .app-rail .rail-links {
    display: flex;
    flex-direction: row;
    align-items: stretch;
    gap: 6px;
    margin: 0;
    padding: 0;
    min-width: max-content;
  }
}

/* Complete light theme. Dark mode remains defined by the existing shared rules. */
body:not(.dark-mode) {
  --surface: #f3f6fa;
  --surface-2: #edf2f7;
  --surface-3: #e3eaf3;
  --card: #ffffff;
  --card-2: #f8fafc;
  --card-3: #eef3f8;
  --glass: rgba(255, 255, 255, 0.94);
  --glass-border: rgba(20, 35, 58, 0.1);
  --text: #152033;
  --text-2: #3e4b5f;
  --text-3: #66758a;
  --muted: #66758a;
  --line: rgba(20, 35, 58, 0.1);
  --line-2: rgba(20, 35, 58, 0.12);
  --line-strong: rgba(20, 35, 58, 0.18);
  --row-odd: #ffffff;
  --row-even: #f8fafc;
  --row-hover: #edf4fb;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow: 0 5px 18px rgba(15, 23, 42, 0.09), 0 1px 4px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 14px 38px rgba(15, 23, 42, 0.12), 0 4px 12px rgba(15, 23, 42, 0.06);
  color-scheme: light;
  color: var(--text);
  background: var(--surface);
}

body:not(.dark-mode)::before {
  background:
    radial-gradient(ellipse 75% 48% at 15% 0%, rgba(244, 84, 35, 0.07) 0%, transparent 58%),
    radial-gradient(ellipse 60% 42% at 92% 8%, rgba(37, 99, 235, 0.045) 0%, transparent 54%),
    linear-gradient(180deg, #f8fafc 0%, var(--surface) 48%, #edf2f7 100%);
}

body:not(.dark-mode) .topbar {
  color: var(--text);
  background: rgba(255, 255, 255, 0.95);
  border-bottom-color: var(--orange);
  box-shadow: 0 2px 0 rgba(244, 84, 35, 0.16), 0 5px 18px rgba(15, 23, 42, 0.09);
}

body:not(.dark-mode) .brand-title,
body:not(.dark-mode) .brand-title strong,
body:not(.dark-mode) .auth-name {
  color: var(--navy);
}

body:not(.dark-mode) .brand-sub,
body:not(.dark-mode) .auth-title,
body:not(.dark-mode) .auth-email,
body:not(.dark-mode) .auth-state {
  color: var(--muted);
}

body:not(.dark-mode) .active-users-tracker {
  background: var(--card-2);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

body:not(.dark-mode) .active-users-count {
  color: var(--text-2);
}

body:not(.dark-mode) .active-users-tracker .user-badge {
  border-color: var(--line-strong);
  background: var(--card);
  color: var(--navy);
}

body:not(.dark-mode) .active-users-tracker .user-badge::after {
  border-color: var(--card-2);
}

body:not(.dark-mode) .btn-alt {
  color: var(--navy);
  background: var(--card);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

body:not(.dark-mode) .btn-alt:hover {
  color: var(--orange-hover);
  background: #fff6f2;
  border-color: rgba(244, 84, 35, 0.48);
}

body:not(.dark-mode) .app-shell,
body:not(.dark-mode) .app-main,
body:not(.dark-mode) .bap-main {
  background: transparent;
}

body:not(.dark-mode) .bap-main::before {
  background: linear-gradient(90deg, rgba(20, 35, 58, 0.08) 0%, rgba(20, 35, 58, 0.025) 56%, transparent 100%);
}

body:not(.dark-mode) .app-rail {
  background-color: #f8fafc;
  background-image: url('../assets/home-hero-bg-V3_0.jpg?v=20260612-home-bg-v2');
  border-right: 1px solid var(--line-strong);
  box-shadow: 5px 0 18px rgba(15, 23, 42, 0.07);
}

body:not(.dark-mode) .app-rail::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86) 0%, rgba(248, 250, 252, 0.89) 48%, rgba(238, 243, 248, 0.92) 100%);
}

body:not(.dark-mode) .rail-section-title {
  color: var(--orange-hover);
  border-bottom-color: rgba(244, 84, 35, 0.22);
}

body:not(.dark-mode) .rail-btn,
body:not(.dark-mode) .rail-caret {
  color: #526177;
}

body:not(.dark-mode) .rail-btn:hover,
body:not(.dark-mode) .rail-btn.active,
body:not(.dark-mode) .rail-group.has-active > .rail-group-btn {
  color: var(--navy);
  background: rgba(244, 84, 35, 0.1);
  border-left-color: var(--orange);
}

body:not(.dark-mode) .rail-btn.static:hover,
body:not(.dark-mode) .rail-btn.static.active {
  color: #526177;
  background: transparent;
  border-left-color: transparent;
}

body:not(.dark-mode) .rail-icon {
  color: var(--orange-hover);
  opacity: 0.88;
}

body:not(.dark-mode) .landing-hero,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child {
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.9) 0%, rgba(248, 250, 252, 0.86) 52%, rgba(238, 243, 248, 0.82) 100%),
    url('../assets/home-hero-bg-V3_0.jpg?v=20260612-home-bg-v2');
  background-size: cover;
  background-position: center 62%;
  background-repeat: no-repeat;
  border-color: rgba(244, 84, 35, 0.28);
  border-top-color: var(--orange);
  box-shadow: var(--shadow);
}

body:not(.dark-mode) .landing-hero::after,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child::after {
  background: linear-gradient(105deg, rgba(244, 84, 35, 0.09) 0%, rgba(244, 84, 35, 0.02) 38%, transparent 68%);
}

body:not(.dark-mode) .landing-hero h1,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child .section-head h2,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child .section-head h3 {
  color: var(--navy);
}

body:not(.dark-mode) .landing-lede,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child .subtle,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child .field-label {
  color: var(--muted);
}

body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child input,
body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child select {
  color: var(--text);
  background: var(--card);
  border-color: #c5d0dd;
  border-bottom-color: #aebdce;
}

body:not(.dark-mode) .tab-panel:not(#homeTab) > .bap-card:first-child input::placeholder {
  color: var(--text-3);
}

body:not(.dark-mode) .card,
body:not(.dark-mode) .bap-card,
body:not(.dark-mode) .metric,
body:not(.dark-mode) .table-wrap {
  background-color: var(--card);
}

body:not(.dark-mode) .shortcut-card {
  background: var(--card);
}

body:not(.dark-mode) th {
  color: var(--navy);
  background: var(--card-3);
  border-bottom-color: var(--orange);
}

body:not(.dark-mode) tbody tr:nth-child(odd) {
  background: var(--row-odd);
}

body:not(.dark-mode) tbody tr:nth-child(even) {
  background: var(--row-even);
}

@media (max-width: 820px) {
  body:not(.dark-mode) .app-rail {
    background-color: #f8fafc;
    background-image: url('../assets/home-hero-bg-V3_0.jpg?v=20260612-home-bg-v2');
    border-top: 1px solid var(--line-strong);
    border-right: 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.12);
  }

  body:not(.dark-mode) .app-rail::after {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.88) 0%, rgba(248, 250, 252, 0.9) 50%, rgba(238, 243, 248, 0.93) 100%);
  }

  body:not(.dark-mode) .rail-btn,
  body:not(.dark-mode) .rail-btn.rail-child {
    color: #526177;
    background: rgba(20, 35, 58, 0.035);
    border-color: rgba(20, 35, 58, 0.08);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  }

  body:not(.dark-mode) .rail-btn:hover,
  body:not(.dark-mode) .rail-btn.active {
    color: var(--navy);
    background: rgba(244, 84, 35, 0.1);
    border-left-color: rgba(20, 35, 58, 0.08);
    border-bottom-color: var(--orange);
  }
}
