* { box-sizing: border-box; }
body { margin: 0; font-family: "Segoe UI", Tahoma, sans-serif; background: #0d1420; color: #e5edf7; }
.app { --bottom-h: 42vh; display: flex; flex-direction: column; gap: 8px; height: 100vh; padding: 8px; }
.panel { background: #132033; border: 1px solid #2a3e5e; border-radius: 8px; padding: 10px; }
.top-nav { padding: 8px 10px; display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.tab-buttons { display: inline-flex; gap: 8px; }
.tab-btn { background: #223958; color: #c9d9f0; }
.tab-btn.active { background: #1f7dff; color: #fff; }
.tab-panel { min-height: 0; flex: 1; }
.is-hidden { display: none !important; }
#tabSearch { display: grid; grid-template-rows: auto minmax(0, 1fr) auto 10px minmax(120px, var(--bottom-h)); gap: 8px; min-height: 0; }
#tabDbEdit { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-height: 0; }
#tabDbSpectrum { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-height: 0; }
#tabAdminUsers { display: grid; grid-template-rows: minmax(0, 1fr); gap: 8px; min-height: 0; }
.top .row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; align-items: center; }
.top .row:last-child { margin-bottom: 0; }
.top .row > label { min-width: 0; }
.actions-right { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
label { display: inline-flex; flex-direction: column; gap: 4px; font-size: 12px; color: #9db0cc; }
input[type="number"] { width: 140px; background: #0b1525; border: 1px solid #2b4161; color: #e5edf7; border-radius: 4px; padding: 6px; }
input[type="text"], select, textarea { width: 170px; background: #0b1525; border: 1px solid #2b4161; color: #e5edf7; border-radius: 4px; padding: 6px; }
button { background: #1f7dff; color: #fff; border: 0; border-radius: 5px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
button:hover { background: #3a90ff; }
.audit-filter-btn { padding: 6px 10px; font-size: 12px; }
.audit-filter-btn.active { background: #1558b0; box-shadow: inset 0 0 0 1px #6ea8ff; }
.auth-block { display: inline-flex; align-items: center; gap: 8px; }
.auth-row { display: inline-flex; align-items: center; gap: 8px; }
.auth-row input[type="text"], .auth-row input[type="password"] { width: 140px; background: #0b1525; border: 1px solid #2b4161; color: #e5edf7; border-radius: 4px; padding: 6px; }
.auth-user { font-size: 12px; color: #c9d9f0; }
.admin-user-create { align-items: flex-end; }
.admin-user-create input[type="text"],
.admin-user-create input[type="password"] { width: 170px; }
.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.group { display: inline-flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#dbList { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.db-group {
  --group-accent: #ff3b3b;
  position: relative;
  border: 1px solid #2a3e5e;
  border-left: 3px solid var(--group-accent);
  border-radius: 6px;
  padding: 2px 6px;
  background: #102038;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
  width: fit-content;
  max-width: 100%;
}
.db-group-summary { display: inline-flex; align-items: center; gap: 6px; }
.db-group-trigger {
  background: transparent;
  color: #e5edf7;
  border: 0;
  padding: 0;
  font-weight: 600;
}
.db-group-trigger:hover { color: #9ec6ff; background: transparent; }
.group-swatch {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--group-accent);
  margin-right: 6px;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15);
}
.db-group-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 320px;
  max-width: min(680px, 92vw);
  max-height: 240px;
  overflow: auto;
  margin-top: 0;
  padding: 8px;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  background: #0f1d32;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
  display: none;
  flex-wrap: wrap;
  gap: 8px;
}
.db-group.open .db-group-popover { display: flex; }
.db-group-items label { display: inline-flex; gap: 4px; align-items: center; flex-direction: row; }
.db-group-empty { color: #9db0cc; font-size: 12px; padding: 2px 0; }
#distanceUnit { width: 74px; }
#deltaKhz { width: 100px; }
#modeFilter { width: 86px; }
#categoryFilter { width: 150px; }
#subCategoryFilter { width: 170px; }
#trafficFilter { width: 90px; }
#bandFilter { width: 90px; }
#nameQuery { width: 220px; max-width: 30vw; }
#callsignQuery { width: 150px; max-width: 22vw; }
#map { width: 100%; height: 100%; border-radius: 6px; }
.map-wrap { padding: 0; overflow: hidden; min-height: 0; }
.map-controls .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.map-controls input[type="number"] { width: 150px; }
.resize-handle {
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  background: #102038;
  cursor: row-resize;
  position: relative;
}
.resize-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 2px;
  transform: translate(-50%, -50%);
  background: #476184;
  border-radius: 2px;
}
body.is-resizing, body.is-resizing * {
  cursor: row-resize !important;
  user-select: none !important;
}
.bottom { display: grid; grid-template-rows: auto 1fr; gap: 8px; min-height: 120px; }
.meta { font-size: 13px; color: #b8c8de; }
.table-wrap { overflow: auto; border: 1px solid #2a3e5e; border-radius: 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid #23354f; padding: 6px 8px; text-align: left; white-space: nowrap; }
thead th { position: sticky; top: 0; background: #10233d; z-index: 1; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable.active { color: #9ec6ff; }
tbody tr:hover { background: #1a2b44; }
.muted { opacity: 0.5; }
.result-group td { font-weight: 600; }
.group-toggle {
  background: transparent;
  color: #d5e4ff;
  border: 1px solid #3d5577;
  border-radius: 3px;
  padding: 0 4px;
  margin-right: 6px;
  font-size: 10px;
  line-height: 14px;
}
.group-toggle:hover { background: #21324a; }
.result-child td { opacity: 0.92; }
.result-child td:nth-child(2) { color: #b8c8de; }

.db-edit-top .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.db-edit-main { min-height: 0; height: 100%; }
.db-edit-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 10px; min-height: 0; height: 100%; }
.db-edit-list, .db-edit-form-wrap { min-height: 0; display: grid; grid-template-rows: auto 1fr; gap: 8px; }
.db-edit-list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
#editEntriesTable tbody tr { cursor: pointer; }
#editEntriesTable tbody tr.active { background: #223654; }
#adminUsersTable tbody tr { cursor: pointer; }
#adminUsersTable tbody tr.active { background: #223654; }
#adminSubmissionsBody tr { cursor: pointer; }
#adminSubmissionsBody tr.active { background: #223654; }
#editEntriesTable thead th.sortable-edit { cursor: pointer; user-select: none; }
#editEntriesTable thead th.sortable-edit.active { color: #9ec6ff; }
.db-edit-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  align-content: start;
  overflow: auto;
  padding-right: 4px;
}
.db-edit-form label { min-width: 0; }
.db-edit-form input, .db-edit-form select, .db-edit-form textarea { width: 100%; }
.db-edit-form label.wide { grid-column: 1 / -1; }
.submissions-create-panel {
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 8px;
  background: #102038;
  margin-bottom: 8px;
}
.submissions-create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
.submissions-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px 8px;
}
.submissions-form label {
  min-width: 0;
}
.submissions-form input,
.submissions-form select,
.submissions-form textarea {
  width: 100%;
}
.submissions-form label.wide {
  grid-column: 1 / -1;
}

#adminUserInfo {
  margin-top: 0;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 10px;
  background: #102038;
  width: 100%;
  max-width: none;
}
#adminSubmissionInfo {
  margin-top: 0;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 6px 8px;
  background: #102038;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 10px;
  max-height: none;
  overflow: hidden;
}
.admin-submission-detail-grid {
  display: flex;
  gap: 8px;
  align-items: start;
}
#adminSubmissionActions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 150px;
}
#adminSubmissionActions button { width: 100%; }
.admin-submission-edit-row .wide {
  min-width: 320px;
}
.admin-submission-edit-row .wide input[type="text"] {
  width: 100%;
}
.admin-submission-edit-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px 10px;
  align-items: end;
}
.admin-submission-edit-row label {
  min-width: 0;
}
.admin-submission-edit-row #adminSubmissionEntrySelect {
  width: 100%;
}
.admin-submission-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 6px;
  background: #102038;
}
.admin-submission-group {
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 6px;
  background: #0f1e33;
}
.admin-submission-group-wide {
  grid-column: 1 / -1;
}
.admin-submission-group-title {
  font-size: 12px;
  font-weight: 700;
  color: #b8c8de;
  margin-bottom: 4px;
}
.admin-submission-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px 8px;
}
.admin-submission-grid-notes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.admin-submission-form label {
  min-width: 0;
  font-size: 11px;
  gap: 2px;
}
.admin-submission-form input[type="text"],
.admin-submission-form input[type="number"],
.admin-submission-form select,
.admin-submission-form textarea {
  width: 100%;
  padding: 4px;
}
.admin-submissions-table-wrap {
  max-height: 150px;
  overflow: auto;
}
.admin-submissions-list-wrap {
  min-height: 160px;
  max-height: 160px;
  overflow-y: auto;
  overflow-x: auto;
}
#mod_traffic,
#mod_status,
#mod_confidence,
#mod_source_quality,
#edit_traffic,
#edit_status,
#edit_confidence,
#edit_source_quality {
  max-width: 150px;
}
#adminUserInfo div { margin-top: 4px; }
.admin-users-panel {
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto auto;
  gap: 8px;
}
.admin-users-panel .row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.admin-users-header {
  justify-content: flex-start;
}
.admin-users-table-wrap {
  min-height: 0;
  overflow: auto;
}
.admin-user-create { align-items: flex-end; }
.admin-user-detail-grid {
  display: flex;
  width: 100%;
  gap: 10px;
  align-items: start;
  justify-content: flex-start;
}
#adminUserActions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#adminUserActions button { width: 100%; }
.admin-user-side-tools {
  display: grid;
  grid-template-rows: auto;
  flex: 0 0 170px;
  width: 170px;
  margin-left: 0;
}
.admin-users-top-search {
  margin-left: auto;
  display: inline-flex;
  gap: 6px;
  align-items: flex-end;
}
.admin-users-top-search input[type="text"] {
  width: 260px;
  max-width: 35vw;
}
#adminUserInfo {
  flex: 0 0 50%;
  max-width: 50%;
}

.spectrum-top .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.spectrum-top .actions-right label {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.spectrum-group-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.spectrum-group-chip {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  gap: 6px;
  border: 1px solid #2a3e5e;
  border-left: 3px solid var(--group-accent, #ff3b3b);
  border-radius: 6px;
  background: #102038;
  padding: 2px 8px;
  font-size: 12px;
  color: #c9d9f0;
}
.spectrum-group-chip input[type="checkbox"] {
  margin: 0;
}
.spectrum-group-chip .group-swatch { margin-right: 0; }
.spectrum-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(260px, 1fr);
  gap: 0;
}
.spectrum-canvas-wrap {
  position: relative;
  min-height: 260px;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  background: #0b1525;
  overflow: hidden;
}
#spectrumCanvas {
  width: 100%;
  height: 100%;
  display: block;
}
.spectrum-tooltip {
  position: absolute;
  pointer-events: none;
  z-index: 10;
  max-width: min(460px, 70vw);
  white-space: pre-wrap;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  background: rgba(11, 21, 37, 0.97);
  color: #e5edf7;
  font-size: 12px;
  line-height: 1.35;
  padding: 8px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.35);
}
.spectrum-legend {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  font-size: 12px;
  color: #b8c8de;
}
.spectrum-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid #2a3e5e;
  border-radius: 6px;
  padding: 4px 8px;
  background: #102038;
}

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 11px;
  border: 1px solid #2b4161;
  margin-right: 6px;
}
.tag.pending { background: #3a2f1f; color: #fbd68a; border-color: #6f5524; }
.tag.approved { background: #1f3a29; color: #9ff3bc; border-color: #2e6f46; }
.tag.rejected { background: #3c2323; color: #ffb3b3; border-color: #7a3434; }
.tag.applied { background: #1d3344; color: #a8d8ff; border-color: #2f5e84; }
#auditBody code {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 11px;
}
#manageBackupDailyTime { width: 110px; }
#manageBackupWeeklyDay { width: 120px; }
#manageBackupMonthlyDay { width: 120px; }
#manageBackupMaxKeep { width: 120px; }

@media (max-width: 1100px) {
  .db-edit-grid { grid-template-columns: 1fr; }
  .admin-submission-form { grid-template-columns: 1fr; }
  .admin-submission-group-wide { grid-column: auto; }
  .admin-submission-edit-row { grid-template-columns: 1fr; }
  .admin-submission-grid,
  .admin-submission-grid-notes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #adminSubmissionInfo { grid-template-columns: 1fr; max-height: none; }
}
@media (max-width: 900px) {
  .admin-submission-grid,
  .admin-submission-grid-notes { grid-template-columns: 1fr; }
}
