* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f0f1a;
  color: #e0e0e0;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 1rem;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid #2a2a4a;
  margin-bottom: 1rem;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: #fff;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.card {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1rem;
}

.hidden {
  display: none !important;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: #a0a0a0;
}

input,
select {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid #3a3a5a;
  background: #0f0f1a;
  color: #e0e0e0;
  font-size: 1rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: #6366f1;
}

button {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: #6366f1;
  color: #fff;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #4f46e5;
}

button:disabled {
  background: #3a3a5a;
  cursor: not-allowed;
}

button.secondary {
  background: #3a3a5a;
}

button.secondary:hover {
  background: #4a4a6a;
}

button.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.hint {
  font-size: 0.75rem;
  color: #888;
}

/* Dispatch Layout */
.dispatch-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  height: calc(100vh - 140px);
}

@media (max-width: 1200px) {
  .dispatch-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
}

.map-panel,
.transmissions-panel {
  background: #1a1a2e;
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

/* Map */
#locate-map {
  flex: 1;
  min-height: 400px;
  border-radius: 6px;
  overflow: hidden;
}

.legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  color: #888;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
}

.dot.green {
  background: #22c55e;
}

.dot.yellow {
  background: #eab308;
}

.dot.gray {
  background: #6b7280;
}

.dot.orange {
  background: #f97316;
}

.dot.red {
  background: #ef4444;
}

/* Map Filter Controls */
.map-filter-controls {
  background: #0f0f1a;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.map-filter-controls .row {
  margin-bottom: 0.5rem;
}

.map-filter-controls .row:last-child {
  margin-bottom: 0;
}

.map-filter-controls label {
  flex: 1;
}

.map-filter-controls select {
  width: 100%;
}

#map-channel-label,
#map-user-label {
  flex: 1;
}

/* Transmissions Panel */
.send-controls {
  background: #0f0f1a;
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

.send-controls .row {
  margin-bottom: 0.5rem;
}

.send-controls .row:last-child {
  margin-bottom: 0;
}

.send-controls label {
  flex: 1;
}

.send-controls select {
  width: 100%;
}

#channel-label,
#user-label {
  flex: 1;
}

.send-controls input[type="text"] {
  flex: 1;
}

/* PTT Button */
.ptt-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: #dc2626;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.2s;
}

.ptt-button:hover {
  background: #b91c1c;
}

.ptt-button.recording {
  background: #16a34a;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(22, 163, 74, 0);
  }
}

.ptt-icon {
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z'/%3E%3C/svg%3E") no-repeat center;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z'/%3E%3C/svg%3E") no-repeat center;
}

/* Transmission List */
.transmission-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.transmission-item {
  background: #0f0f1a;
  border-radius: 6px;
  padding: 0.75rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
}

.transmission-item .time {
  font-size: 0.75rem;
  color: #888;
  white-space: nowrap;
}

.transmission-item .content {
  min-width: 0;
}

.transmission-item .sender {
  font-weight: 600;
  font-size: 0.875rem;
}

.transmission-item .channel {
  font-size: 0.75rem;
  color: #6366f1;
}

.transmission-item .summary {
  font-size: 0.875rem;
  color: #a0a0a0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.transmission-item .summary:hover {
  color: #c0c0c0;
}

.transmission-item .summary.expanded {
  white-space: normal;
  overflow: visible;
}

.transmission-item .expand-icon {
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.7rem;
  color: #6366f1;
  vertical-align: middle;
}

.transmission-item .audio-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.transmission-item .location {
  font-size: 0.7rem;
  color: #666;
}

/* Audio player */
audio {
  height: 32px;
  width: 150px;
}

/* Playing state */
.transmission-item.playing {
  background: #1a2e1a;
  border-left: 3px solid #22c55e;
  animation: playing-pulse 1.5s infinite;
}

@keyframes playing-pulse {
  0%, 100% {
    background: #1a2e1a;
  }
  50% {
    background: #1a3a1a;
  }
}

/* Type badge */
.type-badge {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.type-badge.audio {
  background: #6366f1;
  color: white;
}

.type-badge.text {
  background: #3a3a5a;
  color: #a0a0a0;
}

/* New badge */
.new-badge {
  display: inline-block;
  background: #dc2626;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
  animation: new-pulse 2s infinite;
}

@keyframes new-pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

/* Reply PTT button */
.reply-ptt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: #3a3a5a;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.reply-ptt:hover {
  background: #4a4a6a;
  transform: scale(1.1);
}

.reply-ptt.recording {
  background: #16a34a;
  animation: reply-pulse 1s infinite;
}

@keyframes reply-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.7);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(22, 163, 74, 0);
  }
}

.reply-ptt-icon {
  width: 18px;
  height: 18px;
  background: currentColor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z'/%3E%3C/svg%3E") no-repeat center;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='currentColor'%3E%3Cpath d='M12 14c1.66 0 3-1.34 3-3V5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.91-3c-.49 0-.9.36-.98.85C16.52 14.2 14.47 16 12 16s-4.52-1.8-4.93-4.15c-.08-.49-.49-.85-.98-.85-.61 0-1.09.54-1 1.14.49 3 2.89 5.35 5.91 5.78V20c0 .55.45 1 1 1s1-.45 1-1v-2.08c3.02-.43 5.42-2.78 5.91-5.78.1-.6-.39-1.14-1-1.14z'/%3E%3C/svg%3E") no-repeat center;
}

/* Adjust actions layout for reply button */
.transmission-item .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Toggle group for User/Channel */
.toggle-group {
  display: flex;
  background: #0f0f1a;
  border-radius: 6px;
  padding: 2px;
}

.toggle-btn {
  padding: 0.4rem 1rem;
  background: transparent;
  color: #888;
  font-size: 0.875rem;
  border-radius: 4px;
}

.toggle-btn:hover {
  background: #2a2a4a;
  color: #e0e0e0;
}

.toggle-btn.active {
  background: #6366f1;
  color: #fff;
}

.toggle-group.small {
  margin-left: auto;
}

.toggle-group.small .toggle-btn {
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
}

/* Filter controls */
.filter-controls {
  display: flex;
  gap: 1.5rem;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  border-bottom: 1px solid #2a2a4a;
}

.checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #a0a0a0;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #6366f1;
}

.checkbox-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #a0a0a0;
  cursor: pointer;
  white-space: nowrap;
}

.checkbox-inline input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #6366f1;
}

/* Filtered/dimmed transmission */
.transmission-item.filtered {
  display: none;
}

/* Elevation badge */
.elevation-badge {
  display: inline-block;
  background: #ef4444;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 0.5rem;
  vertical-align: middle;
  animation: elevation-pulse 1.5s infinite;
}

@keyframes elevation-pulse {
  0%, 100% {
    background: #ef4444;
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }
  50% {
    background: #dc2626;
    box-shadow: 0 0 8px 4px rgba(239, 68, 68, 0.3);
  }
}

.transmission-item.elevated {
  border-left: 3px solid #ef4444;
}

.transmission-item.elevated .sender {
  color: #ef4444;
}

/* BOLO Button */
.bolo-btn {
  background: #f59e0b;
  color: #000;
  font-weight: 700;
  padding: 0.5rem 1rem;
}

.bolo-btn:hover {
  background: #d97706;
}

.bolo-btn.active {
  background: #22c55e;
  animation: bolo-pulse 2s infinite;
}

@keyframes bolo-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  50% {
    box-shadow: 0 0 12px 4px rgba(34, 197, 94, 0.3);
  }
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #1a1a2e;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #2a2a4a;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: #fff;
  background: none;
}

.modal-body {
  padding: 1.5rem;
}

.modal-body label {
  margin-bottom: 0.5rem;
}

.modal-body select,
.modal-body textarea {
  width: 100%;
}

.bolo-current {
  background: #0f0f1a;
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  border-left: 3px solid #22c55e;
}

.bolo-current h3 {
  margin: 0 0 0.5rem 0;
  font-size: 0.875rem;
  color: #22c55e;
}

.bolo-current-details {
  font-size: 0.875rem;
}

.bolo-current-details .label {
  color: #888;
  font-size: 0.75rem;
  text-transform: uppercase;
}

/* WebSocket Status Indicator */
.ws-status {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.5rem;
  cursor: help;
  transition: background-color 0.3s ease;
}

.ws-status.connected {
  background-color: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.ws-status.disconnected {
  background-color: #666;
}

.ws-status.connecting {
  background-color: #f59e0b;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
