html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* Sortable + resizable tables (table-sort.js) */
table[data-sortable] th.sortable {
  cursor: pointer;
  user-select: none;
}
table[data-sortable] th.sortable:hover {
  background-color: rgba(0, 0, 0, 0.04);
}
table[data-sortable] th.sort-asc,
table[data-sortable] th.sort-desc {
  background-color: rgba(13, 110, 253, 0.06);
}
.sort-indicator {
  font-size: 0.7em;
  color: #0d6efd;
}

/* Fixed layout so a column resize does NOT redistribute width to neighbors.
   Combined with table-responsive on the wrapper, the table can scroll
   horizontally if the sum of explicit widths exceeds the viewport.
   Slightly smaller font keeps long lists dense without sacrificing legibility. */
table[data-sortable] {
  table-layout: fixed;
  font-size: 0.875rem;
}

/* Sticky header row so column titles stay in view while the user scrolls
   long project lists. Background must be opaque so cells passing under it
   don't bleed through; z-index keeps it above the rest of the table.
   The selector also covers `thead th.resizable-th` so it overrides the
   `position: relative` that the resize-handle rule applies to every header. */
table[data-sortable] thead th,
table[data-sortable] thead th.resizable-th {
  position: sticky;
  top: 0;
  z-index: 2;
  background-color: #f8f9fa;
  box-shadow: inset 0 -1px 0 #dee2e6; /* preserves the bottom border under sticky */
}

/* Bootstrap's .table-responsive sets overflow which captures sticky's
   scroll context — that traps the sticky thead inside the wrapper instead
   of pinning it to the page. When the wrapper holds a sortable table,
   let overflow be visible so sticky references the window. */
.table-responsive:has(table[data-sortable]) {
  overflow: visible;
}

/* Allow cells to compress below their natural-word width so column drag-resize
   can actually shrink a column visually (otherwise a long word like
   "Aluminum" or "Schedule" would set an effective minimum). */
table[data-sortable] th,
table[data-sortable] td {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Resize handle on the right edge of each header cell. */
table[data-sortable] th.resizable-th {
  position: relative;
}
.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  background-color: transparent;
  z-index: 2;
}
.resize-handle:hover,
.resize-handle.active {
  background-color: rgba(13, 110, 253, 0.45);
}

/* Heading row that holds the "Save layout" button on the right (h2 + button). */
.table-prefs-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.table-prefs-heading .save-prefs-btn {
  flex: 0 0 auto;
}

/* Page-level wrapper that gives 10% margin on each side so content stays
   readable on wide monitors. Applied to both Index and Details views. */
.page-content {
  padding-left: 10%;
  padding-right: 10%;
}

/* Per-page brand logo, anchored in the empty left-margin area of summary
   pages. Sits below the navbar and to the left of the page title.
   Hidden on phone-width viewports where the 10% margin is too narrow. */
.page-brand {
  position: absolute;
  top: 80px;
  left: 16px;
  width: 160px;
  text-align: center;
}
.page-brand img {
  max-width: 100%;
  height: auto;
  display: block;
}
.page-brand .page-brand-caption {
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.25rem;
  line-height: 1.2;
}
@media (max-width: 991px) {
  .page-brand {
    display: none;
  }
}

/* Highlight summary qty cells that have a non-zero value so they pop
   visually amid columns of zeros. The actual color is set inline by the
   view to encode magnitude (bigger numbers → darker green). */
.qty-nonzero {
  font-weight: 700;
}

/* Stat cards on Details that jump to a row in the items table when clicked. */
.stat-clickable {
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}
.stat-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
  border-color: #0d6efd;
}

/* Brief flash on the row that the user just jumped to. */
@keyframes rowFlash {
  0%   { background-color: rgba(255, 235, 59, 0.6); }
  100% { background-color: transparent; }
}
.row-highlight > td {
  animation: rowFlash 2.5s ease-out;
}

/* Notes modal — preserve newlines and break long words. */
.notes-modal-body {
  white-space: pre-wrap;
  word-break: break-word;
}
.notes-modal-subtitle {
  font-size: 0.85rem;
  color: #6c757d;
}
.notes-trigger {
  text-decoration: none;
  font-size: 0.85rem;
}

/* Highlight section titles on Details pages so they stand out as separators
   between Project Drawings / Project Team / Items, etc. */
.section-heading {
  font-weight: 700;
  border-left: 4px solid #0d6efd;
  padding: 0.4rem 0.75rem;
  background-color: rgba(13, 110, 253, 0.07);
  border-radius: 0.25rem;
  margin-bottom: 1rem;
}