:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel-soft: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --line: rgba(255, 255, 255, 0.08);
  --primary: #038db2;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(3, 141, 178, 0.14), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.page-shell {
  min-height: 100vh;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 24px;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-label {
  color: var(--muted);
  font-size: 12px;
}

.client-selector-card {
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 14px;
  align-items: end;
}

.client-info {
  min-height: 42px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.client-info span {
  font-weight: 900;
  font-size: 16px;
}

.client-info small {
  color: var(--muted);
  margin-top: 4px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 10px;
}

.summary-card {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.summary-card strong {
  font-size: 28px;
}

.summary-card.ok {
  border-color: rgba(34, 197, 94, 0.35);
}

.summary-card.warning {
  border-color: rgba(245, 158, 11, 0.45);
}

.summary-card.danger {
  border-color: rgba(239, 68, 68, 0.45);
}

.tabs-card {
  flex: 1;
  min-height: 0;
  background: rgba(17, 24, 39, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.45);
}

.tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 14px 18px;
  font-weight: 900;
  cursor: pointer;
}

.tab.active {
  color: white;
  background: rgba(3, 141, 178, 0.16);
  border-bottom: 2px solid var(--primary);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 220px;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.search-input,
input,
select,
textarea {
  width: 100%;
  background: #020617;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  outline: none;
}

label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

label input,
label select,
label textarea {
  margin-top: 6px;
}

.tab-panel {
  display: none;
  flex: 1;
  min-height: 0;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

.table-wrapper {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1260px;
}

thead {
  position: sticky;
  top: 0;
  background: #0f172a;
  z-index: 2;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 12px;
}

th {
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

td {
  color: var(--text);
}

.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 28px;
}

.imei-cell {
  font-weight: 900;
  color: #e0f2fe;
}

.person-cell {
  font-weight: 900;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.ok {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
}

.badge.danger {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.14);
}

.badge.warning {
  color: #fde68a;
  background: rgba(245, 158, 11, 0.14);
}

.badge.neutral {
  color: #cbd5e1;
  background: rgba(148, 163, 184, 0.14);
}

.badge.victim {
  color: #bbf7d0;
  background: rgba(34, 197, 94, 0.15);
}

.badge.aggressor {
  color: #fecaca;
  background: rgba(239, 68, 68, 0.18);
}

.badge.monitor {
  color: #bfdbfe;
  background: rgba(59, 130, 246, 0.16);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 9px 11px;
  color: white;
  cursor: pointer;
  font-weight: 900;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn-primary {
  background: var(--primary);
}

.btn-secondary {
  background: var(--panel-soft);
}

.btn-success {
  background: var(--success);
}

.btn-danger {
  background: var(--danger);
}

.btn-mini {
  padding: 6px 8px;
  font-size: 11px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal {
  border: none;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.modal-content {
  width: min(760px, 94vw);
  background: #111827;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
}

.modal-content h2 {
  margin: 0 0 14px;
}

.device-preview {
  background: rgba(2, 6, 23, 0.55);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.device-preview span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.device-preview strong {
  font-size: 18px;
}

.device-preview small {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

.map-modal .modal-content {
  width: min(920px, 94vw);
  height: min(680px, 88vh);
  display: flex;
  flex-direction: column;
}

.map-modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.map-modal-header h2 {
  margin: 0;
}

.map-modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#miniMap {
  flex: 1;
  min-height: 420px;
  border-radius: 14px;
  overflow: hidden;
  background: #020617;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-selector-card {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

.command-combo {
  display: flex;
  gap: 6px;
  align-items: center;
  width: 100%;
  min-width: 210px;
}

.command-select {
  min-width: 135px;
  max-width: 170px;
  height: 30px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  background: #ffffff;
  color: #0f172a;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.actions .btn-mini {
  white-space: nowrap;
}