/* AAEMM — layout + componenten (CUBO tokens via index-BazUUFoH.css) */

:root {
  --font-sans: "Instrument Sans", system-ui, sans-serif;
  --font-display: "Syne", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --flame: #ff4d00;
  --ember: #ff7a33;
  --bg: #0a0b0d;
  --surface: #12141a;
  --surface-raised: #181b22;
  --border: #2a2e36;
  --border-subtle: #1e2229;
  --text: #eceef2;
  --text-muted: #8b919c;
  --text-dim: #5c6370;
  --ok: #3ecf8e;
  --danger: #f07178;
  --sidebar-w: 360px;
  --header-h: 3.5rem;
}

*, *::before, *::after { box-sizing: border-box; }

/* ── Shell ── */
.aaemm-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans), system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.aaemm-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  height: var(--header-h);
  padding: 0 1.125rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.aaemm-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.aaemm-logo-mark {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  background: var(--flame);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

.aaemm-logo-title {
  font-family: var(--font-display), sans-serif;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
}

.aaemm-logo-sub {
  font-size: 0.6875rem;
  color: var(--text-dim);
  margin: 0;
}

.aaemm-nav-stats {
  display: none;
  gap: 1.5rem;
  margin-left: 0.5rem;
}

@media (min-width: 640px) {
  .aaemm-nav-stats { display: flex; }
}

.aaemm-nav-stat label {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-dim);
  font-weight: 500;
}

.aaemm-nav-stat span {
  font-family: var(--font-mono), monospace;
  font-size: 0.875rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.aaemm-spacer { flex: 1; }

.aaemm-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Body grid ── */
.aaemm-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ── Sidebar (ops console) ── */
.aaemm-sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.aaemm-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-bottom: 1px solid var(--border-subtle);
}

.aaemm-panel--detect {
  flex-shrink: 0;
  padding: 0 0 1rem;
}

.aaemm-panel--flows {
  flex: 1;
  min-height: 0;
}

.aaemm-panel--sim {
  flex-shrink: 0;
  padding: 0 0 1rem;
}

.aaemm-panel-head {
  padding: 1rem 1.125rem 0.75rem;
}

.aaemm-panel-head--split {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.aaemm-panel-title {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.aaemm-panel-hint {
  margin: 0 1.125rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.4;
}

.aaemm-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 0 1.125rem;
  background: var(--border-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  overflow: hidden;
}

.aaemm-stat {
  padding: 0.875rem 1rem;
  background: var(--surface-raised);
}

.aaemm-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.aaemm-stat-value {
  display: block;
  margin-top: 0.35rem;
  font-family: var(--font-mono), monospace;
  font-size: 1.375rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  color: var(--text);
}

.aaemm-stat-value--alert { color: var(--flame); }
.aaemm-stat-value--ok { color: var(--ok); }

.aaemm-meter {
  height: 3px;
  margin-top: 0.65rem;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
}

.aaemm-meter > span {
  display: block;
  height: 100%;
  background: var(--flame);
  border-radius: 2px;
  transition: width 0.35s ease;
}

.aaemm-meter--ok > span { background: var(--ok); }

.aaemm-verdict {
  margin: 0.875rem 1.125rem 0;
  padding: 0.875rem 1rem;
  background: var(--surface-raised);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--border);
  border-radius: 0 8px 8px 0;
}

.aaemm-verdict-action {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.aaemm-verdict-detail {
  margin: 0.4rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.aaemm-verdict--warn {
  border-left-color: var(--ember);
}

.aaemm-verdict--alert {
  border-left-color: var(--flame);
}

.aaemm-verdict--alert .aaemm-verdict-action {
  color: var(--flame);
}

.aaemm-signals {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  border-top: 1px solid var(--border-subtle);
}

.aaemm-signals:empty { display: none; }

.aaemm-signals li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.aaemm-signals li:last-child { border-bottom: none; }

.aaemm-signals li span:last-child {
  font-family: var(--font-mono), monospace;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.aaemm-flow-count {
  font-family: var(--font-mono), monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.aaemm-flow-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.aaemm-flow {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1.125rem;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
  transition: background 0.12s ease;
}

.aaemm-flow:hover { background: var(--surface-raised); }

.aaemm-flow.inbound {
  border-left: 2px solid var(--flame);
  padding-left: calc(1.125rem - 2px);
}

.aaemm-flow.highlight {
  background: rgb(62 207 142 / 0.06);
}

.aaemm-flow-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.aaemm-flow-icon .svc-icon {
  width: 28px;
  height: 28px;
  font-size: 0.65rem;
}

.aaemm-flow-body {
  min-width: 0;
}

.aaemm-flow-title {
  margin: 0;
  font-family: var(--font-mono), monospace;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aaemm-flow-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.2rem 0 0;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.aaemm-flow-meta img {
  border-radius: 2px;
  object-fit: cover;
}

.aaemm-flow-dot { opacity: 0.5; }

.aaemm-flow-dir {
  flex-shrink: 0;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-dim);
}

.aaemm-flow-dir.in { color: var(--flame); }

.aaemm-action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 0 1.125rem;
}

.aaemm-action {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.aaemm-action:hover {
  background: var(--surface-raised);
  border-color: #3d4450;
  color: var(--text);
}

.aaemm-action--primary {
  grid-column: 1 / -1;
  background: var(--flame);
  border-color: var(--flame);
  color: #fff;
}

.aaemm-action--primary:hover {
  background: #e64500;
  border-color: #e64500;
  color: #fff;
}

.aaemm-action--danger {
  color: var(--danger);
  border-color: rgb(240 113 120 / 0.35);
}

.aaemm-action--danger:hover {
  background: rgb(240 113 120 / 0.08);
  color: var(--danger);
}

.aaemm-empty {
  padding: 2.5rem 1.125rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

/* ── Buttons ── */
.aaemm-btn {
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.45rem 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-raised);
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.aaemm-btn:hover {
  border-color: #3d4450;
  color: var(--text);
}

.aaemm-btn.primary {
  background: var(--flame);
  border-color: var(--flame);
  color: #fff;
}

.aaemm-btn.primary:hover {
  background: #e64500;
  border-color: #e64500;
  color: #fff;
}

.aaemm-status {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgb(52 211 153 / 0.35);
  background: rgb(52 211 153 / 0.1);
  color: #34d399;
}

.aaemm-status.warn {
  border-color: rgb(255 77 0 / 0.35);
  background: rgb(255 77 0 / 0.1);
  color: var(--ember);
}

.aaemm-status.alert {
  border-color: rgb(239 68 68 / 0.35);
  background: rgb(239 68 68 / 0.1);
  color: #f87171;
}

/* ── Globe pane ── */
.aaemm-globe {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse 90% 80% at 50% 45%, #2a2c32 0%, #121316 70%);
}

.aaemm-globe-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse 65% 50% at 50% 42%, rgb(160 165 175 / 0.1), transparent 72%);
}

.aaemm-globe-head {
  position: absolute;
  left: 1.25rem;
  top: 1rem;
  z-index: 5;
  pointer-events: none;
}

.aaemm-globe-head h2 {
  font-family: var(--font-display), sans-serif;
  font-size: 1.125rem;
  font-weight: 700;
  margin: 0;
  color: #fff;
}

.aaemm-globe-head p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0;
}

.aaemm-hud {
  position: absolute;
  right: 1.25rem;
  top: 1rem;
  z-index: 5;
  display: flex;
  gap: 0.5rem;
  pointer-events: none;
}

.aaemm-hud-item {
  min-width: 4.5rem;
  padding: 0.5rem 0.75rem;
  text-align: center;
  border-radius: 0.75rem;
  border: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(255 255 255 / 0.05);
  backdrop-filter: blur(12px);
}

.aaemm-hud-item .val {
  font-family: var(--font-mono), monospace;
  font-size: 0.875rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #e4e4e7;
}

.aaemm-hud-item .val.flame { color: var(--ember); }
.aaemm-hud-item .val.alert { color: #f87171; }

.aaemm-hud-item .lbl {
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

#globeViz {
  position: absolute;
  inset: 0;
  z-index: 2;
}

#globeViz canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  filter: grayscale(1) brightness(0.92) contrast(1.05) saturate(0);
}

.globe-fallback {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono), monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 2rem;
  text-align: center;
}

/* ── Grafana drawer ── */
.aaemm-grafana {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 200px;
  z-index: 100;
  border-top: 1px solid rgb(255 255 255 / 0.1);
  background: rgb(12 12 15 / 0.98);
  transform: translateY(100%);
  transition: transform 0.25s ease;
}

.aaemm-grafana.open { transform: translateY(0); }

@media (min-width: 1024px) {
  .aaemm-grafana { left: var(--sidebar-w); }
}

.aaemm-grafana-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  font-weight: 700;
}

.aaemm-grafana iframe {
  width: 100%;
  height: calc(100% - 36px);
  border: 0;
}

/* ── Globe pins (vlag-sateprikkers) ── */
.svc-icon {
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}

.map-pin {
  --pin-scale: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate(-50%, -100%) scale(var(--pin-scale));
  transform-origin: 50% 100%;
  pointer-events: auto;
  cursor: pointer;
  z-index: 1;
  will-change: filter;
}

.map-pin:hover .pin-flag {
  border-color: #fff;
  box-shadow: 0 0 14px rgb(255 120 50 / 0.65);
}

.map-pin.selected {
  z-index: 20;
  filter: drop-shadow(0 8px 28px rgb(0 0 0 / 0.55));
}

.map-pin.selected .pin-flag {
  width: calc(52px * var(--pin-scale));
  height: calc(52px * var(--pin-scale));
  min-width: 44px;
  min-height: 44px;
  border-width: 3px;
  box-shadow: 0 0 22px rgb(255 120 50 / 0.75);
}

.pin-flag {
  width: calc(36px * var(--pin-scale));
  height: calc(36px * var(--pin-scale));
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid rgb(255 255 255 / 0.95);
  box-shadow: 0 2px 12px rgb(0 0 0 / 0.45);
  background: #1a1a22;
}

.map-pin.highlight .pin-flag { border-color: #34d399; }
.map-pin.blocked .pin-flag { border-color: #fbbf24; }
.map-pin.edge-pin .pin-flag {
  border-color: var(--flame);
  box-shadow: 0 0 16px rgb(255 77 0 / 0.5);
}

.pin-flag img { width: 100%; height: 100%; object-fit: cover; }

.pin-needle {
  width: 3px;
  height: calc(12px * var(--pin-scale));
  min-height: 8px;
  background: linear-gradient(180deg, var(--pin-color, var(--flame)), transparent);
  border-radius: 2px;
}

.pin-card {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.45rem 0.65rem;
  max-width: 220px;
  text-align: center;
  border-radius: 0.5rem;
  border: 1px solid rgb(255 77 0 / 0.35);
  background: rgb(8 10 16 / 0.94);
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.5);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
}

.map-pin.show-label .pin-card,
.map-pin.selected .pin-card {
  opacity: 1;
  visibility: visible;
}

.map-pin.selected .pin-card {
  top: calc(100% + 10px);
  min-width: min(92vw, 340px);
  max-width: min(92vw, 420px);
  padding: 1rem 1.35rem 1.15rem;
  border-width: 2px;
  border-color: rgb(255 120 50 / 0.65);
  border-radius: 0.75rem;
  box-shadow: 0 16px 40px rgb(0 0 0 / 0.65);
}

.pin-title {
  display: block;
  font-family: var(--font-mono), monospace;
  font-size: calc(11px * var(--pin-scale));
  font-weight: 700;
  color: var(--flame);
  line-height: 1.25;
  word-break: break-all;
}

.map-pin.selected .pin-title {
  font-size: clamp(1.125rem, calc(22px * var(--pin-scale)), 1.75rem);
  line-height: 1.2;
  color: #fff;
  letter-spacing: 0.01em;
}

.pin-sub {
  display: block;
  margin-top: 0.2rem;
  font-size: calc(9px * var(--pin-scale));
  color: var(--text-muted);
  line-height: 1.35;
}

.map-pin.selected .pin-sub {
  margin-top: 0.45rem;
  font-size: clamp(0.875rem, calc(15px * var(--pin-scale)), 1.125rem);
  color: #e4e4e7;
  line-height: 1.45;
}

.pin-trust {
  display: block;
  margin-top: 0.25rem;
  font-family: var(--font-mono), monospace;
  font-size: calc(8px * var(--pin-scale));
  color: rgb(161 161 170 / 0.9);
}

.map-pin.selected .pin-trust {
  margin-top: 0.55rem;
  padding-top: 0.45rem;
  border-top: 1px solid rgb(255 255 255 / 0.12);
  font-size: clamp(0.8125rem, calc(13px * var(--pin-scale)), 1rem);
  color: #d4d4d8;
}

.globe-tip {
  font-family: var(--font-mono), monospace;
  font-size: 11px;
  color: #f4f4f5;
  background: rgb(12 14 20 / 0.96);
  border: 1px solid rgb(255 77 0 / 0.3);
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.4);
}

.globe-tip--lg {
  font-size: 13px;
  padding: 6px 12px;
}

.globe-country-hover {
  font-family: var(--font-sans), system-ui, sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: #f4f4f5;
  background: rgb(40 42 48 / 0.95);
  border: 1px solid rgb(180 185 195 / 0.45);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgb(0 0 0 / 0.45);
}

/* ── Mobile ── */
@media (max-width: 1023px) {
  .aaemm-body { flex-direction: column; }
  .aaemm-sidebar {
    width: 100%;
    flex: 0 0 auto;
    max-height: 42vh;
    border-right: none;
    border-bottom: 1px solid rgb(255 255 255 / 0.1);
  }
  .aaemm-globe {
    flex: none;
    height: 50vh;
    min-height: 280px;
  }
  .aaemm-grafana { left: 0; }
}
