*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #080C14;
  --bg-card:     #0D1320;
  --bg-hover:    #111827;
  --border:      #1A2540;
  --blue:        #0EA5FF;
  --blue-dim:    rgba(14,165,255,0.12);
  --crimson:     #FF3B5C;
  --crimson-dim: rgba(255,59,92,0.12);
  --amber:       #F59E0B;
  --amber-dim:   rgba(245,158,11,0.12);
  --green:       #10D982;
  --green-dim:   rgba(16,217,130,0.12);
  --purple:      #8B5CF6;
  --purple-dim:  rgba(139,92,246,0.12);
  --text:        #E8EDF5;
  --text-2:      #7A8BA8;
  --text-3:      #3D4F6A;
  --mono:        'JetBrains Mono', monospace;
  --sans:        'Inter', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

a { text-decoration: none; color: inherit; }

/* ── SIDEBAR ── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}

.logo {
  padding: 0 20px 28px;
  border-bottom: 1px solid var(--border);
}
.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 32px; height: 32px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.logo-text {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.logo-sub {
  font-size: 10px;
  color: var(--text-2);
  margin-top: 2px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav { padding: 20px 12px; flex: 1; }
.nav-label {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0 8px;
  margin-bottom: 6px;
  margin-top: 20px;
}
.nav-label:first-child { margin-top: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
  transition: all 0.15s;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--blue-dim); color: var(--blue); }
.nav-item .icon { font-size: 15px; width: 18px; text-align: center; }
.nav-badge {
  margin-left: auto;
  background: var(--crimson);
  color: #fff;
  font-size: 10px;
  font-family: var(--mono);
  padding: 1px 6px;
  border-radius: 20px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.agent-status {
  display: flex;
  align-items: center;
  gap: 10px;
}
.pulse-ring {
  position: relative;
  width: 28px; height: 28px;
  flex-shrink: 0;
}
.pulse-ring::before, .pulse-ring::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--blue);
}
.pulse-ring::after {
  animation: pulse-expand 2s ease-out infinite;
}
.pulse-core {
  position: absolute;
  inset: 6px;
  background: var(--blue);
  border-radius: 50%;
}
@keyframes pulse-expand {
  0%   { transform: scale(1); opacity: 0.8; }
  100% { transform: scale(1.9); opacity: 0; }
}
.agent-info { flex: 1; }
.agent-label { font-size: 11px; font-weight: 600; }
.agent-state { font-size: 10px; color: var(--blue); font-family: var(--mono); }

/* ── MAIN ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 56px;
  min-height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
}
.topbar-title { font-size: 14px; font-weight: 600; }
.topbar-sep { color: var(--text-3); }
.topbar-sub { font-size: 13px; color: var(--text-2); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.status-pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--crimson-dim);
  border: 1px solid rgba(255,59,92,0.3);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--crimson);
}
.status-pill.mode-shadow {
  background: var(--purple-dim);
  border-color: rgba(139,92,246,0.35);
  color: var(--purple);
}
.status-pill.mode-active {
  background: var(--green-dim);
  border-color: rgba(16,217,130,0.35);
  color: var(--green);
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: blink 1.2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

.trigger-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.trigger-btn:hover { opacity: 0.85; }

.content {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 340px;
  overflow: hidden;
}

/* ── LEFT PANEL ── */
.left-panel {
  padding: 20px 24px;
  overflow-y: auto;
  border-right: 1px solid var(--border);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-2);
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.metric-label { font-size: 10px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 6px; }
.metric-value { font-family: var(--mono); font-size: 22px; font-weight: 600; line-height: 1; }
.metric-value.bad  { color: var(--crimson); }
.metric-value.warn { color: var(--amber); }
.metric-value.good { color: var(--green); }
.metric-delta { font-size: 10px; color: var(--text-2); margin-top: 4px; font-family: var(--mono); }

/* ── INCIDENT CARD ── */
.incident-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
  overflow: hidden;
}
.incident-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
}
.incident-card.critical::before { background: var(--crimson); }
.incident-card.warning::before  { background: var(--amber); }
.incident-card.resolved::before { background: var(--green); }
.incident-card:hover { border-color: var(--blue); }
.incident-card.active { border-color: var(--blue); background: var(--bg-hover); }

.inc-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
}
.sev-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  flex-shrink: 0;
  margin-top: 1px;
}
.sev-badge.critical { background: var(--crimson-dim); color: var(--crimson); border: 1px solid rgba(255,59,92,0.3); }
.sev-badge.warning  { background: var(--amber-dim);   color: var(--amber);   border: 1px solid rgba(245,158,11,0.3); }
.sev-badge.resolved { background: var(--green-dim);   color: var(--green);   border: 1px solid rgba(16,217,130,0.3); }

.inc-title { font-size: 13px; font-weight: 500; line-height: 1.4; }
.inc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--mono);
}

.inc-progress {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.progress-steps { display: flex; gap: 4px; flex: 1; }
.step {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--border);
}
.step.done   { background: var(--blue); }
.step.active { background: var(--blue); animation: step-pulse 1.5s ease-in-out infinite; }
.step.ok     { background: var(--green); }
.step.fail   { background: var(--crimson); }
@keyframes step-pulse { 0%,100%{opacity:1} 50%{opacity:0.4} }
.step-label { font-size: 10px; font-family: var(--mono); color: var(--text-2); white-space: nowrap; }

.empty-state {
  font-size: 12px;
  color: var(--text-3);
  padding: 20px;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 10px;
  font-family: var(--mono);
}

/* ── RIGHT PANEL ── */
.right-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.right-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.right-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}

.agent-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.log-entry { display: flex; gap: 10px; font-size: 12px; line-height: 1.5; }
.log-time {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-3);
  white-space: nowrap;
  padding-top: 1px;
}
.log-body { flex: 1; }
.log-tag {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-right: 6px;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.tag-investigate { background: var(--blue-dim); color: var(--blue); }
.tag-hypothesis  { background: rgba(139,92,246,0.15); color: #A78BFA; }
.tag-action      { background: var(--amber-dim); color: var(--amber); }
.tag-verify      { background: var(--green-dim); color: var(--green); }
.tag-escalate    { background: var(--crimson-dim); color: var(--crimson); }
.tag-notify      { background: rgba(14,165,255,0.08); color: var(--blue); }

.log-text { color: var(--text); }
.log-text.dim { color: var(--text-2); }
.log-mono { font-family: var(--mono); font-size: 11px; color: var(--text-2); margin-top: 2px; }

.hyp-bar {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  margin-top: 6px;
}
.hyp-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.hyp-row:last-child { margin-bottom: 0; }
.hyp-name { font-size: 11px; font-family: var(--mono); color: var(--text); width: 100px; }
.hyp-track { flex: 1; height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.hyp-fill { height: 100%; border-radius: 2px; background: var(--blue); }
.hyp-pct { font-size: 10px; font-family: var(--mono); color: var(--text-2); width: 32px; text-align: right; }

.action-panel {
  border-top: 1px solid var(--border);
  padding: 16px 20px;
}
.action-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-2);
  margin-bottom: 12px;
  font-weight: 600;
}
.action-btn {
  width: 100%;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.action-btn:last-child { margin-bottom: 0; }
.btn-approve {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245,158,11,0.3);
}
.btn-approve:hover { background: rgba(245,158,11,0.2); }
.btn-escalate {
  background: var(--crimson-dim);
  color: var(--crimson);
  border: 1px solid rgba(255,59,92,0.2);
}
.btn-escalate:hover { background: rgba(255,59,92,0.2); }
.btn-icon { font-size: 14px; }
.btn-label { flex: 1; text-align: left; }
.btn-sub { font-size: 9px; opacity: 0.7; margin-left: auto; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  width: 400px;
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 20px;
}
.modal-field {
  margin-bottom: 14px;
}
.modal-field label {
  display: block;
  font-size: 11px;
  color: var(--text-2);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.modal-field input,
.modal-field select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--mono);
  outline: none;
}
.modal-field input:focus,
.modal-field select:focus {
  border-color: var(--blue);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}
.btn-cancel {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 12px;
  cursor: pointer;
}
.btn-trigger {
  background: var(--blue);
  border: none;
  color: #fff;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
}
.btn-trigger:hover { opacity: 0.85; }

/* ── INTEGRATIONS PAGE ── */
.page-content {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.page-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}
.page-sub {
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 28px;
}
.integration-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.int-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.int-info { flex: 1; }
.int-name { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.int-desc { font-size: 12px; color: var(--text-2); }
.int-status {
  font-size: 11px;
  font-family: var(--mono);
  padding: 4px 10px;
  border-radius: 20px;
}
.int-status.connected {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(16,217,130,0.3);
}
.int-status.disconnected {
  background: var(--border);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.int-btn {
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--blue);
  color: var(--blue);
  background: var(--blue-dim);
  margin-left: 10px;
}
.int-btn:hover { background: rgba(14,165,255,0.2); }

/* ── SETTINGS PAGE ── */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}
.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
  margin-bottom: 16px;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.setting-row:last-child { border-bottom: none; padding-bottom: 0; }
.setting-label { font-size: 13px; font-weight: 500; }
.setting-desc { font-size: 11px; color: var(--text-2); margin-top: 2px; }
.setting-input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-family: var(--mono);
  width: 120px;
  text-align: center;
  outline: none;
}
.setting-input:focus { border-color: var(--blue); }
.toggle {
  width: 40px; height: 22px;
  background: var(--border);
  border-radius: 11px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle.on { background: var(--blue); }
.toggle::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: transform 0.2s;
}
.toggle.on::after { transform: translateX(18px); }

/* ── MODE STATUS CARD (replaces the old orange banner) ── */
.mode-status-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.mode-status-card.mode-shadow {
  border-color: rgba(139,92,246,0.4);
  background: rgba(139,92,246,0.06);
}
.mode-status-card.mode-active {
  border-color: rgba(16,217,130,0.4);
  background: rgba(16,217,130,0.06);
}
.mode-status-icon { font-size: 20px; flex-shrink: 0; }
.mode-status-body { flex: 1; }
.mode-status-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.mode-status-card.mode-shadow .mode-status-title { color: var(--purple); }
.mode-status-card.mode-active .mode-status-title { color: var(--green); }
.mode-status-desc { font-size: 12px; color: var(--text-2); line-height: 1.5; }
.mode-status-btn {
  flex-shrink: 0;
  border: none;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--mono);
  cursor: pointer;
}
.mode-status-card.mode-shadow .mode-status-btn { background: var(--purple); color: #fff; }
.mode-status-card.mode-active .mode-status-btn { background: var(--green); color: #04120B; }

/* ── SIDEBAR MODE TOGGLE ── */
.mode-toggle-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  position: relative;
}
.mode-toggle-head { display: flex; align-items: center; justify-content: space-between; }
.mode-toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
}
.mode-toggle-label.mode-shadow { color: var(--purple); }
.mode-toggle-label.mode-active { color: var(--green); }
.mode-info-btn {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 12px; padding: 0; line-height: 1;
}
.mode-pill {
  width: 36px; height: 20px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  transition: background 0.2s;
  border: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.mode-pill.mode-shadow { background: var(--purple); }
.mode-pill.mode-active { background: var(--green); }
.mode-pill-knob {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.mode-pill.mode-active .mode-pill-knob { transform: translateX(16px); }
.mode-info-popup {
  display: none;
  position: absolute;
  bottom: 34px; left: 0;
  width: 250px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  font-size: 12px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ── GHOST CARDS (Historical Ghosts page) ── */
.ghost-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}
.ghost-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--purple);
}
.ghost-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ghost-badge {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(139,92,246,0.3);
  white-space: nowrap;
}
.ghost-title { font-size: 13px; font-weight: 500; line-height: 1.4; }
.ghost-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 11px;
  color: var(--text-2);
  font-family: var(--mono);
  margin-bottom: 8px;
}
.ghost-headline { font-size: 12px; color: var(--text-2); line-height: 1.5; margin-bottom: 10px; }
.ghost-view-btn {
  background: var(--purple-dim);
  color: var(--purple);
  border: 1px solid rgba(139,92,246,0.3);
  padding: 6px 12px;
  border-radius: 7px;
  font-size: 11px;
  font-family: var(--mono);
  font-weight: 600;
  cursor: pointer;
}
.ghost-view-btn:hover { background: rgba(139,92,246,0.2); }

/* scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }