* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  color: #1a1a1a;
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}
h1 { margin-bottom: 0.5rem; }
h2 { margin: 1.5rem 0 0.75rem; border-bottom: 2px solid #e0e0e0; padding-bottom: 0.25rem; }
h3 { margin: 0.75rem 0 0.5rem; }
.ai-explainer {
  margin: 0.5rem 0 1rem;
  padding: 0.9rem 1rem;
  background: #fff76a;
  border: 2px dashed #3d2f00;
  border-radius: 6px;
  color: #1f1300;
  font-family: "Courier New", Courier, monospace;
  line-height: 1.45;
}
.ai-explainer h2 {
  margin: 0 0 0.45rem;
  border: 0;
  padding: 0;
  font-size: 1rem;
}
.ai-explainer p {
  margin: 0 0 0.45rem;
}
.ai-explainer ul {
  margin: 0.25rem 0 0.45rem 1.2rem;
}
.ai-explainer a {
  color: #7a001f;
  font-weight: 700;
}

/* Rate estimator */
.company-panel {
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fafafa;
}
.company-panel h3 { margin-top: 0; }
.slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}
.slider-row label { min-width: 220px; font-size: 0.9rem; }
.slider-row input[type="range"] { flex: 1; min-width: 120px; }
.slider-row .val { min-width: 100px; text-align: right; font-variant-numeric: tabular-nums; }
.result-box {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
}
.result-box .estimate {
  font-size: 1.25rem;
  font-weight: 600;
}
.result-box .ci { font-size: 0.9rem; color: #555; }
.graph-svg {
  width: 100%;
  height: auto;
  display: block;
}
.graph-grid {
  display: none;
}
.graph-axis {
  stroke: #a7afbf;
  stroke-width: 1;
}
.graph-line {
  fill: none;
  stroke: #2060c0;
  stroke-width: 2;
}
.graph-band {
  fill: rgba(32, 96, 192, 0.18);
}
.graph-point {
  fill: #d13b2d;
  stroke: #fff;
  stroke-width: 2;
}
.graph-refline {
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}
.graph-reflabel {
  font-size: 10px;
  font-weight: 600;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 3px;
}
.graph-tick {
  fill: #5b6475;
  font-size: 9px;
}
.graph-label {
  fill: #334;
  font-size: 11px;
}
.ci-bar-container {
  position: relative;
  height: 28px;
  margin: 0.5rem 0;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}
.ci-bar {
  position: absolute;
  height: 100%;
  background: #b0d0ff;
  border-radius: 4px;
}
.ci-median {
  position: absolute;
  width: 3px;
  height: 100%;
  background: #2060c0;
  border-radius: 1px;
}
.ci-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: #888;
}

/* Incident browser */
.filters { margin: 0.5rem 0; display: flex; gap: 0.25rem; flex-wrap: wrap; }
.filters button {
  padding: 0.25rem 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.85rem;
}
.filters button.active { background: #2060c0; color: #fff; border-color: #2060c0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
th, td { padding: 0.35rem 0.5rem; text-align: left; border-bottom: 1px solid #e0e0e0; }
th { background: #f5f5f5; position: sticky; top: 0; cursor: pointer; user-select: none; }
th:hover { background: #e8e8e8; }
th .sort-arrow { font-size: 0.7em; margin-left: 0.2em; }
tr:hover { background: #f8f8ff; }
.narrative-cell {
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.narrative-cell.expanded { white-space: normal; }
.cbi { color: #999; font-style: italic; }
.incident-count { font-size: 0.9rem; color: #666; margin: 0.25rem 0; }
.fault-cell {
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
  cursor: help;
}
.fault-bar {
  display: inline-block;
  height: 14px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 4px;
}
.weight-panel {
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: #fafafa;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 0.85rem;
}
.weight-panel h4 { margin: 0 0 0.4rem; font-size: 0.9rem; }
.weight-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.3rem 0;
}
.weight-row label { min-width: 70px; }
.weight-row input[type="range"] { flex: 1; min-width: 80px; }
.weight-row .val { min-width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* Monthly views */
.month-panel {
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: #fafafa;
}
.month-note {
  font-size: 0.9rem;
  color: #5b6475;
  margin-bottom: 0.6rem;
}
.month-chart {
  margin-bottom: 0.8rem;
}
.month-chart h3 {
  margin: 0 0 0.35rem;
}
.month-company-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.9rem;
}
.month-svg {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border: 1px solid #dfe4ef;
  border-radius: 4px;
}
.month-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 0.3rem;
  font-size: 0.82rem;
}
.month-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.month-company-toggle {
  cursor: pointer;
  user-select: none;
}
.month-company-toggle input[type="checkbox"] {
  margin: 0 0.2rem 0 0;
}
.month-chip {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(0, 0, 0, 0.18);
  display: inline-block;
}
.month-grid {
  display: none;
}
.month-axis {
  stroke: #95a0b8;
  stroke-width: 1;
}
.month-vmt-line {
  fill: none;
  stroke-width: 2;
}
.month-mpi-all-line {
  fill: none;
}
.month-inc-count {
  fill: #131313;
  font-size: 9px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 2px;
}
.month-inc-total {
  fill: #131313;
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: middle;
}
.month-dot {
  stroke: #fff;
  stroke-width: 1.5;
}
.month-linekey {
  width: 22px;
  height: 0;
  border-top: 2.5px solid #4a5264;
  display: inline-block;
}
.month-linekey.solid {
  border-top-width: 2.5px;
}
.month-linekey.dashed {
  border-top-width: 1.5px;
}
.month-linekey.atfault {
  border-top-width: 1px;
}
.month-tri {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 7px solid #4a5264;
  display: inline-block;
  transform: translateY(1px);
}
.month-err {
  stroke-width: 1.4;
  opacity: 0.9;
}
.month-mark-tri {
  stroke-width: 1.4;
}
.month-tick {
  fill: #5b6475;
  font-size: 10px;
}
.month-label {
  fill: #334;
  font-size: 11px;
}
.month-summary {
  margin-top: 0.75rem;
  background: #fff;
  border: 1px solid #dfe4ef;
  border-radius: 4px;
  padding: 0.7rem;
}
.month-summary-title {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.month-summary table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.month-summary th,
.month-summary td {
  padding: 0.28rem 0.42rem;
  border-bottom: 1px solid #e8ecf5;
  text-align: right;
}
.month-summary th:first-child,
.month-summary td:first-child {
  text-align: left;
}
.month-summary-scroll {
  overflow-x: auto;
}
.month-summary-scroll table {
  min-width: 760px;
}
.mpi-cards {
  display: flex;
  gap: 0.6rem;
  margin: 0.6rem 0;
}
.mpi-card {
  flex: 1;
  background: #fff;
  border: 1px solid #dfe4ef;
  border-radius: 4px;
  border-left: 3px solid #999;
  padding: 0.5rem 0.65rem;
}
.mpi-card-company {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}
.mpi-card-metric {
  margin-bottom: 0.4rem;
  font-size: 0.82rem;
  line-height: 1.45;
}
.mpi-card-metric:last-child {
  margin-bottom: 0;
}
.mpi-card-metric:not(.primary) {
  color: #5b6475;
}
.mpi-card-formula {
  font-variant-numeric: tabular-nums;
}
.mpi-card-mpi {
  font-weight: 600;
}
.mpi-card-metric.primary .mpi-card-mpi {
  font-size: 0.95rem;
}
.mpi-card-ci {
  font-size: 0.72rem;
  color: #8090a8;
}
@media (max-width: 760px) {
  .mpi-cards {
    flex-direction: column;
  }
  body {
    padding: 0.75rem;
  }
  .month-panel {
    padding: 0.75rem;
  }
  .month-tick {
    font-size: 11px;
  }
  .month-label {
    font-size: 12px;
  }
  .month-inc-count {
    font-size: 8px;
  }
  .month-inc-total {
    font-size: 9px;
  }
}
