:root {
  --lq-brand: #1f4e79;
  --lq-brand-dark: #163a5a;
  --lq-accent: #2a9d8f;
  --lq-surface: #f3f6f9;
  /* 3D viewer stage only. Keep identical to STAGE_BACKGROUND_HEX in scene.js. */
  --ws-stage: #cdcdcd;
}

body {
  background: var(--lq-surface);
}

.nav-sidebar .nav-link.active {
  background-color: var(--lq-brand);
  color: #fff;
}

.content-wrapper {
  min-height: calc(100vh - 3.5rem);
}

.login-page {
  background: linear-gradient(145deg, #163a5a 0%, #1f4e79 45%, #2a9d8f 100%);
}

.login-card {
  border: 0;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.login-helper {
  margin: 0;
}

.login-helper a {
  font-size: 0.875rem;
}

.table thead th a {
  color: inherit;
  text-decoration: none;
}

.badge-status {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.03em;
}

.empty-state {
  padding: 2.5rem 1rem;
  text-align: center;
  color: #6c757d;
}

.flash-stack {
  position: sticky;
  top: 0.75rem;
  z-index: 1030;
}

/*
 * Form footers. A form with class "card" is a column flex container
 * (AdminLTE .card), so unwrapped buttons stretch to full width and stack.
 * Keep primary and secondary actions in this row instead.
 */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.form-actions > .btn,
.form-actions > form {
  width: auto;
  flex: 0 0 auto;
}

/*
 * Project-tree page header. Breadcrumb is a quiet text trail. Back sits on
 * the right of that trail (`.page-header-nav`), not in the action cluster.
 * Title and meta sit left of the title row; other actions sit right.
 */
.page-header {
  margin-bottom: 1rem;
}

.page-header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  width: 100%;
  margin: 0 0 30px;
  padding: 0 0 0.35rem;
  border-bottom: 1px solid #e9ecef;
}

.page-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0.25rem 0.15rem 0.25rem 0.85rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--lq-brand);
  background: transparent;
  border: 0;
  border-left: 1px solid #dee2e6;
  text-decoration: none;
  white-space: nowrap;
}

.page-back i {
  font-size: 0.7rem;
}

.page-back:hover,
.page-back:focus {
  color: var(--lq-brand-dark);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.page-breadcrumb {
  --bs-breadcrumb-divider: ">";
  --bs-breadcrumb-divider-color: #adb5bd;
  --bs-breadcrumb-item-active-color: #495057;
  flex: 1 1 12rem;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.page-breadcrumb .breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  background: transparent;
  margin: 0;
  padding: 0;
  font-size: 0.8125rem;
  line-height: 1.3;
  justify-content: flex-start;
  float: none;
}

.page-breadcrumb .breadcrumb-item {
  color: #6c757d;
  font-weight: 400;
}

.page-breadcrumb .breadcrumb-item.active {
  color: #495057;
  font-weight: 500;
}

.page-breadcrumb .breadcrumb-item a {
  color: #6c757d;
  text-decoration: none;
}

.page-breadcrumb .breadcrumb-item a:hover,
.page-breadcrumb .breadcrumb-item a:focus-visible {
  color: var(--lq-brand);
  text-decoration: underline;
  text-underline-offset: 0.12em;
}

.page-breadcrumb .breadcrumb-item + .breadcrumb-item {
  padding-left: 0.5rem;
}

.page-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  float: none;
  padding-right: 0.5rem;
  color: #adb5bd;
  content: ">";
}

/*
 * Page title row: heading left, other actions right.
 * Back is not here; it lives in .page-header-nav.
 * Do not put Back in .form-actions; that row is Save/Cancel at the form footer.
 */
.page-header-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.page-header-title h1,
.page-header-bar > h1 {
  margin-top: 0;
  margin-bottom: 0;
}

.page-header-meta {
  margin: 0.25rem 0 0;
  color: #6c757d;
  font-size: 0.875rem;
}

.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.page-header-actions > .btn,
.page-header-actions > form {
  width: auto;
  flex: 0 0 auto;
}

/*
 * Search typeahead. Positioned under the field without changing input-group
 * flex (the list is a sibling of the input-group, not a child of it).
 */
.search-suggest {
  position: relative;
  width: 100%;
}

.search-suggest-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 1050;
  display: none;
  margin-top: 0.125rem;
  max-height: 20rem;
  overflow-y: auto;
  list-style: none;
}

.search-suggest-menu.show {
  display: block;
}

/*
 * Navbar search. AdminLTE's default is ~200px; give more room to type
 * without filling the header. Scoped to .navbar so the Search page form
 * stays full-width of its card.
 */
.navbar .search-suggest {
  width: 22.5rem; /* 360px at 16px root */
  max-width: 100%;
}

.navbar .search-suggest .input-group {
  width: 100%;
}

.navbar .search-suggest .form-control {
  flex: 1 1 auto;
  min-width: 0;
}

.navbar .search-suggest-menu {
  width: 100%;
  min-width: 0;
  right: 0;
}

@media (max-width: 767.98px) {
  .navbar .search-suggest {
    width: 16rem;
  }
}

.search-suggest-item.is-active,
.search-suggest-item:hover {
  background-color: #e9ecef;
}

.search-suggest-status {
  cursor: default;
  color: #6c757d;
}

/*
 * Dashboard stat row. Four AdminLTE small-boxes of equal height.
 * Columns stretch; the box fills the column so a storage card with a
 * progress bar does not sit shorter than the count cards.
 */
.dashboard-stat-row > [class*="col-"] {
  display: flex;
}

.dashboard-stat {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 1rem;
}

.dashboard-stat .inner {
  flex: 1 1 auto;
}

.dashboard-stat-progress {
  height: 0.4rem;
  margin: 0 0 0.5rem;
  background-color: rgba(255, 255, 255, 0.35);
}

.dashboard-stat-progress .progress-bar {
  background-color: #fff;
}

/* AdminLTE 3.2 .bg-indigo sets the fill but not text color. */
.dashboard-stat.bg-indigo {
  color: #fff;
}

.dashboard-stat-meta {
  font-size: 0.8rem;
  opacity: 0.9;
}

/*
 * Document detail review surface (FR-86). Left pane is the 3D embed or
 * empty-state uploader; right rail is Revision History, Related, Evidence.
 * Override Bootstrap .mb-3 (1rem) so the three stacked cards have a
 * consistent 1.5rem gap below each block.
 */
.document-show-rail > .card {
  margin-bottom: 1.5rem !important;
}

.document-preview-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 560px;
  min-height: 560px;
  background: var(--ws-stage);
  border: 1px solid #343a40;
  border-radius: 0.25rem;
  overflow: hidden;
}

@media (min-width: 992px) {
  .document-preview-pane {
    height: calc(100vh - 14rem);
  }

  .document-preview-pane.is-empty,
  .document-preview-pane.is-message {
    height: auto;
    min-height: 0;
  }
}

.document-preview-pane.is-empty,
.document-preview-pane.is-message {
  background: #f8f9fa;
  height: auto;
  min-height: 0;
}

.document-preview-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: var(--ws-stage);
}

.workspace-host,
.ws-stage {
  background: var(--ws-stage);
}

.document-preview-pane canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}

.document-preview-message {
  padding: 1.5rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 1rem;
}

.document-preview-message .alert {
  margin-bottom: 0;
}

.document-preview-pane.is-empty .document-uploader,
.document-preview-pane.is-message .document-uploader {
  padding: 0;
}

.document-preview-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  text-align: center;
  padding: 2rem 1.5rem;
}

.document-preview-loading .spinner-border {
  width: 2.5rem;
  height: 2.5rem;
}

.revision-processing-layout {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
}

.revision-processing-layout .spinner-border {
  width: 2rem;
  height: 2rem;
  flex: 0 0 auto;
  margin-top: 0.15rem;
}

.revision-processing-body {
  min-width: 0;
  flex: 1 1 auto;
}

.revision-processing-steps {
  list-style: none;
  margin: 0;
  padding: 0;
}

.revision-processing-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid #e9ecef;
}

.revision-processing-step:first-child {
  border-top: 0;
  padding-top: 0;
}

.revision-processing-mark {
  flex: 0 0 6.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #6c757d;
  padding-top: 0.15rem;
}

.revision-processing-step.is-current .revision-processing-mark {
  color: #0d6efd;
}

.revision-processing-step.is-done .revision-processing-mark {
  color: #198754;
}

.revision-processing-step.is-failed .revision-processing-mark {
  color: #dc3545;
}

.revision-processing-copy {
  min-width: 0;
}

.revision-processing-steps--compact {
  text-align: left;
  max-width: 28rem;
  margin-left: auto;
  margin-right: auto;
}

.revision-processing-steps--compact .revision-processing-mark {
  flex-basis: 5.5rem;
}

.document-preview-toolbar {
  position: relative;
  flex: 0 0 auto;
  z-index: 4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.6rem;
  background: rgba(20, 20, 22, 0.94);
  border-top: 1px solid #444;
  color: #eee;
  width: 100%;
  box-sizing: border-box;
}

.document-preview-toolbar .btn {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  line-height: 1.2;
  color: #fff;
  background: #333;
  border-color: #555;
}

.document-preview-toolbar .btn:hover,
.document-preview-toolbar .btn:focus,
.document-preview-toolbar .btn.active {
  color: #fff;
  background: #4a4a4e;
  border-color: #888;
}

.document-preview-toolbar .btn.active {
  background: #5a4a20;
}

.document-preview-toolbar-search {
  flex: 1 1 8rem;
  width: auto;
  min-width: 6rem;
  height: calc(1.5em + 0.4rem);
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  color: #eee;
  background: #1e1e1e;
  border: 1px solid #555;
}

.document-preview-popover {
  position: absolute;
  left: 0.6rem;
  right: 0.6rem;
  bottom: 3.1rem;
  z-index: 8;
  display: none;
  min-width: 0;
  padding: 0.5rem;
  color: #fff;
  background: rgba(20, 20, 22, 0.96);
  border: 1px solid #444;
  border-radius: 0.35rem;
}

.document-preview-popover.show {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
}

.document-preview-popover[hidden] {
  display: none !important;
}

.document-preview-popover .btn,
.document-preview-popover a.btn {
  margin: 0.1rem;
  color: #fff !important;
  background: #3a3a3e;
  border-color: #777;
}

.document-preview-popover .btn:hover,
.document-preview-popover .btn:focus,
.document-preview-popover a.btn:hover,
.document-preview-popover a.btn:focus {
  color: #fff !important;
  background: #555;
  border-color: #aaa;
}

.ws-side {
  width: 280px;
  background: #1e1e1e;
  color: #eee;
  overflow-x: hidden;
  overflow-y: auto;
  font: 12px/1.4 system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-toolbar {
  flex: 0 0 auto;
  padding: 8px;
  border-bottom: 1px solid #333;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ws-tree {
  flex: 1 1 auto;
  min-height: 14rem;
  max-height: 50vh;
  overflow: auto;
  padding: 8px;
}

.ws-tree-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 2px;
}

.ws-tree-row.is-selected {
  background: #335;
}

.ws-tree-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.ws-tree-vis {
  width: 14px;
  height: 14px;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: #0d6efd;
}

.ws-measure-status {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 10px;
  border-top: 1px solid #444;
  background: #252526;
  color: #bbb;
  font-size: 11px;
  line-height: 1.4;
}

.ws-prepare {
  flex: 0 0 auto;
  padding: 8px;
  border-top: 1px solid #333;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.ws-export-groups {
  display: flex;
  flex-direction: column;
  flex: 0 0 auto;
  min-height: 0;
}

.ws-export-groups-list {
  overflow: visible;
  min-height: 0;
  max-height: none;
}

.ws-export-groups-list:has(> :nth-child(6)) {
  min-height: 14rem;
  max-height: 40vh;
  overflow: auto;
}

.ws-export-group-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  margin-bottom: 4px;
  padding: 6px;
  background: #111;
  border: 1px solid #333;
}

.ws-export-group-name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.35;
}

.ws-export-group-remove {
  flex: 0 0 auto;
  background: #522;
  color: #fff;
  border: 0;
  cursor: pointer;
  line-height: 1;
  padding: 2px 6px;
}

.ws-export-groups-footer {
  flex: 0 0 auto;
  position: static;
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  background: #1e1e1e;
}

.ws-save-btn {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-weight: 600;
}

.document-preview-pane:fullscreen,
.document-preview-pane:-webkit-full-screen {
  width: 100%;
  height: 100%;
  min-height: 100%;
  background: var(--ws-stage);
}

/* Project browse surface (FR-87). Tree, review pane, metadata rail. */

.pb-view-toggle .btn.active {
  background: #6c757d;
  border-color: #6c757d;
  color: #fff;
}

.pb-tree-card {
  display: flex;
  flex-direction: column;
  height: 480px;
  margin-bottom: 0;
}

.pb-tree-filter {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #e9ecef;
}

.pb-tree-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0.35rem 0.5rem 0.5rem 0.75rem;
}

.pb-tree-list,
.pb-tree-scroll .pb-tree-list {
  margin: 0;
  padding: 0;
  padding-inline-start: 0;
  list-style: none;
}

.pb-tree-item {
  margin: 0;
  padding: 0;
}

.pb-tree-list .pb-tree-list {
  padding-left: 0.8rem;
  padding-inline-start: 0.8rem;
}

.pb-tree-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  box-sizing: border-box;
  padding: 0.3rem 0.45rem;
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.35;
}

.pb-tree-row:hover {
  background: #eef2f7;
}

.pb-tree-row.is-selected {
  background: var(--lq-brand-dark);
  color: #fff;
}

.pb-tree-row.is-selected .pb-tree-icon,
.pb-tree-row.is-selected .pb-tree-nopreview {
  color: #dbe6f0;
}

.pb-tree-row.is-muted {
  cursor: default;
  color: #868e96;
  font-style: italic;
}

.pb-tree-row.is-muted:hover {
  background: none;
}

.pb-tree-twisty {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 0.9rem;
  min-width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  line-height: 1;
  cursor: pointer;
}

.pb-tree-twisty-spacer {
  flex: 0 0 auto;
  width: 0.9rem;
}

.pb-tree-icon {
  flex: 0 0 auto;
  color: #6c757d;
}

.pb-tree-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pb-tree-nopreview {
  flex: 0 0 auto;
  font-size: 0.7rem;
  color: #adb5bd;
}

.pb-tree-hint,
.pb-tree-empty-filter {
  margin: 0;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  color: #6c757d;
  border-top: 1px solid #e9ecef;
}

.project-browse-pane {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 480px;
  background: var(--ws-stage);
  border: 1px solid #343a40;
  border-radius: 0.25rem;
  overflow: hidden;
}

.project-browse-host {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  background: var(--ws-stage);
}

.project-browse-host[hidden],
.project-browse-message[hidden] {
  display: none !important;
}

/* The pane keeps its height in every state, so moving between nodes does not
   make the three columns jump. */
.project-browse-message {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1.5rem;
  background: #f8f9fa;
}

.project-browse-pane canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
}

.pb-processing-steps {
  margin: 0.5rem 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
  color: #6c757d;
}

.pb-processing-steps .done::before {
  content: "\2713 ";
}

.pb-processing-steps .current {
  color: #212529;
  font-weight: 600;
}

.project-browse-rail {
  max-height: 480px;
  overflow-y: auto;
}

.project-browse-rail > .card {
  margin-bottom: 1.5rem;
}

.project-browse-rail dl {
  margin-bottom: 0;
}

.project-browse-rail dt {
  font-size: 0.75rem;
  color: #6c757d;
}

.project-browse-rail dd {
  margin-bottom: 0.5rem;
}

.project-browse-pane:fullscreen,
.project-browse-pane:-webkit-full-screen {
  width: 100%;
  height: 100%;
  background: var(--ws-stage);
}

@media (min-width: 992px) {
  .pb-tree-card,
  .project-browse-pane {
    height: calc(100vh - 16rem);
  }

  .project-browse-rail {
    max-height: calc(100vh - 16rem);
  }
}

.revision-history-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.revision-history-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid #e9ecef;
}

.revision-history-item:last-child {
  border-bottom: 0;
}

.revision-history-item.is-obsolete {
  opacity: 0.65;
}

.revision-history-item.is-selected {
  background: #e8f1f8;
  box-shadow: inset 3px 0 0 var(--lq-brand);
}

.revision-history-main {
  flex: 1 1 auto;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.revision-history-main:hover {
  color: var(--lq-brand);
  text-decoration: none;
}

.revision-history-actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.document-uploader {
  padding: 1.25rem;
}

.document-uploader-dropzone {
  display: block;
  padding: 2.5rem 1rem;
  text-align: center;
  color: #495057;
  background: #fff;
  border: 2px dashed #adb5bd;
  border-radius: 0.35rem;
  cursor: pointer;
}

.document-uploader-dropzone:hover,
.document-uploader-dropzone.hover,
.document-uploader-dropzone.in {
  border-color: var(--lq-brand);
  background: #f3f7fb;
}

.document-uploader-file {
  display: none;
}

.document-uploader-list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.document-uploader-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #e9ecef;
}

.document-uploader-progress {
  width: 100%;
  height: 0.4rem;
  margin-top: 0.35rem;
}

.document-uploader-error {
  color: #c0392b;
}

/*
 * Revision detail Files table. A SHA-256 hex string has no wrap points.
 * Default min-width:auto on the Bootstrap column lets that min-content
 * width expand the main column under the sidebar and clip Download.
 */
.revision-detail > [class*="col-"] {
  min-width: 0;
}

.revision-files {
  table-layout: fixed;
  width: 100%;
}

.revision-files .revision-files-name {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.revision-files .revision-files-role,
.revision-files .revision-files-size {
  width: 1%;
  white-space: nowrap;
}

.revision-files .revision-files-hash {
  min-width: 0;
}

.revision-files .revision-files-hash code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
}

.revision-files .revision-files-download {
  width: 1%;
  white-space: nowrap;
}

.card-header.d-flex > .card-title {
  margin-bottom: 0;
}

/*
 * AdminLTE floats .card-title left and inserts a clearfix ::after.
 * That keeps header actions from sitting on the far right.
 */
.card-header-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.card-header-actions::after {
  display: none;
}

.card-header-actions > .card-title {
  float: none;
  flex: 1 1 auto;
  margin: 0;
}

.card-header-actions > .card-tools {
  float: none;
  margin: 0 0 0 auto;
  flex: 0 0 auto;
}

.card-header-actions .btn i {
  margin-right: 0.35rem;
}
