:root {
  --tbm-blue: #1766ad;
  --tbm-blue-soft: #eaf2fb;
  --tbm-line: #7d8b99;
  --tbm-ink: #182230;
}

.tbm-page {
  max-width: 1220px;
  margin: 0 auto;
  color: var(--tbm-ink);
  font-size: 18px;
}

.tbm-page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.tbm-page-head h2,
.tbm-page-head p {
  margin: 0;
}

.tbm-page-head h2 {
  margin-bottom: 5px;
  font-size: 30px;
}

.tbm-page-head > div:first-child > p:last-child {
  color: #526173;
  font-size: 16px;
}

.tbm-eyebrow {
  margin-bottom: 5px !important;
  color: var(--tbm-blue) !important;
  font-size: 14px !important;
  font-weight: 800;
}

.tbm-page-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.tbm-date-control {
  gap: 4px;
  font-size: 14px;
}

.tbm-date-control input {
  min-width: 155px;
}

.tbm-page :is(button, input, select, textarea) {
  font: inherit;
}

.tbm-page-actions :is(button, input),
.tbm-meta-value :is(input, select) {
  min-height: 48px;
}

.tbm-page-actions button {
  min-width: 104px;
}

.tbm-page-actions > [hidden] {
  display: none;
}

.tbm-status,
.tbm-source-notice {
  margin: 0 0 12px;
  padding: 11px 14px;
  border: 1px solid #c9d8e8;
  border-radius: 8px;
  background: #f7fafc;
  color: #435368;
  font-size: 15px;
}

.tbm-status[data-kind="saved"] {
  border-color: #9ec5ad;
  background: #f2faf5;
  color: #21633b;
}

.tbm-status[data-kind="pending"],
.tbm-source-notice {
  border-color: var(--tbm-blue);
  background: var(--tbm-blue-soft);
  color: #174c7c;
}

.tbm-status[data-kind="error"] {
  border-color: #d84b4b;
  background: #fff4f4;
  color: #9a2525;
}

.tbm-sheet {
  overflow: clip;
  border: 1px solid var(--tbm-line);
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 7px 22px rgba(35, 52, 70, 0.08);
}

.tbm-document-title {
  display: flex;
  align-items: center;
  gap: 34px;
  min-height: 126px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--tbm-line);
}

.tbm-document-title > strong {
  font-size: 50px;
  letter-spacing: -2px;
}

.tbm-document-title h1,
.tbm-document-title p {
  margin: 0;
}

.tbm-document-title h1 {
  font-size: 32px;
  line-height: 1.25;
}

.tbm-document-title p {
  margin-top: 8px;
  color: #536477;
  font-size: 16px;
  font-weight: 700;
}

.tbm-meta-grid {
  display: grid;
  grid-template-columns: 150px minmax(150px, 1fr) 150px minmax(170px, 1fr) 130px minmax(190px, 1fr);
  border-bottom: 1px solid var(--tbm-line);
}

.tbm-meta-grid > * {
  display: flex;
  min-height: 58px;
  align-items: center;
  padding: 8px 11px;
  border-right: 1px solid var(--tbm-line);
  border-bottom: 1px solid var(--tbm-line);
}

.tbm-meta-grid > :nth-last-child(-n + 4) {
  border-bottom: 0;
}

.tbm-meta-label {
  justify-content: center;
  background: var(--tbm-blue-soft);
  color: #23374b;
  font-size: 15px;
  font-weight: 800;
  text-align: center;
}

.tbm-meta-value {
  min-width: 0;
  background: #fff;
  word-break: keep-all;
}

.tbm-meta-value input,
.tbm-meta-value select {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #aab8c6;
  border-radius: 6px;
  background: #fff;
}

.tbm-meta-value--span {
  grid-column: span 3;
}

.tbm-section {
  padding: 0 18px 18px;
}

.tbm-section + .tbm-section {
  border-top: 1px solid var(--tbm-line);
}

.tbm-section h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 -18px 14px;
  padding: 0 18px;
  min-height: 50px;
  font-size: 22px;
}

.tbm-section h3 > span {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 46px;
  margin-left: -18px;
  background: var(--tbm-blue);
  color: #fff;
  font-size: 22px;
}

.tbm-section-note {
  margin: -4px 0 12px;
  color: #5d6b7a;
  font-size: 15px;
}

.tbm-choice-grid,
.tbm-attendee-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--tbm-line);
  border-left: 1px solid var(--tbm-line);
}

.tbm-choice-grid--prework {
  grid-template-columns: minmax(0, 3fr) minmax(0, 3fr) minmax(0, 4fr);
}

.tbm-choice-grid label,
.tbm-attendee-grid label {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  padding: 8px 11px;
  border-right: 1px solid var(--tbm-line);
  border-bottom: 1px solid var(--tbm-line);
  background: #fff;
  color: #27384a;
  font-size: 16px;
  font-weight: 500;
}

.tbm-choice-grid input,
.tbm-attendee-grid input,
.tbm-hazard-table input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--tbm-blue);
}

.tbm-text-field {
  display: block;
  margin-top: 14px;
}

.tbm-text-field > span {
  display: block;
  margin-bottom: 7px;
  color: #27384a;
  font-size: 16px;
  font-weight: 800;
}

.tbm-text-field b {
  color: var(--tbm-blue);
  font-size: 12px;
}

.tbm-text-field.is-empty textarea {
  border: 2px solid var(--tbm-blue);
  background: #f7fbff;
}

.tbm-page textarea {
  width: 100%;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #9aa9b8;
  border-radius: 5px;
  background: #fff;
  color: var(--tbm-ink);
  line-height: 1.5;
  resize: vertical;
}

#tbmWorkContent {
  overflow-y: hidden;
  resize: none;
}

.tbm-page :is(input, select, textarea):focus-visible {
  border-color: var(--tbm-blue);
  outline: 3px solid rgba(23, 102, 173, 0.18);
  outline-offset: 1px;
}

.tbm-table-scroll {
  overflow-x: auto;
  max-width: 100%;
}

.tbm-hazard-table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  table-layout: fixed;
}

.tbm-hazard-table th,
.tbm-hazard-table td {
  border: 1px solid var(--tbm-line);
  text-align: center;
  vertical-align: middle;
}

.tbm-hazard-table th {
  padding: 10px;
  background: var(--tbm-blue-soft);
  font-size: 15px;
}

.tbm-hazard-table td {
  padding: 0;
}

.tbm-hazard-table th:nth-child(1) { width: 24%; }
.tbm-hazard-table th:nth-child(2) { width: 20%; }
.tbm-hazard-table th:nth-child(3) { width: 48%; }
.tbm-hazard-table th:nth-child(4) { width: 8%; }

.tbm-hazard-table textarea {
  display: block;
  min-height: 60px;
  padding: 6px 8px;
  border: 0;
  border-radius: 0;
  text-align: center;
}

.tbm-photo-summary {
  margin: 0 0 8px;
  color: #435368;
  font-size: 15px;
}

.tbm-photo-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tbm-photo-actions button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 1px solid var(--tbm-blue);
  border-radius: 6px;
  background: #fff;
  color: var(--tbm-blue);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.tbm-photo-actions input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.tbm-photo-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

#tbmPhotoStatus {
  margin: 12px 0;
}

.tbm-photo-gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  min-height: 120px;
}

.tbm-photo-item {
  min-width: 0;
}

.tbm-photo-card {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  padding: 0;
  border: 2px solid #aab8c6;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}

.tbm-photo-card[aria-pressed="true"] {
  border: 3px solid var(--tbm-blue);
}

.tbm-photo-card img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.tbm-photo-card span {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(24, 34, 48, 0.78);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.tbm-photo-card[aria-pressed="true"] span {
  background: var(--tbm-blue);
}

.tbm-photo-rotation-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.tbm-photo-rotation-actions button {
  min-width: 0;
  min-height: 44px;
  flex: 1 1 72px;
  padding-inline: 8px;
  white-space: nowrap;
}

.tbm-photo-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 120px;
  margin: 0;
  place-items: center;
  border: 1px dashed #aab8c6;
  color: #667587;
}

.tbm-risk-row {
  display: grid;
  grid-template-columns: 1fr 210px;
  border: 1px solid var(--tbm-blue);
}

.tbm-risk-row textarea {
  min-height: 105px;
  border: 0;
  border-radius: 0;
}

.tbm-risk-row strong {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--tbm-blue);
  color: var(--tbm-blue);
  text-align: center;
}

.tbm-leader-sign {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(0, 1fr) minmax(190px, 240px) minmax(0, 1fr);
  min-height: 62px;
  margin-top: 12px;
  border: 1px solid var(--tbm-line);
}

.tbm-leader-sign > * {
  display: grid;
  place-items: center;
}

.tbm-leader-sign strong {
  background: var(--tbm-blue-soft);
}

.tbm-leader-sign strong:nth-of-type(2) {
  border-left: 1px solid var(--tbm-line);
}

.tbm-leader-sign span {
  color: #738091;
}

.tbm-print-body {
  --tbm-ink: #000;
  --tbm-line: #000;
  margin: 0;
  background: #edf1f5;
  color: var(--tbm-ink);
  font-family: "Helvetica Neue", Arial, sans-serif;
}

.tbm-print-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  max-width: 210mm;
  margin: 14px auto;
}

.tbm-print-toolbar :is(a, button) {
  display: inline-flex;
  box-sizing: border-box;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid var(--tbm-blue);
  border-radius: 6px;
  background: #fff;
  color: var(--tbm-blue);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}

.tbm-print-toolbar button {
  background: var(--tbm-blue);
  color: #fff;
}

.tbm-print-toolbar button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.tbm-print-sheet {
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
  box-sizing: border-box;
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto 20px;
  padding: 20mm 10mm 8mm;
  background: #fff;
  box-shadow: 0 8px 28px rgba(24, 34, 48, 0.14);
}

.tbm-print-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 12mm;
  border-bottom: 1px solid var(--tbm-line);
}

.tbm-print-title > strong {
  font-size: 28px;
}

.tbm-print-title h1,
.tbm-print-title p {
  margin: 0;
}

.tbm-print-title h1 {
  font-size: 20px;
}

.tbm-print-title p {
  margin-top: 2px;
  color: var(--tbm-ink);
  font-size: 10pt;
  font-weight: 700;
}

.tbm-print-sheet table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.tbm-print-sheet th,
.tbm-print-sheet td {
  padding: 4px 5px;
  border: 1px solid var(--tbm-line);
  font-size: 10pt;
  line-height: 1.25;
  text-align: center;
  vertical-align: middle;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.tbm-print-sheet th {
  background: var(--tbm-blue-soft);
  font-weight: 800;
}

.tbm-print-meta col:nth-child(odd) {
  width: 14%;
}

.tbm-print-meta col:nth-child(even) {
  width: 19.333333%;
}

.tbm-print-section {
  break-inside: auto;
  margin-top: 2.5mm;
}

.tbm-print-section h2 {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  min-height: 24px;
  margin: 0;
  border: 1px solid var(--tbm-line);
  border-bottom: 0;
  background: var(--tbm-blue-soft);
  font-size: 11pt;
}

.tbm-print-section h2 span {
  display: grid;
  place-items: center;
  align-self: stretch;
  width: 25px;
  margin-right: 7px;
  background: var(--tbm-blue);
  color: #fff;
}

.tbm-print-section h3 {
  margin: 0;
  padding: 3px 4px;
  font-size: 10pt;
}

.tbm-print-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-left: 1px solid var(--tbm-line);
}

.tbm-print-choice-grid--prework {
  grid-template-columns: minmax(0, 3fr) minmax(0, 3fr) minmax(0, 4fr);
}

/* Print the day's work, not every available classification; keep signature space. */
.tbm-print-choice-grid--work label:has(input:not(:checked)) {
  display: none;
}

.tbm-print-choice-grid--work {
  border: 1px solid var(--tbm-line);
}

.tbm-print-choice-grid.tbm-print-choice-grid--work label {
  border-right: 0;
  border-bottom: 0;
}

.tbm-print-choice-grid--prework label {
  padding-inline: 3px;
  font-size: 8.5pt;
  white-space: nowrap;
}

.tbm-print-choice-grid label {
  display: flex;
  min-height: 23px;
  align-items: center;
  gap: 4px;
  padding: 3px 4px;
  border-right: 1px solid var(--tbm-line);
  border-bottom: 1px solid var(--tbm-line);
  font-size: 10pt;
  line-height: 1.25;
  overflow-wrap: break-word;
  word-break: keep-all;
}

.tbm-print-choice-grid input,
.tbm-print-hazards input {
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border: 1px solid #000;
  border-radius: 0;
  background: #fff;
  opacity: 1;
}

.tbm-print-choice-grid input:checked::before,
.tbm-print-hazards input:checked::before {
  content: "";
  width: 6px;
  height: 3px;
  margin-top: -2px;
  border-left: 2px solid #000;
  border-bottom: 2px solid #000;
  transform: rotate(-45deg);
}

.tbm-print-text {
  min-height: 0;
  padding: 5px 6px;
  border: 1px solid var(--tbm-line);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: keep-all;
  font-size: 10pt;
  line-height: 1.3;
}

.tbm-print-text--opinions {
  min-height: 9mm;
}

.tbm-print-hazards th:nth-child(1) { width: 20%; }
.tbm-print-hazards th:nth-child(2) { width: 20%; }
.tbm-print-hazards th:nth-child(3) { width: 52%; }
.tbm-print-hazards th:nth-child(4) { width: 8%; }

.tbm-print-hazards td:nth-child(2),
.tbm-print-hazards td:nth-child(3) {
  padding-inline: 3px;
  font-size: 9pt;
  white-space: nowrap;
}

.tbm-print-hazards tr,
.tbm-print-signatures tr,
.tbm-print-leader-signature tr {
  break-inside: avoid;
}

.tbm-print-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  box-sizing: border-box;
  width: 100%;
  border-top: 1px solid var(--tbm-line);
  border-left: 1px solid var(--tbm-line);
}

.tbm-print-photo-slot {
  display: grid;
  box-sizing: border-box;
  min-width: 0;
  min-height: 0;
  height: 54mm;
  place-items: center;
  overflow: hidden;
  border-right: 1px solid var(--tbm-line);
  border-bottom: 1px solid var(--tbm-line);
  background: #fff;
}

.tbm-print-photo-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.tbm-print-risk {
  display: grid;
  grid-template-columns: 1fr 27mm;
  min-height: 10mm;
  border: 1px solid var(--tbm-line);
}

.tbm-print-risk > div {
  padding: 5px 6px;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: keep-all;
  font-size: 10pt;
}

.tbm-print-risk strong {
  display: grid;
  place-items: center;
  border-left: 1px solid var(--tbm-line);
  color: var(--tbm-blue);
  font-size: 10pt;
  text-align: center;
}

.tbm-print-signatures th {
  width: 10%;
}

.tbm-print-signatures td {
  width: 23.333%;
}

.tbm-print-leader-signature {
  margin-top: 1mm;
}

.tbm-print-leader-signature :is(th, td):nth-child(1),
.tbm-print-leader-signature :is(th, td):nth-child(2),
.tbm-print-leader-signature :is(th, td):nth-child(4) {
  width: 16%;
}

.tbm-print-leader-signature :is(th, td):nth-child(3),
.tbm-print-leader-signature :is(th, td):nth-child(5) {
  width: 26%;
}

.tbm-signature-space {
  height: 9mm;
}

.tbm-print-signatures :is(th, td),
.tbm-print-leader-signature :is(th, td) {
  padding-block: 0;
}

@media (max-width: 1180px) {
  .tbm-page-head,
  .tbm-page-actions {
    align-items: stretch;
  }

  .tbm-page-head {
    flex-direction: column;
  }

  .tbm-page-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
  }

  .tbm-date-control {
    grid-column: 1 / -1;
  }

  .tbm-date-control input {
    width: 100%;
  }

  #tbmReloadBtn:not([hidden]) {
    grid-column: 1 / -1;
  }

  .tbm-meta-grid {
    grid-template-columns: 140px minmax(0, 1fr);
  }

  .tbm-meta-value--span {
    grid-column: auto;
  }

  .tbm-meta-grid > * {
    border-bottom: 1px solid var(--tbm-line);
  }

}

@media (max-width: 900px) {
  .tbm-choice-grid,
  .tbm-attendee-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .tbm-page {
    font-size: 18px;
  }

  .tbm-page-head h2 {
    font-size: 27px;
  }

  .tbm-document-title {
    align-items: flex-start;
    gap: 14px;
    min-height: 0;
    padding: 18px 15px;
  }

  .tbm-document-title > strong {
    font-size: 35px;
  }

  .tbm-document-title h1 {
    font-size: 21px;
  }

  .tbm-document-title p {
    font-size: 14px;
  }

  .tbm-meta-grid {
    grid-template-columns: 116px minmax(0, 1fr);
  }

  .tbm-meta-grid > * {
    min-height: 54px;
    padding: 7px 8px;
  }

  .tbm-meta-label {
    font-size: 13px;
  }

  .tbm-meta-value {
    font-size: 15px;
  }

  .tbm-section {
    padding-inline: 10px;
  }

  .tbm-section h3 {
    margin-inline: -10px;
    padding-inline: 10px;
    font-size: 19px;
  }

  .tbm-section h3 > span {
    margin-left: -10px;
  }

  .tbm-choice-grid,
  .tbm-attendee-grid {
    grid-template-columns: 1fr;
  }

  .tbm-photo-gallery {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tbm-choice-grid label,
  .tbm-attendee-grid label {
    min-height: 48px;
    font-size: 16px;
  }

  .tbm-risk-row {
    grid-template-columns: 1fr;
  }

  .tbm-risk-row strong {
    min-height: 58px;
    border-top: 1px solid var(--tbm-blue);
    border-left: 0;
  }

  .tbm-leader-sign {
    grid-template-columns: 1fr;
  }

  .tbm-leader-sign > * {
    min-height: 48px;
  }

  .tbm-leader-sign strong:nth-of-type(2) {
    border-top: 1px solid var(--tbm-line);
    border-left: 0;
  }

  .nav-link--sub {
    margin-left: 0;
  }
}

@page {
  size: A4 portrait;
  margin: 0;
}

@media print {
  .tbm-print-body {
    background: #fff;
  }

  .tbm-print-toolbar {
    display: none;
  }

  .tbm-print-sheet {
    width: 100%;
    min-height: 0;
    margin: 0;
    padding: 20mm 10mm 8mm;
    box-shadow: none;
  }
}
