:root {
  --bg-dark: #1a1a1a;
  --accent: #d32f2f;
  --text-light: #e0e0e0;
  --border: #333;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text-light);
  overflow: hidden;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 56px 1fr 100px;
}

.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 700;
}

.title {
  font-size: 15px;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.system-clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.connection-status .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.connection-status.online .dot {
  background: #2e7d32;
}

.connection-status.offline .dot {
  background: #c62828;
}

.language-switcher {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.mode-toggle {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #242424;
  color: var(--text-light);
  padding: 0 10px;
  cursor: pointer;
}

.mode-toggle.live {
  background: #37474f;
}

.lang-btn {
  width: 42px;
  height: 30px;
  border: 0;
  color: var(--text-light);
  background: #222;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn.active {
  background: var(--accent);
  color: #fff;
}

.lang-btn:hover {
  background: #444;
}

.map-layout {
  position: relative;
  width: 100%;
  height: 100%;
}

#map {
  width: 100%;
  height: 100%;
  background: #efefef;
}

#timeline-container {
  background: var(--bg-dark);
  border-top: 1px solid var(--border);
  overflow: hidden;
}

.top-controls {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1100;
  width: min(760px, calc(100% - 24px));
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-box input {
  flex: 1;
  height: 38px;
  border: 1px solid var(--border);
  background: rgba(26, 26, 26, 0.92);
  color: var(--text-light);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.search-box button {
  height: 38px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(26, 26, 26, 0.92);
  color: var(--text-light);
  padding: 0 14px;
  cursor: pointer;
}

.search-box button:hover {
  background: var(--accent);
}

.search-results {
  position: absolute;
  top: 42px;
  left: 0;
  right: 0;
  max-height: 290px;
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(20, 20, 20, 0.95);
  z-index: 1200;
}

.search-result {
  padding: 10px 12px;
  border-bottom: 1px solid #2c2c2c;
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background: #2f2f2f;
}

.search-result small {
  color: #aaa;
}

.fullscreen-btn {
  position: absolute;
  right: 16px;
  bottom: 112px;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(26, 26, 26, 0.95);
  color: var(--text-light);
  cursor: pointer;
  z-index: 1100;
  transition: all 0.2s ease;
}

.fullscreen-btn:hover {
  background: var(--accent);
}

.hidden {
  display: none !important;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 120px;
  background: #222;
  color: var(--text-light);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  z-index: 2000;
}

.error-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 10, 10, 0.85);
  z-index: 2500;
  display: flex;
  align-items: center;
  justify-content: center;
}

.error-card {
  width: min(420px, calc(100% - 24px));
  background: #1f1f1f;
  border: 1px solid #7a2323;
  border-radius: 12px;
  padding: 18px;
}

.error-card h2 {
  margin: 0 0 10px;
}

.error-card button {
  margin-top: 10px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
}

.loading-spinner {
  position: fixed;
  inset: 0;
  z-index: 2400;
  background: #111;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spinner {
  width: 42px;
  height: 42px;
  border: 3px solid #3a3a3a;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.custom-layers-panel,
.legend-panel {
  z-index: 1200;
  color: var(--text-light);
  font-size: 13px;
  background: rgba(26, 26, 26, 0.92);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  min-width: 220px;
  transition: all 0.2s ease;
}

.custom-layers-panel h4,
.legend-panel h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.layer-item,
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

.layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.legend-toggle {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #212121;
  color: var(--text-light);
  padding: 8px 10px;
  cursor: pointer;
}

.legend-content {
  margin-top: 10px;
}

.legend-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.timeline-root {
  height: 100%;
  display: grid;
  grid-template-columns: 300px 1fr 220px;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}

.timeline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #252525;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-btn:hover,
.speed-btn:hover,
.speed-btn.active {
  background: var(--accent);
}

.speed-group {
  display: inline-flex;
  gap: 4px;
  margin-left: 8px;
}

.speed-btn {
  border: 1px solid var(--border);
  background: #252525;
  color: #fff;
  border-radius: 6px;
  padding: 0 8px;
  height: 30px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.timeline-center {
  position: relative;
  padding-top: 18px;
}

.time-ticks {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  color: #999;
  font-size: 11px;
}

.event-markers {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  height: 10px;
  pointer-events: none;
}

.event-dot {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translateX(-50%);
}

.event-dot.start {
  background: #d32f2f;
}

.event-dot.end {
  background: #6d6d6d;
}

.timeline-slider {
  width: 100%;
  height: 6px;
  appearance: none;
  background: #333;
  border-radius: 10px;
  outline: none;
}

.timeline-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.timeline-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.timeline-seconds {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #bbb;
  font-size: 12px;
}

.timeline-subtitle {
  height: 26px;
  margin-top: 6px;
  padding: 4px 12px;
  border-top: 1px solid #2b2b2b;
  color: #fff;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.timeline-subtitle.show {
  opacity: 1;
}

.timeline-clock {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
}

.now-btn {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #252525;
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
}

.info-card {
  background: #202020;
  color: #fff;
  border-radius: 8px;
  padding: 10px;
  max-width: 240px;
}

.incident-card {
  background: #2b1b1b;
  border: 1px solid #5a2a2a;
}

.info-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.info-card p {
  margin: 5px 0;
  font-size: 13px;
}

.info-card .badge {
  display: inline-block;
  font-size: 11px;
  border-radius: 999px;
  padding: 3px 8px;
  margin-bottom: 6px;
  color: #fff;
}

.info-card img {
  max-width: 200px;
  border-radius: 6px;
  display: block;
  margin-bottom: 8px;
}

.badge-regional {
  background: #1976d2;
}

.badge-city {
  background: #c62828;
}

.badge-rescue-station {
  background: #ef6c00;
}

.badge-fire-truck,
.badge-fire {
  background: #c62828;
}

.badge-ambulance {
  background: #ad1457;
}

.badge-rescue,
.badge-flood {
  background: #ef6c00;
}

.badge-drone,
.badge-helicopter {
  background: #1565c0;
}

.badge-earthquake,
.badge-chemical,
.badge-other {
  background: #8e2424;
}

.status-on-duty {
  color: #4caf50;
}

.status-en-route {
  color: #ffca28;
}

.status-at-scene {
  color: #ef5350;
}

.status-maintenance {
  color: #9e9e9e;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: transparent;
  box-shadow: none;
}

.leaflet-popup-content {
  margin: 0;
}

.leaflet-control-zoom a {
  transition: all 0.2s ease;
}

.leaflet-marker-icon {
  transition: transform 120ms linear;
}

body.timeline-busy .leaflet-marker-icon {
  transition: none;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #1f1f1f;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 10px;
}

.scenario-incident-dot {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #d32f2f;
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

.drone-icon span {
  font-size: 22px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.drone-video-btn {
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #333;
  color: #fff;
  cursor: pointer;
}

.video-panel {
  position: fixed;
  top: 68px;
  right: 12px;
  width: 320px;
  z-index: 1400;
  display: grid;
  gap: 8px;
}

.video-tile {
  background: #111;
  border: 1px solid #333;
  border-radius: 8px;
  overflow: hidden;
  height: 160px;
  position: relative;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.video-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 1px;
  background: #3a3a3a;
  color: #d9d9d9;
}

.alert-channels {
  position: fixed;
  inset: 0;
  z-index: 1700;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-channels-card {
  background: rgba(26, 26, 26, 0.95);
  border: 1px solid #444;
  border-radius: 12px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
}

.channel {
  border: 1px solid #333;
  border-radius: 8px;
  padding: 8px 10px;
  background: #242424;
  text-align: center;
}

.channel.pulse {
  animation: pulse-channel 0.6s ease 2;
}

@keyframes pulse-channel {
  0% { transform: scale(1); background: #242424; }
  50% { transform: scale(1.05); background: #d32f2f; }
  100% { transform: scale(1); background: #242424; }
}

.alert-mini-icon {
  height: 30px;
  width: 36px;
  border: 1px solid #333;
  border-radius: 6px;
  background: #252525;
  color: #fff;
  cursor: pointer;
}

.sidebar-catalog {
  position: fixed;
  left: 0;
  top: 56px;
  bottom: 100px;
  width: 60px;
  background: rgba(26, 26, 26, 0.96);
  border-right: 1px solid #333;
  z-index: 1350;
  overflow-y: auto;
}

.sidebar-item {
  width: 100%;
  min-height: 64px;
  border: 0;
  border-bottom: 1px solid #2a2a2a;
  background: transparent;
  color: #e0e0e0;
  display: grid;
  align-items: center;
  justify-items: center;
  gap: 2px;
  padding: 6px 4px;
  cursor: pointer;
}

.sidebar-item .text {
  font-size: 10px;
  text-align: center;
  line-height: 1.1;
}

.sidebar-item.active,
.sidebar-item:hover {
  background: #2a2a2a;
}

.sidebar-content {
  position: fixed;
  left: 60px;
  top: 56px;
  bottom: 100px;
  width: 260px;
  background: rgba(23, 23, 23, 0.96);
  border-right: 1px solid #333;
  z-index: 1349;
  padding: 12px;
}

.tasks-tree-panel {
  position: fixed;
  right: 340px;
  top: 68px;
  width: 360px;
  max-height: calc(100vh - 190px);
  background: rgba(20, 20, 20, 0.96);
  border: 1px solid #333;
  border-radius: 10px;
  z-index: 1450;
  display: grid;
  grid-template-rows: 42px 1fr;
}

.tasks-tree-head {
  border-bottom: 1px solid #333;
  padding: 10px 12px;
  font-weight: 600;
}

.tasks-tree-body {
  overflow: auto;
  padding: 8px 10px;
}

.tasks-tree-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-children {
  margin-left: 16px;
}

.task-node {
  display: grid;
  grid-template-columns: 22px 1fr auto auto;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid #2a2a2a;
  padding: 5px 0;
}

.task-toggle {
  width: 20px;
  height: 20px;
  border: 1px solid #333;
  border-radius: 4px;
  background: #222;
  color: #ddd;
  cursor: pointer;
}

.task-title {
  font-size: 12px;
}

.task-meta,
.task-weight {
  color: #9e9e9e;
  font-size: 11px;
}

.task-pill {
  font-size: 11px;
  border-radius: 10px;
  padding: 2px 7px;
  color: #fff;
}

.tasks-summary {
  font-size: 12px;
  color: #bdbdbd;
  margin-bottom: 8px;
}

.task-toggle-empty {
  display: inline-block;
}

.task-status-done {
  background: #2e7d32;
}

.task-status-progress {
  background: #f9a825;
}

.task-status-pending {
  background: #c62828;
}

.route-arrow {
  color: #2e7d32;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-content-list {
  margin: 8px 0 0;
  padding-left: 16px;
  font-size: 13px;
}

.sidebar-content-list li {
  margin: 6px 0;
}
