/* Manager analytics */
.analytics-grid .panel {
  min-height: 300px;
}

.trend-chart {
  height: 205px;
  padding: 1rem 0.4rem 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(44px, 1fr));
  align-items: end;
  gap: 0.55rem;
  border-bottom: 1px solid var(--line-strong);
}

.trend-column {
  height: 100%;
  display: grid;
  grid-template-rows: minmax(130px, 1fr) auto auto;
  align-items: end;
  justify-items: center;
  gap: 0.16rem;
}

.trend-bars {
  width: min(100%, 48px);
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.trend-bar {
  width: 18px;
  min-height: 3px;
  display: block;
  border-radius: 4px 4px 0 0;
  transition: filter 140ms ease;
}

.trend-bar:hover {
  filter: brightness(0.9);
}

.trend-incident {
  background: var(--incident);
}

.trend-hazard {
  background: var(--hazard);
}

.trend-column > strong {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.trend-column > small {
  color: var(--ink-soft);
  font-size: 0.65rem;
  white-space: nowrap;
}

.chart-legend {
  margin-top: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  color: var(--ink-soft);
  font-size: 0.7rem;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.chart-legend i {
  width: 9px;
  height: 9px;
  display: block;
  border-radius: 2px;
}

.legend-incident {
  background: var(--incident);
}

.legend-hazard {
  background: var(--hazard);
}

.horizontal-bars {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.horizontal-bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.8fr) minmax(120px, 2fr) 30px;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.75rem;
}

.horizontal-bar-row > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.horizontal-bar-row > div {
  height: 11px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f3;
}

.horizontal-bar-row i {
  height: 100%;
  min-width: 3px;
  display: block;
  border-radius: inherit;
  background: var(--brand-600);
}

.horizontal-bar-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lifecycle-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.lifecycle-stats > div {
  padding: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #fafbfb;
}

.lifecycle-stats > div:last-child {
  border-right: 0;
}

.lifecycle-stats strong {
  color: #254d63;
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
}

.lifecycle-stats span {
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Tablet */
@media (max-width: 860px) {
  .app-header,
  .context-nav {
    position: static;
  }

  .app-header-inner {
    min-height: auto;
    padding: 10px 16px;
    grid-template-columns: 1fr auto;
    gap: 8px 16px;
  }

  .workspace-switcher {
    width: 100%;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .workspace-switcher a {
    flex: 1;
    justify-content: center;
  }

  .account-actions {
    gap: 0.7rem;
  }

  .user-name {
    display: none;
  }

  /* The bar scrolls sideways with its scrollbar hidden, so on a phone nothing said
     there was more past the edge. The fade does; the extra end padding lets the
     last item scroll clear of it (audit, 30 October 2026). */
  .context-nav {
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent);
  }

  .context-nav::-webkit-scrollbar {
    display: none;
  }

  .context-nav-inner {
    width: max-content;
    min-width: 100%;
    padding: 0 38px 0 10px;
  }

  .page-container {
    padding: 24px 18px 52px;
  }

  .two-col,
  .form-grid,
  .dashboard-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .span2,
  .form-grid .full {
    grid-column: auto;
  }

  .quick-links {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-question {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-shortcuts {
    align-items: flex-start;
    flex-direction: column;
  }

  .shell {
    flex-direction: column;
  }

  .content {
    padding: 1.25rem 1rem 3rem;
  }

  .login-layout {
    grid-template-columns: 1fr;
  }

  .login-brand-panel {
    min-height: 310px;
    padding: 2rem;
    gap: 2.5rem;
  }

  .login-brand-panel h1 {
    max-width: 650px;
    font-size: clamp(2rem, 7vw, 3rem);
  }

  .login-footnote {
    display: none;
  }

  .login-form-panel {
    padding: 3rem 1.5rem;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .app-header-inner {
    padding-inline: 12px;
  }

  .product-name {
    font-size: 0.9rem;
  }

  .product-arrows {
    width: 32px;
  }

  .account-actions {
    gap: 0.5rem;
  }

  .account-actions > a {
    min-height: 40px;
    font-size: 0.75rem;
  }

  .user-chip {
    display: none;
  }

  .environment-banner,
  .test-banner {
    padding: 0.48rem 0.75rem;
    font-size: 0.68rem;
    line-height: 1.35;
  }

  .page-container {
    padding: 22px 14px 44px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .page-head .head-actions {
    width: 100%;
  }

  .page-head .head-actions .btn {
    flex: 1;
  }

  .site-footer {
    padding-inline: 14px;
  }

  .stat-row,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    padding: 0.8rem;
  }

  .stat b,
  .stat strong {
    font-size: 1.45rem;
  }

  .panel,
  .card {
    padding: 1rem;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filters input[type="search"],
  .filters select,
  .filters .btn {
    width: 100%;
    min-width: 0;
  }

  .inline-form,
  .copy-row,
  .upload-form {
    align-items: stretch;
    flex-direction: column;
  }

  .copy-label {
    width: auto;
  }

  .form-actions .btn {
    min-height: 44px;
  }

  .quick-links,
  .builder-question {
    grid-template-columns: 1fr;
  }

  .risk-grid {
    grid-template-columns: repeat(5, minmax(92px, 1fr));
  }

  .safety-home-container {
    padding-top: 26px;
  }

  .safety-hero {
    margin-bottom: 1rem;
  }

  .safety-hero > p:last-child {
    font-size: 0.93rem;
  }

  .module-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .module-card {
    min-height: 102px;
    padding: 1rem;
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 0.85rem;
    border-radius: 14px;
  }

  .module-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
  }

  .module-icon svg {
    width: 28px;
    height: 28px;
  }

  .module-copy strong {
    font-size: 1rem;
  }

  .module-copy span {
    font-size: 0.79rem;
  }

  .module-arrow {
    display: none;
  }

  .safety-status-line {
    margin-top: 1.4rem;
    align-items: flex-start;
    flex-direction: column;
    gap: 0.25rem;
  }

  .compact-row {
    align-items: flex-start;
  }

  .compact-row small {
    max-width: 190px;
  }

  .login-brand-panel {
    min-height: 280px;
    padding: 1.5rem;
  }

  .product-brand-large .product-env {
    font-size: 1.25rem;
  }

  .product-brand-large .product-arrows {
    width: 41px;
  }

  .product-brand-large .product-name {
    font-size: 1.05rem;
  }

  .login-brand-panel h1 {
    font-size: 2rem;
  }

  .login-brand-panel h1 + p {
    font-size: 0.9rem;
  }

  .login-form-panel {
    padding: 2.25rem 1rem;
  }

  .login-card {
    width: min(100%, 430px);
    padding: 1.35rem;
    border-radius: 13px;
  }

  .login-form-panel .login-card {
    padding: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* Safety tablet refinements */
@media (max-width: 860px) {
  .record-layout {
    grid-template-columns: 1fr;
  }

  .record-side {
    position: static;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .record-side .panel {
    margin-bottom: 0;
  }

  .record-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .risk-controls {
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .risk-result {
    grid-column: 1 / -1;
  }

  .investigation-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .investigation-summary > div:nth-child(2) {
    border-right: 0;
  }

  .investigation-summary > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .checklist-question {
    grid-template-columns: minmax(190px, 0.8fr) minmax(230px, 1.2fr);
    gap: 0.9rem;
  }

  .signon-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .signon-row .signature-pad {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .signon-row .icon-button {
    grid-column: 2;
    grid-row: 1;
  }

  .checklist-card-grid {
    grid-template-columns: 1fr;
  }

  .action-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-update {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-update .btn {
    justify-self: start;
  }

  .filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-search {
    grid-column: 1 / -1;
  }

  .filter-actions {
    align-self: end;
  }

  .stop-work-alert {
    top: 12px;
  }
}

/* Safety mobile refinements */
@media (max-width: 600px) {
  .safety-form-container,
  .checklist-form-container {
    padding-inline: 12px;
  }

  .page-head-accent {
    padding-left: 0.85rem;
  }

  .form-section {
    padding: 1rem;
    border-radius: 13px;
  }

  .form-section-head {
    margin-bottom: 0.9rem;
    gap: 0.65rem;
  }

  .step-number {
    width: 27px;
    height: 27px;
    font-size: 0.7rem;
  }

  .nested-fields {
    padding: 0.8rem;
  }

  .reporter-summary {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 0.55rem 0.7rem;
  }

  .reporter-summary > span:not(.user-avatar) {
    min-width: 0;
  }

  .reporter-summary > span:nth-child(n + 3) {
    grid-column: 2;
  }

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

  .risk-times {
    display: none;
  }

  .risk-result {
    grid-column: auto;
    min-height: 58px;
  }

  .matrix-grid {
    min-width: 520px;
    grid-template-columns: repeat(5, minmax(92px, 1fr));
  }

  .matrix-grid .risk-cell {
    min-height: 60px;
    padding: 0.45rem;
  }

  .risk-matrix {
    min-width: 560px;
    font-size: 0.66rem;
  }

  .risk-matrix th[scope="row"] {
    min-width: 88px;
  }

  .risk-matrix .risk-cell {
    min-height: 46px;
    padding: 0.4rem 0.25rem;
  }

  .upload-drop {
    min-height: 130px;
    padding: 0.8rem;
  }

  .sticky-form-actions {
    position: static;
    padding: 0.65rem;
    box-shadow: var(--shadow-sm);
  }

  .sticky-form-actions .btn {
    flex: 1;
  }

  .record-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .record-layout {
    display: block;
  }

  .record-side {
    display: block;
  }

  .record-side .panel {
    margin-bottom: 1rem;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid > div,
  .detail-grid > div:nth-child(2n),
  .detail-grid > div:nth-last-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid #e9edef;
  }

  .detail-grid > div:last-child {
    border-bottom: 0;
  }

  .detail-grid .detail-wide {
    grid-column: auto;
  }

  .create-panel > summary {
    min-height: 64px;
    padding: 0.85rem 1rem;
  }

  .create-panel > form {
    padding: 1rem;
  }

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

  .attachment-image img {
    height: 105px;
  }

  .document-row {
    grid-template-columns: 34px minmax(0, 1fr) auto;
    gap: 0.5rem;
  }

  .document-row > span:last-child,
  .document-row time {
    font-size: 0.66rem;
  }

  .inline-upload {
    grid-template-columns: 1fr;
  }

  .file-picker,
  .inline-upload .btn {
    width: 100%;
  }

  .file-picker {
    justify-content: center;
  }

  .library-folder-head {
    grid-template-columns: 24px minmax(0, 1fr);
  }

  .library-folder-head > span {
    grid-column: 2;
  }

  .library-folder .document-list {
    padding-inline: 0.75rem;
  }

  .empty-page {
    min-height: 220px;
    padding: 1.5rem 1rem;
  }

  .status-badge {
    align-self: flex-start;
  }

  .investigation-summary {
    grid-template-columns: 1fr;
  }

  .investigation-summary > div,
  .investigation-summary > div:nth-child(2),
  .investigation-summary > div:nth-child(-n + 2) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .investigation-summary > div:last-child {
    border-bottom: 0;
  }

  .factor-card {
    padding: 0.8rem;
  }

  .checklist-question {
    padding: 0.9rem 0;
    grid-template-columns: 1fr;
    gap: 0.7rem;
  }

  .question-copy {
    grid-template-columns: 25px minmax(0, 1fr);
  }

  .question-number {
    width: 24px;
    height: 24px;
  }

  .signature-pad canvas {
    height: 135px;
  }

  .signature-pad-small canvas {
    height: 90px;
  }

  .signon-row {
    grid-template-columns: 1fr auto;
  }

  .checklist-card {
    grid-template-columns: 44px minmax(0, 1fr);
    align-items: start;
  }

  .checklist-card-icon {
    width: 44px;
    height: 44px;
  }

  .checklist-card-actions {
    grid-column: 1 / -1;
    align-items: center;
    flex-direction: row;
    justify-content: flex-end;
  }

  .response-list > div {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .report-signons {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-bar label {
    min-width: 0;
  }

  .filter-bar .btn {
    width: 100%;
  }

  .action-card-head {
    align-items: flex-start;
  }

  .action-card-head .pill {
    flex: none;
  }

  .action-meta {
    grid-template-columns: 1fr;
    gap: 0.45rem;
  }

  .action-meta .detail-wide {
    grid-column: auto;
  }

  .action-update {
    grid-template-columns: 1fr;
  }

  .action-update .btn {
    width: 100%;
  }

  .filter-panel {
    grid-template-columns: 1fr;
    padding: 0.85rem;
  }

  .filter-search {
    grid-column: auto;
  }

  .filter-actions {
    width: 100%;
  }

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

  .analytics-grid .panel {
    min-height: 0;
    overflow: hidden;
  }

  .trend-chart {
    width: 100%;
    grid-template-columns: repeat(6, minmax(58px, 1fr));
    overflow-x: auto;
  }

  .horizontal-bar-row {
    grid-template-columns: minmax(72px, 0.8fr) minmax(90px, 1.5fr) 28px;
    gap: 0.45rem;
  }

  .lifecycle-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lifecycle-stats > div:nth-child(2) {
    border-right: 0;
  }

  .lifecycle-stats > div:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

.print-brand {
  display: none;
}

/* Checklist report printing */
@media print {
  @page {
    size: A4;
    margin: 13mm;
  }

  html,
  body {
    min-width: 0;
    min-height: 0;
    display: block;
    background: #ffffff !important;
    color: #000000;
    font-size: 9.5pt;
  }

  .app-header,
  .context-nav,
  .environment-banner,
  .site-footer,
  .no-print {
    display: none !important;
  }

  .page-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .print-brand {
    margin-bottom: 7mm;
    display: flex;
    align-items: center;
    gap: 2mm;
    font-size: 15pt;
  }

  .print-brand strong {
    font-size: 18pt;
  }

  .print-brand span {
    color: var(--env-yellow-dark);
    letter-spacing: -1px;
  }

  .page-head {
    margin: 0 0 8mm;
    padding-bottom: 4mm;
    border-bottom: 1px solid #aeb7bc;
  }

  .page-head-accent {
    padding-left: 4mm;
  }

  .page-head h1 {
    font-size: 18pt;
  }

  .back-link {
    display: none;
  }

  .page-intro {
    color: #333333;
    font-size: 9pt;
  }

  .stat-row,
  .record-stats {
    margin-bottom: 6mm;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 2mm;
  }

  .stat {
    padding: 3mm;
    border-color: #aeb7bc;
    box-shadow: none;
  }

  .stat b,
  .stat strong,
  .record-stats .stat b {
    color: #000000;
    font-size: 10pt;
  }

  .stat span {
    color: #444444;
    font-size: 6.5pt;
  }

  .alert {
    break-inside: avoid;
    border-color: #555555;
    background: #ffffff !important;
    color: #000000;
  }

  .panel,
  .card {
    margin-bottom: 5mm;
    padding: 4mm;
    break-inside: avoid;
    border-color: #aeb7bc;
    border-radius: 2mm;
    box-shadow: none;
  }

  .panel-head {
    margin-bottom: 2mm;
  }

  .panel-head h2 {
    font-size: 11pt;
  }

  .eyebrow {
    color: #444444;
    font-size: 6.5pt;
  }

  .response-list > div {
    min-height: 0;
    padding: 2.5mm 0;
    grid-template-columns: 42% 58%;
    break-inside: avoid;
    border-color: #d3d8db;
  }

  .response-list dt,
  .response-list dd {
    color: #000000;
    font-size: 8.5pt;
  }

  .response-critical {
    border-left-color: #000000;
    background: #f1f1f1 !important;
  }

  .pill,
  .pill-danger {
    border: 1px solid #555555;
    background: #ffffff !important;
    color: #000000;
  }

  .report-signons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .report-signons > div {
    break-inside: avoid;
    border-color: #aeb7bc;
  }

  .report-signons img {
    height: 20mm;
  }

  .report-evidence-image {
    max-width: 100%;
    max-height: 70mm;
    border-color: #aeb7bc;
  }

  a {
    color: #000000;
    text-decoration: none;
  }
}

