/* Hide Shiny error messages that briefly pop up (errors shown via modal instead) */
.shiny-output-error,
.shiny-output-error-validation {
  display: none !important;
}

/* Layout and navbar positioning */
.navbar {
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  margin-bottom: 0;
}

body {
  padding-top: 55px; /* Fallback; JS syncs with actual navbar height on resize */
  font-family: "Calibri", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Remove extra top spacing from content containers */
.container-fluid,
.tab-content,
.tab-pane {
  padding-top: 0 !important;
}

.container-fluid {
  margin-top: 0 !important;
}

/* Pull content up to minimise gap below navbar */
.tab-content {
  margin-top: -12px !important;
}

/* Remove top whitespace from first elements in each tab */
.tab-pane > *:first-child {
  margin-top: 0 !important;
}

.tab-pane .row:first-child {
  margin-top: 0 !important;
}

.tab-pane .well {
  margin-top: 0 !important;
}

.tab-pane h1:first-child,
.tab-pane h3:first-child,
.tab-pane h4:first-child,
.tab-pane h5:first-child {
  margin-top: 0 !important;
}

.tab-pane .start-page-content,
.tab-pane .criteria-page-content,
.tab-pane .validation-report-page-content {
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.tab-pane .row > [class*="col-"]:first-child .well {
  margin-top: 0 !important;
  padding-top: 0.25rem !important;
}

.tab-pane .row > [class*="col-"]:last-child {
  padding-top: 0 !important;
}

.tab-pane .row > [class*="col-"]:last-child > *:first-child {
  margin-top: 0 !important;
}

/* Compact checkboxes - reduce spacing between checkbox form groups */
.compact-checkboxes .form-group {
  margin-bottom: 0.25rem;
}

/* Button row - align buttons in same row with space between */
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 0.5rem;
}

/* Scrollbar styling for calibration review table container */
#table-container::-webkit-scrollbar {
  width: 1px;   /* Width of the vertical scrollbar */
  height: 10px; /* Height of the horizontal scrollbar */
}

#table-container::-webkit-scrollbar-thumb {
  background-color: #16002f; /* Color of the scrollbar thumb */
  border-radius: 5px;        /* Round edges for the thumb */
}

#table-container::-webkit-scrollbar-track {
  background-color: #ecf0f1; /* Color of the scrollbar track */
  border-radius: 5px;        /* Round edges for the track */
}

#table-container::-webkit-scrollbar-thumb:hover {
  background: #ff62f1;
}

/* Custom scrollbar styling for Firefox */
#table-container {
  scrollbar-color: #16002f #ecf0f1; /* Thumb and track color */
  scrollbar-width: thin;            /* Thin scrollbar */
}

/* Make navbar tab labels bold in both themes */
.navbar-nav > li > a,
.navbar-nav .nav-link {
  font-weight: 600;
}

/* Floating settings button and panel */
.settings-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1200;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.settings-panel {
  position: fixed;
  bottom: 80px;
  right: 20px;
  z-index: 1200;
  min-width: 220px;
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: none;
}

/* Uniform spacing - match Appearance-to-Font size gap; hide br/hr that add extra space */
.settings-panel br,
.settings-panel hr {
  display: none !important;
}
.settings-panel-compact .shiny-input-container,
.settings-panel-compact .form-group,
.settings-panel-compact .shiny-input-radiogroup {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.settings-panel-compact .shiny-input-container:last-of-type,
.settings-panel-compact .form-group:last-of-type {
  margin-bottom: 0 !important;
}
.settings-panel-compact > h5 {
  margin-top: 0 !important;
  margin-bottom: 0.5rem !important;
  font-weight: bold !important;
}

body.dark-theme .settings-fab {
  background-color: #16002f;
  color: #ffffff;
  border: none;
}

body.light-theme .settings-fab {
  background-color: #ffffff;
  color: #212529;
  border: 1px solid #ced4da;
}

body.dark-theme .settings-panel {
  background-color: #16002f;
  color: #ffffff;
}

body.light-theme .settings-panel {
  background-color: #ffffff;
  color: #212529;
}

/* Session buttons - load and save FABs, revealed to the left of settings when settings is clicked */
/* Vertical gap between settings and help = 10px; same gap used horizontally between buttons */
.session-buttons-wrapper {
  position: fixed;
  bottom: 20px;
  right: 80px; /* 10px left of settings (settings right: 20px, width 50px) */
  display: flex;
  flex-direction: row;
  gap: 10px;
  align-items: center;
  z-index: 1100;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, visibility 0.2s;
}
.session-buttons-wrapper.session-buttons-expanded {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.session-save-fab-wrapper {
  position: relative;
  width: 50px;
  height: 50px;
}

.session-save-fab-wrapper a.session-save-fab {
  position: absolute !important;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  border-radius: 50%;
  padding: 0 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.session-load-fab {
  position: relative !important;
  left: auto !important;
  bottom: auto !important;
  right: auto !important;
  top: auto !important;
  width: 50px;
  height: 50px;
  flex-shrink: 0;
}

/* Example session dropdown in settings panel */
.session-load-example-in-panel {
  margin-top: 1rem;
}
.session-load-example-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 160px;
}
.session-load-example-select {
  flex: 1;
  min-width: 0;
  max-width: 140px;
}
.session-load-example-in-panel label {
  white-space: nowrap;
}
.session-load-example-in-panel .shiny-input-container {
  margin-top: 0;
  margin-bottom: 0;
}
.session-load-example-in-panel select {
  width: 100%;
  max-width: 140px;
  font-size: 13px;
}
/* Small spinner next to Load example session */
.session-load-spinner {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: session-spinner-spin 0.8s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.session-load-spinner.visible {
  opacity: 1;
}
body.light-theme .session-load-spinner {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: #333;
}
@keyframes session-spinner-spin {
  to { transform: rotate(360deg); }
}

/* Hidden file input (triggered by load FAB) and session status */
.session-load-hidden {
  position: fixed;
  bottom: 20px;
  left: 20px;
  z-index: 1000;
  pointer-events: none;
}
.session-load-hidden .shiny-input-container {
  position: absolute;
  left: -9999px;
  top: 0;
}

.session-status-success { color: #5cb85c; }
.session-status-warning { color: #f0ad4e; }
.session-status-error { color: #d9534f; }

/* Session details in settings panel */
.session-loaded-filename {
  font-size: 12px;
  opacity: 0.9;
}
.session-loaded-saved-at {
  font-size: 11px;
  opacity: 0.75;
  margin-top: 2px;
}

/* Floating help button and panel - above settings on right */
.help-fab {
  position: fixed;
  bottom: 80px;
  right: 20px;
  left: auto;
  z-index: 1100;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.help-panel {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  width: 92%;
  max-width: 1400px;
  height: 88vh;
  max-height: 88vh;
  min-width: 600px;
  min-height: 400px;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* Resize handles on the outside of the help panel */
.help-panel-resize-e,
.help-panel-resize-s,
.help-panel-resize-se {
  position: absolute;
  z-index: 10;
  background: transparent;
}

.help-panel-resize-e {
  top: 0;
  right: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
}

.help-panel-resize-s {
  bottom: 0;
  left: 0;
  width: 100%;
  height: 8px;
  cursor: row-resize;
}

.help-panel-resize-se {
  bottom: 0;
  right: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
}

.help-panel-resize-e:hover,
.help-panel-resize-s:hover {
  background-color: rgba(255, 98, 241, 0.15);
}

.help-panel-resize-se:hover {
  background-color: rgba(255, 98, 241, 0.2);
  border-radius: 0 0 8px 0;
}

body.dark-theme .help-fab {
  background-color: #16002f;
  color: #ffffff;
  border: none;
}

body.light-theme .help-fab {
  background-color: #ffffff;
  color: #212529;
  border: 1px solid #ced4da;
}

body.dark-theme .help-panel {
  background-color: #16002f;
  color: #ffffff;
}

body.light-theme .help-panel {
  background-color: #ffffff;
  color: #212529;
}

/* Help panel: header (title + logo) and top section */
.help-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.help-panel-title {
  margin: 0;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
}

.help-panel-logo {
  height: 40px;
  width: auto;
  flex-shrink: 0;
}

.help-panel-header + .help-panel-intro {
  margin-top: 0;
}

.help-panel-intro {
  font-size: 0.9rem;
  margin-bottom: 14px;
  font-weight: 600;
  opacity: 0.92;
  line-height: 1.4;
}

.help-panel-body {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  gap: 0;
  margin-top: 10px;
}

.help-sidebar {
  flex: 0 0 260px;
  max-width: 260px;
  border-right: none;
  padding-right: 12px;
  overflow-y: auto;
  min-height: 0;
}

.help-resizer {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
  background-color: rgba(0, 0, 0, 0.12);
}

.help-resizer:hover {
  background-color: rgba(0, 0, 0, 0.2);
}

body.dark-theme .help-resizer {
  background-color: rgba(255, 255, 255, 0.12);
}

body.dark-theme .help-resizer:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.help-sidebar .help-tab-table {
  width: 100%;
  margin-bottom: 0;
  font-size: 0.9rem;
}

.help-sidebar .help-tab-table thead th {
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px 6px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.15);
}

.help-sidebar .help-tab-table td:first-child {
  font-weight: 600;
}

.help-sidebar .help-tab-table td {
  padding: 6px 8px;
  vertical-align: middle;
}

.help-tab-row {
  cursor: pointer;
}

.help-tab-row:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

.help-tab-row.active {
  background-color: rgba(255, 98, 241, 0.18);
  font-weight: 600;
}

.help-tab-row.active td:first-child {
  font-weight: 700;
}

.help-details {
  flex: 1 1 auto;
  min-width: 0;
  padding-left: 12px;
  font-size: 0.9rem;
  overflow-y: auto;
  min-height: 0;
}

.help-details h5 {
  margin-top: 0;
  margin-bottom: 8px;
  font-weight: 600;
}

.help-details h6 {
  margin-top: 16px;
  margin-bottom: 6px;
  font-weight: 600;
}

.help-controls-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.help-controls-table th,
.help-controls-table td {
  padding: 6px 8px;
  vertical-align: top;
}

.help-controls-table th {
  text-align: left;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.help-controls-table tr:nth-child(even) td {
  background-color: rgba(0, 0, 0, 0.01);
}

/* ---------------- Theme support ---------------- */

/* Light theme (hard-coded colours overriding the dark Bootswatch) */
body.light-theme {
  background-color: #f8f9fa;
  color: #212529;
}

body.light-theme a {
  color: #007bff;
}

body.light-theme a:hover,
body.light-theme a:focus {
  color: #0056b3;
}

/* Navbar in light mode: match page background so it blends in */
body.light-theme .navbar,
body.light-theme .navbar.navbar-default,
body.light-theme .navbar.navbar-inverse {
  background-color: #f8f9fa !important;
  border-bottom: 1px solid #dee2e6 !important;
  border-top: none !important;
  margin-bottom: 0;
}

body.light-theme .navbar-nav .nav-link,
body.light-theme .navbar-brand,
body.light-theme .navbar-default .navbar-nav > li > a,
body.light-theme .navbar-default .navbar-brand {
  color: #212529 !important;
}

body.light-theme .navbar-default .navbar-nav > li > a:hover,
body.light-theme .navbar-default .navbar-nav > li > a:focus,
body.light-theme .navbar-nav .nav-link:hover {
  color: #0056b3 !important;
}

body.light-theme .navbar-default .navbar-nav > .active > a,
body.light-theme .navbar-default .navbar-nav > .active > a:focus,
body.light-theme .navbar-default .navbar-nav > .active > a:hover,
body.light-theme .navbar-nav .nav-link.active {
  color: #0056b3 !important;
  background-color: transparent !important;
}

/* Make general UI elements readable in light mode */
body.light-theme,
body.light-theme .container-fluid,
body.light-theme .tab-content {
  background-color: #f8f9fa;
  color: #212529;
}

body.light-theme .well,
body.light-theme .panel,
body.light-theme .panel-body,
body.light-theme .card,
body.light-theme .modal-content {
  background-color: #ffffff;
  color: #212529;
}

/* Login/other modal inputs: Shiny defaults .shiny-input-container to 300px, which leaves empty
   space on the right of the 500px modal. Let them fill the modal width. */
.modal-body .shiny-input-container,
.modal-body .form-group {
  width: 100%;
  max-width: 100%;
}

body.light-theme .form-control,
body.light-theme .shiny-input-container {
  background-color: #ffffff;
  color: #212529;
}

body.light-theme .btn-default {
  background-color: #ffffff;
  color: #212529;
  border-color: #ced4da;
}

/* Tables (including DT) readable in light mode */
body.light-theme table,
body.light-theme table.dataTable,
body.light-theme .table {
  background-color: #ffffff;
  color: #212529;
}

/* Help details theming */
body.dark-theme .help-details h5,
body.dark-theme .help-details h6 {
  color: #ff62f1;
}

body.light-theme .help-details h5,
body.light-theme .help-details h6 {
  color: #16002f;
}

body.dark-theme .help-controls-table th {
  background-color: rgba(255, 98, 241, 0.12);
  border-bottom-color: rgba(255, 98, 241, 0.5);
}

body.light-theme .help-controls-table th {
  background-color: #f1eef8;
  border-bottom-color: #d0c4f0;
}

body.dark-theme .help-controls-table tr:nth-child(even) td {
  background-color: rgba(255, 255, 255, 0.02);
}

body.light-theme .help-controls-table tr:nth-child(even) td {
  background-color: #f8f9fa;
}

/* :not([style*="color"]) matters: DT::formatStyle colours a verdict cell with an inline style,
   and an !important blanket rule here beats inline - which silently turned the green/amber/red
   pass-and-flag colouring back to plain black. Cells that ask for a colour keep it. */
body.light-theme table th,
body.light-theme table td,
body.light-theme table.dataTable th,
body.light-theme table.dataTable td {
  background-color: #ffffff !important;
}
body.light-theme table th:not([style*="color"]),
body.light-theme table td:not([style*="color"]),
body.light-theme table.dataTable th:not([style*="color"]),
body.light-theme table.dataTable td:not([style*="color"]) {
  color: #212529 !important;
}

body.light-theme .table-striped > tbody > tr:nth-of-type(odd),
body.light-theme table.dataTable.stripe tbody tr.odd {
  background-color: #f2f2f2 !important;
}

body.light-theme .dataTables_wrapper .dataTables_scrollHead,
body.light-theme .dataTables_wrapper .dataTables_scrollBody {
  background-color: #ffffff;
  color: #212529;
}

/* Logged-in banner should blend with background in light mode */
body.light-theme h5 {
  background-color: transparent;
  color: #212529;
}

/* Dark theme base surfaces (Claude-like dark grey, not pure black).
   The bslib theme sets --bs-body-bg to #262624; these keep containers, panels,
   inputs and tables consistent with it and give panels a touch of depth. */
body.dark-theme,
body.dark-theme .container-fluid,
body.dark-theme .tab-content {
  background-color: #262624;
  color: #ececec;
}

body.dark-theme .well,
body.dark-theme .panel,
body.dark-theme .panel-body,
body.dark-theme .card,
body.dark-theme .modal-content {
  background-color: #30302e;   /* slightly lighter than the body for separation */
  color: #ececec;
  border-color: #3d3c39;
}

body.dark-theme .form-control,
body.dark-theme select,
body.dark-theme textarea {
  background-color: #1f1e1d;   /* inputs a touch darker, like Claude fields */
  color: #ececec;
  border-color: #4a4844;
}

body.dark-theme table,
body.dark-theme table.dataTable,
body.dark-theme .table {
  background-color: #2b2a28;
  color: #ececec;
}

body.dark-theme .table-striped > tbody > tr:nth-of-type(odd),
body.dark-theme table.dataTable.stripe tbody tr.odd {
  background-color: #2f2e2c;
}

/* Dark theme: whole top bar in the brand purple. The tabs sit inside the navbar's
   .container-fluid, which was picking up the grey page background (the "grey box") - force it
   transparent so the purple navbar shows across the entire bar. */
body.dark-theme .navbar,
body.dark-theme .navbar.navbar-default,
body.dark-theme .navbar.navbar-inverse,
body.dark-theme .navbar-default {
  background-color: #16002f !important;   /* brand purple */
  background-image: none !important;
  border-bottom: 1px solid #2a0a4a !important;
}
body.dark-theme .navbar .container-fluid,
body.dark-theme .navbar > .container-fluid,
body.dark-theme .navbar .navbar-collapse,
body.dark-theme .navbar .navbar-header {
  background-color: transparent !important;
}

/* Dark theme: dropdowns (native <select> and selectize) dark with readable white text
   (previously the selectize control rendered light/grey with low-contrast text). */
body.dark-theme select,
body.dark-theme select.form-control {
  background-color: #1f1e1d;
  color: #ffffff;
}
body.dark-theme select option {
  background-color: #1f1e1d;
  color: #ffffff;
}
body.dark-theme .selectize-input,
body.dark-theme .selectize-control.single .selectize-input {
  background-color: #1f1e1d !important;
  color: #ffffff !important;
  border-color: #4a4844 !important;
}
body.dark-theme .selectize-input input,
body.dark-theme .selectize-input > div {
  color: #ffffff !important;
}
body.dark-theme .selectize-dropdown,
body.dark-theme .selectize-dropdown-content,
body.dark-theme .selectize-dropdown .option {
  background-color: #1f1e1d;
  color: #ffffff;
  border-color: #4a4844;
}
body.dark-theme .selectize-dropdown .active {
  background-color: #16002f;
  color: #ffffff;
}

/* Experiments-performed "Choose manually": a distinct tile beside the mode selector */
.experiments-checkbox-tile {
  border-radius: 8px;
  padding: 12px 16px;
  background-color: rgba(255, 98, 241, 0.06);
  border: 1px solid rgba(255, 98, 241, 0.28);
}
.experiments-checkbox-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #ff62f1;
}
/* Top-align the checkbox tile and the right-hand description with the mode radio
   (the radio's empty NULL-label otherwise leaves them sitting lower). */
.experiments-checkbox-tile {
  margin-top: 0;
}
.experiments-help-right {
  margin-top: 0;
}
body.light-theme .experiments-checkbox-tile {
  background-color: #f8f6fc;
  border-color: #d0c4f0;
}
body.light-theme .experiments-checkbox-title {
  color: #16002f;
}
/* two balanced columns of checkboxes inside the tile */
.experiments-manual-checkboxes .shiny-options-group {
  column-count: 2;
  column-gap: 28px;
  margin-top: 0;
}
.experiments-manual-checkboxes .checkbox {
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  margin-top: 0;
  margin-bottom: 6px;
}

/* ---------------- Layout controls from settings ---------------- */

/* Font size controls */
body.font-normal {
  font-size: 14px;
}

body.font-large {
  font-size: 16px;
}

body.font-xlarge {
  font-size: 18px;
}

/* Table density controls */
body.table-comfortable table,
body.table-comfortable table.dataTable,
body.table-comfortable .table {
  font-size: 1rem;
}

body.table-compact table,
body.table-compact table.dataTable,
body.table-compact .table {
  font-size: 0.9rem;
}

body.table-compact table th,
body.table-compact table td,
body.table-compact table.dataTable th,
body.table-compact table.dataTable td {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

/* Sidebar + main layout using flex, to let main panel fill remaining space */
.sidebar-layout-row {
  display: flex;
  flex-wrap: nowrap;
  width: 100%;
}

.sidebar-layout-sidebar {
  flex: 0 0 320px;
  max-width: 320px;
}

.sidebar-layout-main {
  flex: 1 1 auto;
  max-width: 100%;
  overflow-x: hidden;
}

/* Sidebar width controls (override base flex when narrow mode is enabled) */
body.sidebar-default .sidebar-layout-sidebar {
  flex: 0 0 320px;
  max-width: 320px;
}

body.sidebar-narrow .sidebar-layout-sidebar {
  flex: 0 0 260px;
  max-width: 260px;
}

/* LOD tab: prevent sidebar table from overlapping main panel */
#lod-tab-layout .sidebar-layout-sidebar.lod-sidebar-expanded {
  overflow-x: auto;
}

/* Stability tab: wider sidebar by default to accommodate timepoint order table */
#stability-tab-layout .sidebar-layout-sidebar {
  flex: 0 0 420px;
  max-width: 420px;
}

/* Stability tab: horizontal scroll for table when it overflows */
.stability-sidebar-table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

/* Draggable resizer between sidebar and main */
.sidebar-resizer {
  width: 6px;
  cursor: col-resize;
  background-color: #b0b0b0; /* visible neutral gray */
}

.sidebar-resizer:hover {
  background-color: #8c8c8c;
}

body.light-theme .sidebar-resizer:hover {
  background-color: #7a7a7a;
}

/* Ensure plots and widgets respect main-panel width in sidebar layouts */
.sidebar-layout-main .html-widget,
.sidebar-layout-main .plotly,
.sidebar-layout-main .shiny-plot-output {
  max-width: 100% !important;
}

/* ---------------- Start page and Criteria (tile layout) ---------------- */
.start-page-content,
.criteria-page-content,
.validation-report-page-content {
  width: 100%;
  max-width: 100%;
  padding: 0 clamp(16px, 4vw, 32px);
  margin: 0 auto;
  box-sizing: border-box;
}

.greeting-banner {
  padding: 10px 16px;
  margin-bottom: 16px;
  border-radius: 8px;
}

body.dark-theme .greeting-banner {
  background-color: rgba(255, 98, 241, 0.12);
  border: 1px solid rgba(255, 98, 241, 0.3);
}

body.light-theme .greeting-banner {
  background-color: #f1eef8;
  border: 1px solid #d0c4f0;
}

.start-hero-card,
.start-intro-card,
.start-tutorial-card,
.start-downloads-card {
  margin-bottom: 20px;
}

.start-hero-card .card-body,
.start-intro-card .card-body,
.start-tutorial-card .card-body,
.start-downloads-card .card-body {
  padding-top: 0.5rem;
}

.start-hero-card .card-body h3:first-child,
.start-intro-card .card-body h3:first-child,
.start-downloads-card .card-body h3:first-child {
  margin-top: 0;
}

.start-tutorial-card .card-body > div {
  margin-top: 0;
}

.start-tutorial-card .card-body h3 {
  margin-top: 0;
}

.start-downloads-card .btn {
  margin-right: 8px;
  margin-bottom: 8px;
}

.accent-heading {
  color: #ff62f1;
}

body.light-theme .accent-heading {
  color: #16002f;
}

/* Start page tile header hierarchy - match Criteria & Definitions scale */
.start-tile-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

/* Sample Processing tile - smaller header for sidebar */
.sample-processing-tile-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.start-tile-subtitle {
  font-size: 1.15rem;
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

.citation {
  font-size: 12px;
  opacity: 0.9;
}

/* ---------------- Criteria cards ---------------- */
.criterion-card {
  margin-bottom: 16px;
}

.criterion-card .card-body {
  padding-top: 0.75rem;
}

/* Criterion card inputs fill available width */
.criterion-card .form-group,
.criterion-card .shiny-input-container {
  width: 100%;
}
.criterion-card .form-control {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Criteria specs row: align input boxes when labels wrap to 2 lines */
.criteria-specs-row > [class*="col-"] {
  display: flex;
}
.criteria-specs-row .form-group,
.criteria-specs-row .shiny-input-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}
.criteria-specs-row .form-group .form-control,
.criteria-specs-row .form-group input {
  margin-top: auto;
}

/* Equal-height tiles per row */
.criterion-tile-row {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.criterion-tile-row > [class*="col-"] {
  display: flex;
}

.criterion-tile-row .criterion-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-bottom: 0;
}

.criterion-tile-row .criterion-card .card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Align single inputs across side-by-side tiles (e.g. Calibration, Carryover) */
.criterion-tile-row .criterion-card .card-body > .form-group,
.criterion-tile-row .criterion-card .card-body > .shiny-input-container {
  margin-top: auto;
}

.criterion-tile-row .criterion-card .criterion-help {
  /* Fixed, consistent size (no flex-stretch) so help tiles don't grow to different
     heights depending on how much content sits above them in each card. */
  flex: 0 0 auto;
  min-height: 64px;
}

.criterion-section-title {
  color: #ff62f1;
  margin-top: 0;
  margin-bottom: 12px;
}

body.light-theme .criterion-section-title {
  color: #16002f;
}

.criterion-help {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  line-height: 1.5;
  /* Consistent minimum size so callouts with a similar amount of text render as
     uniform tiles; text is vertically centred within the box. */
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.dark-theme .criterion-help {
  background-color: rgba(255, 98, 241, 0.08);
  border-left: 4px solid rgba(255, 98, 241, 0.4);
}

body.light-theme .criterion-help {
  background-color: #f8f6fc;
  border-left: 4px solid #d0c4f0;
}

.criterion-help ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.criterion-help li {
  margin-bottom: 4px;
}

/* Interference tile: align input boxes when labels vary in length (same as criteria-specs-row) */
.interference-inputs-row > [class*="col-"] {
  display: flex;
}
.interference-inputs-row .form-group,
.interference-inputs-row .shiny-input-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  width: 100%;
}
.interference-inputs-row .form-group .form-control,
.interference-inputs-row .form-group input {
  margin-top: auto;
}

/* Logo link in navbar */
.navbar-brand a {
  text-decoration: none;
}

.navbar-brand a:hover {
  opacity: 0.9;
}


/* ============================================================================================
   Editable grids (verification: manufacturer claims, assigned targets)
   A cell the user still has to fill is tinted and outlined, so it is obvious where to type
   rather than the grid looking like a finished read-only table. The class is applied per row by
   the rowCallback in R/verification.R and removed as soon as a value is entered.

   !important is required, not decorative: the theme rules above set every table cell background
   with !important, which silently won this fight and left the cells looking untouched.
   ============================================================================================ */
table.editable-grid td.needs-entry,
body.light-theme table.editable-grid td.needs-entry,
body.light-theme table.dataTable.editable-grid td.needs-entry,
body.dark-theme table.editable-grid td.needs-entry {
  background-color: #fff3cd !important;
  box-shadow: inset 0 0 0 2px #f0ad4e !important;
  border-radius: 3px;
  cursor: text;
  font-weight: 600;
}
body.dark-theme table.editable-grid td.needs-entry {
  background-color: #57430f !important;
  box-shadow: inset 0 0 0 2px #d99b1c !important;
  color: #ffe6a8 !important;
}
table.editable-grid td.needs-entry::after {
  content: "\270E";                /* pencil: this cell expects a value */
  float: right;
  opacity: 0.75;
  font-size: 0.95em;
  padding-left: 6px;
}
table.editable-grid td.needs-entry:hover {
  filter: brightness(0.96);
}
/* Editable cells that are already filled still invite a click, just quietly. */
table.editable-grid tbody td:nth-child(n+3) { cursor: text; }

/* ============================================================================================
   Sidebar hints
   Sidebar copy is one scannable line; the full explanation is on hover. The whole line is the
   hover target - an icon glyph beside it was both fiddly to hit and rendered as a stray letter
   wherever the tooltip JS had not loaded.
   ============================================================================================ */
.sidebar-hint.has-hint {
  display: block;
  margin-bottom: 8px;
  line-height: 1.4;
  cursor: help;
  border-bottom: 1px dotted rgba(255, 98, 241, 0.55);
  padding-bottom: 2px;
}
.sidebar-hint.has-hint:hover { color: #ff62f1; }
body.light-theme .sidebar-hint.has-hint {
  border-bottom-color: rgba(140, 20, 130, 0.45);
}
body.light-theme .sidebar-hint.has-hint:hover { color: #8c1482; }
.tooltip-inner { max-width: 340px; text-align: left; font-size: 0.85em; line-height: 1.45; padding: 8px 10px; }

/* ============================================================================================
   Accent button - the primary action in a group of small buttons (e.g. Load ACB example)
   ============================================================================================ */
.btn-accent, .btn-accent:focus {
  background-color: #6f2dbd !important;
  border-color: #6f2dbd !important;
  color: #ffffff !important;
  font-weight: 600;
}
.btn-accent:hover { background-color: #8b46d9 !important; border-color: #8b46d9 !important; }
body.dark-theme .btn-accent, body.dark-theme .btn-accent:focus {
  background-color: #a855f7 !important;
  border-color: #a855f7 !important;
  color: #1a0b2e !important;
}
body.dark-theme .btn-accent:hover { background-color: #c084fc !important; border-color: #c084fc !important; }

/* ============================================================================================
   Report export buttons + header fields
   ============================================================================================ */
.report-download-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.report-dl-btn {
  display: block !important;
  width: 100%;
  text-align: left;
  padding: 9px 12px !important;
  border-radius: 8px !important;
  font-weight: 600;
  border: 1px solid transparent !important;
  transition: transform 0.08s ease, box-shadow 0.15s ease;
}
.report-dl-btn i { margin-right: 8px; opacity: 0.95; }
.report-dl-btn:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18); }
.report-dl-word { background-color: #005EB8 !important; border-color: #005EB8 !important; color: #fff !important; }
.report-dl-word:hover { background-color: #0072e0 !important; }
.report-dl-html { background-color: #6f2dbd !important; border-color: #6f2dbd !important; color: #fff !important; }
.report-dl-html:hover { background-color: #8b46d9 !important; }
.report-dl-note { margin-top: 8px; display: block; line-height: 1.35; }
/* The header inputs are one block of fields, not eight separate sections. */
.report-header-fields .form-group { margin-bottom: 8px; }
.report-header-fields label { margin-bottom: 2px; font-size: 0.9em; opacity: 0.85; }

/* ============================================================================================
   Sign-in modal
   Small, centred and quiet: two fields and a button, with no wasted vertical space.
   ============================================================================================ */
/* Scoped to the sign-in dialog (the only modal opened at size "s"): a global .modal-dialog width
   also squeezed the source-data dialog, which needs to be wide. */
.modal-sm { max-width: 400px; }
.modal-sm .modal-content { border-radius: 14px; border: none; overflow: hidden; }
.modal-sm .modal-body { padding: 0 !important; }
/* The source-data dialog carries the pooled import table, which is wider than a default modal. */
.modal-lg { max-width: 940px; }
.login-modal { padding: 30px 32px 24px; text-align: center; }
.login-logo { height: 46px; margin-bottom: 14px; }
.login-title { margin: 0 0 4px; font-weight: 700; letter-spacing: 0.2px; }
.login-sub { margin: 0 0 18px; opacity: 0.7; font-size: 0.92em; }
.login-modal .form-group { margin-bottom: 10px; text-align: left; }
.login-modal .form-control {
  height: 42px; border-radius: 8px; padding: 8px 12px; font-size: 0.98em;
}
.login-start {
  width: 100%; height: 42px; margin-top: 6px; border-radius: 8px;
  font-weight: 600; letter-spacing: 0.3px;
  background-color: #6f2dbd !important; border-color: #6f2dbd !important; color: #fff !important;
}
.login-start:hover { background-color: #8b46d9 !important; border-color: #8b46d9 !important; }
.login-note { margin: 16px 0 0; font-size: 0.78em; opacity: 0.6; line-height: 1.4; }
.login-error {
  display: none; margin: 2px 0 6px; font-size: 0.85em; color: #b3261e; text-align: left;
}
.login-error.visible { display: block; }
body.dark-theme .modal-content { background: #2f2f2d; color: #ececec; }
body.dark-theme .login-error { color: #ff8a80; }
body.dark-theme .login-start,
body.dark-theme .login-start:focus { background-color: #a855f7 !important; border-color: #a855f7 !important; color: #1a0b2e !important; }
body.dark-theme .login-start:hover { background-color: #c084fc !important; border-color: #c084fc !important; }

/* Source-data button: sits at the foot of each analysis tab's sidebar, opening the imported rows
   that tab is working from. Quiet by default - it is a reference, not a primary action. */
.show-data-btn {
  margin-top: 4px;
  text-align: left;
  border: 1px solid rgba(111, 45, 189, 0.45) !important;
  background: rgba(111, 45, 189, 0.07) !important;
  color: #6f2dbd !important;
  font-weight: 600;
}
.show-data-btn:hover { background: rgba(111, 45, 189, 0.16) !important; }
.show-data-btn i { margin-right: 6px; }
body.dark-theme .show-data-btn {
  border-color: rgba(168, 85, 247, 0.55) !important;
  background: rgba(168, 85, 247, 0.12) !important;
  color: #c084fc !important;
}
body.dark-theme .show-data-btn:hover { background: rgba(168, 85, 247, 0.25) !important; }
/* The pooled table is wider than a dialog, so let it scroll rather than crush the columns. */
.modal-lg .dataTables_wrapper { overflow-x: auto; }

/* Source-data dialog: keep every row on one line and let the table scroll sideways instead.
   Long source filenames otherwise wrap to three lines and the ten rows fill the screen. */
.modal-lg table.dataTable td,
.modal-lg table.dataTable th { white-space: nowrap; }

/* ============================================================================================
   Verification sidebars
   The section headings read as body text and the buttons ran together. Give the headings weight
   and a rule, and space the button rows so each is a separate target.
   ============================================================================================ */
.criterion-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 98, 241, 0.25);
}
body.light-theme .criterion-section-title { border-bottom-color: rgba(111, 45, 189, 0.25); }
.criterion-section-title ~ .criterion-section-title { margin-top: 18px; }
/* Button rows: lay them out as a wrapping flex row with real gaps rather than inline neighbours. */
.compact-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 4px;
}
.compact-checkboxes .btn { margin: 0 !important; }
.compact-checkboxes .form-group { margin-bottom: 0; }
.criterion-card .card-body > .btn,
.criterion-card .card-body > .shiny-download-link { margin-top: 8px; }
/* The sidebar's own card: a little more breathing room inside it. */
.criterion-card .card-body { padding: 16px 16px 18px; }
.sidebar-hint.has-hint + .criterion-section-title { margin-top: 18px; }

/* ============================================================================================
   Light-theme dropdowns
   The native <select> and the selectize control both inherited a light background with pale text,
   so the chosen option and the open list were hard to read.
   ============================================================================================ */
body.light-theme select.form-control,
body.light-theme select {
  background-color: #ffffff !important;
  color: #212529 !important;
  border: 1px solid #ced4da !important;
}
body.light-theme select.form-control option,
body.light-theme select option {
  background-color: #ffffff !important;
  color: #212529 !important;
}
body.light-theme .selectize-input,
body.light-theme .selectize-control.single .selectize-input,
body.light-theme .selectize-input input,
body.light-theme .selectize-input > div {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da;
}
body.light-theme .selectize-dropdown,
body.light-theme .selectize-dropdown-content,
body.light-theme .selectize-dropdown .option {
  background-color: #ffffff !important;
  color: #212529 !important;
  border-color: #ced4da;
}
body.light-theme .selectize-dropdown .active,
body.light-theme .selectize-dropdown .option:hover {
  background-color: #6f2dbd !important;
  color: #ffffff !important;
}

/* ============================================================================================
   Table paging and export buttons, in the app's own colours
   DataTables here renders through its Bootstrap 4 integration, so the pager is
   li.paginate_button.page-item > a.page-link and the buttons are .btn.btn-secondary - not the
   .paginate_button.current / .dt-button of the plain build.
   ============================================================================================ */
.dataTables_paginate .page-item .page-link {
  color: #6f2dbd !important;
  background: transparent !important;
  border-color: rgba(111, 45, 189, 0.25) !important;
}
.dataTables_paginate .page-item .page-link:hover {
  background: rgba(111, 45, 189, 0.12) !important;
  border-color: rgba(111, 45, 189, 0.4) !important;
}
.dataTables_paginate .page-item.active .page-link,
.dataTables_paginate .page-item.active .page-link:hover {
  background: #6f2dbd !important;
  border-color: #6f2dbd !important;
  color: #ffffff !important;
}
.dataTables_paginate .page-item.disabled .page-link {
  color: #adb5bd !important;
  background: transparent !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}
body.dark-theme .dataTables_paginate .page-item .page-link {
  color: #c084fc !important;
  border-color: rgba(168, 85, 247, 0.35) !important;
}
body.dark-theme .dataTables_paginate .page-item .page-link:hover {
  background: rgba(168, 85, 247, 0.22) !important;
}
body.dark-theme .dataTables_paginate .page-item.active .page-link,
body.dark-theme .dataTables_paginate .page-item.active .page-link:hover {
  background: #a855f7 !important;
  border-color: #a855f7 !important;
  color: #1a0b2e !important;
}
body.dark-theme .dataTables_paginate .page-item.disabled .page-link {
  color: #6c6a67 !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}
/* Copy / CSV buttons, which arrive as Bootstrap secondary buttons. */
.dt-buttons .btn,
.dt-buttons .btn-secondary {
  background: rgba(111, 45, 189, 0.10) !important;
  border: 1px solid rgba(111, 45, 189, 0.35) !important;
  color: #6f2dbd !important;
  font-weight: 600;
  box-shadow: none !important;
}
.dt-buttons .btn:hover, .dt-buttons .btn-secondary:hover {
  background: rgba(111, 45, 189, 0.2) !important;
  color: #6f2dbd !important;
}
body.dark-theme .dt-buttons .btn,
body.dark-theme .dt-buttons .btn-secondary {
  background: rgba(168, 85, 247, 0.16) !important;
  border-color: rgba(168, 85, 247, 0.45) !important;
  color: #c084fc !important;
}
body.dark-theme .dt-buttons .btn:hover,
body.dark-theme .dt-buttons .btn-secondary:hover {
  background: rgba(168, 85, 247, 0.3) !important;
  color: #e9d5ff !important;
}

/* ============================================================================================
   First paint
   The workflow routing runs in R, so for a moment on load the browser showed the validation tabs
   and start page before they were hidden again. A cover sits over the page until the routing has
   run. Deliberately NOT done by hiding the individual tabs in CSS: the routing reveals them with
   jQuery .show() on the parent <li>, which would not override a rule on the <a> inside, and a
   validation build would then have permanently invisible tabs.
   ============================================================================================ */
#app-loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #f8f9fa;
  transition: opacity 0.25s ease;
}
body.dark-theme #app-loading { background: #262624; }
body.workflow-ready #app-loading { opacity: 0; pointer-events: none; visibility: hidden; }
#app-loading img { height: 54px; opacity: 0.95; }
#app-loading .app-loading-bar {
  width: 180px; height: 3px; border-radius: 2px; overflow: hidden;
  background: rgba(111, 45, 189, 0.18);
}
#app-loading .app-loading-bar span {
  display: block; height: 100%; width: 40%; border-radius: 2px; background: #6f2dbd;
  animation: app-loading-slide 1.1s ease-in-out infinite;
}
body.dark-theme #app-loading .app-loading-bar { background: rgba(168, 85, 247, 0.2); }
body.dark-theme #app-loading .app-loading-bar span { background: #a855f7; }
@keyframes app-loading-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}
/* The validation start page is hidden from the outset; the routing sets an inline style on this
   element directly, so a validation build still shows it. */
#start-validation { display: none; }

/* Third report action: builds the interactive report and hands over a link to open it. */
.report-dl-view {
  background: transparent !important;
  border: 1px solid rgba(111, 45, 189, 0.5) !important;
  color: #6f2dbd !important;
}
.report-dl-view:hover { background: rgba(111, 45, 189, 0.1) !important; }
body.dark-theme .report-dl-view {
  border-color: rgba(168, 85, 247, 0.55) !important;
  color: #c084fc !important;
}
body.dark-theme .report-dl-view:hover { background: rgba(168, 85, 247, 0.2) !important; }
