/* Unified registry search, header filters and column order. */
.archive-toolbar,
.entity-list-toolbar,
.device-list-toolbar {
  min-height: 64px;
  align-items: center;
}

.archive-toolbar { display: flex; }

.entity-search,
.archive-search,
.device-search {
  width: min(360px, 100%);
  min-width: 220px;
  max-width: 360px;
  min-height: 46px;
  flex: 1 1 280px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  border: 1px solid var(--ui-border);
  border-radius: 7px;
  color: var(--ui-text-secondary);
  background: var(--ui-surface-soft);
}

.entity-search svg,
.archive-search svg,
.device-search svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.entity-search input,
.archive-search input,
.device-search input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ui-text);
  background: transparent;
  box-shadow: none;
  font-size: 16px;
}

.entity-search:focus-within,
.archive-search:focus-within,
.device-search:focus-within {
  color: var(--accent-text);
  border-color: var(--accent-solid);
  background: var(--ui-surface);
}

.archive-filter-reset,
.device-list-toolbar .secondary-action,
.entity-list-toolbar .secondary-action { margin-left: auto; }

.device-table-head.device-column-filters {
  min-height: 58px;
  align-items: stretch;
  padding-block: 7px;
}

.device-head-filter {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 2px;
  margin: 0;
}

.device-head-filter > span {
  color: var(--ui-text-subtle);
  font-size: 10px;
  font-weight: 600;
  line-height: 1.1;
}

.device-head-filter select {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 20px 0 0;
  border: 0;
  border-radius: 4px;
  color: var(--ui-text-secondary);
  background-color: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 600;
  text-overflow: ellipsis;
}

.device-head-filter select:hover,
.device-head-filter select:focus,
.device-head-filter.active select {
  color: var(--accent-text);
  background-color: var(--accent-soft);
  outline: none;
}

.device-head-filter.active > span { color: var(--accent-text); }

@media (min-width: 1240px) {
  .incident-table-head,
  .incident-row,
  body.role-operator .incident-table-head,
  body.role-operator .incident-row {
    grid-template-columns: minmax(220px, 1.35fr) minmax(145px, .9fr) 96px 92px 140px 82px 54px;
  }
}

@media (min-width: 861px) and (max-width: 1239px) {
  .incident-table-head,
  .incident-row,
  body.role-operator .incident-table-head,
  body.role-operator .incident-row {
    grid-template-columns: minmax(190px, 1.35fr) minmax(120px, .85fr) 88px 132px 80px 52px;
  }

  #incident-table-head > :nth-child(3),
  #incidents-page .incident-date { display: none; }
}

@media (min-width: 761px) and (max-width: 860px) {
  .incident-table-head,
  .incident-row,
  body.role-operator .incident-table-head,
  body.role-operator .incident-row {
    grid-template-columns: minmax(170px, 1fr) 84px 126px 76px 50px;
  }

  #incident-table-head > :nth-child(2),
  #incident-table-head > :nth-child(3),
  #incidents-page .incident-zone,
  #incidents-page .incident-date { display: none; }
}

/* A registry status must stay inside its own grid track at every saved width. */
#incidents-page .incident-record-status,
#incidents-page .incident-review-status,
#disputes-page .review-status-chip,
#disputes-page .review-result-chip {
  box-sizing: border-box;
  inline-size: fit-content;
  min-width: 0;
  max-inline-size: 100%;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#incidents-page .incident-review-status {
  padding-inline: 10px;
  white-space: nowrap;
}

@media (min-width: 761px) {
  #incidents-page .incident-review-status.under_review {
    justify-content: center;
  }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .camera-device-head,
  .camera-device-row {
    grid-template-columns: minmax(190px, 1fr) minmax(120px, .7fr) 104px 18px;
  }

  .camera-device-head > :nth-child(3),
  .camera-device-head > :nth-child(4),
  .camera-device-row .device-cell.role,
  .camera-device-row .device-cell.source { display: none; }

  .camera-device-row .device-cell.zone { display: block; }
}

@media (max-width: 760px) {
  .archive-toolbar,
  .entity-list-toolbar,
  .device-list-toolbar { min-height: 60px; }

  .archive-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .entity-search,
  .archive-search,
  .device-search {
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .device-list-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .device-column-filters {
    min-height: 62px !important;
    display: flex !important;
    gap: 7px;
    padding: 7px 11px !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .device-column-filters::-webkit-scrollbar { display: none; }
  .device-column-filters > span { display: none !important; }

  .device-head-filter {
    min-width: 150px;
    flex: 0 0 150px;
    padding: 3px 8px;
    border: 1px solid var(--ui-border);
    border-radius: 7px;
    background: var(--ui-surface-soft);
  }
}

@media (max-width: 520px) {
  .incident-table-head.archive-column-filters {
    min-height: 0;
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 7px 0 11px;
    overflow: visible;
  }

  .incident-table-head.archive-column-filters[hidden] {
    display: none !important;
  }

  .archive-column-filter,
  .archive-date-filter {
    width: 100%;
    min-width: 0;
    padding: 3px 8px;
  }
}

@media (max-width: 340px) {
  .incident-table-head.archive-column-filters {
    grid-template-columns: minmax(0, 1fr);
  }
}
