:root {
  color-scheme: dark;
  --bg: #11130f;
  --panel: #171a15;
  --panel-2: #1d211b;
  --line: #31362d;
  --line-strong: #4a5143;
  --text: #f2f5ec;
  --muted: #9da695;
  --faint: #6c7466;
  --lime: #c9f45b;
  --cyan: #4bd8e8;
  --coral: #ff705d;
  --amber: #f2b84b;
  --magenta: #e86cd5;
  --blue: #67a9ff;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
  --topbar-height: 64px;
  --rail-width: 72px;
  --panel-width: 390px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Manrope", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  color: inherit;
}

#app-shell {
  display: grid;
  width: 100vw;
  height: 100vh;
  grid-template-columns: var(--rail-width) minmax(0, 1fr) var(--panel-width);
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  grid-template-areas:
    "topbar topbar topbar"
    "rail map panel";
}

.topbar {
  grid-area: topbar;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
  align-items: center;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(17, 19, 15, 0.96);
  backdrop-filter: blur(16px);
}

.brand-block,
.system-strip,
.top-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
  padding-left: 18px;
}

.brand-mark {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
}

.brand-mark span {
  position: absolute;
  width: 7px;
  height: 7px;
  background: var(--lime);
}

.brand-mark span:nth-child(1) {
  left: 6px;
  top: 6px;
}

.brand-mark span:nth-child(2) {
  right: 6px;
  top: 13px;
  background: var(--cyan);
}

.brand-mark span:nth-child(3) {
  left: 10px;
  bottom: 5px;
  background: var(--coral);
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
}

.brand-subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.system-strip {
  height: 100%;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.status-cell {
  display: flex;
  height: 100%;
  min-width: 92px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 14px;
  border-right: 1px solid var(--line);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.status-cell:last-child {
  border-right: 0;
}

.status-label {
  color: var(--faint);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 12px currentColor;
}

.status-dot.online {
  color: var(--lime);
  background: var(--lime);
}

.status-dot.partial {
  color: var(--amber);
  background: var(--amber);
}

.status-dot.blocked {
  color: var(--coral);
  background: var(--coral);
}

.top-actions {
  justify-content: flex-end;
  gap: 8px;
  padding-right: 14px;
}

.icon-button,
.command-button,
.secondary-button,
.filter-chip,
.rail-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.icon-button svg,
.command-button svg,
.secondary-button svg {
  width: 16px;
  height: 16px;
}

.command-button,
.secondary-button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  padding: 0 15px;
  font-weight: 700;
  font-size: 12px;
}

.command-button {
  background: var(--lime);
  color: #11130f;
}

.command-button:hover {
  background: #dcff7f;
}

.command-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
}

.rail {
  grid-area: rail;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 8px;
  border-right: 1px solid var(--line);
  background: var(--bg);
}

.rail-button {
  display: flex;
  width: 55px;
  height: 52px;
  flex: 0 0 52px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
}

.rail-button svg {
  width: 18px;
  height: 18px;
}

.rail-button:hover,
.rail-button.active {
  color: var(--text);
  background: var(--panel);
}

.rail-button.active {
  border-left-color: var(--lime);
}

.map-stage {
  position: relative;
  grid-area: map;
  min-width: 0;
  overflow: hidden;
  background: #121510;
}

#map {
  position: absolute;
  inset: 0;
}

.maplibregl-ctrl-attrib {
  font-size: 9px;
  opacity: 0.55;
}

.map-toolbar,
.filter-dock,
.map-legend {
  position: absolute;
  z-index: 10;
  display: flex;
  background: rgba(17, 19, 15, 0.9);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
}

.map-toolbar {
  top: 14px;
  left: 14px;
  flex-direction: column;
  border: 1px solid var(--line);
}

.map-toolbar .icon-button {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}

.map-toolbar .icon-button:last-child {
  border-bottom: 0;
}

.filter-dock {
  left: 50%;
  bottom: 18px;
  max-width: calc(100% - 34px);
  transform: translateX(-50%);
  gap: 4px;
  overflow-x: auto;
  border: 1px solid var(--line);
  padding: 5px;
}

.filter-chip {
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.filter-chip:hover,
.filter-chip.active {
  border-color: var(--line-strong);
  background: var(--panel-2);
  color: var(--text);
}

.swatch {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.swatch.all { background: var(--lime); }
.swatch.seismic { background: var(--coral); }
.swatch.wildfire { background: var(--amber); }
.swatch.storm { background: var(--cyan); }
.swatch.volcano { background: var(--magenta); }

.map-legend {
  right: 14px;
  bottom: 18px;
  flex-direction: column;
  gap: 7px;
  border: 1px solid var(--line);
  padding: 9px 11px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
}

.map-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ring {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--amber);
}

.ring.verified {
  border-color: var(--lime);
}

.intel-panel {
  grid-area: panel;
  z-index: 22;
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: var(--bg);
}

.panel-header {
  display: flex;
  min-height: 78px;
  align-items: center;
  justify-content: space-between;
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  color: var(--lime);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.panel-header h1 {
  margin: 4px 0 0;
  font-size: 19px;
  line-height: 1.15;
}

.panel-content {
  height: calc(100% - 78px);
  overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent;
}

.loading-state,
.empty-state {
  display: grid;
  min-height: 260px;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.loading-state p,
.empty-state p {
  margin: 0;
  max-width: 260px;
  font-size: 12px;
  line-height: 1.6;
}

.scanner-line {
  position: relative;
  width: 140px;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.scanner-line::after {
  position: absolute;
  width: 45px;
  height: 2px;
  background: var(--lime);
  content: "";
  animation: scan 1.1s infinite ease-in-out;
}

@keyframes scan {
  from { transform: translateX(-45px); }
  to { transform: translateX(140px); }
}

.feed-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.metric {
  padding: 12px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.fact-label {
  display: block;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 17px;
}

.event-list {
  padding: 8px;
}

.event-card,
.claim-card,
.finding {
  width: 100%;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  background: transparent;
}

.event-card {
  display: grid;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 10px;
  padding: 13px 8px;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.event-card:hover,
.event-card.selected {
  border-color: var(--line);
  background: var(--panel);
}

.event-beacon {
  width: 8px;
  height: 8px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 10px currentColor;
}

.event-beacon.seismic { color: var(--coral); background: var(--coral); }
.event-beacon.wildfire { color: var(--amber); background: var(--amber); }
.event-beacon.storm { color: var(--cyan); background: var(--cyan); }
.event-beacon.volcano { color: var(--magenta); background: var(--magenta); }

.event-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.4;
}

.event-meta,
.claim-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
}

.risk-badge,
.class-badge {
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 5px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 7px;
  text-transform: uppercase;
}

.risk-badge.high,
.risk-badge.critical {
  border-color: rgba(255, 112, 93, 0.45);
  color: var(--coral);
}

.detail-drawer {
  position: absolute;
  z-index: 25;
  left: calc(var(--rail-width) + 18px);
  bottom: 18px;
  width: min(560px, calc(100vw - var(--rail-width) - var(--panel-width) - 50px));
  max-height: min(620px, calc(100vh - var(--topbar-height) - 36px));
  overflow-y: auto;
  transform: translateY(calc(100% + 40px));
  border: 1px solid var(--line-strong);
  background: rgba(17, 19, 15, 0.97);
  box-shadow: var(--shadow);
  transition: transform 220ms ease;
}

.detail-drawer.open {
  transform: translateY(0);
}

.drawer-grip {
  display: none;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 17px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 {
  margin: 5px 0 0;
  font-size: 18px;
  line-height: 1.3;
}

#detail-body {
  padding: 17px;
}

.detail-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 15px 0;
  border: 1px solid var(--line);
}

.fact {
  min-width: 0;
  padding: 11px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.fact:nth-child(2n) {
  border-right: 0;
}

.fact-value {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.drawer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.text-link {
  color: var(--cyan);
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.section-block {
  padding: 14px 15px;
  border-bottom: 1px solid var(--line);
}

.section-block h3 {
  margin-bottom: 8px;
  font-size: 13px;
}

.section-block p,
.section-block li {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.section-block ul {
  margin: 8px 0 0;
  padding-left: 17px;
}

.claim-card {
  padding: 14px 15px;
}

.claim-statement {
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.55;
}

.claim-hash {
  margin-top: 8px;
  overflow: hidden;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.claim-form {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
}

.field-label textarea,
.field-label select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  outline: 0;
  background: var(--panel);
  color: var(--text);
}

.field-label textarea {
  min-height: 110px;
  resize: vertical;
  padding: 10px;
  line-height: 1.5;
}

.field-label select {
  height: 38px;
  padding: 0 9px;
}

.field-label textarea:focus,
.field-label select:focus {
  border-color: var(--lime);
}

.briefing-hero {
  padding: 17px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.briefing-hero p {
  margin: 8px 0 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.65;
}

.finding {
  padding: 14px 15px;
}

.finding p {
  margin: 7px 0;
  font-size: 11px;
  line-height: 1.6;
}

.source-pill {
  display: inline-block;
  margin: 2px 3px 2px 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 5px;
  color: var(--cyan);
  font-family: "IBM Plex Mono", monospace;
  font-size: 7px;
}

.mobile-panel-close {
  display: none;
}

.tour-overlay {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 6, 4, 0.78);
  backdrop-filter: blur(8px);
}

.tour-overlay.hidden {
  display: none;
}

.tour-dialog {
  width: min(480px, 100%);
  border: 1px solid var(--line-strong);
  background: var(--bg);
  box-shadow: var(--shadow);
  padding: 22px;
}

.tour-visual {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--lime);
}

.tour-visual svg {
  width: 28px;
  height: 28px;
}

.tour-progress {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  margin-bottom: 14px;
}

.tour-progress span {
  height: 2px;
  background: var(--line);
}

.tour-progress span.active {
  background: var(--lime);
}

.tour-dialog h2 {
  margin: 6px 0 9px;
  font-size: 23px;
}

.tour-dialog p {
  min-height: 74px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.tour-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 22px;
}

.toast-region {
  position: fixed;
  z-index: 120;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 340px;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  box-shadow: var(--shadow);
  padding: 11px 13px;
  color: var(--text);
  font-size: 11px;
}

@media (max-width: 1060px) {
  :root {
    --panel-width: 340px;
  }

  .desktop-only,
  .brand-subtitle {
    display: none;
  }

  .map-legend {
    display: none;
  }
}

@media (max-width: 780px) {
  :root {
    --topbar-height: 58px;
    --rail-width: 0px;
    --panel-width: 100vw;
  }

  #app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-height) minmax(0, 1fr) 58px;
    grid-template-areas:
      "topbar"
      "map"
      "rail";
  }

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

  .brand-block {
    padding-left: 10px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    flex-basis: 30px;
  }

  .brand-name {
    font-size: 12px;
  }

  .system-strip {
    display: none;
  }

  .top-actions {
    padding-right: 8px;
  }

  .command-button {
    padding: 0 11px;
  }

  .rail {
    position: relative;
    z-index: 40;
    flex-direction: row;
    justify-content: space-around;
    padding: 3px 8px;
    border-top: 1px solid var(--line);
    border-right: 0;
  }

  .rail-button {
    width: 82px;
    height: 50px;
    flex-basis: 50px;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .rail-button.active {
    border-bottom-color: var(--lime);
  }

  .intel-panel {
    position: fixed;
    z-index: 50;
    inset: var(--topbar-height) 0 58px;
    display: none;
    border-left: 0;
  }

  .intel-panel.mobile-open {
    display: block;
  }

  .mobile-panel-close {
    display: inline-grid;
  }

  .filter-dock {
    bottom: 12px;
    width: calc(100% - 24px);
    justify-content: flex-start;
  }

  .detail-drawer {
    position: fixed;
    z-index: 60;
    left: 0;
    bottom: 0;
    width: 100%;
    max-height: 76vh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
  }

  .drawer-grip {
    display: block;
    width: 42px;
    height: 3px;
    margin: 8px auto 0;
    border-radius: 2px;
    background: var(--line-strong);
  }

  .tour-dialog {
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

