* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #080c14;
  --surface: #0d1220;
  --surface2: #131a2b;
  --border: #1a2340;
  --text: #c8d0e0;
  --text-dim: #5a6580;
  --accent: #00ffcc;
  --red: #ff4455;
  --orange: #ff8833;
  --yellow: #ffcc00;
  --purple: #aa55ff;
  --blue: #3399ff;
  --sidebar-w: 380px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'SF Mono', 'Fira Code', 'Courier New', monospace;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

#app {
  display: flex;
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ── Globe ─────────────────────────────── */
#globe-container {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

#globe {
  width: 100%;
  height: 100%;
  cursor: grab;
}
#globe:active { cursor: grabbing; }

.tooltip {
  position: absolute;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px;
  max-width: 320px;
  pointer-events: none;
  z-index: 100;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.tooltip.hidden { display: none; }
.tooltip .tt-actor { color: var(--accent); font-weight: bold; font-size: 14px; }
.tooltip .tt-type { color: var(--text-dim); font-size: 11px; margin-top: 2px; }
.tooltip .tt-desc { margin-top: 8px; line-height: 1.5; color: var(--text); }
.tooltip .tt-iocs { margin-top: 8px; font-size: 11px; color: var(--text-dim); }
.tooltip .tt-iocs span { color: var(--yellow); }
.tooltip .tt-date { margin-top: 6px; font-size: 10px; color: var(--text-dim); }
.tooltip .tt-link { margin-top: 6px; font-size: 10px; color: var(--accent); }

#globe-controls {
  position: absolute;
  bottom: 60px;
  left: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}
#globe-controls button {
  width: 36px; height: 36px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}
#globe-controls button:hover { background: var(--border); }

#legend {
  position: absolute;
  top: 20px;
  left: 20px;
  background: rgba(13,18,32,0.85);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  z-index: 10;
  backdrop-filter: blur(8px);
}
.legend-title { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px; }
.legend-items { display: flex; flex-direction: column; gap: 6px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

#status-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 36px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  font-size: 11px;
  color: var(--text-dim);
  z-index: 10;
}

/* ── Sidebar ───────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-flame {
  flex-shrink: 0;
  filter: drop-shadow(0 0 12px rgba(124,58,237,0.5)) drop-shadow(0 0 24px rgba(0,255,204,0.2));
}
.flame-svg { display: block; }
.brand-text h1 {
  font-size: 20px;
  color: #fff;
  letter-spacing: 2px;
  margin: 0;
  background: linear-gradient(135deg, #7c3aed, #a78bfa, #00ffcc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-text .subtitle {
  font-size: 9.5px;
  color: var(--text-dim);
  margin-top: 3px;
  font-style: italic;
  letter-spacing: 0.3px;
  line-height: 1.4;
}

.panel {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.panel-title {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

/* Time controls */
.time-presets {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}
.preset {
  flex: 1;
  padding: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: inherit;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.preset:hover { border-color: var(--accent); color: var(--text); }
.preset.active { background: rgba(0,255,204,0.1); border-color: var(--accent); color: var(--accent); }

.custom-range {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.custom-range label {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
}
.custom-range input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 4px;
  color-scheme: dark;
}
#btn-apply-range {
  padding: 4px 10px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-family: inherit;
  font-size: 11px;
  font-weight: bold;
  cursor: pointer;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.stat-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  text-align: center;
}
.stat-card .stat-value { font-size: 22px; font-weight: bold; color: var(--accent); }
.stat-card .stat-label { font-size: 10px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card:nth-child(4) .stat-value { color: var(--red); }

/* Actor filters */
.actor-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 150px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.actor-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.actor-tag:hover { border-color: var(--accent); }
.actor-tag.active { background: rgba(0,255,204,0.08); border-color: var(--accent); color: var(--accent); }
.actor-tag .tag-dot { width: 8px; height: 8px; border-radius: 50%; }

/* Event feed */
.feed-panel { border-bottom: none; }
.event-feed { max-height: 60vh; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }

.event-card {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  background: var(--surface2);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.event-card:hover { border-color: var(--accent); background: rgba(0,255,204,0.03); }
.event-card .ev-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.event-card .ev-actor { font-weight: bold; font-size: 13px; }
.event-card .ev-severity { font-size: 10px; padding: 2px 8px; border-radius: 10px; font-weight: bold; }
.ev-severity.critical { background: rgba(255,68,85,0.15); color: var(--red); }
.ev-severity.high { background: rgba(255,136,51,0.15); color: var(--orange); }
.ev-severity.medium { background: rgba(255,204,0,0.15); color: var(--yellow); }
.ev-severity.low { background: rgba(0,170,255,0.15); color: var(--blue); }
.event-card .ev-title { font-size: 12px; line-height: 1.4; margin-bottom: 6px; }
.event-card .ev-meta { font-size: 10px; color: var(--text-dim); display: flex; gap: 12px; }
.event-card .ev-iocs { font-size: 10px; color: var(--text-dim); margin-top: 6px; }
.event-card .ev-iocs span { color: var(--yellow); }
.event-card .ev-link { font-size: 10px; color: var(--accent); margin-top: 4px; display: block; }


/* ── MITRE ATT&CK Styles ──────────────── */

/* Tactic filter tags */
.mitre-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.mitre-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}
.mitre-tag:hover { border-color: var(--accent); }
.mitre-tag.active { background: rgba(0,255,204,0.08); border-color: var(--accent); color: var(--accent); }
.mitre-tag .tag-dot { width: 6px; height: 6px; border-radius: 50%; }

/* Top tactics bar in stats */
.top-tactics-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.top-tactic {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.top-tactic-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.top-tactic-name { flex: 1; color: var(--text-dim); }
.top-tactic-count { color: var(--accent); font-weight: bold; font-size: 12px; }

/* MITRE tags in event cards */
.ev-mitre {
  margin: 6px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ev-mitre-tactics {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}
.mitre-tactic-tag {
  font-size: 9px;
  padding: 1px 6px;
  border: 1px solid;
  border-radius: 8px;
  font-weight: bold;
  letter-spacing: 0.3px;
}
.ev-mitre-techniques {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.mitre-tech-link {
  font-size: 9px;
  color: var(--blue);
  text-decoration: none;
  padding: 1px 5px;
  background: rgba(51,153,255,0.08);
  border-radius: 4px;
  transition: background 0.2s;
}
.mitre-tech-link:hover {
  background: rgba(51,153,255,0.2);
  text-decoration: underline;
}

/* MITRE in tooltip */
.tt-mitre-section {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
.tt-mitre-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.tt-mitre-tactics {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}
.tt-mitre-tag {
  font-size: 10px;
  font-weight: bold;
}
.tt-mitre-techs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tt-mitre-tech {
  font-size: 10px;
  color: var(--blue);
}

/* Actor group labels */
.actor-group-label {
  font-size: 9px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-top: 8px;
  margin-bottom: 4px;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
}
.actor-group-label:first-child { margin-top: 0; }
.actor-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}


/* ── About Panel ───────────────────────── */
.about-panel {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--surface);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.about-panel.hidden { display: none; }

.about-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.about-header h2 {
  font-size: 16px;
  color: var(--accent);
  margin: 0;
}
.about-close {
  width: 28px;
  height: 28px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.about-close:hover { background: var(--border); color: var(--accent); }

.about-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Markdown rendered styles */
.md-body { font-size: 12px; line-height: 1.7; color: var(--text); }
.md-body h2 { font-size: 16px; color: var(--accent); margin: 20px 0 8px; }
.md-body h3 { font-size: 14px; color: var(--text); margin: 16px 0 6px; }
.md-body h4 { font-size: 12px; color: var(--text-dim); margin: 12px 0 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.md-body p { margin: 8px 0; }
.md-body a { color: var(--accent); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body strong { color: #fff; }
.md-body code {
  background: var(--surface2);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--yellow);
}
.md-body pre {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 8px 0;
}
.md-body pre code {
  background: none;
  padding: 0;
  font-size: 11px;
  color: var(--text);
}
.md-body ul { padding-left: 18px; margin: 6px 0; }
.md-body li { margin: 3px 0; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 11px;
}
.md-body table td {
  padding: 4px 8px;
  border: 1px solid var(--border);
}
.md-body table tr:first-child td {
  background: var(--surface2);
  color: var(--accent);
  font-weight: bold;
}
.md-body .md-badge { height: 18px; vertical-align: middle; margin-right: 4px; }
.md-body img { max-width: 100%; }


/* ── Case Management System ────────────── */
.header-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}
.hdr-btn {
  position: relative;
  flex: 1;
  padding: 6px 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hdr-btn:hover { border-color: var(--accent); color: var(--accent); background: rgba(0,255,204,0.05); }
.cases-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: bold;
  border-radius: 8px;
  display: none; align-items: center; justify-content: center;
}

/* Unified overlay panels */
.overlay-panel {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--surface); z-index: 200;
  display: flex; flex-direction: column; overflow: hidden;
}
.overlay-panel.hidden { display: none; }
.op-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.op-header h2 { font-size: 15px; color: var(--accent); margin: 0; }
.op-content {
  flex: 1; overflow-y: auto; padding: 12px 16px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}

/* Metrics bar */
.cm-metrics { display: flex; gap: 6px; margin-bottom: 12px; }
.cm-metric {
  flex: 1; text-align: center; padding: 8px 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
}
.cm-metric-val { display: block; font-size: 18px; font-weight: bold; color: var(--accent); }
.cm-metric-val.cm-open { color: var(--orange); }
.cm-metric-val.cm-crit { color: var(--red); }
.cm-metric-lbl { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

/* Toolbar */
.cm-toolbar { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.cm-input {
  flex: 1; min-width: 100px; padding: 6px 8px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px; border-radius: 4px;
}
.cm-input:focus { border-color: var(--accent); outline: none; }
.cm-select {
  padding: 5px 6px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px; border-radius: 4px;
}
.cm-btn {
  padding: 5px 10px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px; border-radius: 4px; cursor: pointer;
  transition: all 0.2s;
}
.cm-btn:hover { border-color: var(--accent); color: var(--accent); }
.cm-btn-primary { background: rgba(0,255,204,0.1); border-color: var(--accent); color: var(--accent); font-weight: bold; }
.cm-btn-primary:hover { background: rgba(0,255,204,0.2); }
.cm-btn-danger { background: rgba(255,68,85,0.1); border-color: var(--red); color: var(--red); }
.cm-btn-danger:hover { background: rgba(255,68,85,0.2); }

/* Case cards */
.cm-case-list { display: flex; flex-direction: column; gap: 8px; }
.cm-case-card {
  padding: 10px 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; transition: border-color 0.2s;
}
.cm-case-card:hover { border-color: var(--accent); }
.cm-case-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cm-case-id { font-size: 10px; color: var(--text-dim); font-family: monospace; }
.cm-case-priority { font-size: 9px; padding: 1px 6px; border-radius: 8px; font-weight: bold; }
.cm-pri-critical { background: rgba(255,68,85,0.15); color: var(--red); }
.cm-pri-high { background: rgba(255,136,51,0.15); color: var(--orange); }
.cm-pri-medium { background: rgba(255,204,0,0.15); color: var(--yellow); }
.cm-pri-low { background: rgba(0,170,255,0.15); color: var(--blue); }
.cm-case-title { font-size: 12px; line-height: 1.4; margin-bottom: 6px; }
.cm-case-meta { display: flex; gap: 8px; font-size: 10px; color: var(--text-dim); flex-wrap: wrap; }
.cm-case-status { padding: 1px 6px; border-radius: 8px; font-weight: bold; font-size: 9px; }
.cm-st-new { background: rgba(0,255,204,0.12); color: var(--accent); }
.cm-st-triage { background: rgba(136,136,255,0.12); color: #8888ff; }
.cm-st-investigating { background: rgba(255,204,0,0.12); color: var(--yellow); }
.cm-st-containment { background: rgba(255,136,51,0.12); color: var(--orange); }
.cm-st-eradication { background: rgba(255,68,85,0.12); color: var(--red); }
.cm-st-recovery { background: rgba(51,221,170,0.12); color: #33ddaa; }
.cm-st-closed { background: rgba(90,101,128,0.12); color: var(--text-dim); }
.cm-case-type { color: var(--text-dim); }
.cm-case-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.cm-tag { font-size: 9px; padding: 1px 5px; background: rgba(0,255,204,0.06); border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); }
.cm-tag-actor { border-color: rgba(170,85,255,0.3); color: var(--purple); }
.cm-case-time { font-size: 9px; color: var(--text-dim); margin-top: 4px; }
.cm-empty { text-align: center; padding: 24px 12px; color: var(--text-dim); font-size: 12px; }
.cm-empty-sm { padding: 8px; color: var(--text-dim); font-size: 11px; }

/* Case detail */
.cm-detail-header { display: flex; justify-content: space-between; margin-bottom: 8px; }
.cm-back { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 12px; cursor: pointer; padding: 4px 0; }
.cm-back:hover { text-decoration: underline; }
.cm-detail-id { font-size: 11px; color: var(--text-dim); font-family: monospace; margin-bottom: 4px; }
.cm-detail-title {
  width: 100%; padding: 6px 8px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 14px; font-weight: bold; border-radius: 4px; margin-bottom: 10px;
}
.cm-detail-title:focus { border-color: var(--accent); outline: none; }
.cm-detail-row { display: flex; gap: 8px; margin-bottom: 8px; }
.cm-detail-row label { flex: 1; font-size: 10px; color: var(--text-dim); display: flex; flex-direction: column; gap: 3px; }
.cm-label { font-size: 10px; color: var(--text-dim); margin-bottom: 3px; display: block; }
.cm-textarea {
  width: 100%; padding: 6px 8px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px; border-radius: 4px; resize: vertical;
}
.cm-textarea:focus { border-color: var(--accent); outline: none; }
.cm-save-btn { width: 100%; margin-bottom: 12px; }

/* Sections */
.cm-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.cm-section-title { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }

/* MITRE in case */
.cm-mitre-map { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.cm-mitre-tag { font-size: 9px; padding: 2px 6px; border: 1px solid; border-radius: 8px; font-weight: bold; }
.cm-mitre-techs { display: flex; flex-direction: column; gap: 3px; }
.cm-tech-link { font-size: 10px; color: var(--blue); text-decoration: none; }
.cm-tech-link:hover { text-decoration: underline; }

/* Linked events */
.cm-linked-events { display: flex; flex-direction: column; gap: 4px; }
.cm-linked-ev { font-size: 11px; padding: 4px 6px; background: var(--surface2); border-radius: 4px; display: flex; gap: 6px; align-items: center; }
.cm-linked-date { margin-left: auto; font-size: 9px; color: var(--text-dim); flex-shrink: 0; }

/* IOCs */
.cm-ioc-list { display: flex; flex-direction: column; gap: 3px; margin-bottom: 6px; }
.cm-ioc { display: flex; align-items: center; justify-content: space-between; padding: 3px 6px; background: var(--surface2); border-radius: 4px; }
.cm-ioc-val { font-size: 11px; color: var(--yellow); font-family: monospace; word-break: break-all; }
.cm-ioc-rm { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 10px; padding: 2px 4px; }
.cm-ioc-rm:hover { color: var(--red); }
.cm-ioc-add { display: flex; gap: 6px; }

/* Notes */
.cm-notes { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; max-height: 200px; overflow-y: auto; }
.cm-note { padding: 6px 8px; background: var(--surface2); border-radius: 4px; border-left: 2px solid var(--accent); }
.cm-note-meta { font-size: 9px; color: var(--text-dim); margin-bottom: 2px; }
.cm-note-text { font-size: 11px; line-height: 1.5; white-space: pre-wrap; }
.cm-note-add { display: flex; flex-direction: column; gap: 4px; }

/* Audit trail */
.cm-audit { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.cm-audit-entry { display: flex; gap: 8px; font-size: 10px; padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.03); }
.cm-audit-ts { color: var(--text-dim); flex-shrink: 0; width: 130px; font-family: monospace; font-size: 9px; }
.cm-audit-action { flex: 1; color: var(--text); }
.cm-audit-user { color: var(--accent); flex-shrink: 0; }

/* Event card create case button */
.ev-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.ev-create-case {
  font-size: 9px; padding: 2px 8px;
  background: rgba(0,255,204,0.08); border: 1px solid var(--accent);
  color: var(--accent); border-radius: 10px;
  cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.ev-create-case:hover { background: rgba(0,255,204,0.2); }

/* ── Mobile Toggle Button ──────────────── */
.mobile-toggle {
  display: none;
  position: fixed;
  bottom: 48px;
  right: 12px;
  z-index: 300;
  width: 44px; height: 44px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,255,204,0.3);
  transition: transform 0.2s;
}
.mobile-toggle:active { transform: scale(0.9); }

/* ── Desktop: ensure sidebar always visible ── */
@media (min-width: 681px) {
  #sidebar { display: flex !important; }
  #sidebar.mobile-hidden { display: flex !important; }
  .mobile-toggle { display: none !important; }
}

/* ── Responsive: Tablet (≤900px) ───────── */
@media (max-width: 900px) {
  :root { --sidebar-w: 320px; }
  .brand-text h1 { font-size: 17px; }
  .flame-svg { width: 28px; height: 40px; }
  .stat-card .stat-value { font-size: 18px; }
  .stat-card { padding: 8px; }
  #legend { padding: 8px 12px; }
  .legend-item { font-size: 11px; }
}

/* ── Responsive: Mobile (≤680px) ───────── */
@media (max-width: 680px) {
  body { overflow-y: auto; overflow-x: hidden; height: auto; min-height: 100vh; }

  #app {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  /* Globe takes top portion */
  #globe-container {
    width: 100%;
    height: 50vh;
    min-height: 260px;
    flex: none;
  }

  /* Sidebar becomes full-width bottom section — always visible */
  #sidebar {
    width: 100% !important;
    min-width: 100% !important;
    border-left: none;
    border-top: 1px solid var(--border);
    overflow-y: visible;
    flex: none;
    display: flex !important;
  }

  /* Override mobile-hidden — sidebar always shows on mobile as bottom panel */
  #sidebar.mobile-hidden {
    display: flex !important;
  }

  /* Hide the toggle button — sidebar is always visible as bottom section */
  .mobile-toggle { display: none !important; }

  /* Header adjustments */
  .sidebar-header { padding: 12px 16px; }
  .brand { gap: 8px; }
  .flame-svg { width: 26px; height: 36px; }
  .brand-text h1 { font-size: 16px; letter-spacing: 1.5px; }
  .brand-text .subtitle { font-size: 9px; }
  .header-actions { top: 12px; right: 12px; }

  /* Panels */
  .panel { padding: 12px 16px; }
  .panel-title { font-size: 10px; margin-bottom: 8px; }

  /* Stats grid — 4 across on mobile */
  .stats-grid { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 4px; }
  .stat-card { padding: 6px 4px; }
  .stat-card .stat-value { font-size: 16px; }
  .stat-card .stat-label { font-size: 8px; }

  /* Time presets */
  .time-presets { gap: 4px; }
  .preset { padding: 5px 4px; font-size: 11px; }
  .custom-range { font-size: 10px; }
  .custom-range input[type="date"] { font-size: 10px; padding: 3px 4px; }

  /* Actor filters — scrollable horizontal */
  .actor-filters { max-height: 120px; overflow-y: auto; }
  .actor-tag { font-size: 10px; padding: 3px 8px; }

  /* MITRE filters */
  .mitre-filters { max-height: 80px; overflow-y: auto; }

  /* Event feed — limit height */
  .feed-panel { max-height: 50vh; }
  .event-feed { max-height: 45vh; }
  .event-card { padding: 10px; }
  .event-card .ev-actor { font-size: 12px; }
  .event-card .ev-title { font-size: 11px; }
  .event-card .ev-meta { gap: 8px; flex-wrap: wrap; }

  /* Globe controls */
  #globe-controls { bottom: 48px; left: 10px; }
  #globe-controls button { width: 32px; height: 32px; font-size: 16px; }

  /* Legend — compact */
  #legend { top: 10px; left: 10px; padding: 6px 10px; max-width: 140px; }
  .legend-title { font-size: 9px; margin-bottom: 4px; }
  .legend-item { font-size: 10px; gap: 5px; }
  .legend-dot { width: 8px; height: 8px; }

  /* Status bar */
  #status-bar { height: 30px; padding: 0 12px; font-size: 10px; }

  /* Tooltip — full width on mobile */
  .tooltip { max-width: 260px; font-size: 11px; padding: 10px 12px; }

  /* About/Cases/Intel panels — full screen on mobile */
  .about-panel, .overlay-panel {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 500;
  }

  /* Case management adjustments */
  .cm-metrics { gap: 4px; }
  .cm-metric { padding: 6px 2px; }
  .cm-metric-val { font-size: 15px; }
  .cm-toolbar { flex-direction: column; }
  .cm-input { min-width: auto; }
  .cm-detail-row { flex-direction: column; gap: 6px; }
  .cm-audit-ts { width: 100px; font-size: 8px; }
  .cm-audit-entry { flex-wrap: wrap; }
}

/* ── Responsive: Small phones (≤400px) ─── */
@media (max-width: 400px) {
  #globe-container { height: 45vh; min-height: 240px; }
  .brand-text h1 { font-size: 14px; }
  .flame-svg { width: 22px; height: 30px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .stat-value { font-size: 14px; }
  #legend { display: none; }
  .event-card .ev-severity { font-size: 8px; padding: 1px 5px; }
}

/* ── Analytics Panel ───────────────────── */
.an-metrics { display: flex; gap: 6px; margin-bottom: 14px; }
.an-metric {
  flex: 1; text-align: center; padding: 8px 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
}
.an-metric-val { display: block; font-size: 16px; font-weight: bold; color: var(--accent); }
.an-metric-lbl { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.an-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.an-section-title { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }

/* Bar chart */
.an-chart { display: flex; flex-direction: column; gap: 3px; }
.an-bar-row { display: flex; align-items: center; gap: 6px; font-size: 10px; }
.an-bar-label { width: 40px; color: var(--text-dim); text-align: right; flex-shrink: 0; font-family: monospace; font-size: 9px; }
.an-bar-track { flex: 1; height: 14px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.an-bar-fill { height: 100%; background: linear-gradient(90deg, #7c3aed, var(--accent)); border-radius: 3px; min-width: 2px; transition: width 0.3s; }
.an-bar-count { width: 20px; color: var(--accent); font-weight: bold; font-size: 10px; }

/* Devices */
.an-devices { display: flex; flex-direction: column; gap: 6px; }
.an-device { display: flex; align-items: center; gap: 8px; font-size: 11px; padding: 4px 8px; background: var(--surface2); border-radius: 4px; }
.an-device-icon { font-size: 14px; }
.an-device-pct { margin-left: auto; color: var(--accent); font-weight: bold; }

/* Recent visits */
.an-recent { display: flex; flex-direction: column; gap: 3px; max-height: 200px; overflow-y: auto; }
.an-visit { display: flex; gap: 8px; font-size: 10px; padding: 4px 6px; background: var(--surface2); border-radius: 4px; }
.an-visit-time { color: var(--text); flex-shrink: 0; }
.an-visit-screen { color: var(--text-dim); }
.an-visit-ref { color: var(--text-dim); margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 120px; }

/* ── Intel Search Panel ────────────────── */
.intel-search-box {
  display: flex; gap: 6px; margin-bottom: 14px;
}
.intel-search-box input {
  flex: 1; padding: 8px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 12px; border-radius: 6px;
}
.intel-search-box input:focus { border-color: var(--accent); outline: none; }
.intel-search-box input::placeholder { color: var(--text-dim); }

.intel-type-filters { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.intel-type-btn {
  padding: 4px 10px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text-dim); font-family: inherit; font-size: 10px; border-radius: 12px;
  cursor: pointer; transition: all 0.2s;
}
.intel-type-btn:hover { border-color: var(--accent); color: var(--text); }
.intel-type-btn.active { background: rgba(0,255,204,0.1); border-color: var(--accent); color: var(--accent); }

.intel-results { display: flex; flex-direction: column; gap: 8px; }

/* Actor card in search results */
.intel-actor-card {
  padding: 12px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; transition: border-color 0.2s;
}
.intel-actor-card:hover { border-color: var(--accent); }
.intel-actor-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.intel-actor-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.intel-actor-name { font-size: 14px; font-weight: bold; }
.intel-actor-meta { display: flex; gap: 8px; font-size: 10px; color: var(--text-dim); flex-wrap: wrap; }
.intel-actor-type { padding: 1px 6px; border-radius: 8px; font-size: 9px; font-weight: bold; background: rgba(0,255,204,0.08); border: 1px solid var(--border); }
.intel-actor-nation { color: var(--text-dim); }
.intel-actor-stat { color: var(--accent); }

/* Actor detail view */
.intel-detail-back { background: none; border: none; color: var(--accent); font-family: inherit; font-size: 12px; cursor: pointer; padding: 4px 0; margin-bottom: 8px; display: block; }
.intel-detail-back:hover { text-decoration: underline; }
.intel-detail-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.intel-detail-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.intel-detail-name { font-size: 18px; font-weight: bold; }
.intel-detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.intel-badge { padding: 3px 10px; border-radius: 10px; font-size: 10px; font-weight: bold; border: 1px solid var(--border); }
.intel-badge-type { background: rgba(0,255,204,0.08); color: var(--accent); }
.intel-badge-nation { background: rgba(170,85,255,0.08); color: var(--purple); border-color: rgba(170,85,255,0.3); }

.intel-desc { font-size: 12px; line-height: 1.6; color: var(--text); margin-bottom: 14px; padding: 10px; background: var(--surface2); border-radius: 6px; border-left: 3px solid var(--accent); }

.intel-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.intel-section-title { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 8px; }

.intel-event-card {
  padding: 8px 10px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 6px; cursor: pointer; transition: border-color 0.2s;
}
.intel-event-card:hover { border-color: var(--accent); }
.intel-ev-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.intel-ev-title { font-size: 11px; line-height: 1.4; }
.intel-ev-meta { font-size: 9px; color: var(--text-dim); display: flex; gap: 8px; margin-top: 4px; }

.intel-ioc-list { display: flex; flex-wrap: wrap; gap: 4px; }
.intel-ioc { font-size: 10px; padding: 2px 6px; background: rgba(255,204,0,0.06); border: 1px solid var(--border); border-radius: 4px; color: var(--yellow); font-family: monospace; }

.intel-mitre-row { display: flex; flex-wrap: wrap; gap: 4px; }
.intel-empty { text-align: center; padding: 30px 12px; color: var(--text-dim); font-size: 12px; }

/* ── Weekly Summary Panel ──────────────── */
.ws-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.ws-nav-btn {
  padding: 6px 12px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 11px; border-radius: 6px; cursor: pointer; transition: all 0.2s;
}
.ws-nav-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ws-nav-btn:disabled { opacity: 0.3; cursor: default; }
.ws-nav-label { text-align: center; }
.ws-nav-week { font-size: 14px; font-weight: bold; color: var(--accent); }
.ws-nav-dates { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.ws-metrics { display: flex; gap: 6px; margin-bottom: 14px; }
.ws-metric {
  flex: 1; text-align: center; padding: 10px 4px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 6px;
}
.ws-metric-val { display: block; font-size: 20px; font-weight: bold; color: var(--accent); }
.ws-metric-val.ws-crit { color: var(--red); }
.ws-metric-val.ws-high { color: var(--orange); }
.ws-metric-lbl { font-size: 9px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; }

.ws-section { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.ws-section-title { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; font-weight: bold; }

/* Headlines */
.ws-headline {
  padding: 10px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 6px; transition: border-color 0.2s;
}
.ws-headline:hover { border-color: var(--accent); }
.ws-hl-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.ws-hl-actor { font-size: 12px; font-weight: bold; margin-bottom: 2px; }
.ws-hl-title { font-size: 11px; line-height: 1.4; }
.ws-hl-meta { font-size: 9px; color: var(--text-dim); margin-top: 4px; }

/* Bar charts */
.ws-bar-chart { display: flex; flex-direction: column; gap: 4px; }
.ws-bar-row { display: flex; align-items: center; gap: 6px; font-size: 10px; }
.ws-bar-label { width: 90px; text-align: right; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-bar-track { flex: 1; height: 16px; background: var(--surface2); border-radius: 3px; overflow: hidden; }
.ws-bar-fill { height: 100%; background: linear-gradient(90deg, #7c3aed, var(--accent)); border-radius: 3px; min-width: 4px; transition: width 0.3s; }
.ws-bar-count { width: 24px; color: var(--accent); font-weight: bold; text-align: right; }

/* Columns */
.ws-columns { display: flex; gap: 12px; }
.ws-col { flex: 1; }

/* Tactic rows */
.ws-tactic-row { display: flex; align-items: center; gap: 6px; font-size: 11px; padding: 3px 0; }
.ws-tactic-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.ws-tactic-name { flex: 1; color: var(--text-dim); }
.ws-tactic-count { color: var(--accent); font-weight: bold; }

/* All events list */
.ws-all-events { max-height: 300px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.ws-ev-row {
  display: flex; align-items: center; gap: 6px; padding: 5px 6px; font-size: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.03); transition: background 0.2s;
}
.ws-ev-row:hover { background: rgba(0,255,204,0.03); }
.ws-ev-date { color: var(--text-dim); flex-shrink: 0; width: 70px; font-family: monospace; font-size: 9px; }
.ws-ev-actor { flex-shrink: 0; width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: bold; font-size: 9px; }
.ws-ev-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }

.ws-empty { text-align: center; padding: 40px 12px; color: var(--text-dim); font-size: 13px; }

@media (max-width: 680px) {
  .ws-columns { flex-direction: column; gap: 0; }
  .ws-bar-label { width: 70px; font-size: 9px; }
  .ws-ev-actor { width: 60px; }
}

/* ── Newsletter Subscribe ──────────────── */
.subscribe-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; line-height: 1.4; }
.subscribe-form { display: flex; gap: 6px; }
.subscribe-form input { flex: 1; }
.subscribe-msg { font-size: 11px; margin-top: 6px; min-height: 16px; }
.subscribe-msg.success { color: var(--accent); }
.subscribe-msg.error { color: var(--red); }
