.traffic-shell {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}
.traffic-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  background: #fff;
  border: 1px solid #e7e2ee;
  border-radius: 6px;
  padding: 14px;
}
.traffic-filter label,
.traffic-setting-fields label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #685677;
  flex: 1;
  min-width: 120px;
}
.traffic-filter input,
.traffic-filter select,
.traffic-setting-fields input,
.traffic-setting-fields select {
  width: 100%;
  height: 36px;
  border: 1px solid #ddd6e8;
  border-radius: 4px;
  background: #fff;
  padding: 7px 9px;
  color: #40354e;
  font:
    13px Arial,
    "Segoe UI",
    sans-serif;
}
.traffic-message {
  margin: 0;
  padding: 9px 12px;
  font-size: 13px;
  background: #f0ecf7;
  color: #665379;
  border-left: 3px solid #7569b3;
}
.traffic-message.is-error {
  background: #fff2ed;
  border-color: #b46c45;
}
.traffic-metrics {
  display: flex;
  gap: 12px;
}
.traffic-metric {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  border: 1px solid #e7e2ee;
  border-top: 3px solid #7569b3;
  border-radius: 5px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.traffic-metric > span {
  font-size: 12px;
  font-weight: 700;
  color: #776685;
}
.traffic-metric > strong {
  font-size: 27px;
  color: #4c3b60;
  font-family: Arial, "Segoe UI", sans-serif;
}
.traffic-metric > small {
  font-size: 10px;
  color: #a191ad;
}
.traffic-metric.traffic-truck {
  border-top-color: #548b9c;
}
.traffic-metric.traffic-bus {
  border-top-color: #ae815a;
}
.traffic-metric.traffic-unknown {
  border-top-color: #a29aad;
}
.traffic-charts {
  display: flex;
  gap: 14px;
}
.traffic-charts > .panel {
  flex: 1;
  min-width: 0;
  padding: 14px;
}
.traffic-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  min-height: 158px;
  overflow-x: auto;
  padding-top: 10px;
}
.traffic-hour {
  flex: 1;
  min-width: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 150px;
}
.traffic-hour-stack {
  width: 100%;
  max-width: 22px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: #eee8f2;
}
.traffic-hour-stack span {
  display: block;
  min-height: 0;
}
.traffic-fill-car {
  background: #7569b3;
}
.traffic-fill-truck {
  background: #548b9c;
}
.traffic-fill-bus {
  background: #ae815a;
}
.traffic-fill-unknown {
  background: #a29aad;
}
.traffic-hour small {
  font-size: 9px;
  color: #93829e;
  margin-top: 7px;
}
.traffic-distribution-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #eee8f2;
}
.traffic-distribution-row strong {
  flex: 1;
  color: #625071;
}
.traffic-distribution-row small {
  width: 100%;
  color: #91819f;
}
.traffic-empty {
  padding: 20px;
  color: #92839d;
  font-size: 12px;
  line-height: 1.7;
  text-align: center;
}
.traffic-camera-settings,
.traffic-shell > section.panel {
  padding: 14px;
}
.traffic-camera-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 9px 0;
  border-bottom: 1px solid #eee8f2;
  font-size: 12px;
}
.traffic-camera-row > strong {
  flex: 1;
  color: #5f4c70;
  min-width: 130px;
}
.traffic-camera-row > span {
  color: #756386;
}
.traffic-camera-row small {
  color: #92839d;
}
.traffic-settings-form {
  margin-top: 14px;
  padding: 16px;
  background: #f8f6fb;
  border: 1px solid #e2dbea;
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.traffic-settings-form h3 {
  font:
    700 14px Arial,
    "Segoe UI",
    sans-serif;
  margin: 0;
  color: #665077;
}
.traffic-line-preview {
  position: relative;
  background: #17131d;
  aspect-ratio: 16/9;
  max-width: 780px;
  cursor: crosshair;
  overflow: hidden;
}
.traffic-line-preview img {
  width: 100%;
  height: 100%;
  object-fit: fill;
}
.traffic-line-preview svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.traffic-line-preview line {
  stroke: #52d1a7;
  stroke-width: 6;
  vector-effect: non-scaling-stroke;
}
.traffic-line-preview text {
  fill: #d5fff1;
  font:
    600 32px Arial,
    sans-serif;
}
.traffic-line-preview > span {
  position: absolute;
  top: 45%;
  left: 10%;
  right: 10%;
  color: #a99bb8;
  font-size: 12px;
  text-align: center;
}
.traffic-setting-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.traffic-enable {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #665077;
}
.traffic-table-scroll {
  overflow: auto;
}
.traffic-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.traffic-table th {
  font-size: 10px;
  color: #8c789d;
  text-transform: uppercase;
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e8e0ef;
}
.traffic-table td {
  padding: 10px;
  border-bottom: 1px solid #eee8f2;
  color: #625071;
}
.traffic-image {
  width: 90px;
  min-height: 48px;
  background: #eee8f2;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  border-radius: 3px;
}
.traffic-image img {
  width: 90px;
  height: 54px;
  object-fit: cover;
}
.traffic-type {
  font-size: 11px;
  padding: 4px 8px;
  background: #eee8f6;
  border-radius: 3px;
}
.traffic-pagination {
  display: flex;
  align-items: center;
  gap: 7px;
  padding-top: 12px;
  font-size: 11px;
  color: #8b7a97;
}
.traffic-pagination > span {
  margin-right: auto;
}
.traffic-note {
  font-size: 11px;
  color: #8c7d99;
  line-height: 1.7;
  margin: 0;
}
.traffic-overview {
  padding: 14px;
  margin-top: 14px;
}
.traffic-overview .traffic-metrics {
  margin-bottom: 10px;
}
.traffic-overview .traffic-metric {
  padding: 10px 14px;
}
.traffic-overview .traffic-metric strong {
  font-size: 23px;
}
.traffic-overview .traffic-metric small {
  display: none;
}
@media (max-width: 900px) {
  .traffic-charts {
    flex-direction: column;
  }
  .traffic-metrics {
    flex-wrap: wrap;
  }
  .traffic-metric {
    flex-basis: 40%;
  }
  .traffic-filter label {
    flex-basis: 35%;
  }
}
@media (max-width: 550px) {
  .traffic-filter {
    flex-direction: column;
    align-items: stretch;
  }
  .traffic-filter label {
    width: 100%;
  }
  .traffic-metric {
    padding: 12px;
  }
  .traffic-overview .panel-heading {
    flex-wrap: wrap;
    gap: 8px;
  }
  .traffic-camera-row > span {
    width: 100%;
  }
  .traffic-setting-fields label {
    min-width: 90px;
  }
}

.traffic-charts > .panel {
  display: flex;
  flex-direction: column;
}
.traffic-charts .panel-heading {
  flex: 0 0 auto;
}
.traffic-chart {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex: 1;
  min-height: 260px;
  gap: 8px;
  overflow: hidden;
  padding: 10px 0 0;
}
.traffic-chart svg {
  display: block;
  width: 100%;
  flex: 1;
  min-height: 230px;
}
.traffic-gridline {
  stroke: #e9e3ef;
  stroke-width: 1;
}
.traffic-axis-text {
  fill: #85768e;
  font:
    11px Arial,
    sans-serif;
}
.traffic-svg-car {
  fill: #7569b3;
}
.traffic-svg-truck {
  fill: #548b9c;
}
.traffic-svg-bus {
  fill: #ae815a;
}
.traffic-svg-unknown {
  fill: #a29aad;
}
.traffic-chart-legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 10px;
  color: #776685;
}
.traffic-chart-legend span::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 1px;
  margin-right: 5px;
  background: #7569b3;
}
.traffic-chart-legend .traffic-legend-truck::before {
  background: #548b9c;
}
.traffic-chart-legend .traffic-legend-bus::before {
  background: #ae815a;
}
.traffic-chart-legend .traffic-legend-unknown::before {
  background: #a29aad;
}

/* Transport panels: intensity 50%, distribution 25%, cameras 25%. */
.traffic-charts {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}
.traffic-charts > .panel {
  min-width: 0;
  margin: 0;
}
.traffic-charts .panel-heading {
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}
.traffic-charts [data-distribution],
.traffic-charts [data-camera-settings] {
  max-height: 340px;
  overflow-y: auto;
  overflow-wrap: anywhere;
  scrollbar-width: thin;
}
.traffic-charts .traffic-camera-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px;
  padding: 10px 0;
}
.traffic-charts .traffic-camera-row > strong {
  grid-column: 1 / -1;
  min-width: 0;
}
.traffic-charts .traffic-camera-row > span {
  font-size: 11px;
}
.traffic-charts .traffic-camera-row > small {
  grid-column: 1 / -1;
  font-size: 10px;
  line-height: 1.5;
}
.traffic-charts .traffic-camera-row > button {
  grid-column: 2;
  grid-row: 2;
  padding: 3px 6px;
  font-size: 11px;
}
.traffic-charts .traffic-chart svg {
  min-height: 230px;
}
.traffic-settings-editor:empty {
  display: none;
}
.traffic-settings-editor .traffic-settings-form {
  margin-top: 0;
}
@media (max-width: 1199px) {
  .traffic-charts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .traffic-charts > .traffic-camera-settings {
    grid-column: 1 / -1;
  }
}
@media (max-width: 900px) {
  .traffic-charts {
    grid-template-columns: minmax(0, 1fr);
  }
  .traffic-charts > .traffic-camera-settings {
    grid-column: auto;
  }
}

body.traffic-settings-open {
  overflow: hidden;
}
.traffic-settings-dialog {
  width: min(1100px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid #ddd6e8;
  border-radius: 7px;
  background: #fff;
  color: #5f4c70;
  overflow: auto;
  box-shadow: 0 18px 60px #20152f40;
}
.traffic-settings-dialog::backdrop {
  background: #21192e80;
}
.traffic-settings-dialog .traffic-settings-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  align-items: start;
  gap: 12px 18px;
  padding: 20px;
  margin: 0;
  border: 0;
  background: #fff;
}
.traffic-settings-dialog h3,
.traffic-settings-dialog .traffic-note,
.traffic-settings-dialog .toolbar-actions,
.traffic-settings-dialog [data-settings-message] {
  grid-column: 1 / -1;
}
.traffic-settings-dialog .traffic-line-preview {
  grid-column: 1;
  grid-row: 3 / 6;
  width: 100%;
  max-width: none;
  border-radius: 4px;
}
.traffic-settings-dialog .traffic-setting-fields {
  grid-column: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.traffic-settings-dialog .traffic-setting-fields label {
  min-width: 0;
}
.traffic-settings-dialog .traffic-enable {
  grid-column: 2;
  justify-content: flex-start;
}
.traffic-enable input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #7569b3;
}
.traffic-settings-dialog [data-settings-message]:empty {
  display: none;
}
.traffic-settings-dialog .toolbar-actions {
  justify-content: flex-end;
}
@media (max-width: 760px) {
  .traffic-settings-dialog {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }
  .traffic-settings-dialog .traffic-settings-form {
    grid-template-columns: minmax(0, 1fr);
    padding: 14px;
  }
  .traffic-settings-dialog .traffic-line-preview,
  .traffic-settings-dialog .traffic-setting-fields,
  .traffic-settings-dialog .traffic-enable {
    grid-column: 1;
    grid-row: auto;
  }
}

.traffic-plate {
  display: block;
  font:
    700 13px Arial,
    "Segoe UI",
    sans-serif;
  white-space: nowrap;
  color: #554264;
}
.traffic-cell-detail {
  display: block;
  font-size: 10px;
  color: #92839d;
  margin-top: 4px;
}
.traffic-evidence {
  display: inline-block;
  padding: 4px 6px;
  font-size: 10px;
  border-radius: 3px;
  background: #f1eef8;
  color: #67527c;
  white-space: nowrap;
}
.traffic-evidence-anpr {
  background: #eaf7f1;
  color: #36765d;
}
.traffic-evidence-both {
  background: #eeeaf7;
  color: #663399;
}

/* Passage snapshot opens a protected, read-only event card. */
button.traffic-image {
  padding: 0;
  border: 1px solid transparent;
  cursor: pointer;
  font: 11px/1.4 Arial, "Segoe UI", sans-serif;
  color: #685677;
}
button.traffic-image:hover { border-color: #7569b3; }
button.traffic-image:focus-visible { outline: 2px solid #7569b3; outline-offset: 3px; }
body.traffic-event-open { overflow: hidden; }
.traffic-event-dialog {
  width: min(1160px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid #ddd6e8;
  border-radius: 8px;
  background: #fff;
  color: #554264;
  overflow: auto;
  box-shadow: 0 18px 60px #20152f40;
  font-family: Arial, "Segoe UI", sans-serif;
}
.traffic-event-dialog::backdrop { background: #21192e99; backdrop-filter: blur(3px); }
.traffic-event-head { position: sticky; top: 0; z-index: 1; }
.traffic-event-content { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; gap: 20px; padding: 18px; }
.traffic-event-figure { min-width: 0; margin: 0; }
.traffic-event-photo { display: flex; align-items: center; justify-content: center; min-height: 220px; background: #f3f0f8; border: 1px solid #e7e2ee; border-radius: 5px; color: #82768d; font-size: 12px; }
.traffic-event-photo img { display: block; width: 100%; height: auto; max-height: 68dvh; object-fit: contain; border-radius: 4px; }
.traffic-event-figure figcaption { margin-top: 8px; font-size: 11px; color: #82768d; }
.traffic-event-info { min-width: 0; }
.traffic-event-info > .traffic-type { display: inline-block; color: #665379; margin-bottom: 8px; }
.traffic-event-facts { display: grid; margin: 0; }
.traffic-event-facts > div { padding: 9px 0; border-bottom: 1px solid #eee8f2; }
.traffic-event-facts dt { color: #82768d; font-size: 11px; margin-bottom: 4px; }
.traffic-event-facts dd { margin: 0; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; }
.traffic-event-explanation, .traffic-event-pending { margin: 12px 0 0; padding: 10px; font-size: 11px; line-height: 1.6; background: #f7f5fb; color: #776685; border-radius: 4px; }
.traffic-event-pending { border-left: 2px solid #7569b3; }
@media (max-width: 760px) {
  .traffic-event-dialog { width: calc(100vw - 20px); max-width: calc(100vw - 20px); max-height: calc(100dvh - 20px); }
  .traffic-event-content { grid-template-columns: minmax(0, 1fr); gap: 14px; padding: 14px; }
  .traffic-event-photo { min-height: 140px; }
  .traffic-event-photo img { max-height: 45dvh; }
}
