:root {
  --bg: #05070a;
  --bg-soft: #0a0d12;
  --surface: rgba(10, 14, 19, 0.84);
  --surface-strong: rgba(6, 10, 14, 0.94);
  --line: rgba(122, 136, 146, 0.24);
  --text: #c7d0d8;
  --muted: #77828d;
  --accent: #7d8f7c;
  --accent-2: #9ba38f;
  --alert: #b06a6f;
  --warning: #9a8461;
  --radius: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 8%, #152025 0%, transparent 45%),
    radial-gradient(circle at 82% 38%, #1b1e16 0%, transparent 38%),
    linear-gradient(145deg, #030507, #070a0d 52%, #0b1016);
  padding: 1.2rem;
}

.bg-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: radial-gradient(#6e7a86 1px, transparent 1px);
  background-size: 3px 3px;
}

.bg-glow {
  position: fixed;
  width: 45vw;
  height: 45vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.06;
  pointer-events: none;
  animation: float 18s ease-in-out infinite alternate;
}

.bg-glow-a {
  background: #1f2c31;
  top: -12vw;
  right: -12vw;
}

.bg-glow-b {
  background: #2b2f22;
  left: -18vw;
  bottom: -18vw;
  animation-delay: 2s;
}

.topbar,
.stats,
.layout {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.topbar-right {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: flex-end;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

h1 {
  margin: 0.1rem 0 0;
  line-height: 1;
  font-size: clamp(1.8rem, 5vw, 3rem);
}

h2,
h3 {
  margin: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  background: rgba(5, 9, 13, 0.86);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
}

.client-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.76rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
  background: rgba(5, 9, 13, 0.8);
}

.client-pill #client-profile {
  color: var(--text);
}

.client-pill #client-origin {
  opacity: 0.85;
}

.client-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 6px currentColor;
}

.status-pill.online .dot {
  background: var(--accent-2);
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.intel-search {
  margin-bottom: 1rem;
  min-height: 0;
  padding: 1.05rem 1.1rem;
  background:
    linear-gradient(165deg, rgba(10, 14, 19, 0.92), rgba(7, 11, 15, 0.9)),
    radial-gradient(circle at 68% -15%, rgba(88, 106, 90, 0.2), transparent 54%);
}

.intel-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

.intel-options {
  display: grid;
  grid-template-columns: auto 1fr 1fr;
  gap: 0.6rem;
  align-items: end;
}

.intel-options label {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-family: "IBM Plex Mono", monospace;
}

.intel-options .inline-check {
  flex-direction: row;
  align-items: center;
  gap: 0.42rem;
}

.intel-options .inline-check input {
  width: auto;
}

#intel-query-input {
  min-height: 44px;
}

#intel-search-btn {
  min-width: 170px;
}

.intel-result {
  border: 1px solid rgba(127, 143, 153, 0.28);
  border-radius: 16px;
  padding: 0.82rem;
  background:
    linear-gradient(175deg, rgba(8, 12, 16, 0.9), rgba(7, 11, 15, 0.8));
  min-height: clamp(260px, 34vh, 420px);
  display: grid;
  gap: 0.65rem;
  align-content: start;
  box-shadow:
    inset 0 0 24px rgba(117, 137, 123, 0.05),
    0 10px 28px rgba(3, 6, 8, 0.24);
}

.intel-stage-shell {
  position: relative;
  margin-top: 0.72rem;
  border-radius: 18px;
  padding: 0.72rem;
  background:
    linear-gradient(160deg, rgba(8, 13, 17, 0.7), rgba(7, 11, 15, 0.52)),
    radial-gradient(circle at 12% 22%, rgba(120, 145, 126, 0.14), transparent 54%),
    radial-gradient(circle at 88% 78%, rgba(112, 125, 140, 0.12), transparent 58%);
  border: 1px solid rgba(121, 136, 147, 0.24);
  box-shadow: inset 0 0 0 1px rgba(6, 9, 12, 0.55), 0 18px 42px rgba(2, 4, 6, 0.34);
}

.intel-stage-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 18px;
  pointer-events: none;
  background:
    linear-gradient(125deg, rgba(159, 181, 166, 0.05), transparent 36%),
    linear-gradient(-125deg, rgba(141, 160, 175, 0.05), transparent 44%);
}

.intel-stage {
  display: grid;
  grid-template-columns: 1.12fr 0.88fr;
  gap: 0.72rem;
  align-items: stretch;
}

.intel-viz-frame {
  position: relative;
  border: 1px solid rgba(130, 146, 156, 0.3);
  border-radius: 18px;
  background:
    linear-gradient(165deg, rgba(8, 12, 16, 0.96), rgba(6, 10, 14, 0.95));
  overflow: hidden;
  min-height: clamp(260px, 34vh, 420px);
  box-shadow:
    inset 0 0 52px rgba(122, 143, 124, 0.11),
    0 10px 28px rgba(3, 6, 8, 0.32);
}

.intel-viz-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(173, 188, 160, 0.08), transparent 42%),
    radial-gradient(circle at 14% 10%, rgba(130, 151, 163, 0.08), transparent 44%);
}

#intel-viz-canvas {
  display: block;
  width: 100%;
  height: clamp(260px, 34vh, 420px);
}

.intel-viz-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.55rem 0.65rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  color: rgba(186, 198, 208, 0.9);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.intel-viz-phase,
.intel-viz-count {
  background: rgba(6, 11, 15, 0.72);
  border: 1px solid rgba(127, 142, 152, 0.32);
  border-radius: 999px;
  padding: 0.18rem 0.52rem;
  backdrop-filter: blur(4px);
}

.intel-placeholder {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
}

.intel-meta {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

.intel-answer {
  margin: 0;
  white-space: pre-wrap;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text);
}

.intel-sources {
  border-top: 1px solid var(--line);
  padding-top: 0.5rem;
  display: grid;
  gap: 0.35rem;
}

.intel-source-title {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", monospace;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.intel-source-row {
  color: #b8c0c8;
  text-decoration: none;
  font-size: 0.8rem;
  font-family: "IBM Plex Mono", monospace;
  word-break: break-word;
}

.intel-source-row:hover {
  color: #d7dde3;
  text-decoration: underline;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  padding: 0.8rem 0.9rem;
  backdrop-filter: blur(6px);
}

.stat-card p {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
}

.stat-card strong {
  font-size: 1.5rem;
  line-height: 1.2;
}

.ops-layout {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 1rem;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: 0.95rem;
  min-height: 460px;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.4rem;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.78rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea {
  border-radius: 10px;
  border: 1px solid rgba(122, 136, 146, 0.34);
  color: var(--text);
  background: rgba(9, 13, 18, 0.92);
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

button {
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  transition: 120ms ease;
}

button:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.ghost {
  background: rgba(7, 11, 15, 0.8);
}

.dispatch-btn {
  background: linear-gradient(90deg, #4a5659, #5d6657);
  color: #e4e8e3;
  font-weight: 700;
  border: 1px solid rgba(143, 154, 140, 0.46);
}

.dispatch-hint {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

.dispatch-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.dispatch-query {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.dispatch-results {
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
  display: grid;
  gap: 0.55rem;
  max-height: 500px;
  overflow: auto;
}

.dispatch-placeholder {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
}

.dispatch-card {
  border: 1px solid rgba(122, 136, 146, 0.3);
  border-radius: 11px;
  padding: 0.5rem 0.65rem;
  background: rgba(8, 12, 16, 0.9);
  display: grid;
  gap: 0.4rem;
}

.dispatch-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.55rem;
}

.dispatch-card-head strong {
  font-size: 0.86rem;
  line-height: 1.2;
}

.dispatch-summary {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.38;
}

.dispatch-ok,
.dispatch-fail {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  border-radius: 999px;
  border: 1px solid var(--line);
  padding: 0.14rem 0.44rem;
}

.dispatch-ok {
  color: #d8e2d4;
  background: rgba(112, 133, 112, 0.2);
}

.dispatch-fail {
  color: #d9b0b1;
  background: rgba(143, 77, 80, 0.2);
}

.dispatch-citations {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.dispatch-citations a {
  font-size: 0.75rem;
  color: #b8c0c8;
  text-decoration: none;
  border: 1px solid rgba(126, 140, 150, 0.32);
  border-radius: 999px;
  padding: 0.16rem 0.46rem;
  font-family: "IBM Plex Mono", monospace;
}

.dispatch-citations a:hover {
  color: #d7dde3;
  border-color: rgba(161, 175, 186, 0.52);
}

.sector-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: end;
}

.sector-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.76rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.sector-map-frame {
  border: 1px solid rgba(127, 141, 152, 0.3);
  border-radius: 14px;
  overflow: hidden;
  min-height: 260px;
  background: rgba(8, 12, 16, 0.9);
}

#sector-map {
  display: block;
  width: 100%;
  height: 290px;
  border: 0;
  background: #070a0d;
}

.news-stream {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 0.6rem;
  overflow: auto;
  flex: 1;
  min-height: 170px;
  max-height: 300px;
  display: grid;
  gap: 0.45rem;
}

.news-placeholder {
  margin: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
}

.news-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.48rem;
  border-left: 2px solid rgba(125, 143, 124, 0.45);
  padding-left: 0.5rem;
}

.news-rank {
  color: var(--muted);
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
  padding-top: 0.12rem;
}

.news-content {
  display: grid;
  gap: 0.2rem;
}

.news-title {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
}

.news-title:hover {
  text-decoration: underline;
}

.news-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: "IBM Plex Mono", monospace;
}

.feed-log {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  padding: 0.6rem;
  overflow: auto;
  flex: 1;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.79rem;
  line-height: 1.35;
  display: grid;
  gap: 0.4rem;
}

.feed-item {
  border-left: 2px solid rgba(125, 143, 124, 0.45);
  padding-left: 0.5rem;
  color: var(--muted);
}

.feed-item strong {
  color: var(--text);
}

body.client-profile-tablet {
  --line: rgba(130, 145, 157, 0.3);
  --surface: rgba(11, 16, 22, 0.86);
}

body.client-profile-phone {
  --surface: rgba(9, 14, 20, 0.9);
  --surface-strong: rgba(7, 10, 14, 0.95);
  --line: rgba(132, 146, 158, 0.34);
}

body.client-profile-phone .stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.client-profile-phone .intel-controls {
  grid-template-columns: 1fr;
}

body.client-profile-phone #intel-search-btn {
  width: 100%;
  min-width: 0;
}

body.client-profile-phone .intel-options {
  grid-template-columns: 1fr;
}

body.client-profile-phone .intel-stage-shell {
  padding: 0.55rem;
  border-radius: 14px;
}

body.client-profile-phone #intel-viz-canvas {
  height: clamp(210px, 32vh, 280px);
}

body.client-profile-phone .intel-viz-frame {
  min-height: clamp(210px, 32vh, 280px);
}

body.client-profile-phone .intel-stage {
  grid-template-columns: 1fr;
}

body.client-profile-phone .ops-layout {
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

body.client-profile-phone .panel {
  padding: 0.7rem;
}

body.client-profile-phone button,
body.client-profile-phone input,
body.client-profile-phone select,
body.client-profile-phone textarea {
  min-height: 40px;
}

body.client-profile-phone textarea {
  min-height: 132px;
}

body.client-platform-iphone {
  --accent: #7e7466;
  --accent-2: #9a9481;
  --warning: #8f7a5d;
}

body.client-platform-iphone .dispatch-btn {
  font-size: 1rem;
  padding: 0.8rem 0.85rem;
}

body.client-platform-iphone #multi-dispatch-panel {
  order: 1;
}

body.client-platform-iphone #sector-panel {
  order: 2;
}

@keyframes float {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, 30px, 0);
  }
}

@media (max-width: 1180px) {
  .ops-layout {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 0;
  }

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

@media (max-width: 680px) {
  body {
    padding: 0.8rem;
  }

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

  .topbar-right {
    align-items: flex-start;
    width: 100%;
  }

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

  .intel-controls {
    grid-template-columns: 1fr;
  }

  .intel-options {
    grid-template-columns: 1fr;
  }

  .intel-stage {
    grid-template-columns: 1fr;
  }

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

  .sector-controls {
    grid-template-columns: 1fr;
  }

  #intel-viz-canvas {
    height: clamp(200px, 34vh, 260px);
  }

  .intel-viz-frame {
    min-height: clamp(200px, 34vh, 260px);
  }

  #sector-map {
    height: 250px;
  }
}
