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;
}

#theme-toggle:focus:not(:focus-visible),
#theme-toggle:active:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

#theme-toggle:focus-visible {
  outline: 2px solid rgba(var(--link-accent-rgb), 0.45);
  outline-offset: 2px;
  box-shadow: none;
}

.navbar-toggler:focus,
.navbar-toggler:focus-visible,
.navbar-toggler:active:focus {
  outline: none;
  box-shadow: none;
}

.general-factor-toggle:focus,
.general-factor-toggle:focus-visible,
.general-factor-toggle:active:focus {
  outline: none;
  box-shadow: none;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
  background:
    linear-gradient(180deg, rgba(var(--link-accent-rgb), 0.05), transparent 220px),
    var(--app-bg);
}

/* Link accent colors by theme */
:root {
  --app-bg: #f6f8fa;
  --app-surface: #ffffff;
  --app-surface-muted: #f8fafb;
  --app-border: rgba(33, 37, 41, 0.11);
  --app-shadow: 0 12px 32px rgba(24, 36, 51, 0.07);
  --link-accent-rgb: 31, 111, 101;
  --link-accent: rgb(var(--link-accent-rgb));
  --action-rgb: 72, 110, 142;
  --action: rgb(var(--action-rgb));
  --action-hover: #3f6380;
  --action-active: #36566f;
  --action-border: #3f6380;
  --factor-adults-color: #d97706;
  --factor-young-adults-color: #22c55e;
  --factor-teens-color: #3b82f6;
  --factor-children-color: #d946ef;
}

[data-bs-theme="dark"] {
  --app-bg: #101418;
  --app-surface: #171c21;
  --app-surface-muted: #1d2329;
  --app-border: rgba(255, 255, 255, 0.11);
  --app-shadow: 0 14px 36px rgba(0, 0, 0, 0.28);
  --link-accent-rgb: 120, 201, 191;
  --action-rgb: 102, 146, 182;
  --action: rgb(var(--action-rgb));
  --action-hover: #5d8db1;
  --action-active: #547f9f;
  --action-border: #5d8db1;
}

.app-page {
  padding-bottom: 2rem;
}

.app-navbar .navbar-collapse {
  gap: 1rem;
}

.app-navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: auto;
}

.theme-toggle-button,
.app-user-menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  color: var(--bs-secondary-color);
  background: transparent;
  border: 1px solid var(--app-border);
  border-radius: 0.4rem;
}

.theme-toggle-button {
  width: 2rem;
  padding: 0;
}

.theme-toggle-button:hover,
.theme-toggle-button:focus-visible,
.app-user-menu-toggle:hover,
.app-user-menu-toggle:focus-visible,
.app-user-menu-toggle[aria-expanded="true"] {
  color: var(--bs-emphasis-color);
  background: var(--app-surface-muted);
  border-color: rgba(var(--link-accent-rgb), 0.42);
}

.theme-toggle-icon {
  display: none;
  width: 1.05rem;
  height: 1.05rem;
  color: currentColor;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle-button[data-theme="light"] .theme-toggle-sun,
.theme-toggle-button[data-theme="dark"] .theme-toggle-moon {
  display: block;
}

.app-user-menu-toggle {
  gap: 0.42rem;
  padding: 0.18rem 0.48rem 0.18rem 0.25rem;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 650;
}

.app-user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  color: var(--link-accent);
  background: rgba(var(--link-accent-rgb), 0.13);
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
}

.app-user-chevron {
  width: 0.42rem;
  height: 0.42rem;
  margin-left: 0.08rem;
  border-right: 1.7px solid currentColor;
  border-bottom: 1.7px solid currentColor;
  transform: translateY(-0.12rem) rotate(45deg);
  transition: transform 0.15s ease;
}

.app-user-menu-toggle[aria-expanded="true"] .app-user-chevron {
  transform: translateY(0.1rem) rotate(225deg);
}

.app-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.app-page-title {
  margin: 0;
  font-size: clamp(1.7rem, 1.45rem + 1vw, 2.3rem);
  line-height: 1.1;
  font-weight: 700;
}

.app-page-lead {
  max-width: 48rem;
  margin: 0.45rem 0 0;
  color: var(--bs-secondary-color);
}

.app-page-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-surface {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--app-shadow);
}

.app-surface > .card-body {
  padding: 1rem;
}

.password-field {
  position: relative;
}

.password-field .form-control {
  padding-right: 2.75rem;
}

.password-visibility-toggle {
  position: absolute;
  top: 50%;
  right: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--bs-secondary-color);
  background: transparent;
  border: 0;
  border-radius: 0.35rem;
  transform: translateY(-50%);
}

.password-visibility-toggle:hover,
.password-visibility-toggle:focus-visible {
  color: var(--bs-emphasis-color);
  background: var(--app-surface-muted);
}

.password-toggle-eye {
  position: relative;
  display: block;
  width: 1.05rem;
  height: 1.05rem;
  border: 1.7px solid currentColor;
  border-radius: 75% 15%;
  transform: rotate(45deg);
}

.password-toggle-eye::before {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  width: 0.32rem;
  height: 0.32rem;
  background: currentColor;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.password-visibility-toggle.is-visible .password-toggle-eye::after {
  position: absolute;
  content: "";
  top: 50%;
  left: 50%;
  width: 1.25rem;
  border-top: 1.7px solid currentColor;
  transform: translate(-50%, -50%) rotate(90deg);
}

input.form-control:-webkit-autofill,
input.form-control:-webkit-autofill:hover,
input.form-control:-webkit-autofill:focus,
input.form-control:-webkit-autofill:active {
  -webkit-text-fill-color: var(--bs-body-color) !important;
  caret-color: var(--bs-body-color);
  -webkit-box-shadow: 0 0 0 1000px var(--bs-body-bg) inset !important;
  box-shadow: 0 0 0 1000px var(--bs-body-bg) inset !important;
  transition: background-color 9999s ease-in-out 0s;
}

input.form-control:autofill {
  color: var(--bs-body-color);
  box-shadow: 0 0 0 1000px var(--bs-body-bg) inset !important;
}

#resetPasswordModal .modal-header,
#resetPasswordModal .modal-footer {
  border: 0;
}

.app-surface-muted {
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.app-section {
  margin-bottom: 1rem;
}

.app-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.app-section-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

.app-section-meta {
  margin: 0.2rem 0 0;
  color: var(--bs-secondary-color);
  font-size: 0.94rem;
}

.app-toolbar {
  display: flex;
  align-items: end;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.app-toolbar .form-label {
  margin-bottom: 0.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
}

.report-filter-toolbar .validation-summary-valid,
.report-filter-toolbar .field-validation-valid {
  display: none;
}

.app-toolbar-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.report-filter-actions {
  align-items: center;
  margin-left: 0;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.kpi-card {
  padding: 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.kpi-label {
  margin-bottom: 0.35rem;
  color: var(--bs-secondary-color);
  font-size: 0.88rem;
}

.kpi-value {
  font-size: 1.65rem;
  line-height: 1.1;
  font-weight: 700;
}

.kpi-note {
  margin-top: 0.25rem;
  color: var(--bs-secondary-color);
  font-size: 0.86rem;
}

.workflow-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.9rem;
}

.workflow-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1rem;
  color: inherit;
  text-decoration: none;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--app-shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.workflow-card:hover,
.workflow-card:focus-visible {
  color: inherit;
  border-color: rgba(var(--link-accent-rgb), 0.5);
  transform: translateY(-1px);
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.85rem;
  margin-bottom: 0.75rem;
  color: var(--link-accent);
  background: rgba(var(--link-accent-rgb), 0.11);
  border-radius: 999px;
  font-weight: 700;
}

.workflow-title {
  margin: 0 0 0.35rem;
  font-weight: 700;
}

.workflow-text {
  margin: 0;
  color: var(--bs-secondary-color);
  font-size: 0.93rem;
}

.table-shell {
  overflow: auto;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.table-shell .table {
  margin-bottom: 0;
}

.table-shell thead th {
  color: var(--bs-secondary-color);
  background: var(--app-surface-muted);
  border-bottom-color: var(--app-border);
  font-size: 0.9rem;
  font-weight: 700;
}

.table-shell tbody tr:last-child td {
  border-bottom: 0;
}

.app-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.app-tab {
  display: inline-flex;
  align-items: center;
  min-height: 2.25rem;
  padding: 0.35rem 0.75rem;
  color: var(--bs-emphasis-color);
  text-decoration: none;
  border: 1px solid var(--app-border);
  border-radius: 999px;
  background: var(--app-surface);
}

.app-tab:hover,
.app-tab:focus-visible {
  color: var(--bs-emphasis-color);
  border-color: rgba(var(--link-accent-rgb), 0.55);
}

.app-tab.active {
  color: #fff;
  background: var(--action);
  border-color: var(--action-border);
}

.form-panel {
  padding: 1rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.upload-panel {
  padding: 1.25rem;
  background: var(--app-surface);
  border: 1px dashed rgba(var(--link-accent-rgb), 0.55);
  border-radius: 8px;
}

.empty-state {
  padding: 1rem;
  color: var(--bs-secondary-color);
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
}

.status-badge-success {
  color: #0f5132;
  background: #d1e7dd;
}

.status-badge-muted {
  color: #495057;
  background: #e9ecef;
}

[data-bs-theme="dark"] .status-badge-success {
  color: #b7f0ce;
  background: rgba(25, 135, 84, 0.25);
}

[data-bs-theme="dark"] .status-badge-muted {
  color: #d4d8dc;
  background: rgba(255, 255, 255, 0.12);
}

.factor-row-actions-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  color: var(--bs-secondary-color);
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 0.4rem;
  cursor: pointer;
}

.factor-row-actions-toggle:hover,
.factor-row-actions-toggle:focus-visible {
  color: var(--bs-emphasis-color);
  border-color: rgba(var(--link-accent-rgb), 0.45);
}

.factor-row-actions-icon {
  display: grid;
  gap: 0.16rem;
}

.factor-row-actions-icon span {
  display: block;
  width: 0.22rem;
  height: 0.22rem;
  background: currentColor;
  border-radius: 999px;
}

.factor-row-actions-popover {
  position: fixed;
  inset: 0 auto auto 0;
  margin: 0;
  padding: 0;
  color: var(--bs-body-color);
  background: transparent;
  border: 0;
  overflow: visible;
  z-index: 1080;
}

.factor-row-actions-popover:popover-open {
  display: block;
}

.factor-row-actions-menu {
  display: grid;
  gap: 0.15rem;
  min-width: 9rem;
  margin-top: 0.35rem;
  padding: 0.3rem;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 0.45rem;
  box-shadow: var(--app-shadow);
}

.factor-row-action-item {
  display: block;
  width: 100%;
  padding: 0.4rem 0.5rem;
  color: var(--bs-emphasis-color);
  background: transparent;
  border: 0;
  border-radius: 0.3rem;
  text-align: left;
  text-decoration: none;
  font: inherit;
  white-space: nowrap;
}

.factor-row-action-item:hover,
.factor-row-action-item:focus-visible {
  color: var(--bs-emphasis-color);
  background: var(--app-surface-muted);
}

.factor-row-action-danger {
  color: var(--bs-danger);
}

.user-row-actions-menu {
  min-width: 13rem;
}

.factor-table-comment {
  min-width: 18rem;
  max-width: 28rem;
}

.factor-table-comment-text,
.factor-table-comment .factor-comment-preview,
.factor-table-comment .factor-comment-full {
  color: var(--bs-secondary-color);
  font-weight: 500;
}

.factor-table-comment-disclosure {
  max-width: 28rem;
}

/* Global link treatment: less default-blue, clearer hover/focus behavior */
a:not(.btn):not(.nav-link):not(.navbar-brand):not(.workflow-card):not(.app-tab) {
  color: var(--bs-emphasis-color);
  text-decoration-color: rgba(var(--link-accent-rgb), 0.45);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}

a:not(.btn):not(.nav-link):not(.navbar-brand):not(.workflow-card):not(.app-tab):hover,
a:not(.btn):not(.nav-link):not(.navbar-brand):not(.workflow-card):not(.app-tab):focus-visible {
  color: var(--link-accent);
  text-decoration-color: rgba(var(--link-accent-rgb), 0.75);
}

.btn-primary {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--action);
  --bs-btn-border-color: var(--action-border);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--action-hover);
  --bs-btn-hover-border-color: var(--action-hover);
  --bs-btn-focus-shadow-rgb: var(--action-rgb);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--action-active);
  --bs-btn-active-border-color: var(--action-active);
  --bs-btn-disabled-color: #fff;
  --bs-btn-disabled-bg: var(--action);
  --bs-btn-disabled-border-color: var(--action-border);
}

.btn-outline-primary {
  --bs-btn-color: var(--action);
  --bs-btn-border-color: var(--action-border);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--action);
  --bs-btn-hover-border-color: var(--action-border);
  --bs-btn-focus-shadow-rgb: var(--action-rgb);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--action-active);
  --bs-btn-active-border-color: var(--action-active);
  --bs-btn-disabled-color: var(--action);
  --bs-btn-disabled-bg: transparent;
  --bs-btn-disabled-border-color: var(--action-border);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}

.audit-action-chip {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: 0.16rem 0.5rem;
  color: var(--bs-emphasis-color);
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.factor-timeline {
  display: grid;
  gap: 0.5rem;
}

.factor-timeline-event {
  position: relative;
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: var(--app-shadow);
  overflow: hidden;
}

.factor-timeline-event[open] {
  border-color: rgba(var(--link-accent-rgb), 0.28);
}

.factor-timeline-row {
  display: grid;
  grid-template-columns: 2rem 8.5rem minmax(16rem, 1fr) minmax(11rem, 0.65fr) 1.25rem;
  gap: 0.9rem;
  align-items: center;
  padding: 0.85rem 1rem;
  cursor: pointer;
  list-style: none;
}

.factor-timeline-row::-webkit-details-marker {
  display: none;
}

.factor-timeline-event[open] > .factor-timeline-row {
  border-bottom: 1px solid var(--app-border);
}

.factor-timeline-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 1.9rem;
  height: 1.9rem;
  color: var(--bs-secondary-color);
  background: var(--app-surface-muted);
  border: 1px solid var(--app-border);
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
}

.factor-timeline-created .factor-timeline-marker {
  color: #198754;
  background: rgba(25, 135, 84, 0.13);
  border-color: rgba(25, 135, 84, 0.32);
}

.factor-timeline-updated .factor-timeline-marker {
  color: var(--action);
  background: rgba(var(--action-rgb), 0.13);
  border-color: rgba(var(--action-rgb), 0.32);
}

.factor-timeline-deleted .factor-timeline-marker {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.13);
  border-color: rgba(220, 53, 69, 0.32);
}

.factor-timeline-date-time {
  display: grid;
  gap: 0.12rem;
  color: var(--bs-secondary-color);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.factor-timeline-clock {
  color: var(--bs-emphasis-color);
  font-size: 0.98rem;
  font-weight: 400;
}

.factor-timeline-identity {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  flex-wrap: wrap;
}

.factor-title {
  color: var(--bs-emphasis-color);
  font-weight: 400;
  white-space: nowrap;
}

.factor-timeline-user {
  color: var(--bs-secondary-color);
  font-size: 0.9rem;
  white-space: nowrap;
}

.factor-timeline-when {
  display: grid;
  gap: 0.18rem;
  color: var(--bs-secondary-color);
  font-size: 0.93rem;
  justify-self: end;
  white-space: nowrap;
}

.factor-timeline-when > span,
.factor-timeline-range {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.factor-timeline-range {
  color: var(--bs-emphasis-color);
  font-size: 0.98rem;
  font-weight: 400;
}

.factor-timeline-when-icon {
  position: relative;
  display: inline-block;
  width: 1rem;
  height: 1rem;
  color: var(--bs-secondary-color);
  flex: 0 0 auto;
}

.factor-timeline-when-calendar {
  border: 1.7px solid currentColor;
  border-radius: 0.2rem;
}

.factor-timeline-when-calendar::before {
  position: absolute;
  content: "";
  left: -1.7px;
  right: -1.7px;
  top: 0.25rem;
  border-top: 1.7px solid currentColor;
}

.factor-timeline-when-calendar::after {
  position: absolute;
  content: "";
  left: 0.22rem;
  right: 0.22rem;
  top: -0.22rem;
  height: 0.32rem;
  border-left: 1.7px solid currentColor;
  border-right: 1.7px solid currentColor;
}

.factor-timeline-when-clock {
  border: 1.7px solid currentColor;
  border-radius: 999px;
}

.factor-timeline-when-clock::before,
.factor-timeline-when-clock::after {
  position: absolute;
  content: "";
  left: 50%;
  top: 50%;
  width: 1.7px;
  background: currentColor;
  transform-origin: 50% 0;
}

.factor-timeline-when-clock::before {
  height: 0.34rem;
  transform: translate(-50%, -0.04rem);
}

.factor-timeline-when-clock::after {
  height: 0.27rem;
  transform: translate(-50%, -0.04rem) rotate(90deg);
}

.factor-timeline-chevron {
  width: 0.7rem;
  height: 0.7rem;
  border-right: 2px solid var(--bs-secondary-color);
  border-bottom: 2px solid var(--bs-secondary-color);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
  justify-self: end;
}

.factor-timeline-event[open] .factor-timeline-chevron {
  transform: rotate(225deg);
}

.factor-timeline-expanded {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(14rem, 0.9fr);
  gap: 1rem;
  padding: 1rem 1rem 1rem 3.9rem;
}

.factor-detail-heading {
  margin-bottom: 0.7rem;
  color: var(--bs-secondary-color);
  font-size: 0.88rem;
  font-weight: 800;
}

.factor-values-panel {
  padding-right: 1rem;
  border-right: 1px solid var(--app-border);
}

.factor-values-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.factor-values-grid div {
  display: grid;
  gap: 0.25rem;
}

.factor-values-grid span {
  color: var(--bs-secondary-color);
  font-size: 0.86rem;
}

.factor-values-grid strong {
  font-size: 1.15rem;
}

.factor-comment-panel {
  min-width: 0;
}

.factor-comment-panel p {
  margin: 0;
  color: var(--bs-emphasis-color);
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.factor-comment-empty {
  color: var(--bs-secondary-color) !important;
  font-weight: 500 !important;
}

.factor-comment-disclosure summary {
  display: flex;
  gap: 0.5rem;
  align-items: baseline;
  max-width: 100%;
  cursor: pointer;
  list-style: none;
}

.factor-comment-disclosure summary::-webkit-details-marker {
  display: none;
}

.factor-comment-preview {
  min-width: 0;
  overflow: hidden;
  color: var(--bs-emphasis-color);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.factor-comment-full {
  display: none;
  color: var(--bs-emphasis-color);
  font-weight: 400;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: normal;
}

.factor-comment-disclosure summary em {
  color: var(--link-accent);
  font-style: normal;
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.factor-comment-less,
.factor-comment-disclosure[open] .factor-comment-preview,
.factor-comment-disclosure[open] .factor-comment-more {
  display: none;
}

.factor-comment-disclosure[open] summary {
  display: block;
}

.factor-comment-disclosure[open] .factor-comment-full {
  display: inline;
}

.factor-comment-disclosure[open] .factor-comment-less {
  display: inline;
  margin-left: 0.45rem;
}

.factor-timeline .badge,
.factor-timeline .status-badge {
  white-space: nowrap;
}

.report-chart-wrap {
  overflow-x: auto;
  position: relative;
}

.report-chart-svg {
  width: 100%;
  min-width: 720px;
  height: auto;
  display: block;
}

.report-chart-svg .chart-axis-line {
  stroke: none;
}

.chart-grid-line {
  stroke: var(--bs-border-color);
  stroke-width: 1;
  opacity: 0.6;
}

.chart-axis-line {
  stroke: var(--bs-emphasis-color);
  stroke-width: 1.2;
}

.chart-axis-label {
  fill: var(--bs-secondary-color);
  font-size: 12px;
}

.chart-axis-title {
  fill: var(--bs-emphasis-color);
  font-size: 12px;
  font-weight: 600;
}

.chart-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-line-passages {
  stroke: #3f6380;
}

.chart-line-visits {
  stroke: #198754;
}

.chart-line-factor-adults {
  stroke: var(--factor-adults-color);
}

.chart-line-factor-young-adults {
  stroke: var(--factor-young-adults-color);
}

.chart-line-factor-teens {
  stroke: var(--factor-teens-color);
}

.chart-line-factor-children {
  stroke: var(--factor-children-color);
}

.chart-hover-zone {
  fill: transparent;
  pointer-events: all;
}

.chart-hover-zone:hover {
  fill: rgba(var(--link-accent-rgb), 0.08);
}

.report-week-wrap {
  overflow-x: auto;
}

.report-week-table {
  min-width: 980px;
}

.report-week-table th:first-child,
.report-week-table td:first-child {
  white-space: nowrap;
  min-width: 5.5rem;
}

.text-week-adults {
  color: var(--factor-adults-color);
}

.text-week-young-adults {
  color: var(--factor-young-adults-color);
}

.text-week-teens {
  color: var(--factor-teens-color);
}

.text-week-children {
  color: var(--factor-children-color);
}

.report-week-table thead th.text-week-adults {
  color: var(--factor-adults-color) !important;
}

.report-week-table thead th.text-week-young-adults {
  color: var(--factor-young-adults-color) !important;
}

.report-week-table thead th.text-week-teens {
  color: var(--factor-teens-color) !important;
}

.report-week-table thead th.text-week-children {
  color: var(--factor-children-color) !important;
}

.factors-active-table thead th.text-week-adults {
  color: var(--factor-adults-color) !important;
}

.factors-active-table thead th.text-week-young-adults {
  color: var(--factor-young-adults-color) !important;
}

.factors-active-table thead th.text-week-teens {
  color: var(--factor-teens-color) !important;
}

.factors-active-table thead th.text-week-children {
  color: var(--factor-children-color) !important;
}

.factors-old-table thead th.text-week-adults {
  color: var(--factor-adults-color) !important;
}

.factors-old-table thead th.text-week-young-adults {
  color: var(--factor-young-adults-color) !important;
}

.factors-old-table thead th.text-week-teens {
  color: var(--factor-teens-color) !important;
}

.factors-old-table thead th.text-week-children {
  color: var(--factor-children-color) !important;
}

.factors-active-table,
.factors-old-table {
  min-width: 1080px;
}

.factors-active-table th,
.factors-active-table td,
.factors-old-table th,
.factors-old-table td {
  white-space: nowrap;
}

.week-stack-track {
  width: 100%;
  height: 16px;
  overflow: visible;
}

.week-stack-svg {
  width: 100%;
  max-width: 100%;
  height: 100%;
  border-radius: 999px;
  overflow: hidden;
  display: block;
}

.chart-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-9999px, -9999px);
  padding: 0.35rem 0.5rem;
  border-radius: 0.4rem;
  border: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
  color: var(--bs-emphasis-color);
  font-size: 0.82rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  pointer-events: none;
  white-space: nowrap;
  z-index: 5;
}

.chart-tooltip-global {
  z-index: 2000;
}

.chart-tooltip.is-visible {
  transform: none;
}

.report-chart-legend {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.report-view-switch {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend-swatch {
  width: 0.75rem;
  height: 0.75rem;
  margin-right: 0.35rem;
  vertical-align: -0.1em;
}

.legend-swatch circle {
  fill: currentColor;
}

.legend-visits {
  color: #198754;
}

.legend-factor-adults {
  color: var(--factor-adults-color);
}

.legend-factor-young-adults {
  color: var(--factor-young-adults-color);
}

.legend-factor-teens {
  color: var(--factor-teens-color);
}

.legend-factor-children {
  color: var(--factor-children-color);
}

.week-segment-adults {
  fill: var(--factor-adults-color);
}

.week-segment-young-adults {
  fill: var(--factor-young-adults-color);
}

.week-segment-teens {
  fill: var(--factor-teens-color);
}

.week-segment-children {
  fill: var(--factor-children-color);
}

@media (max-width: 991.98px) {
  .app-page-header,
  .app-section-header {
    flex-direction: column;
  }

  .app-page-actions,
  .app-toolbar-actions {
    width: 100%;
    justify-content: flex-start;
    margin-left: 0;
  }

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

  .factor-timeline-row {
    grid-template-columns: 2rem 7.5rem minmax(0, 1fr) 1.25rem;
  }

  .factor-timeline-marker {
    grid-column: 1;
    grid-row: 1 / span 2;
  }

  .factor-timeline-date-time {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .factor-timeline-identity {
    grid-column: 3;
    grid-row: 1;
  }

  .factor-timeline-when {
    grid-column: 3;
    grid-row: 2;
    justify-self: start;
  }

  .factor-timeline-chevron {
    grid-column: 4;
    grid-row: 1 / span 2;
  }

  .factor-timeline-expanded {
    grid-template-columns: 1fr;
  }

  .factor-values-panel {
    padding-right: 0;
    padding-bottom: 1rem;
    border-right: 0;
    border-bottom: 1px solid var(--app-border);
  }

  .navbar-collapse .app-navbar-actions {
    width: 100%;
    justify-content: flex-start;
    margin-top: 0.55rem;
    margin-left: 0;
    padding-top: 0.55rem;
    border-top: 1px solid var(--bs-border-color);
  }
}

@media (max-width: 768px) {
  .app-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .report-filter-actions {
    display: grid;
    grid-template-columns: auto auto;
    justify-content: space-between;
    width: 100%;
  }

  .kpi-grid,
  .workflow-grid {
    grid-template-columns: 1fr;
  }

  .kpi-value {
    font-size: 1.45rem;
  }

  .factor-timeline-row {
    grid-template-columns: 2rem minmax(0, 1fr) 1.25rem;
    gap: 0.65rem;
    padding: 0.85rem;
  }

  .factor-timeline-marker {
    grid-column: 1;
    grid-row: 1;
  }

  .factor-timeline-date-time {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    gap: 0.75rem;
    align-items: baseline;
  }

  .factor-timeline-identity {
    grid-column: 2 / 4;
    grid-row: 2;
  }

  .factor-timeline-when {
    grid-column: 2 / 4;
    grid-row: 3;
  }

  .factor-timeline-chevron {
    grid-column: 3;
    grid-row: 1;
  }

  .factor-timeline-expanded {
    padding: 0.85rem 0.85rem 0.85rem 3.5rem;
  }

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

  .report-chart-svg {
    min-width: 640px;
  }

  .report-week-table {
    min-width: 860px;
  }
}
