:root {
  color-scheme: dark;
  --bg: #151b22;
  --panel: #1f2831;
  --panel-2: #26333d;
  --line: #3b4a55;
  --text: #f4f7f8;
  --muted: #98a8b2;
  --green: #52d184;
  --amber: #f5b84b;
  --red: #ee6b5f;
  --blue: #68a8f5;
  --cyan: #62d0d8;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(100%, 440px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  width: 112px;
  height: 112px;
  margin-bottom: 18px;
  object-fit: contain;
}

.auth-card h1 {
  margin: 2px 0 22px;
  font-size: 32px;
}

.form-stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #121a21;
  color: var(--text);
  padding: 0 12px;
}

.checkbox-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  min-height: auto;
  width: auto;
}

.app-shell {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 26px;
  height: 100vh;
  min-width: 0;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: #111820;
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
}

.eyebrow,
.section-title {
  color: var(--green);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.brand-row h1,
.topbar h2,
.detail-panel h3 {
  margin: 2px 0 0;
  line-height: 1.05;
}

.brand-row h1 {
  font-size: 22px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item,
.incident-row,
.filter,
.icon-button,
.primary-button,
.secondary-button,
.play-button {
  border: 1px solid transparent;
  color: var(--text);
  cursor: pointer;
}

.nav-item {
  padding: 12px 14px;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  color: var(--muted);
}

.nav-item.active,
.nav-item:hover {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.account-panel,
.metric,
.map-panel,
.detail-panel,
.activity-panel,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.account-panel {
  margin-top: auto;
  padding: 14px;
}

.account-name {
  margin-top: 10px;
  font-weight: 900;
}

.account-role {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.access-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  color: var(--muted);
  font-size: 13px;
}

.access-row strong {
  color: var(--text);
}

.workspace {
  display: grid;
  align-content: start;
  gap: 18px;
  min-width: 0;
  padding: 24px;
}

.topbar,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h2 {
  font-size: 32px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.play-button {
  min-height: 40px;
  border-radius: 8px;
}

.primary-button {
  padding: 0 16px;
  background: var(--green);
  color: #0e2116;
  font-weight: 800;
}

.secondary-button,
.play-button {
  padding: 0 14px;
  background: var(--panel-2);
  border-color: var(--line);
}

.full {
  width: 100%;
}

.flash {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(82, 209, 132, 0.45);
  border-radius: 8px;
  background: rgba(82, 209, 132, 0.1);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.flash.inline {
  margin-bottom: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.metric {
  padding: 14px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 6px 0 2px;
  font-size: 28px;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  min-height: 560px;
}

.map-panel,
.detail-panel,
.activity-panel,
.panel {
  padding: 16px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.filter-row,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-row {
  margin: 16px 0 12px;
}

.filter {
  padding: 8px 11px;
  border-color: var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.filter.active {
  background: var(--panel-2);
  color: var(--text);
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-canvas {
  position: relative;
  overflow: hidden;
  min-height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 30% 30%, rgba(82, 209, 132, 0.12), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(104, 168, 245, 0.12), transparent 24%),
    linear-gradient(135deg, #1a232b 0%, #111820 100%);
}

.leaflet-map,
.map-fallback {
  position: absolute;
  inset: 0;
}

.leaflet-map {
  z-index: 1;
  background: #101820;
}

.map-fallback {
  z-index: 0;
}

.map-canvas.leaflet-ready .map-fallback {
  display: none;
}

.leaflet-container {
  font: inherit;
  background: #101820;
}

.leaflet-control-attribution,
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
}

.leaflet-control-attribution a {
  color: var(--green);
}

.leaflet-incident-pin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  color: #0e1114;
  font-weight: 900;
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.08), var(--shadow);
}

.leaflet-incident-pin.active {
  outline: 3px solid var(--green);
}

.map-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 48px 48px;
}

.map-route {
  position: absolute;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  transform-origin: left center;
}

.route-one {
  left: 8%;
  top: 62%;
  width: 82%;
  transform: rotate(-10deg);
}

.route-two {
  left: 18%;
  top: 24%;
  width: 62%;
  transform: rotate(24deg);
}

.map-pin {
  position: absolute;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50% 50% 50% 8px;
  color: #0e1114;
  font-weight: 900;
  transform: translate(-50%, -50%) rotate(-45deg);
  box-shadow: 0 0 0 8px rgba(255, 255, 255, 0.06), var(--shadow);
}

.map-pin span {
  transform: rotate(45deg);
}

.map-pin.high,
.priority-dot.high,
.detail-status.high,
.leaflet-incident-pin.high {
  background: var(--red);
}

.map-pin.medium,
.priority-dot.medium,
.detail-status.medium,
.leaflet-incident-pin.medium {
  background: var(--amber);
}

.map-pin.low,
.priority-dot.low,
.detail-status.low,
.leaflet-incident-pin.low {
  background: var(--blue);
}

.map-pin.info,
.priority-dot.info,
.detail-status.info,
.leaflet-incident-pin.info {
  background: var(--cyan);
}

.map-pin.active {
  outline: 3px solid var(--green);
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.detail-status {
  align-self: flex-start;
  padding: 6px 10px;
  border-radius: 999px;
  color: #0e1114;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.detail-panel h3 {
  font-size: 24px;
}

.detail-place,
.detail-panel p,
.transcript p,
.verification-note {
  color: var(--muted);
}

.detail-panel p,
.transcript p {
  margin: 0;
  line-height: 1.55;
}

.tag-row span {
  padding: 6px 9px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 12px;
}

.audio-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #172027;
}

.audio-meta {
  display: grid;
  gap: 4px;
}

.audio-meta span {
  color: var(--muted);
  font-size: 12px;
}

.transcript,
.verification-note,
.ai-box {
  padding: 12px;
  border-radius: 8px;
  background: #172027;
}

.ai-box {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
}

.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-head small,
.ai-box small,
.muted-copy {
  color: var(--muted);
}

.incident-list,
.list-panel {
  display: grid;
  gap: 10px;
}

.incident-row,
.data-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px;
  border-color: var(--line);
  border-radius: 8px;
  background: #172027;
  text-align: left;
}

.incident-row.active {
  border-color: var(--green);
}

.priority-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.incident-main,
.incident-meta,
.data-card div {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.incident-main small,
.incident-meta small,
.data-card small {
  color: var(--muted);
  font-size: 12px;
}

.incident-meta {
  text-align: right;
}

.two-column {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.data-card {
  grid-template-columns: minmax(0, 1fr);
}

.data-card.horizontal {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.scanner-card small + small {
  margin-top: 2px;
}

@media (max-width: 980px) {
  .app-shell,
  .main-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar,
  .auth-screen {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 26px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .incident-row,
  .data-card.horizontal {
    grid-template-columns: 1fr;
  }

  .incident-meta {
    text-align: left;
  }
}
