:root {
  color-scheme: dark;
}

body {
  font-family: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  background-color: #0f172a;
}

::selection {
  background-color: rgba(79, 96, 255, 0.35);
  color: #f8fafc;
}

.form-control::placeholder {
  color: #94a3b8;
  opacity: 1;
}

.glass-surface {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 40px -28px rgba(15, 23, 42, 0.75);
}

/* Identity UI theming */
.identity-shell h1, .identity-shell h2, .identity-shell h3 {
  color: #e2e8f0;
  margin-bottom: 0.65rem;
}

.identity-shell p {
  color: #cbd5e1;
}

.identity-shell hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0.75rem 0;
}

.identity-shell .row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-top: 0.75rem;
}

.identity-shell .row > [class*="col-"] {
  flex: 1 1 280px;
}

.identity-shell .row > .col-md-3 {
  max-width: 16rem;
}

.identity-shell .row > .col-md-4 {
  max-width: 22rem;
}

.identity-shell .row > .col-md-6 {
  max-width: 32rem;
}

.identity-shell .row > .col-md-9 {
  flex: 2 1 460px;
}

.identity-shell .row section {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 10px 40px -28px rgba(15, 23, 42, 0.75);
}

.identity-shell form,
.app-form {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.identity-shell .form-floating,
.app-form .form-floating {
  position: relative;
  margin-bottom: 0.9rem;
}

.identity-shell .form-control,
.app-form .form-control {
  width: 100%;
  border-radius: 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background-color: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
  padding: 1.35rem 1rem 0.55rem;
  min-height: 3.1rem;
  transition: all 0.15s ease;
}

.identity-shell .form-control:focus,
.app-form .form-control:focus {
  outline: none;
  border-color: #4e8aff;
  box-shadow: 0 0 0 4px rgba(79, 96, 255, 0.18);
  background-color: rgba(255, 255, 255, 0.07);
}

.identity-shell .form-control::placeholder,
.app-form .form-control::placeholder {
  color: #64748b;
}

.identity-shell .form-floating > label,
.app-form .form-floating > label {
  position: absolute;
  top: 0.32rem;
  left: 1rem;
  color: #94a3b8;
  font-size: 0.72rem;
  line-height: 1;
  transition: color 0.15s ease;
  pointer-events: none;
  z-index: 1;
  background-color: #0f172a;
  padding: 0 0.35rem;
  border-radius: 999px;
}

.identity-shell .form-floating > input:focus + label,
.identity-shell .form-floating > textarea:focus + label,
.identity-shell .form-floating > select:focus + label,
.app-form .form-floating > input:focus + label,
.app-form .form-floating > textarea:focus + label,
.app-form .form-floating > select:focus + label {
  color: #cbd5e1;
}

.identity-shell .form-check,
.app-form .form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.identity-shell .form-check-input,
.app-form .form-check-input {
  width: 1.05rem;
  height: 1.05rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.35rem;
  background-color: rgba(255, 255, 255, 0.05);
  accent-color: #1f5bff;
}

.identity-shell .form-check-label,
.identity-shell .form-label,
.app-form .form-check-label,
.app-form .form-label {
  color: #cbd5e1;
  font-weight: 500;
}

.identity-shell .checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mb-3 { margin-bottom: 0.9rem; }
.mb-4 { margin-bottom: 1.2rem; }
.mt-3 { margin-top: 0.9rem; }
.mt-4 { margin-top: 1.2rem; }
.w-100 { width: 100%; }
.col-md-offset-2 { margin-left: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 1.1rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #1f5bff, #a855f7);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 40px -22px rgba(79, 96, 255, 0.65);
}

.btn-primary:hover {
  border-color: rgba(255, 255, 255, 0.22);
  box-shadow: 0 18px 50px -22px rgba(79, 96, 255, 0.85);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  border-color: rgba(255, 255, 255, 0.08);
}

.btn-sm {
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
}

.btn-link {
  color: #93c5fd;
  background: transparent;
  border: none;
  padding: 0.1rem;
  box-shadow: none;
}

.btn-link:hover {
  color: #cbd5e1;
  background: transparent;
}

.btn-lg {
  padding: 0.9rem 1.2rem;
  font-size: 1rem;
  border-radius: 0.95rem;
}

.btn-close {
  appearance: none;
  -webkit-appearance: none;
  height: 2rem;
  width: 2rem;
  border: none;
  border-radius: 0.75rem;
  background-color: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-close::before {
  content: "✕";
  font-size: 0.95rem;
}

.btn-close:hover {
  background-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.text-danger { color: #f87171; }
.text-success { color: #34d399; }
.text-info { color: #67e8f9; }
.text-dark { color: #e2e8f0; }

.alert {
  border-radius: 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.alert-success {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.35);
  color: #d1fae5;
}

.alert-danger {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fee2e2;
}

.alert-dismissible {
  justify-content: space-between;
}

.nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-link {
  color: #cbd5e1;
  text-decoration: none;
  font-weight: 600;
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
}

.nav-link:hover {
  color: #fff;
}

.identity-nav-link {
  display: block;
  padding: 0.65rem 0.9rem;
  border-radius: 0.9rem;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.identity-nav-link:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.12);
}

.identity-nav-link.active {
  color: #fff;
  background: linear-gradient(135deg, #1f5bff, #a855f7);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 14px 40px -22px rgba(79, 96, 255, 0.75);
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  overflow: hidden;
}

.table th, .table td {
  padding: 0.75rem 0.9rem;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.table th {
  text-align: left;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.04);
}

.table tr:last-child td {
  border-bottom: none;
}

.tracker-map-canvas {
  min-height: 540px;
  border-radius: 1.5rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tracker-map-panel-surface {
  position: relative;
}

.tracker-map-panel-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 1.5rem;
  border: 1px dashed rgba(255, 255, 255, 0.1);
  background: rgba(2, 6, 23, 0.82);
}

.tracker-map-panel-empty.hidden,
.tracker-map-wallboard__empty.hidden {
  display: none !important;
}

.tracker-map-wallboard {
  position: relative;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 15% 15%, rgba(34, 211, 238, 0.12), transparent 24%),
    radial-gradient(circle at 85% 10%, rgba(59, 130, 246, 0.12), transparent 26%),
    #020617;
}

.tracker-map-wallboard__surface {
  position: relative;
  width: 100%;
  height: 100%;
}

.tracker-map-wallboard__canvas,
.tracker-map-wallboard__empty {
  position: absolute;
  inset: 0;
}

.tracker-map-wallboard__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.tracker-map-wallboard__overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1rem;
  gap: 1rem;
}

.tracker-map-wallboard__panel,
.tracker-map-wallboard__legend {
  pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.82);
  backdrop-filter: blur(16px);
  box-shadow: 0 24px 60px -40px rgba(15, 23, 42, 0.95);
}

.tracker-map-wallboard__panel {
  border-radius: 1.5rem;
  padding: 1.1rem 1.2rem;
}

.tracker-map-wallboard__legend {
  align-self: flex-end;
  width: min(360px, calc(100vw - 2rem));
  max-height: min(44vh, 420px);
  border-radius: 1.5rem;
  padding: 1rem 1.1rem;
  overflow: hidden;
}

.tracker-map-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  border: 3px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 14px 35px -18px rgba(15, 23, 42, 0.9);
  font-weight: 700;
  color: #fff;
}

.tracker-map-cluster span {
  display: inline-flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 30%, rgba(34, 211, 238, 0.45), rgba(15, 23, 42, 0.95));
  backdrop-filter: blur(8px);
}

.tracker-map-cluster--small {
  width: 42px !important;
  height: 42px !important;
  margin-left: -21px !important;
  margin-top: -21px !important;
  font-size: 0.82rem;
}

.tracker-map-cluster--medium {
  width: 48px !important;
  height: 48px !important;
  margin-left: -24px !important;
  margin-top: -24px !important;
  font-size: 0.9rem;
}

.tracker-map-cluster--large {
  width: 56px !important;
  height: 56px !important;
  margin-left: -28px !important;
  margin-top: -28px !important;
  font-size: 1rem;
}

.tracker-map-legend-swatch {
  width: 0.9rem;
  height: 0.9rem;
  flex: 0 0 auto;
  border-radius: 9999px;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.tracker-map-popup {
  min-width: 200px;
}

.tracker-map-popup__eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748b;
}

.tracker-map-popup__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.3;
  color: #0f172a;
}

.tracker-map-popup__meta {
  margin: 0.9rem 0 0;
  display: grid;
  gap: 0.5rem;
}

.tracker-map-popup__meta div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.82rem;
}

.tracker-map-popup__meta dt {
  color: #475569;
  font-weight: 600;
}

.tracker-map-popup__meta dd {
  margin: 0;
  color: #0f172a;
  text-align: right;
}

@media (max-width: 960px) {
  .tracker-map-wallboard__overlay {
    justify-content: flex-start;
  }

  .tracker-map-wallboard__legend {
    align-self: stretch;
    width: auto;
    max-height: 32vh;
  }
}
