:root {
  --primary: #405C8C;
  --secondary: #393939;
  --bg-page: #e5e7eb;
  --card-bg: #ffffff;
  --text-main: #111827;
  --muted: #6b7280;
  --border-light: #d1d5db;
}

html:not(.theme-bootstrapped) body {
  visibility: hidden;
}

html.theme-bootstrapped body {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.12s linear;
}



* {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  margin: 0;
  padding: 20px;
  background: var(--bg-page);
  color: var(--text-main);
}

/* When a modal is open, prevent background scrolling */
body.modal-open {
  overflow: hidden;
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 16px 20px 20px 20px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
  margin-bottom: 16px;
}

/* Header */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  border-bottom: 3px solid var(--primary, #760F13);
  padding-bottom: 10px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#app-title {
  font-size: 50px;
  font-weight: 700;
  color: var(--primary, #760F13);
}

.header-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.logo-wrapper img {
  height: 120px;
  width: auto;
  display: block;
}

/* User strip in header */
.header-user-row {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.header-user-name {
  font-size: 0.9rem;
  color: var(--secondary, #555);
}

.small {
  font-size: 13px;
  color: var(--muted);
}

.error {
  color: #b91c1c;
}

/* Header navigation dropdown (Go to:) */
.header-nav-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.header-nav-dropdown .field-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.header-nav-dropdown select {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  background: #fff;
  min-width: 180px;
}



/* ---------------------------------- */
/* Standard header navigation row       */
/* ---------------------------------- */

.header-nav {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.header-nav .btn-secondary,
.header-nav .btn-primary {
  padding: 6px 12px;
  font-size: 13px;
}

/* Layout bits */

.section-heading,
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 10px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 16px;
  margin-bottom: 4px;
}

/* Inputs */

input[type="text"],
input[type="date"],
input[type="email"],
input[type="password"],
select,
textarea {
  padding: 7px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  font-size: 14px;
  background: #ffffff;
}

input[type="text"]:focus,
input[type="date"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary, #760F13);
  box-shadow: 0 0 0 1px rgba(118, 15, 19, 0.15);
  background: #ffffff;
}

/* --- Keep inputs/selects from blowing out layouts --- */
.field-input,
.field-group input,
.field-group select,
.field-group textarea,
.two-col input,
.two-col select,
.two-col textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* Optional: if you ever get long select text, keep it sane */
select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}



textarea {
  min-height: 90px;
  resize: vertical;
}

/* Buttons */

.btn-primary {
  border-radius: 999px;
  border: 1px solid var(--primary, #760F13);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary, #760F13);
  color: #ffffff;
  cursor: pointer;
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: default;
}

.btn-secondary {
  border-radius: 999px;
  border: 1px solid var(--secondary, #d1d5db);
  padding: 7px 14px;
  font-size: 14px;
  background: var(--secondary, #fdfaf5);
  color: #ffffff;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-secondary:disabled {
  opacity: 0.7;
  cursor: default;
}

.btn-danger {
  border-radius: 999px;
  border: none;
  padding: 7px 14px;
  font-size: 14px;
  background: #b91c1c;
  color: #ffffff;
  cursor: pointer;
}

/* ---------------------------------- */
/* Modern file upload control (#7)     */
/* ---------------------------------- */

.file-input-hidden {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.file-picker-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.file-meta {
  font-size: 13px;
  color: var(--muted);
  word-break: break-word;
}

.file-clear {
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 6px 12px;
  font-size: 13px;
  background: #ffffff;
  color: #111827;
  cursor: pointer;
}

/* Table */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
}

.data-table {
 
  border-collapse: collapse;
  font-size: 14px;
  table-layout: auto;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: top;
}

.data-table tbody tr:hover {
  background: #f3f4f6;
}

/* Table: AMF-style filters + zebra rows */

.data-table tbody tr:nth-child(even) {
  background: #f9fafb;
}

.data-table thead th {
  font-size: 13px;
  font-weight: 700;
  color: #374151;
  white-space: nowrap;
}

.data-table thead tr.filter-row th {
  padding-top: 2px;
  padding-bottom: 10px;
}

.table-filter {
  width: 100%;
  min-width: 140px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-light);
  font-size: 13px;
  background: #ffffff;
}

.table-filter:focus {
  outline: none;
  border-color: var(--primary, #760F13);
  box-shadow: 0 0 0 1px rgba(118, 15, 19, 0.15);
}

.type-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}

.type-pill.type-observation {
  border-color: var(--primary);
  background: #ffffff;
  color: var(--primary);
}

.type-pill.type-efficiency {
  border-color: var(--secondary);
  background: #ffffff;
  color: var(--secondary);
}

.type-pill.type-defect {
  border-color: #9ca3af;
  background: #ffffff;
  color: #374151;
}

.obs-loc-cell .obs-name {
  font-weight: 700;
}

.obs-loc-cell .obs-location {
  font-size: 12px;
  color: var(--muted);
}

.summary-cell {
  min-width: 240px;
}

.summary-text {
  display: -webkit-box;

  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}

.status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-label {
  text-transform: none;
}

.status-comment {
  font-size: 14px;
}

.btn-view {
  border-radius: 999px;
  border: 1px solid var(--primary, #760F13);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  background: #ffffff;
  color: var(--primary, #760F13);
  cursor: pointer;
}

.btn-view:hover {
  background: #f9fafb;
}

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Viewer header row (AMF-like) */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 8px;
}

.header-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-subrow {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#obs-count {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Reuse AMF-style button look */
.export-button {
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  text-decoration: none;
}

.export-button:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* Type cell now contains type + status bubble */
.type-cell {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
}

.status-bubble {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: #374151;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #9ca3af;
}

/* Status variants */
.status-open {
  border-color: var(--primary);
  color: var(--primary);
}
.status-open .status-dot { background: var(--primary); }

.status-inprogress {
  border-color: var(--secondary);
  color: var(--secondary);
}
.status-inprogress .status-dot { background: var(--secondary); }

.status-closed {
  border-color: #9ca3af;
  color: #374151;
}
.status-closed .status-dot { background: #6b7280; }

.status-notset {
  border-color: #e5e7eb;
  color: #6b7280;
}
.status-notset .status-dot { background: #9ca3af; }

/* Summary comment icon next to observation_text */
.summary-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comment-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.9;
}


/* Title row: heading left, buttons right (same row) */
.viewer-title-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.viewer-title-actions h2 {
  margin: 0;
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.title-actions #obs-count {
  margin: 0;
  white-space: nowrap;
}

/* Filters button below KPI charts */
.viewer-filters-below-kpis {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
  margin-bottom: 8px;
}



/* Modal */

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 50;
}

.modal-dialog {
  max-width: 640px;
  width: 100%;
  max-height: 80vh;
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  padding: 16px 18px 14px 18px;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.modal-body {
  margin-top: 4px;
  margin-bottom: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding-right: 4px;
}

.modal-footer {
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

/* Question blocks */

.question-block {
  border: 2px solid var(--primary);
  border-radius: 4px;
  margin-bottom: 14px;
  background: #ffffff;
}

.question-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: #f9fafb;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  font-weight: 600;
}

.question-body {
  padding: 10px 12px 12px;
}

.question-number {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 10px;
  font-weight: 700;
}

/* Textareas */

textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 10px 12px;
  font-size: 14px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  background: #f9fafb;
  box-sizing: border-box;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px rgba(118, 15, 19, 0.35);
  outline: none;
  background: #ffffff;
}

/* Responsive */

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  .card {
    padding: 14px 14px 18px 14px;
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .logo-wrapper img {
    height: 40px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .btn-primary {
    width: 100%;
    text-align: center;
  }

  .modal {
    padding: 24px 10px;
  }

  .modal-dialog {
    padding: 14px 14px 12px 14px;
    max-height: 85vh;
  }
}

/* ---------------------------------- */
/* Index dashboard overview (charts)  */
/* ---------------------------------- */

.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.chart-card {
  background: #f9fafb;
  border-radius: 10px;
  padding: 10px 12px 8px 12px;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 4px 0;
}

.chart-wrapper {
  flex: 1;
  min-height: 140px;
  position: relative;
}

.chart-wrapper canvas {
  width: 100% !important;
  height: 100% !important;
}

.perday-card {
  min-height: 220px;
}

.perday-card .chart-wrapper {
  min-height: 160px;
}

@media (max-width: 640px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}


/* ----------------------------- */
/* Safety Pulse UI               */
/* ----------------------------- */

.pulse-dial-wrap {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
}

.pulse-dial {
  --sweep: 180deg;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background:
    conic-gradient(
      var(--primary) var(--sweep),
      #e5e7eb 0deg
    );
  position: relative;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  border: 1px solid #e5e7eb;
}

.pulse-dial::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid #e5e7eb;
}

.pulse-dial-readout {
  position: relative;
  z-index: 1;
}

.pulse-score {
  font-size: 42px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.pulse-range {
  width: 100%;
  margin-top: 10px;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.segmented input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented label {
  border: 1px solid var(--border-light);
  background: #f9fafb;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.segmented input[type="radio"]:checked + label {
  border-color: var(--primary);
  background: rgba(118, 15, 19, 0.08);
  box-shadow: 0 0 0 1px rgba(118, 15, 19, 0.15);
}

.pulse-anon-note {
  background: #f9fafb;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0 0 10px 0;
}

@media (max-width: 640px) {
  .pulse-dial-wrap {
    grid-template-columns: 1fr;
  }
  .pulse-dial {
    width: 110px;
    height: 110px;
  }
}

.pulse-meaning {
  margin-top: 6px;
  font-weight: 600;
}

.pulse-10-hint {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
}

.pulse-comments-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  max-height: 240px;
  overflow: auto;
  white-space: pre-wrap;
}

.pulse-comment-item {
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.pulse-comment-item:last-child {
  border-bottom: none;
}

.pulse-comment-meta {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.pulse-comment-text {
  font-size: 14px;
  color: #111827;
}
#pulse-comments-card {
  grid-column: 1 / -1;
}

#pulse-comments-card {
  grid-column: 1 / -1;
  margin-top: 14px; /* match the feel of other gaps */
}

#safety-pulse-dashboard{
  margin-top: 14px;
}


.header-user-role {
  font-size: 0.85rem;
  color: var(--muted);
}

/* Fix for date column width in view.html */
.data-table .date-col {
  min-width: 120px;
  white-space: nowrap;
}

.viewer-title-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}

.filters-toggle-btn{
  border:1px solid #cbd5e1;
  background:#fff;
  color:#111827;
  padding:6px 12px;
  border-radius:999px;
  font-size:13px;
  cursor:pointer;
}

.filters-toggle-btn:hover{
  background:#f8fafc;
}

.filters-hidden .filter-row{
  display:none;
}

.data-table tbody tr.clickable-row{
  cursor:pointer;
}

.data-table tbody tr.clickable-row:hover{
  background:#f8fafc;
}

.data-table tbody tr.clickable-row:focus{
  outline:2px solid #cbd5e1;
  outline-offset:-2px;
}


/* ---------------------------------- */
/* Manual Handling (scoped .mh-*)     */
/* ---------------------------------- */

.mh-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
  margin-bottom: 16px;
}

@media (max-width: 980px) {
  .mh-grid {
    grid-template-columns: 1fr;
  }
}

.mh-lead {
  margin: 0 0 12px 0;
  color: var(--muted);
  line-height: 1.45;
}

.mh-section-title {
  margin: 16px 0 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--primary, #760F13);
}

.mh-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}

@media (max-width: 680px) {
  .mh-form-grid {
    grid-template-columns: 1fr;
  }
}

.mh-mt {
  margin-top: 10px;
}

.mh-chipset {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.mh-chip {
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #ffffff;
  padding: 8px 10px;
  border-radius: 999px;
  display: inline-flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.mh-chip input {
  width: auto;
}

.mh-chip span {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 600;
}

.mh-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  align-items: center;
}

.mh-hint {
  border-left: 4px solid var(--primary, #760F13);
  background: rgba(0, 0, 0, 0.03);
  padding: 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.45;
  margin-top: 12px;
  color: var(--text-main);
}

.mh-score-box {
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #f9fafb;
  padding: 12px;
}

.mh-score-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.mh-score-h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary, #760F13);
}

.mh-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  font-weight: 800;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #fff;
  color: var(--text-main);
}

.mh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9ca3af;
}

.mh-score-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 6px;
  border-top: 1px dashed rgba(0, 0, 0, 0.15);
  margin-top: 10px;
}

.mh-kpi {
  display: grid;
  gap: 4px;
}

.mh-k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
}

.mh-v {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.3px;
}

.mh-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--text-main);
}

.mh-list li {
  margin: 6px 0;
}

.mh-list-tight {
  margin: 0;
}

.mh-footer-card {
  margin-top: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: #ffffff;
}

.mh-json-preview {
  min-height: 210px;
}

/* Print: hide nav/header chrome and action buttons */
@media print {
  #sitekit-header {
    display: none !important;
  }

  .mh-actions,
  .btn-primary,
  .btn-secondary,
  .btn-danger {
    display: none !important;
  }

  .mh-grid {
    grid-template-columns: 1fr;
  }

  body {
    background: #ffffff !important;
  }

  .card {
    box-shadow: none !important;
  }
}

/* Manual handling: minor UX polish */
.mh-actions button { white-space: nowrap; }

/* If you ever print the page itself, hide app chrome */
@media print {
  #sitekit-header,
  #mh-home,
  #mh-list,
  .mh-actions {
    display: none !important;
  }
}

/* Prevent selects from overflowing cards / flex rows */
.field-input,
select.field-input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.ra-row > * {
  min-width: 0;
}


/* Vehicle pre-use "check sheet" */
.preuse-sheet {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.preuse-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.75);
}

.preuse-no {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: rgba(30, 64, 175, 1);
}

.preuse-item {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  line-height: 1.2;
  margin: 0;
}

.preuse-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

/* Responsive: 2 cols then 1 col */
@media (max-width: 980px) {
  .preuse-sheet {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }
}
@media (max-width: 620px) {
  .preuse-sheet {
    grid-template-columns: 1fr;
  }
}

.container {
  max-width: 1100px;
  margin: 0 auto;
}

/* ----------------------------- */
/* HAVS formatting tidy-up       */
/* ----------------------------- */

/* Top header strip: KPI cards + status box aligned nicely */
#havs-editor .havs-head{
  display: grid;
  grid-template-columns: 260px 1fr; /* KPI stack + status */
  gap: 14px;
  align-items: stretch;
}

#havs-editor .havs-kpi{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#havs-editor .havs-kpi-item{
  width: 100%;
}

#havs-editor .havs-status{
  width: 100%;
}

/* Make label/input/textarea behave consistently */
#havs-editor label{
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
}

#havs-editor input,
#havs-editor textarea{
  width: 100%;
  box-sizing: border-box;
}

/* First row: Employee / Date / Assessor / Location */
#havs-editor .havs-row{
  display: grid;
  grid-template-columns: 1.4fr 0.9fr 1.2fr 1.2fr;
  gap: 14px;
  align-items: start;
}

/* Second row (the 4 text areas / ack section): make it look deliberate */
#havs-editor .havs-row:nth-of-type(2){
  grid-template-columns: 1.4fr 1.4fr 1.2fr 1.0fr;
}

/* Textareas same height so the row lines up */
#havs-editor textarea{
  min-height: 92px;
  resize: vertical; /* still allow resizing */
}

/* Employee acknowledgement block: checkbox + initials aligned */
#havs-editor .havs-ack{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 0;
}

#havs-editor .havs-ack label.havs-check{
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-weight: 500;
}

#havs-editor .havs-ack input{
  height: 36px;
}

/* Tools header buttons sit nicely */
#havs-editor .havs-tools-head{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-top: 18px;
}

#havs-editor .havs-tools-actions{
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* Table spacing a bit cleaner */
#havs-editor .havs-table th,
#havs-editor .havs-table td{
  padding: 10px 12px;
}

/* Responsive: stack nicely on narrow screens */
@media (max-width: 980px){
  #havs-editor .havs-head{
    grid-template-columns: 1fr;
  }

  #havs-editor .havs-row,
  #havs-editor .havs-row:nth-of-type(2){
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------- */
/* HAVS HOME (list) tidy-up           */
/* ---------------------------------- */

#havs-home .havs-home-head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  margin-bottom:10px;
}

#havs-home .havs-home-actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
}

#havs-home .havs-home-filters{
  display:flex;
  align-items:center;
  gap:12px;
  margin: 10px 0 12px 0;
  flex-wrap:wrap;
}

#havs-home #havs-search{
  flex: 1 1 360px;
  min-width: 260px;
  height: 36px;
}

#havs-home .havs-check{
  display:flex;
  align-items:center;
  gap:8px;
  margin: 0;
  white-space: nowrap;
}

#havs-home .havs-check input[type="checkbox"]{
  width: 18px;
  height: 18px;
}

/* List layout */
#havs-home .havs-saved-list{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap:12px;
  margin-top: 10px;
}

/* Each saved assessment card */
#havs-home .havs-saved-card{
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}

#havs-home .havs-saved-card:hover{
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

#havs-home .havs-saved-title{
  font-weight: 800;
  font-size: 16px;
  margin-bottom: 4px;
}

#havs-home .havs-saved-main .small{
  color: var(--muted);
}

#havs-home .havs-saved-main .num{
  font-weight: 800;
  color: var(--text-main);
}

/* Make the description line look intentional */
#havs-home .havs-saved-main .small[style*="color:var(--muted)"]{
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Tiny badge (inactive) */
#havs-home .havs-chip{
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,0.08);
  background: rgba(0,0,0,0.03);
}

#havs-home .havs-chip-muted{
  color: var(--muted);
}

/* Responsive: go single column earlier */
@media (max-width: 760px){
  #havs-home .havs-saved-list{
    grid-template-columns: 1fr;
  }
}

/* =========================
   Modules launcher modal
   ========================= */

.modules-btn {
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: #fff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  cursor: pointer;
}

.modules-btn:hover {
  background: rgba(0, 0, 0, 0.03);
}

.modules-modal.hidden {
  display: none;
}

.modules-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.modules-modal-dialog {
  width: min(980px, 96vw);
  max-height: 90vh;
  overflow: auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  border: 1px solid #e5e7eb;
}

.modules-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.modules-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.modules-modal-body {
  padding: 14px 16px 18px;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* 3-wide like you asked */
  gap: 12px;
}

@media (max-width: 520px) {
  .modules-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)); /* avoids microscopic tiles */
  }
}

.module-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: color-mix(in srgb, var(--primary) 10%, white);
  cursor: pointer;
  user-select: none;
  text-decoration: none;
  color: inherit;
  min-height: 110px; /* keeps tiles nice on mobile */
}


.module-tile:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, #e5e7eb);
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

.module-icon-wrap {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}


.module-icon {
  width: 92%;
  height: 92%;
  max-width: none;
  max-height: 140px; /* stops one logo dominating */
  object-fit: contain;
  display: block;
}


.module-label {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.15;
  text-align: center;
  color: #111827;
}



/* Per-icon zoom helpers (hack to compensate for whitespacey SVG viewBoxes) */
.module-icon.zoom-110 { transform: scale(1.10); transform-origin: center; }
.module-icon.zoom-120 { transform: scale(1.20); transform-origin: center; }
.module-icon.zoom-130 { transform: scale(1.30); transform-origin: center; }
.module-icon.zoom-140 { transform: scale(1.40); transform-origin: center; }
.module-icon.zoom-150 { transform: scale(1.50); transform-origin: center; }
.module-icon.zoom-160 { transform: scale(1.60); transform-origin: center; }
.module-icon.zoom-170 { transform: scale(1.70); transform-origin: center; }



/* ================================
   Accident Investigation - Actions
   ================================ */

.ai-actions-wrap {
  overflow-x: auto; /* allow scroll on small screens instead of crushing columns */
}

.ai-actions-table {
  table-layout: fixed;
  width: 100%;
  min-width: 900px; /* prevents the “everything collapses” look */
}

.ai-actions-table th,
.ai-actions-table td {
  vertical-align: middle;
  padding: 10px 8px;
}

.ai-actions-table th:nth-child(1),
.ai-actions-table td:nth-child(1) { width: 40%; }

.ai-actions-table th:nth-child(2),
.ai-actions-table td:nth-child(2) { width: 10%; }

.ai-actions-table th:nth-child(3),
.ai-actions-table td:nth-child(3) { width: 14%; }

.ai-actions-table th:nth-child(4),
.ai-actions-table td:nth-child(4) { width: 12%; }

.ai-actions-table th:nth-child(5),
.ai-actions-table td:nth-child(5) { width: 10%; }

.ai-actions-table th:nth-child(6),
.ai-actions-table td:nth-child(6) { width: 8%; }

.ai-actions-table th:nth-child(7),
.ai-actions-table td:nth-child(7) { width: 6%; }

.ai-actions-table input,
.ai-actions-table select {
  width: 100%;
  box-sizing: border-box;
}

/* Let the action description breathe */
.ai-actions-table td:nth-child(1) input {
  min-width: 260px;
}

/* CAT link should not wrap */
.ai-actions-table td:nth-child(6) a,
.ai-actions-table td:nth-child(6) span {
  white-space: nowrap;
}

/* Remove button stays neat */
.ai-actions-table td:nth-child(7) {
  text-align: right;
}

.ai-actions-table td:nth-child(7) button {
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}
/* ================================
   Accident Investigation - Actions
   Card layout (replaces table)
   ================================ */

.ai-actions-list {
  display: grid;
  gap: 12px;
}

.ai-action-card {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  padding: 12px;
}

.ai-action-card + .ai-action-card {
  border-top: 3px solid rgba(0,0,0,0.06);
}

.ai-action-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}


.ai-action-title label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-action-title input {
  width: 100%;
  box-sizing: border-box;
}

.ai-action-tools {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ai-action-tools a {
  white-space: nowrap;
}

.ai-action-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.ai-action-grid label {
  display: block;
  font-size: 12px;
  color: rgba(0,0,0,0.6);
  margin-bottom: 6px;
}

.ai-action-grid input,
.ai-action-grid select {
  width: 100%;
  box-sizing: border-box;
}

/* Make it usable on smaller screens */
@media (max-width: 1000px) {
  .ai-action-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 520px) {
  .ai-action-top {
    grid-template-columns: 1fr;
  }
  .ai-action-grid {
    grid-template-columns: 1fr;
  }
}


.ai-action-meta {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}

.ai-action-meta a {
  font-weight: 700;
  white-space: nowrap;
}
