/* Scutum One shell. Bootstrap 5.3 provides the components; this file adds layout and brand. */

:root {
  --scutum-navy: #14233c;
  --scutum-navy-2: #1d3253;
  --scutum-accent: #2f7de1;
  --app-topbar-height: 3.5rem;
  --app-sidebar-width: 15rem;
  --bs-primary: var(--scutum-accent);
  --bs-primary-rgb: 47, 125, 225;
  --bs-link-color-rgb: 31, 98, 186;
}

html {
  font-size: 15px;
}

body {
  background: #f4f6f9;
  min-height: 100vh;
}

.skip-link {
  position: absolute;
  top: .5rem;
  left: .5rem;
  z-index: 1100;
  padding: .5rem 1rem;
  background: #fff;
  border-radius: .25rem;
}

.btn-primary {
  --bs-btn-bg: var(--scutum-accent);
  --bs-btn-border-color: var(--scutum-accent);
  --bs-btn-hover-bg: #2468c2;
  --bs-btn-hover-border-color: #2468c2;
}

/* Top bar */
.app-topbar {
  background: var(--scutum-navy);
  min-height: var(--app-topbar-height);
  color: #fff;
}

.app-topbar .navbar-brand {
  color: #fff;
  letter-spacing: .02em;
}

.site-selector {
  display: flex;
  gap: .25rem;
  min-width: 0;
}

.site-selector .form-select {
  max-width: 16rem;
  background-color: var(--scutum-navy-2);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}

.site-selector .form-select option,
.site-selector .form-select optgroup {
  color: #212529;
  background: #fff;
}

.user-menu {
  max-width: 12rem;
}

/* Phones: the site selector gets its own full-width row under the brand. */
.app-topbar.navbar-expand > .container-fluid {
  flex-wrap: wrap;
}

@media (max-width: 575.98px) {
  .site-selector {
    order: 3;
    flex: 1 1 100%;
    padding-bottom: .5rem;
  }

  .site-selector .form-select {
    max-width: none;
  }

  .user-menu {
    max-width: 9rem;
  }
}

.data-table a {
  text-decoration: none;
}

.data-table a:hover,
.data-table a:focus-visible {
  text-decoration: underline;
}

/* Shell: sidebar + content */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--app-topbar-height));
}

.app-main {
  flex: 1;
  min-width: 0;
  padding: 1.25rem 1rem 3rem;
}

@media (min-width: 992px) {
  .app-sidebar {
    width: var(--app-sidebar-width);
    flex-shrink: 0;
    border-right: 1px solid #dfe3ea;
    background: #fff;
  }

  .app-sidebar .offcanvas-body {
    position: sticky;
    top: var(--app-topbar-height);
    height: calc(100vh - var(--app-topbar-height));
    display: flex;
    padding: 1rem .75rem;
  }

  .app-main {
    padding: 1.5rem 2rem 3rem;
  }
}

.app-sidebar .nav-link {
  color: #2b3a52;
  border-radius: .375rem;
}

.app-sidebar .nav-link:hover {
  background: #eef2f8;
}

.app-sidebar .nav-link.active {
  background: var(--scutum-accent);
  color: #fff;
}

/* Cards and data */
.stat-card {
  border: 1px solid #dfe3ea;
  color: inherit;
  transition: border-color .15s ease;
}

a.stat-card:hover {
  border-color: var(--scutum-accent);
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: .85rem;
  color: var(--bs-secondary-color);
}

.stat-card.stat-alert {
  border-color: var(--bs-danger);
}

.stat-card.stat-alert .stat-value {
  color: var(--bs-danger);
}

.filter-bar {
  background: #fff;
  border: 1px solid #dfe3ea;
  border-radius: .5rem;
  padding: .75rem;
  margin-left: 0;
  margin-right: 0;
}

[data-grid] {
  background: #fff;
  border: 1px solid #dfe3ea;
  border-radius: .5rem;
  padding: .5rem .75rem .75rem;
  transition: opacity .15s ease;
}

[data-grid].is-loading {
  opacity: .5;
  pointer-events: none;
}

.data-table {
  margin-bottom: 0;
}

.data-table thead th {
  font-size: .8rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
  white-space: nowrap;
}

.detail-list dt {
  font-weight: 500;
  color: var(--bs-secondary-color);
}

/* Checklists: single column, comfortable on a phone. */
.checklist-form {
  max-width: 60rem;
}

.checklist-section {
  background: #fff;
  border: 1px solid #dfe3ea;
  border-radius: .5rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.checklist-section legend {
  float: none;
  width: auto;
}

/* Questions sit in a grid row (half and third widths); the row's gap spaces them. */
.checklist-section > .row,
.repeat-copy > .row {
  --bs-gutter-y: 1.1rem;
}

.checklist-heading {
  border-bottom: 1px solid #e9ecf1;
  padding-bottom: .25rem;
}

.checklist-section .btn-group .btn {
  min-width: 3rem;
}

.checklist-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: .75rem 0;
}

@media (max-width: 575.98px) {
  .checklist-actions {
    position: sticky;
    bottom: 0;
    background: #f4f6f9;
    border-top: 1px solid #dfe3ea;
  }

  .checklist-actions .btn {
    flex: 1;
  }
}

.studio-details > summary {
  cursor: pointer;
  color: var(--bs-link-color);
}

.role-matrix th[scope="row"] {
  white-space: nowrap;
}

.form-card {
  max-width: 56rem;
}

.change-table th {
  width: 30%;
  font-weight: 500;
  color: var(--bs-secondary-color);
}

.change-table th,
.change-table td {
  word-break: break-word;
}

.text-pre-line {
  white-space: pre-line;
}

.signin {
  max-width: 34rem;
  padding-top: 2rem;
}

.btn:focus-visible,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 .2rem rgba(47, 125, 225, .35);
}

/* Guard tours */
.tour-progress {
  height: .75rem;
  accent-color: var(--bs-primary);
}

.tag-qr {
  width: 100%;
  max-width: 14rem;
  image-rendering: pixelated;
}

.qr-video-wrap video {
  max-height: 60vh;
  background: #000;
}

@media print {
  .app-topbar,
  .app-sidebar,
  .d-print-none {
    display: none !important;
  }

  .app-main {
    padding: 0 !important;
    margin: 0 !important;
  }

  .tag-cell {
    width: 33.333%;
    break-inside: avoid;
  }

  .tag-card {
    border: 1px dashed #666 !important;
  }
}

/* Searchable lists (site picker, incident picker) */
.combo-list {
  position: absolute;
  z-index: 1060;
  top: 100%;
  left: 0;
  right: 0;
  min-width: 16rem;
  max-height: 20rem;
  overflow-y: auto;
  margin: 2px 0 0;
  padding: 0.25rem 0;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  box-shadow: var(--bs-box-shadow);
}

.combo-group {
  padding: 0.35rem 0.75rem 0.15rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--bs-secondary-color);
}

.combo-option {
  padding: 0.3rem 0.75rem;
  cursor: pointer;
}

.combo-option.combo-indent {
  padding-left: 1.5rem;
}

.combo-option.active,
.combo-option:hover {
  background: var(--bs-primary);
  color: #fff;
}

.combo-option.active .text-body-secondary,
.combo-option:hover .text-body-secondary {
  color: rgba(255, 255, 255, 0.8) !important;
}

.combo-empty {
  padding: 0.4rem 0.75rem;
  color: var(--bs-secondary-color);
  font-size: 0.875rem;
}

.site-selector .combo {
  flex: 1 1 auto;
  min-width: 0;
}

.site-selector .combo-input {
  width: 16rem;
  max-width: 100%;
  background-color: var(--scutum-navy-2);
  border-color: rgba(255, 255, 255, .25);
  color: #fff;
}

.site-selector .combo-input::placeholder {
  color: rgba(255, 255, 255, .8);
}

.site-selector .combo-list {
  left: auto;
  min-width: 20rem;
}

@media (max-width: 575.98px) {
  .site-selector .combo-input {
    width: 100%;
  }

  .site-selector .combo-list {
    left: 0;
    min-width: 0;
  }
}

/* Charts (one series, HTML/CSS): thin marks, rounded data ends, faint grid, tooltip on hover/focus */
.chart-title {
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
  margin-bottom: .5rem;
}

.vbars {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 160px;
  border-bottom: 1px solid var(--bs-border-color);
  margin-top: 1rem;
}

.vbars-grid {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1px dashed var(--bs-border-color-translucent);
  pointer-events: none;
}

.vbars-grid > span {
  position: absolute;
  right: 0;
  bottom: 2px;
  font-size: .6875rem;
  color: var(--bs-secondary-color);
}

.vbar {
  position: relative;
  flex: 1 1 0;
  height: 100%;
  outline: none;
}

.vbar-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.vbar-svg rect,
.hbar-track rect {
  fill: var(--bs-primary);
}

.vbars-grid-top { bottom: 100%; }
.vbars-grid-mid { bottom: 50%; }
.cell-clip { max-width: 18rem; }

.vbar:hover rect,
.vbar:focus rect,
.hbar-row:hover rect,
.hbar-row:focus rect {
  fill: var(--bs-primary-text-emphasis);
}

.vbar[data-tip]:hover::after,
.vbar[data-tip]:focus::after,
.hbar-row[data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  white-space: nowrap;
  padding: .2rem .45rem;
  font-size: .75rem;
  color: #fff;
  background: rgba(17, 24, 39, .92);
  border-radius: 4px;
  pointer-events: none;
}

.vbars-axis {
  display: flex;
  gap: 2px;
  font-size: .6875rem;
  color: var(--bs-secondary-color);
}

.vbars-axis > span {
  flex: 1 1 0;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

.hbars {
  display: grid;
  gap: .3rem;
}

.hbar-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(6rem, 40%) 1fr auto;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  outline: none;
}

.hbar-track {
  display: block;
  width: 100%;
  height: 10px;
}

.hbar-fill {
  display: block;
  height: 100%;
  min-width: 1px;
  background: var(--bs-primary);
  border-radius: 0 4px 4px 0;
}

.hbar-value {
  font-variant-numeric: tabular-nums;
  color: var(--bs-body-color);
}

/* KPI tiles (dashboard and reports) */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  overflow: hidden;
}

.kpi {
  display: block;
  padding: .85rem 1rem;
  background: var(--bs-body-bg);
  box-shadow: 1px 0 0 var(--bs-border-color), 0 1px 0 var(--bs-border-color);
  color: inherit;
  text-decoration: none;
}

a.kpi:hover {
  background: var(--bs-tertiary-bg);
}

.kpi-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.kpi-label {
  margin-top: .2rem;
  font-size: .75rem;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--bs-secondary-color);
}

.kpi-alert .kpi-value { color: var(--bs-danger); }
.kpi-warn .kpi-value { color: var(--bs-warning-text-emphasis); }
.kpi-info .kpi-value { color: var(--bs-primary); }

/* Activity feed and list/detail report */
.feed-item + .feed-item { border-top: 1px solid var(--bs-border-color-translucent); }
.report-list .list-group-item.active { background: var(--bs-primary-bg-subtle); color: var(--bs-body-color); border-color: var(--bs-border-color); }
.detail-pane { position: sticky; top: 4.5rem; }
.detail-pane pre { white-space: pre-wrap; font-family: inherit; font-size: .875rem; margin: 0; }
.timeline-row { display: grid; grid-template-columns: 6.5rem 1fr; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--bs-border-color-translucent); font-size: .875rem; }
.timeline-row > span:first-child { color: var(--bs-primary); font-variant-numeric: tabular-nums; }

/* Searchable boxes show a magnifier so they read as search fields. */
.combo-input {
  padding-left: 1.9rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%236c757d'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: .6rem center;
  background-size: .85rem;
}

.site-selector .combo-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23ffffff'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398l3.85 3.85a1 1 0 0 0 1.415-1.414zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E");
}

.suggestion-list {
  max-height: 22rem;
  overflow-y: auto;
  border: 1px solid var(--bs-border-color-translucent);
  border-radius: var(--bs-border-radius);
  padding: .5rem .75rem;
}

/* Evidence: drop zones, chosen files and the gallery */
.drop-zone,
.drop-select {
  border: 2px dashed var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  padding: 1rem;
  text-align: center;
  cursor: pointer;
  background: var(--bs-tertiary-bg);
  transition: border-color .15s, background-color .15s;
}

.drop-zone:focus-visible,
.drop-zone.is-dragover,
.drop-select.is-dragover {
  border-color: var(--bs-primary);
  background: var(--bs-primary-bg-subtle);
  outline: none;
}

.drop-zone.is-uploading {
  cursor: progress;
  opacity: .8;
}

.drop-select {
  text-align: left;
  cursor: default;
}

.chosen-files {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin: .5rem 0 0;
  padding: 0;
  list-style: none;
}

.chosen-file {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .25rem .5rem;
  font-size: .8125rem;
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
}

.chosen-file img {
  width: 2rem;
  height: 2rem;
  object-fit: cover;
  border-radius: 3px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .75rem;
}

.gallery-thumb {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  background: var(--bs-tertiary-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  color: var(--bs-secondary-color);
  text-decoration: none;
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb:hover,
.gallery-thumb:focus-visible {
  border-color: var(--bs-primary);
}

.gallery-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.gallery-ext {
  margin-top: .25rem;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .05em;
}

.gallery-item figcaption {
  margin-top: .35rem;
}

.gallery-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  background: #111;
}

.gallery-full {
  max-width: 100%;
  max-height: 75vh;
}

/* Client → sites tree */
.scope-tree .tree {
  max-height: 22rem;
  overflow-y: auto;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: .35rem .5rem;
  background: var(--bs-body-bg);
}

.scope-tree.is-all .tree {
  opacity: .5;
  pointer-events: none;
}

.tree-row,
.tree-sites > li {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .1rem 0;
}

.tree-sites {
  margin: 0 0 .25rem 2.4rem;
}

.tree-toggle {
  width: 1.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bs-secondary-color);
  line-height: 1;
}

.tree-label {
  cursor: pointer;
}

.location-picker .dropdown-menu {
  width: min(32rem, calc(100vw - 2rem));
  padding: .75rem;
}

/* Repeating sections, scores and step-by-step forms */
.repeat-copy {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: .75rem;
  margin-bottom: .75rem;
  background: var(--bs-tertiary-bg);
}

.form-score {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .4rem;
  padding: .5rem .75rem;
  margin-top: .5rem;
  border-radius: var(--bs-border-radius);
  background: var(--bs-tertiary-bg);
}

.form-score [data-score] {
  font-size: 1.1rem;
}

.checklist-section.step-hidden {
  display: none;
}

.step-nav {
  margin: .75rem 0;
}

.question-set-list {
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: .35rem .6rem;
}

/* Fields the browser-side check found missing (jQuery validation), e.g. required questions of a type. */
.form-control.input-validation-error,
.form-select.input-validation-error {
  border-color: var(--bs-form-invalid-border-color);
}

.form-check-input.input-validation-error,
.btn-check.input-validation-error + .btn {
  border-color: var(--bs-form-invalid-border-color);
}

.type-questions + .type-questions {
  margin-top: 1.25rem;
}

/* Client event report (prints and copies like the reports sent by email) */
.event-report {
  max-width: 48rem;
  background: #fff;
  color: #212529;
  padding: 1rem;
  border: 1px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
}

.event-report-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.event-report-table th,
.event-report-table td {
  border: 1px solid #bfc5cd;
  padding: .3rem .5rem;
  vertical-align: top;
}

.event-report-table th {
  width: 40%;
  font-weight: 600;
}

.event-report-images {
  border: 1px solid #bfc5cd;
  padding: .5rem;
  margin-bottom: 1rem;
}

.event-report-images img {
  display: block;
  max-width: 100%;
  margin-top: .5rem;
}

.event-report [contenteditable="true"] {
  outline: 1px dashed transparent;
}

.event-report [contenteditable="true"]:hover,
.event-report [contenteditable="true"]:focus {
  outline-color: var(--bs-primary);
}

@media print {
  .event-report {
    border: 0;
    padding: 0;
    max-width: none;
  }
}

/* Template builder: sections are titled rows; question cards sit on a 12-column grid by their width. */
.builder-section {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  margin-bottom: 1rem;
}

.builder-section.is-dragging {
  opacity: .5;
}

.builder-section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--bs-border-color);
  background: var(--bs-tertiary-bg);
  border-radius: .5rem .5rem 0 0;
}

.builder-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 1.4rem .6rem;
  padding: 1.4rem .75rem .75rem;
  min-height: 4.5rem;
}

.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-6 { grid-column: span 6; }
.span-8 { grid-column: span 8; }
.span-9 { grid-column: span 9; }
.span-12 { grid-column: span 12; }

@media (max-width: 767.98px) {
  .builder-grid > * { grid-column: span 12; }
}

.builder-section-footer {
  text-align: center;
  padding: 0 .75rem .5rem;
}

.builder-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: .55rem;
  min-width: 0;
  padding: .55rem .6rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .4rem;
  background: var(--bs-body-bg);
}

.builder-card:hover,
.builder-card:focus-within {
  border-color: var(--bs-primary);
}

.builder-card.is-dragging {
  opacity: .4;
  border-style: dashed;
}

.builder-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.builder-card-title {
  font-weight: 600;
  font-size: .9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.builder-card-meta {
  font-size: .75rem;
  color: var(--bs-secondary-color);
}

/* The card's toolbar (width, narrower / wider, settings, duplicate, remove) shows on hover or focus. */
.builder-card-actions {
  position: absolute;
  top: -1.15rem;
  left: .5rem;
  display: inline-flex;
  align-items: center;
  gap: .1rem;
  padding: 0 .3rem;
  border-radius: .3rem;
  background: var(--bs-primary);
  color: #fff;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
}

/* Hidden by transparency, not display, so keyboard users can tab into it (focus shows it). */
.builder-card:hover .builder-card-actions,
.builder-card:focus-within .builder-card-actions {
  opacity: 1;
  pointer-events: auto;
}

@media (hover: none) {
  .builder-card-actions {
    opacity: 1;
    pointer-events: auto;
  }
}

.builder-card-actions .builder-action,
.builder-card-actions [data-width-label] {
  color: #fff !important;
  padding: 0 .3rem;
  line-height: 1.6;
  text-decoration: none;
}

.builder-card-actions form {
  display: inline;
}

.builder-grip {
  cursor: grab;
  color: var(--bs-secondary-color);
  user-select: none;
}

.builder-drop-hint {
  border: 1px dashed var(--bs-border-color);
  border-radius: .4rem;
  padding: .75rem;
  text-align: center;
  font-size: .85rem;
  color: var(--bs-secondary-color);
}

.builder-empty {
  border: 1px dashed var(--bs-border-color);
  border-radius: .5rem;
  padding: 3rem 1rem;
  margin-bottom: 1rem;
  background: var(--bs-body-bg);
}

.builder-panel {
  --bs-offcanvas-width: min(42rem, 100vw);
}

/* Question type icons */
.ft-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: .7rem;
  font-weight: 700;
  color: #fff;
  background: #6c757d;
}

.ft-text { background: #3730a3; }
.ft-area { background: #475569; }
.ft-number { background: #0f766e; }
.ft-date { background: #0284c7; }
.ft-time { background: #0891b2; }
.ft-yesno { background: #15803d; }
.ft-radio { background: #ea580c; }
.ft-select { background: #1d4ed8; }
.ft-check { background: #c2410c; }
.ft-scale { background: #6d28d9; }
.ft-contact { background: #be185d; }
.ft-heading { background: #fff; color: #212529; border: 1px solid var(--bs-border-color); }

.builder-palette-menu {
  width: min(28rem, calc(100vw - 2rem));
}

.builder-palette-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .4rem;
}

.builder-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .25rem;
  padding: .5rem .25rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .4rem;
  background: var(--bs-body-bg);
  color: inherit;
}

.builder-tile:hover,
.builder-tile:focus {
  border-color: var(--bs-primary);
  background: var(--bs-tertiary-bg);
}

/* A type's forms, in the order they load */
.form-stack-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  margin-bottom: .3rem;
  border: 1px solid var(--bs-border-color);
  border-radius: .4rem;
  background: var(--bs-body-bg);
  font-size: .875rem;
}

.form-stack-item.is-shared {
  background: var(--bs-tertiary-bg);
  color: var(--bs-secondary-color);
}

.form-stack-name {
  flex: 1;
  min-width: 0;
}

.form-stack-item[draggable="true"] {
  cursor: grab;
}

.form-stack-item.is-dragging {
  opacity: .5;
  border-style: dashed;
}

.form-stack-grip {
  color: var(--bs-secondary-color);
  cursor: grab;
}

/* Sections can sit side by side: the form is a 12-column grid and each section spans its width. */
.form-body {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 1rem;
}

.form-body > * {
  grid-column: 1 / -1;
  min-width: 0;
}

@media (min-width: 768px) {
  .form-body > .sec-span-3 { grid-column: span 3; }
  .form-body > .sec-span-4 { grid-column: span 4; }
  .form-body > .sec-span-6 { grid-column: span 6; }
  .form-body > .sec-span-8 { grid-column: span 8; }
  .form-body > .sec-span-9 { grid-column: span 9; }
}

/* Builder: sections sit on a 12-column grid too, and cards and sections resize by dragging their right edge. */
.builder-sections {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: 1rem;
  align-items: start;
}

.builder-sections > .builder-section {
  position: relative;
  min-width: 0;
}

@media (max-width: 767.98px) {
  .builder-sections > * { grid-column: span 12; }
}

.builder-resize {
  position: absolute;
  top: 50%;
  right: -6px;
  width: 12px;
  height: 12px;
  margin-top: -6px;
  border: 2px solid var(--bs-primary);
  border-radius: 50%;
  background: var(--bs-body-bg);
  cursor: ew-resize;
  opacity: 0;
  z-index: 3;
  touch-action: none;
}

.builder-card:hover > .builder-resize,
.builder-card:focus-within > .builder-resize,
.builder-section:hover > .builder-resize,
.builder-resize.is-resizing {
  opacity: 1;
}

.builder-section > .builder-resize {
  top: 1.2rem;
}

.builder-section-width {
  display: inline-flex;
  align-items: center;
}

body.is-resizing,
body.is-resizing * {
  cursor: ew-resize !important;
  user-select: none;
}

/* Sidebar: collapsible groups (Operations, Reports, Administration) with their pages as children. */
.nav-group-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  padding: .45rem 1rem;
  border: 0;
  border-radius: var(--bs-border-radius);
  background: none;
  color: inherit;
  font-weight: 600;
  text-align: left;
}

.nav-group-toggle:hover,
.nav-group-toggle:focus-visible {
  background: var(--bs-tertiary-bg);
}

.nav-group-toggle::after {
  content: "";
  margin-left: auto;
  width: .45rem;
  height: .45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform .15s;
  opacity: .6;
}

.nav-group-toggle.collapsed::after {
  transform: rotate(-45deg);
}

.nav-group {
  margin: .1rem 0 .4rem;
  padding-left: .75rem;
  border-left: 1px solid var(--bs-border-color);
  margin-left: 1rem;
}

.nav-sublink {
  padding: .3rem .75rem;
  font-size: .925rem;
}

/* Help tooltip icon by a question's label. */
.field-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.05rem;
    height: 1.05rem;
    margin-left: .35rem;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    line-height: 1;
    cursor: help;
    vertical-align: text-top;
    transition: background-color .12s;
}

.field-tip:hover,
.field-tip:focus-visible {
    background: var(--bs-primary-text-emphasis);
    outline: none;
}

.field-tip:focus-visible {
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .3);
}

/* Text / label and divider elements on forms. */
.checklist-text-body {
    white-space: pre-line;
}

.checklist-divider hr {
    margin: .25rem 0;
    opacity: .2;
}

/* Group boxes: a titled box inside a section. */
.checklist-group {
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    padding: .75rem 1rem 1rem;
    height: 100%;
    background: var(--bs-tertiary-bg);
}

.checklist-group-title {
    float: none;
    width: auto;
    padding: 0 .35rem;
    margin: 0 0 .25rem -.35rem;
    font-size: .9rem;
    font-weight: 600;
}

/* Builder group boxes: a titled box in a section's grid, with its own grid of question cards. */
.builder-group {
  position: relative;
  min-width: 0;
  border: 1px dashed var(--bs-primary-border-subtle);
  border-radius: .5rem;
  background: var(--bs-primary-bg-subtle);
}

.builder-group.is-dragging {
  opacity: .5;
}

.builder-group-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding: .35rem .6rem;
  border-bottom: 1px dashed var(--bs-primary-border-subtle);
}

.builder-group > .builder-grid {
  padding: 1rem .6rem .5rem;
  min-height: 3.5rem;
}

.builder-group-footer {
  text-align: center;
  padding: 0 .6rem .35rem;
}

.builder-group > .builder-resize {
  top: 1rem;
}

.builder-group:hover > .builder-resize {
  opacity: 1;
}

.builder-group .builder-card {
  background: var(--bs-body-bg);
}

.ft-group { background: var(--bs-primary-bg-subtle); color: var(--bs-primary-text-emphasis); border: 1px dashed var(--bs-primary-border-subtle); }

/* Contact form: a client's sites as a scrolling checklist. */
.contact-site-list {
    max-height: 16rem;
    overflow-y: auto;
    column-width: 16rem;
    padding: .5rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
}

/* Form templates: folded groups (retired, imported). */
.template-group > summary {
    cursor: pointer;
    list-style-position: inside;
}

.template-group:not([open]) > summary {
    border-bottom: 0;
}

/* Imported records: a quiet marker instead of a badge on every row. */
.imported-mark {
    margin-left: .35rem;
    font-size: .75rem;
    color: var(--bs-secondary-color);
    font-style: italic;
}

/* Log categories: a coloured label (picker cards, lists, badges). */
.log-cat {
    display: inline-block;
    padding: .1rem .5rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    border: 1px solid transparent;
}

.log-cat-blue { background: #e7f0ff; color: #0b4fb3; border-color: #b9d2fb; }
.log-cat-teal { background: #e3f6f5; color: #0b6b66; border-color: #a9e0dc; }
.log-cat-green { background: #e6f5ea; color: #19693a; border-color: #b4dfc0; }
.log-cat-amber { background: #fff4d6; color: #845a00; border-color: #f2d58a; }
.log-cat-orange { background: #ffeadb; color: #9a4100; border-color: #f7c49e; }
.log-cat-red { background: #fde8e8; color: #a61b1b; border-color: #f4b8b8; }
.log-cat-purple { background: #f0e9fb; color: #5b2ca0; border-color: #d2c0f0; }
.log-cat-gray { background: #f1f3f5; color: #495057; border-color: #d6dade; }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .log-cat { filter: brightness(.9); }
}

/* Log an entry wizard. */
.log-wizard {
    max-width: 960px;
}

.wizard-steps {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
    margin-bottom: 1rem;
    font-size: .875rem;
    color: var(--bs-secondary-color);
}

.wizard-steps li {
    display: flex;
    align-items: center;
    gap: .4rem;
    cursor: pointer;
}

.wizard-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    font-weight: 600;
}

.wizard-steps li.is-current {
    color: var(--bs-body-color);
    font-weight: 600;
}

.wizard-steps li.is-current .wizard-num {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}

.wizard-steps li.is-done .wizard-num {
    background: var(--bs-success-bg-subtle);
    border-color: var(--bs-success-border-subtle);
    color: var(--bs-success-text-emphasis);
}

.category-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: .75rem;
}

.category-card {
    position: relative;
    display: block;
    padding: 1rem;
    border: 1px solid var(--bs-border-color);
    border-left-width: 4px;
    border-radius: .5rem;
    background: var(--bs-body-bg);
    cursor: pointer;
    transition: box-shadow .15s ease, border-color .15s ease;
}

.category-card:hover {
    box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .08);
}

.category-card input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.category-card:has(input:checked) {
    outline: 2px solid var(--bs-primary);
    outline-offset: 1px;
}

.category-card:has(input:focus-visible) {
    outline: 2px solid var(--bs-primary);
}

.log-cat-border-blue { border-left-color: #3b7ddd; }
.log-cat-border-teal { border-left-color: #14a19a; }
.log-cat-border-green { border-left-color: #2f9e55; }
.log-cat-border-amber { border-left-color: #e0a100; }
.log-cat-border-orange { border-left-color: #e8711c; }
.log-cat-border-red { border-left-color: #d63939; }
.log-cat-border-purple { border-left-color: #7c4dcc; }
.log-cat-border-gray { border-left-color: #868e96; }

.wizard-summary {
    padding: .75rem 1rem;
    border-radius: .5rem;
    background: var(--bs-tertiary-bg);
}

/* Dashboard: the big "Log an entry" call to action. */
.log-cta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: .75rem;
    background: linear-gradient(135deg, var(--bs-primary-bg-subtle), var(--bs-body-bg));
    border: 1px solid var(--bs-primary-border-subtle);
}

.log-cta .btn-lg {
    font-weight: 600;
}

.nav-sublink-cta {
    font-weight: 600;
}

.nav-sublink-cta:not(.active) {
    color: var(--bs-primary) !important;
}

/* Menu icons, and the menu collapsed to icons (wide screens only; phones keep the slide-out menu). */
.nav-icon {
    display: inline-flex;
    flex-shrink: 0;
    width: 18px;
    margin-right: .6rem;
    opacity: .8;
}

.app-sidebar .nav-link,
.nav-group-toggle {
    display: flex;
    align-items: center;
}

.nav-quick-log {
    display: none;
}

.nav-collapse-toggle {
    align-items: center;
    width: 100%;
    padding: .45rem 1rem;
    border: 0;
    border-radius: var(--bs-border-radius);
    background: none;
    color: var(--bs-secondary-color);
    font-size: .875rem;
}

.nav-collapse-toggle:hover {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

@media (min-width: 992px) {
    .app-sidebar {
        transition: width .15s ease;
    }

    .nav-collapsed {
        --app-sidebar-width: 4.25rem;
    }

    .nav-collapsed .app-sidebar .offcanvas-body {
        padding: 1rem .5rem;
        overflow: visible;
        /* Sticky makes its own stacking layer: lift it so the flyouts open above the page's cards and sticky headers. */
        z-index: 1025;
    }

    .nav-collapsed .app-sidebar .nav-text,
    .nav-collapsed .nav-group-toggle::after,
    .nav-collapsed .nav-group-toggle .badge {
        display: none;
    }

    .nav-collapsed .nav-icon {
        margin-right: 0;
        opacity: 1;
    }

    .nav-collapsed .app-sidebar .nav-link,
    .nav-collapsed .nav-group-toggle,
    .nav-collapsed .nav-collapse-toggle {
        justify-content: center;
        padding: .6rem 0;
    }

    .nav-collapsed .nav-collapse-toggle .nav-icon {
        transform: rotate(180deg);
    }

    .nav-collapsed .nav-quick-log {
        display: list-item;
        list-style: none;
    }

    .nav-collapsed .nav-quick-log .nav-link {
        color: var(--scutum-accent);
    }

    /* A group's pages fly out beside its icon. */
    .nav-collapsed .app-nav > .nav-item {
        position: relative;
    }

    .nav-collapsed .app-nav .nav-group {
        display: none !important;
        position: absolute;
        top: 0;
        left: 100%;
        z-index: 1050;
        min-width: 15rem;
        margin: 0 0 0 .4rem;
        padding: .4rem;
        border: 1px solid var(--bs-border-color);
        border-radius: .5rem;
        background: var(--bs-body-bg);
        box-shadow: 0 .5rem 1.5rem rgba(0, 0, 0, .12);
    }

    .nav-collapsed .app-nav > .nav-item:hover > .nav-group,
    .nav-collapsed .app-nav > .nav-item:focus-within > .nav-group {
        display: block !important;
        height: auto !important;
    }

    /* A bridge so the pointer can travel from the icon to the flyout. */
    .nav-collapsed .app-nav .nav-group::before {
        content: "";
        position: absolute;
        top: 0;
        bottom: 0;
        left: -.6rem;
        width: .6rem;
    }
}

@media (min-width: 992px) {
    .nav-collapsed .app-nav .nav-group .nav-link {
        justify-content: flex-start;
        padding: .35rem .75rem;
    }

    .nav-collapsed .app-nav .nav-group .nav-link.d-flex {
        justify-content: space-between;
    }
}

/* Colour questions. */
.ft-color { background: linear-gradient(135deg, #e11d48, #f59e0b, #10b981, #3b82f6); }

.color-field .form-control-color {
    max-width: 3.25rem;
    flex: 0 0 3.25rem;
}

.color-swatch {
    display: inline-block;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: .25rem;
    border: 1px solid var(--bs-border-color);
}

.insert-form-menu {
    min-width: 20rem;
}

.ft-upload { background: #0e7490; }

/* Logbook: category chips. */
.category-chips {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}

.category-chips .chip {
    padding: .3rem .8rem;
    border-radius: 999px;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    font-size: .875rem;
    text-decoration: none;
}

.category-chips .chip:hover {
    border-color: var(--scutum-accent);
}

.category-chips .chip.is-on {
    background: var(--scutum-accent);
    border-color: var(--scutum-accent);
    color: #fff;
}

.site-contacts > summary {
    cursor: pointer;
}

.site-contacts .card {
    margin-bottom: 0 !important;
}
