/* ===== Theme (2026-11-23, the user's request: something more contemporary than stock Bootstrap) =====
   Brand settings as Bootstrap 5.3's CSS variables, so every component picks them up with no build step. Change the
   colours here and the whole app follows. The primary is a deep teal (clear contrast with white text), the navbar a
   dark teal ink, on a cool light grey page so white cards stand out. Inter is served from static/fonts (not Google
   Fonts, which would send visitors' addresses to Google) */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2");
}
/* a stand-in drawn at Inter's size while it loads (base.html preloads it), so the page doesn't move when it swaps in */
@font-face {
  font-family: "Inter Fallback";
  src: local("Arial");
  size-adjust: 107.12%;
  ascent-override: 90.44%;
  descent-override: 22.52%;
  line-gap-override: 0%;
}

:root {
  --app-primary: #0f766e;
  --app-primary-rgb: 15, 118, 110;
  --app-primary-hover: #115e59;
  --app-primary-active: #134e4a;
  --app-primary-subtle: #e6f4f2;
  --app-ink: #12302d;
  --app-page: #f4f6f6;
  --app-border: #e1e7e6;

  --bs-primary: var(--app-primary);
  --bs-primary-rgb: var(--app-primary-rgb);
  --bs-primary-text-emphasis: var(--app-primary-active);
  --bs-primary-bg-subtle: var(--app-primary-subtle);
  --bs-primary-border-subtle: #b3ddd8;
  --bs-link-color: var(--app-primary);
  --bs-link-color-rgb: var(--app-primary-rgb);
  --bs-link-hover-color: var(--app-primary-hover);
  --bs-link-hover-color-rgb: 17, 94, 89;
  --bs-body-font-family: "Inter", "Inter Fallback", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-body-font-size: 0.9375rem;
  --bs-body-color: #1f2a29;
  /* components (cards, inputs, dropdowns, tabs) take their background from body-bg, so it stays white and only the
     page itself is grey (below) */
  --bs-body-bg: #fff;
  --bs-border-color: var(--app-border);
  --bs-border-radius: 0.5rem;
  --bs-border-radius-sm: 0.375rem;
  --bs-border-radius-lg: 0.75rem;
  --bs-box-shadow-sm: 0 1px 2px rgba(16, 42, 40, 0.06), 0 1px 3px rgba(16, 42, 40, 0.04);
  --bs-focus-ring-color: rgba(var(--app-primary-rgb), 0.25);
}

body { background-color: var(--app-page); }

/* headings: a little smaller and tighter than Bootstrap's, so index pages (h1) and form pages (h3) sit together */
h1, .h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.4rem; }
h3, .h3 { font-size: 1.45rem; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 {
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--app-ink);
}
.text-bg-danger h1, .text-bg-success h1, .text-bg-danger h6, .text-bg-success h6 { color: inherit; }

/* buttons: Bootstrap gives each variant its own variables, so primary is set here, and outline-primary to match */
.btn { font-weight: 500; }
.btn-primary {
  --bs-btn-bg: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary-hover);
  --bs-btn-hover-border-color: var(--app-primary-hover);
  --bs-btn-active-bg: var(--app-primary-active);
  --bs-btn-active-border-color: var(--app-primary-active);
  --bs-btn-disabled-bg: var(--app-primary);
  --bs-btn-disabled-border-color: var(--app-primary);
  --bs-btn-focus-shadow-rgb: var(--app-primary-rgb);
}
.btn-outline-primary {
  --bs-btn-color: var(--app-primary);
  --bs-btn-border-color: var(--app-primary);
  --bs-btn-hover-bg: var(--app-primary);
  --bs-btn-hover-border-color: var(--app-primary);
  --bs-btn-active-bg: var(--app-primary-hover);
  --bs-btn-active-border-color: var(--app-primary-hover);
  --bs-btn-disabled-color: var(--app-primary);
  --bs-btn-disabled-border-color: var(--app-primary);
  --bs-btn-focus-shadow-rgb: var(--app-primary-rgb);
}
.btn-secondary {
  --bs-btn-color: #33413f;
  --bs-btn-bg: #fff;
  --bs-btn-border-color: #cfd8d6;
  --bs-btn-hover-color: #1f2a29;
  --bs-btn-hover-bg: #eef2f1;
  --bs-btn-hover-border-color: #bfcac8;
  --bs-btn-active-color: #1f2a29;
  --bs-btn-active-bg: #e3e9e8;
  --bs-btn-active-border-color: #bfcac8;
}
.btn-link { --bs-btn-color: var(--app-primary); --bs-btn-hover-color: var(--app-primary-hover); }

/* form controls: the teal focus ring */
.form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: rgba(var(--app-primary-rgb), 0.55);
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.18);
}
.form-check-input:checked {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}
.form-label { font-weight: 500; }

/* cards: white on the grey page, soft border and shadow */
.card {
  --bs-card-border-color: var(--app-border);
  --bs-card-cap-bg: #fbfcfc;
  --bs-card-border-radius: 0.75rem;
  --bs-card-inner-border-radius: calc(0.75rem - 1px);
}
.card.shadow-sm { box-shadow: var(--bs-box-shadow-sm) !important; }

/* tables: a quiet header row and a soft hover, on white */
.table {
  --bs-table-bg: #fff;
  --bs-table-hover-bg: #f1f7f6;
  --bs-table-border-color: #e8eeed;
}
.table > thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: #5b6b69;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background-color: #f8faf9;
}
.table-responsive {
  border: 1px solid var(--app-border);
  border-radius: 0.75rem;
  background: #fff;
}
.table-responsive > .table { margin-bottom: 0; }
/* inside a card the card is the frame */
.card .table-responsive { border: 0; border-radius: 0; }

/* tabs, pagination and list groups in the brand colour */
.nav-tabs {
  --bs-nav-tabs-link-active-color: var(--app-primary);
  --bs-nav-link-color: #4b5a58;
  --bs-nav-link-hover-color: var(--app-primary);
}
.nav-tabs {
  --bs-nav-tabs-link-active-bg: #fff;
  --bs-nav-tabs-link-active-border-color: var(--app-border) var(--app-border) #fff;
}
.nav-tabs .nav-link.active {
  font-weight: 600;
  box-shadow: inset 0 3px 0 var(--app-primary);
}
.pagination {
  --bs-pagination-color: var(--app-primary);
  --bs-pagination-hover-color: var(--app-primary-hover);
  --bs-pagination-active-bg: var(--app-primary);
  --bs-pagination-active-border-color: var(--app-primary);
  --bs-pagination-focus-box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.18);
}
.list-group { --bs-list-group-active-bg: var(--app-primary); --bs-list-group-active-border-color: var(--app-primary); }
.dropdown-menu {
  --bs-dropdown-link-active-bg: var(--app-primary);
  --bs-dropdown-border-color: var(--app-border);
  box-shadow: 0 8px 24px rgba(16, 42, 40, 0.12);
}

/* the navbar: dark teal ink, the brand in white with a mint icon, the current section underlined */
.app-navbar {
  background-color: var(--app-ink);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.app-navbar .navbar-brand {
  font-weight: 700;
  letter-spacing: -0.02em;
}
.app-navbar .navbar-brand .bi { color: #5eead4; }
.app-navbar .nav-link { font-weight: 500; }

/* Tom Select (searchable selects) to match the inputs */
.ts-wrapper.focus .ts-control {
  border-color: rgba(var(--app-primary-rgb), 0.55);
  box-shadow: 0 0 0 0.2rem rgba(var(--app-primary-rgb), 0.18);
}
.ts-dropdown .active { background-color: var(--app-primary-subtle); color: var(--app-ink); }

/* badges a touch softer */
.badge { font-weight: 600; }

/* the signed-out pages: the brand in teal on a soft tint */
.auth-brand { color: var(--app-ink); }
.auth-brand .bi { color: var(--app-primary); }

/* Forms drawn as app.js will leave them, so nothing moves when it runs (base.html adds these classes in <head>, and
   app.js takes one off if Bootstrap or Tom Select didn't load):
   - help text under a field with a label becomes a ? icon by the label (app.js "Help text"): hidden from the start,
     though still read by screen readers, as visually-hidden does
   - a multiple select becomes a one-line searchable box (Tom Select) rather than a tall list */
.js-help :has(.form-label:not(.visually-hidden), label:not(.visually-hidden)) > .form-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.js-select select.form-select[multiple]:not([data-no-search]):not(.tomselected) {
  height: calc(1.5em + 0.75rem + 2px);
  overflow: hidden;
  /* its first option would show cut in half for that moment */
  color: transparent;
}

/* ===== End of theme ===== */


/* Required fields: app.js adds .required to the label of every input, select or textarea with the
   required attribute (WTForms sets it from DataRequired / InputRequired) */
.form-label.required::after,
.form-check-label.required::after {
  content: " *";
  color: var(--bs-danger);
}

/* a required Yes / No question marks its legend, not each answer (the follow-up question on Complete) */
.yes-no-question .form-check-label.required::after {
  content: none;
}

/* the help icon app.js puts after a label in place of its .form-text */
.form-help {
  cursor: pointer;
  text-decoration: none;
}

/* The locations tree (locations/index.html): a card per location, each level indented a little and given its own
   colour on the left, so where a location sits is clear without much indenting on a phone */
.location-children {
  margin-left: 0.75rem;
}
.location-card {
  border-left-width: 4px;
}
.location-depth-1 { border-left-color: var(--bs-primary); }
.location-depth-2 { border-left-color: var(--bs-success); }
.location-depth-3 { border-left-color: var(--bs-warning); }
.location-depth-4 { border-left-color: var(--bs-info); }
.location-depth-5 { border-left-color: var(--bs-secondary); }
/* the chevron, or the same space when there's nothing inside, so the names line up */
.location-toggle {
  display: inline-flex;
  justify-content: center;
  flex: 0 0 1.25rem;
  text-decoration: none;
}
.location-toggle .bi {
  transition: transform 0.15s;
}
.location-toggle:not(.collapsed) .bi {
  transform: rotate(90deg);
}

/* a button that opens a collapse and gets out of the way while it's open (Bootstrap sets aria-expanded on it),
   e.g. a job's Add Note */
.hide-when-open[aria-expanded="true"] {
  display: none;
}

/* Detail page headers (record-header on the card-header, record-actions round the buttons). Below lg, phones and
   tablets, the buttons go under the title in an even grid, so the title isn't squashed and the buttons don't run off
   the screen; from lg they sit to the right of the title as before, wrapping if there are many */
.record-header {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.record-header > h1,
.record-header > h4 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.record-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr));
  gap: 0.5rem;
}
.record-actions > form {
  margin: 0;
}
.record-actions .btn {
  width: 100%;
  /* a bigger tap target than btn-sm on a phone */
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
@media (min-width: 992px) {
  .record-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  .record-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .record-actions .btn {
    width: auto;
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
  }
}

/* The notification bell beside the menu button on phones and tablets (navbar.html): Bootstrap makes navbar
   dropdowns static below lg, so open it under the navbar on the right, no wider than the screen */
.navbar-bell-mobile .dropdown-menu {
  position: absolute;
  top: 100%;
  right: 1rem;
  left: auto;
  width: min(20rem, calc(100vw - 2rem));
  min-width: 0 !important;
}

/* A disabled button with a title that says why (e.g. Delete on a person who has worked on jobs): app.js turns it into
   a dead button with a question mark that shows the reason in a popover, styled here like Bootstrap's disabled one.
   Without app.js it stays disabled, and Bootstrap's pointer-events: none would hide its title, so let the hover through */
.btn.btn-disabled-reason {
  opacity: var(--bs-btn-disabled-opacity);
  cursor: help;
}
.btn:disabled[title] {
  pointer-events: auto;
  cursor: not-allowed;
}

/* Signed-out pages (sign in, code, register...): one card in the middle of the screen, see _auth_box.html */
.auth-page {
  min-height: calc(100vh - 6rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 0;
}
.auth-box {
  width: 100%;
  max-width: 26rem;
}
.auth-box-wide {
  max-width: 32rem;
}
.auth-brand {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
}
.auth-code {
  letter-spacing: 0.5em;
}
