:root {
  --rc-bg: #0a1420;
  --rc-bg-2: #0e1c2b;
  --rc-panel: rgba(10, 22, 36, 0.92);
  --rc-panel-solid: #0d1a2b;
  --rc-line: rgba(120, 170, 215, 0.22);
  --rc-line-soft: rgba(120, 170, 215, 0.12);
  --rc-text: #e7f0f8;
  --rc-dim: #8ba6bd;
  --rc-faint: #5d7790;
  --rc-cyan: #14d9ff;
  --rc-gold: #ffd21e;
  --rc-red: #ff4d5e;
  --rc-green: #3ddc84;
  --rc-amber: #ffb020;
  --rc-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --rc-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--rc-bg);
  color: var(--rc-text);
  font-family: var(--rc-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, select, input { font-family: inherit; }

[hidden] { display: none !important; }

#reconApp {
  display: grid;
  grid-template-rows: auto auto 1fr;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ---------------- Toolbar ---------------- */

.recon-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #0d1b2c 0%, #0a1626 100%);
  border-bottom: 1px solid var(--rc-line);
  flex-wrap: wrap;
  z-index: 4;
}

.recon-brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }

.recon-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, #12324d, #0a1f33);
  border: 1px solid var(--rc-cyan);
  color: var(--rc-cyan);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.5px;
  box-shadow: 0 0 12px rgba(20, 217, 255, 0.25);
}

.recon-title b { display: block; font-size: 14px; letter-spacing: 2px; color: var(--rc-text); }
.recon-title span { display: block; font-size: 10.5px; letter-spacing: 1.5px; color: var(--rc-faint); text-transform: uppercase; }

.recon-controls {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.recon-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 150px;
  flex: 0 1 200px;
}

.recon-field > span {
  font-size: 9.5px;
  letter-spacing: 1.6px;
  color: var(--rc-faint);
}

.recon-field select {
  appearance: none;
  background: #0e1e30 url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%2314d9ff' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 10px center;
  color: var(--rc-text);
  border: 1px solid var(--rc-line);
  border-radius: 7px;
  padding: 7px 28px 7px 10px;
  font-size: 12.5px;
  min-height: 34px;
  cursor: pointer;
}

.recon-field select:focus {
  outline: none;
  border-color: var(--rc-cyan);
  box-shadow: 0 0 0 2px rgba(20, 217, 255, 0.18);
}

.recon-actions { margin-left: auto; }

.recon-btn {
  background: linear-gradient(180deg, #16314c, #0e2236);
  color: var(--rc-cyan);
  border: 1px solid var(--rc-line);
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  letter-spacing: 0.8px;
  cursor: pointer;
  min-height: 34px;
  text-transform: uppercase;
}

.recon-btn:hover { border-color: var(--rc-cyan); background: #163a57; }

/* ---------------- Layer toggles ---------------- */

.recon-toggles {
  display: flex;
  gap: 8px;
  padding: 7px 14px;
  background: rgba(8, 16, 27, 0.96);
  border-bottom: 1px solid var(--rc-line-soft);
  overflow-x: auto;
  scrollbar-width: thin;
  z-index: 3;
}

.recon-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--rc-line);
  background: #0d1a2a;
  color: var(--rc-dim);
  font-size: 11px;
  letter-spacing: 0.6px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.recon-toggle input { accent-color: var(--rc-cyan); margin: 0; width: 13px; height: 13px; }

.recon-toggle.on { border-color: rgba(20, 217, 255, 0.5); color: var(--rc-text); background: #12304a; }

/* ---------------- Map ---------------- */

.recon-map { position: relative; width: 100%; height: 100%; background: #070f18; }

.recon-map .maplibregl-ctrl-group { background: var(--rc-panel-solid); border: 1px solid var(--rc-line); border-radius: 8px; overflow: hidden; box-shadow: none; }

.recon-map .maplibregl-ctrl button { background-color: transparent; border: none; }

.recon-map .maplibregl-ctrl button span { background-image: none; filter: invert(1); }

.recon-map .maplibregl-ctrl-attrib { background: transparent; color: var(--rc-faint); }

.recon-map .maplibregl-ctrl-attrib a { color: var(--rc-dim); }

.recon-map .maplibregl-popup-content {
  background: var(--rc-panel-solid);
  border: 1px solid var(--rc-line);
  border-radius: 10px;
  color: var(--rc-text);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  padding: 12px 14px;
}

.recon-map .maplibregl-popup-tip { border-top-color: var(--rc-panel-solid); border-bottom-color: var(--rc-panel-solid); }

/* ---------------- Status strip ---------------- */

.recon-status {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(760px, 70vw);
  z-index: 2;
}

.rst-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 16px;
  background: var(--rc-panel);
  border: 1px solid var(--rc-line-soft);
  color: var(--rc-dim);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: border-color 0.15s ease;
}

.rst-chip:hover { border-color: var(--rc-cyan); }
.rst-chip.is-active { border-color: var(--rc-cyan); color: var(--rc-text); }

.rst-chip b { color: var(--rc-text); font-weight: 600; }

.rst-chip .dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.rst-chip.is-loading .dot { background: var(--rc-amber); animation: rcPulse 1.1s ease-in-out infinite; }
.rst-chip.is-available .dot { background: var(--rc-green); }
.rst-chip.is-empty .dot { background: var(--rc-faint); }
.rst-chip.is-unavailable .dot, .rst-chip.is-error .dot { background: var(--rc-red); }

@keyframes rcPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.rst-banner {
  flex-basis: 100%;
  margin-top: 4px;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(120, 30, 40, 0.75);
  border: 1px solid rgba(255, 77, 94, 0.4);
  color: #ffd9dd;
  font-size: 11px;
  line-height: 1.5;
}

/* ---------------- Site analysis panel ---------------- */

.recon-site {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(430px, 94vw);
  background: var(--rc-panel);
  border-left: 1px solid var(--rc-line);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  z-index: 5;
  box-shadow: -14px 0 40px rgba(0, 0, 0, 0.45);
}

.recon-site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--rc-line);
  background: linear-gradient(180deg, #0e2134 0%, rgba(14, 33, 52, 0.4) 100%);
}

.recon-site-head b { font-size: 12px; letter-spacing: 2px; color: var(--rc-cyan); }

.recon-site-actions { display: flex; gap: 6px; }

.recon-icon-btn {
  background: #0e1e30;
  color: var(--rc-dim);
  border: 1px solid var(--rc-line);
  border-radius: 7px;
  padding: 5px 9px;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
}

.recon-icon-btn:hover { border-color: var(--rc-cyan); color: var(--rc-text); }

.recon-site-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: #23405a transparent;
}

.recon-placeholder {
  display: grid;
  place-items: center;
  min-height: 40vh;
  text-align: center;
  color: var(--rc-faint);
  padding: 24px;
  border: 1px dashed var(--rc-line-soft);
  border-radius: 10px;
}

.recon-placeholder b { display: block; color: var(--rc-dim); font-size: 13px; letter-spacing: 1px; margin-bottom: 8px; }
.recon-placeholder span { font-size: 11.5px; line-height: 1.6; }

.rsec { margin-bottom: 16px; }

.rsec h4 {
  margin: 0 0 7px;
  font-size: 10px;
  letter-spacing: 1.8px;
  color: var(--rc-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.rsec h4::after { content: ""; flex: 1; height: 1px; background: var(--rc-line-soft); }

.rsec > div {
  background: rgba(13, 27, 43, 0.55);
  border: 1px solid var(--rc-line-soft);
  border-radius: 9px;
  overflow: hidden;
}

.rrow {
  display: grid;
  grid-template-columns: minmax(110px, 38%) 1fr;
  gap: 10px;
  padding: 7px 11px;
  font-size: 12px;
  border-bottom: 1px solid var(--rc-line-soft);
}

.rrow:last-child { border-bottom: none; }

.rrow span { color: var(--rc-faint); font-size: 10px; text-transform: uppercase; letter-spacing: 0.9px; padding-top: 1px; }

.rrow b { color: var(--rc-text); font-family: var(--rc-mono); font-size: 11.5px; font-weight: 500; word-break: break-word; white-space: pre-wrap; }

.rrow.is-kicker b { color: var(--rc-gold); }
.rrow.is-coord b { color: var(--rc-cyan); font-size: 12px; }

.rrow a { color: var(--rc-cyan); word-break: break-all; }

/* ---------------- Empty / error states ---------------- */

.recon-feed-error {
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 77, 94, 0.1);
  border: 1px solid rgba(255, 77, 94, 0.35);
  color: #ffd2d8;
  font-size: 11.5px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.recon-feed-empty {
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(141, 166, 189, 0.08);
  border: 1px dashed var(--rc-line-soft);
  color: var(--rc-dim);
  font-size: 11.5px;
  margin-bottom: 12px;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 900px) {
  .recon-toolbar { gap: 10px; padding: 9px 12px; }
  .recon-brand { min-width: 0; }
  .recon-title span { display: none; }
  .recon-controls { justify-content: flex-start; }
  .recon-field { flex: 1 1 46%; min-width: 0; }
  .recon-actions { width: 100%; display: flex; justify-content: flex-end; }
  .recon-mark { width: 30px; height: 30px; font-size: 12px; }
}

@media (max-width: 640px) {
  #reconApp { grid-template-rows: auto auto 1fr; }
  .recon-field { flex: 1 1 100%; }
  .recon-field > span { display: none; }
  .recon-status {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
  .recon-site {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 58dvh;
    border-left: none;
    border-top: 1px solid var(--rc-line);
    box-shadow: 0 -14px 40px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}