/* ============================================================
   PulseWise Sovereign Intelligence Design Language v2
   Founder Console — Styles
   ============================================================ */

/* -------- CUSTOM PROPERTIES (Tokens) -------- */
:root {
  --navy:       oklch(12% 0.018 268);
  --navy-light: oklch(18% 0.025 268);
  --navy-mid:   oklch(28% 0.03 268);
  --navy-lift:  oklch(38% 0.035 268);
  --cyan:       oklch(72% 0.19 220);
  --blue:       oklch(52% 0.14 248);
  --blue-deep:  oklch(42% 0.16 250);
  --neutral:    oklch(72% 0.012 260);
  --neutral-dim: oklch(55% 0.015 260);
  --white:      oklch(98% 0.002 260);
  --surface:    oklch(14% 0.02 268);
  --surface-raised: oklch(18% 0.025 268);

  /* PulseWise DL v2 semantic tokens */
  --bg:                    var(--navy);
  --bg-surface:            var(--surface);
  --bg-raised:             var(--surface-raised);
  --bg-elevated:           oklch(22% 0.03 268);
  --fg:                    var(--white);
  --fg-muted:              var(--neutral);
  --fg-dim:                var(--neutral-dim);
  --accent:                var(--cyan);
  --accent-secondary:      var(--blue);
  --accent-deep:           var(--blue-deep);
  --border:                oklch(24% 0.025 268);
  --border-light:          oklch(20% 0.02 268);

  /* Status */
  --status-success:  oklch(65% 0.18 152);
  --status-warning:  oklch(72% 0.18 82);
  --status-danger:   oklch(58% 0.22 28);
  --status-info:     var(--accent);

  /* Typography */
  --font-sans: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-arabic: 'Cairo', 'Montserrat', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', ui-monospace, monospace;

  /* Type scale */
  --fs-xs:   0.6875rem;
  --fs-sm:   0.75rem;
  --fs-base: 0.875rem;
  --fs-md:   1rem;
  --fs-lg:   1.125rem;
  --fs-xl:   1.5rem;
  --fs-2xl:  2rem;
  --fs-3xl:  2.5rem;
  --fs-4xl:  3rem;

  --lh-tight: 1.15;
  --lh-body:  1.6;

  /* Space */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* Radii */
  --radius-sm:  4px;
  --radius-md:  6px;
  --radius-lg:  8px;
  --radius-xl:  12px;

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 24px rgba(0,0,0,0.5);
  --shadow-cyan: 0 0 20px rgba(0,224,255,0.08);

  /* Sidebar */
  --sidebar-w: 240px;
  --sidebar-w-collapsed: 64px;

  /* Transitions */
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out:   cubic-bezier(0.65, 0, 0.35, 1);
  --ease-default:  ease;
  --duration-fast:  150ms;
  --duration-base:  250ms;
  --duration-slow:  400ms;
}

/* -------- RESET & BASE -------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-body);
  color: var(--fg);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input, textarea, select {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  color: var(--fg);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  outline: none;
  transition: border-color var(--duration-fast) var(--ease-default);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-cyan);
}

::selection {
  background: var(--accent);
  color: var(--navy);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* -------- SKIP LINK -------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  z-index: 9999;
  padding: var(--space-2) var(--space-4);
  background: var(--fg);
  color: var(--bg);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  transition: top var(--duration-fast);
}
.skip-link:focus {
  top: var(--space-2);
}

/* -------- APP LAYOUT -------- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

/* -------- SIDEBAR (Global Navigation) -------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--duration-base) var(--ease-out-expo);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.brand-mark {
  color: var(--accent);
  flex-shrink: 0;
}

.brand-name {
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
  width: 100%;
  text-align: left;
  position: relative;
}

.nav-item:hover {
  color: var(--fg);
  background: var(--bg-raised);
}

.nav-item.active {
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 8%, transparent);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  padding: var(--space-3) var(--space-2);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  flex-shrink: 0;
}

/* -------- BADGE -------- */
.badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--navy);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

.badge-sm {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--status-danger);
  color: var(--white);
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

/* -------- AVATAR -------- */
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy-mid);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-btn {
  margin-top: var(--space-1);
}

/* -------- MOBILE HEADER -------- */
.mobile-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: var(--space-2);
  color: var(--fg);
}
.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--fg);
  border-radius: 1px;
  transition: transform var(--duration-fast) var(--ease-out-expo);
}

.mobile-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--fs-md);
}

.notification-bell {
  position: relative;
  padding: var(--space-2);
  color: var(--accent);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-default);
}

/* -------- MAIN AREA -------- */
.main-area {
  overflow-y: auto;
  overflow-x: hidden;
  height: 100vh;
  position: relative;
  scroll-behavior: smooth;
}

/* -------- PANELS -------- */
.panel {
  display: none;
  padding: var(--space-8) var(--space-8) var(--space-16);
  max-width: 1440px;
  margin: 0 auto;
  width: 100%;
  animation: panel-fade-in var(--duration-base) var(--ease-out-expo);
}

.panel.active {
  display: block;
}

@keyframes panel-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.panel-title {
  font-size: var(--fs-2xl);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.panel-subtitle {
  color: var(--fg-muted);
  font-size: var(--fs-md);
  font-weight: 400;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.last-sync {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- BUTTONS -------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: var(--navy);
}
.btn-primary:hover {
  background: color-mix(in oklch, var(--accent) 85%, white);
  box-shadow: var(--shadow-cyan);
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
}
.btn-ghost:hover {
  color: var(--fg);
  background: var(--bg-raised);
}

.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
}

/* -------- CARDS -------- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: var(--fs-md);
  font-weight: 500;
}

.card-body {
  padding: var(--space-5);
}

.card-footer {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border-light);
}

.card-lg {
  grid-column: 1 / -1;
}

.card-full {
  grid-column: 1 / -1;
}

/* -------- METRIC GRID -------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.metric-label {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}

.metric-value {
  font-size: var(--fs-2xl);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1;
  margin-bottom: var(--space-2);
  font-variant-numeric: tabular-nums;
}

.metric-change {
  font-size: var(--fs-xs);
  font-weight: 500;
}

.metric-change.positive {
  color: var(--status-success);
}
.metric-change.neutral {
  color: var(--fg-muted);
}
.metric-change.negative {
  color: var(--status-danger);
}

/* -------- DASHBOARD GRID -------- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-4);
}

/* -------- ACTIVITY FEED -------- */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.activity-dot.decision {
  background: var(--accent);
}
.activity-dot.agent {
  background: var(--blue);
}
.activity-dot.memory {
  background: var(--status-success);
}
.activity-dot.automation {
  background: var(--status-warning);
}
.activity-dot.system {
  background: var(--fg-muted);
}
.activity-dot.pending {
  background: var(--neutral-dim);
}

.activity-content {
  flex: 1;
}
.activity-heading {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}
.activity-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- QUICK ACTIONS -------- */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.action-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--fg-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: all var(--duration-fast) var(--ease-default);
}

.action-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 6%, var(--bg-raised));
}

/* -------- GAUGE -------- */
.gauge-group {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
}

.gauge {
  text-align: center;
}

.gauge-ring {
  width: 60px;
  height: 60px;
  margin: 0 auto var(--space-2);
  position: relative;
}

.gauge-ring svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 3;
}

.gauge-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 100;
}

.gauge-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
}

.gauge-label {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- SMA WORKSPACE -------- */
.sma-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

.sma-layout > .card:first-child {
  grid-column: 1 / -1;
}

.architecture-graph {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) 0;
  flex-wrap: wrap;
}

.arch-node {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  text-align: center;
  min-width: 160px;
  transition: border-color var(--duration-fast);
}

.arch-node.core {
  border-color: var(--accent);
}
.arch-node.strategic {
  border-color: var(--blue);
}
.arch-node.tactical {
  border-color: var(--accent-deep);
}
.arch-node.reflective {
  border-color: var(--status-success);
}

.arch-node-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.arch-node-desc {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

.arch-connector {
  width: 24px;
  height: 2px;
  background: var(--border);
  flex-shrink: 0;
}

/* -------- DIRECTIVES -------- */
.directive-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.directive-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast);
}
.directive-item.active {
  border-color: var(--accent);
}

.directive-priority {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
}
.directive-priority.high {
  background: var(--status-danger);
}
.directive-priority.medium {
  background: var(--status-warning);
}
.directive-priority.low {
  background: var(--status-success);
}

.directive-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.directive-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- STATE LIST -------- */
.state-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.state-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-light);
}
.state-row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.state-key {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.state-value {
  font-size: var(--fs-sm);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* -------- AGENT GRID -------- */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.agent-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  position: relative;
  transition: border-color var(--duration-fast);
}
.agent-card:hover {
  border-color: var(--navy-mid);
}

.agent-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}
.agent-status.active {
  background: var(--status-success);
  box-shadow: 0 0 6px var(--status-success);
}
.agent-status.idle {
  background: var(--fg-muted);
}
.agent-status.pending {
  background: var(--status-warning);
}

.agent-info {
  flex: 1;
}

.agent-name {
  font-size: var(--fs-md);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.agent-role {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin-bottom: var(--space-2);
}

.agent-metrics {
  display: flex;
  gap: var(--space-3);
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

.agent-actions {
  display: flex;
  gap: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-light);
}

.agent-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
}

.add-agent-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--fg-dim);
  font-size: var(--fs-sm);
  font-weight: 500;
  transition: color var(--duration-fast);
  padding: var(--space-6);
}
.add-agent-btn:hover {
  color: var(--accent);
}

/* -------- KNOWLEDGE GRAPH -------- */
.knowledge-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}

.knowledge-layout > .card:first-child {
  grid-column: 1 / -1;
}

/* -------- SEARCH FIELD -------- */
.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  min-width: 240px;
}

.search-icon {
  color: var(--fg-dim);
  flex-shrink: 0;
}

.search-input {
  border: none;
  background: transparent;
  padding: var(--space-1) 0;
  color: var(--fg);
  width: 100%;
}
.search-input::placeholder {
  color: var(--fg-dim);
}
.search-input:focus {
  box-shadow: none;
  border-color: transparent;
}

/* -------- GRAPH CANVAS -------- */
.canvas-container {
  min-height: 360px;
  position: relative;
}

.graph-canvas {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--surface-raised) 0%, var(--bg) 100%);
  overflow: hidden;
}

.graph-node {
  position: absolute;
  transform: translate(-50%, -50%);
}

.graph-node-inner {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  transition: all var(--duration-fast);
}

.graph-node-inner.core {
  border-color: var(--accent);
  color: var(--accent);
  font-size: var(--fs-sm);
  padding: var(--space-3) var(--space-5);
}

.graph-node-inner.person {
  border-color: var(--blue);
  color: var(--blue);
}

.graph-node-inner.concept {
  border-color: var(--accent-deep);
  color: var(--accent);
}

.graph-node-inner.project {
  border-color: var(--status-success);
  color: var(--status-success);
}

.graph-node-inner.doc {
  border-color: var(--status-warning);
  color: var(--status-warning);
}

/* -------- DISCOVERIES -------- */
.discovery-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.discovery-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.discovery-type {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.discovery-type.concept {
  background: var(--accent);
}
.discovery-type.connection {
  background: var(--blue);
}
.discovery-type.insight {
  background: var(--status-success);
}

.discovery-text {
  font-size: var(--fs-sm);
  color: var(--fg);
}

/* -------- CATEGORIES -------- */
.category-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.category-badge {
  padding: var(--space-1) var(--space-3);
  border-radius: 100px;
  font-size: var(--fs-xs);
  font-weight: 600;
}
.category-badge.person {
  background: color-mix(in oklch, var(--blue) 15%, transparent);
  color: var(--blue);
}
.category-badge.project {
  background: color-mix(in oklch, var(--status-success) 15%, transparent);
  color: var(--status-success);
}
.category-badge.concept {
  background: color-mix(in oklch, var(--accent) 10%, transparent);
  color: var(--accent);
}
.category-badge.doc {
  background: color-mix(in oklch, var(--status-warning) 15%, transparent);
  color: var(--status-warning);
}
.category-badge.decision {
  background: color-mix(in oklch, var(--accent-deep) 15%, transparent);
  color: var(--accent-deep);
}

.category-count {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--fg-muted);
}

/* -------- MEMORY LAYOUT -------- */
.memory-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}

.memory-layout > .card:first-child {
  grid-column: 1 / -1;
}

/* -------- MEMORY TIMELINE -------- */
.memory-timeline {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.memory-entry {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-light);
}
.memory-entry:last-child {
  border-bottom: none;
}

.memory-time {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
  font-weight: 500;
  min-width: 60px;
  flex-shrink: 0;
  padding-top: 2px;
}

.memory-content {
  flex: 1;
}

.memory-heading {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.memory-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- MEMORY TYPES -------- */
.memory-types {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.memory-type-row {
  display: grid;
  grid-template-columns: 80px 50px 1fr;
  gap: var(--space-2);
  align-items: center;
}

.memory-type-label {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}

.memory-type-value {
  font-size: var(--fs-xs);
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.memory-type-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.memory-type-fill {
  height: 100%;
  border-radius: 3px;
}
.memory-type-fill.episodic {
  background: var(--accent);
}
.memory-type-fill.semantic {
  background: var(--blue);
}
.memory-type-fill.procedural {
  background: var(--status-success);
}
.memory-type-fill.associative {
  background: var(--status-warning);
}

/* -------- AUTOMATION GRID -------- */
.automation-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

.automation-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.automation-status.running {
  background: var(--status-success);
  box-shadow: 0 0 6px var(--status-success);
}
.automation-status.paused {
  background: var(--fg-muted);
}
.automation-status.failed {
  background: var(--status-danger);
}

.automation-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
  margin-bottom: var(--space-2);
}

.automation-triggers {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.trigger-badge {
  padding: 2px var(--space-2);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 600;
  background: color-mix(in oklch, var(--accent) 10%, transparent);
  color: var(--accent);
}

.trigger-badge.error {
  background: color-mix(in oklch, var(--status-danger) 15%, transparent);
  color: var(--status-danger);
}

/* -------- DECISION LAYOUT -------- */
.decision-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-4);
}

.decision-layout > .card:first-child {
  grid-column: 1 / -1;
}

/* -------- PIPELINE -------- */
.pipeline-stages {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  overflow-x: auto;
  padding-bottom: var(--space-2);
}

.pipeline-stage {
  min-width: 220px;
  flex: 1;
}

.stage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.stage-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--fg-muted);
}

.stage-count {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-dim);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 100px;
  font-variant-numeric: tabular-nums;
}

.stage-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.pipeline-card {
  padding: var(--space-3);
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  transition: border-color var(--duration-fast);
}
.pipeline-card:hover {
  border-color: var(--navy-mid);
}
.pipeline-card.ready {
  border-left: 3px solid var(--status-success);
}

.pipeline-card-title {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: var(--space-1);
}

.pipeline-card-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

.pipeline-arrow {
  color: var(--fg-dim);
  padding-top: var(--space-4);
  flex-shrink: 0;
}

/* -------- REVENUE -------- */
.revenue-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.revenue-layout {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: var(--space-4);
}

.revenue-period {
  display: flex;
  gap: var(--space-1);
}

.period-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--fg-dim);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}
.period-btn:hover {
  color: var(--fg);
}
.period-btn.active {
  color: var(--accent);
  background: color-mix(in oklch, var(--accent) 10%, transparent);
}

/* -------- BAR CHART -------- */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.bar-group {
  display: grid;
  grid-template-columns: 100px 1fr 60px;
  gap: var(--space-3);
  align-items: center;
}

.bar-label {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.bar-track {
  height: 24px;
  background: var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width var(--duration-slow) var(--ease-out-expo);
}
.bar-fill.subscription {
  background: var(--accent);
}
.bar-fill.services {
  background: var(--blue);
}
.bar-fill.licensing {
  background: var(--accent-deep);
}

.bar-value {
  font-size: var(--fs-sm);
  font-weight: 600;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* -------- CUSTOMER LIST -------- */
.customer-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.customer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--border-light);
}
.customer-row:last-child {
  border-bottom: none;
}

.customer-name {
  font-size: var(--fs-sm);
  font-weight: 500;
}

.customer-value {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

/* -------- SYSTEM HEALTH -------- */
.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.health-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast);
}
.health-card:hover {
  border-color: var(--navy-mid);
}

.health-status-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--status-success);
  box-shadow: 0 0 8px var(--status-success);
}
.health-status-icon.warning {
  background: var(--status-warning);
  box-shadow: 0 0 8px var(--status-warning);
}

.health-info {
  flex: 1;
}

.health-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.health-detail {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

.health-metric {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.health-card.warning .health-metric {
  color: var(--status-warning);
}

/* -------- INCIDENTS -------- */
.incident-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.incident-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.incident-content {
  flex: 1;
}

.incident-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--status-success);
}
.incident-dot.monitoring {
  background: var(--status-warning);
}

.incident-name {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.incident-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- ACTIVITY TIMELINE (full page) -------- */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.tl-item {
  display: grid;
  grid-template-columns: 60px 20px 1fr;
  gap: var(--space-3);
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-light);
  align-items: flex-start;
}
.tl-item:last-child {
  border-bottom: none;
}

.tl-time {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
  font-weight: 500;
  text-align: right;
  padding-top: 3px;
}

.tl-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  position: relative;
}
.tl-dot::after {
  content: '';
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: 1px;
  height: calc(100% + 30px);
  background: var(--border);
}
.tl-item:last-child .tl-dot::after {
  display: none;
}
.tl-dot.decision {
  background: var(--accent);
}
.tl-dot.agent {
  background: var(--blue);
}
.tl-dot.memory {
  background: var(--status-success);
}
.tl-dot.system {
  background: var(--fg-muted);
}
.tl-dot.automation {
  background: var(--status-warning);
}

.tl-heading {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.tl-meta {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

/* -------- TIMELINE FILTERS -------- */
.timeline-filters {
  display: flex;
  gap: var(--space-1);
}

.filter-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--fg-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--duration-fast);
}
.filter-btn:hover {
  color: var(--fg);
  border-color: var(--navy-mid);
}
.filter-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 8%, transparent);
}

/* -------- NOTIFICATIONS -------- */
.notification-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 680px;
}

.notification-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast);
}
.notification-item:hover {
  border-color: var(--navy-mid);
}
.notification-item.unread {
  border-left: 3px solid var(--accent);
}

.notification-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
}
.notification-icon.decision {
  background: color-mix(in oklch, var(--accent) 15%, transparent);
}
.notification-icon.agent {
  background: color-mix(in oklch, var(--blue) 15%, transparent);
}
.notification-icon.system {
  background: color-mix(in oklch, var(--fg-muted) 15%, transparent);
}
.notification-icon.automation {
  background: color-mix(in oklch, var(--status-warning) 15%, transparent);
}

.notification-content {
  flex: 1;
}

.notification-heading {
  font-size: var(--fs-sm);
  font-weight: 500;
  margin-bottom: 2px;
}

.notification-body {
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin-bottom: var(--space-1);
}

.notification-time {
  font-size: var(--fs-xs);
  color: var(--fg-dim);
}

.notification-dismiss {
  font-size: var(--fs-lg);
  color: var(--fg-dim);
  padding: var(--space-1);
  line-height: 1;
  transition: color var(--duration-fast);
}
.notification-dismiss:hover {
  color: var(--fg);
}

/* -------- TEXT UTILITIES -------- */
.text-muted {
  color: var(--fg-muted);
}

/* -------- RESPONSIVE (Mobile) -------- */
@media (max-width: 1024px) {
  #app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    z-index: 100;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .mobile-header {
    display: flex;
  }

  .main-area {
    height: calc(100vh - 56px);
    padding-top: 0;
  }

  .panel {
    padding: var(--space-5) var(--space-4) var(--space-12);
  }

  .panel-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .panel-title {
    font-size: var(--fs-xl);
  }

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

  .sma-layout,
  .memory-layout,
  .decision-layout,
  .revenue-layout,
  .knowledge-layout {
    grid-template-columns: 1fr;
  }

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

  .revenue-metrics {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

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

  .pipeline-stages {
    flex-direction: column;
  }

  .pipeline-arrow {
    display: none;
  }

  .pipeline-stage {
    min-width: unset;
  }

  .search-field {
    min-width: unset;
    width: 100%;
  }

  .gauge-group {
    flex-direction: column;
    align-items: center;
  }

  .architecture-graph {
    flex-direction: column;
  }

  .arch-connector {
    width: 2px;
    height: 16px;
  }

  .tl-item {
    grid-template-columns: 50px 16px 1fr;
  }

  .notification-list {
    max-width: unset;
  }
}

@media (max-width: 480px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .revenue-metrics {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .bar-group {
    grid-template-columns: 70px 1fr 50px;
    gap: var(--space-2);
  }
}

/* -------- PRINT -------- */
@media print {
  .sidebar,
  .mobile-header,
  .sidebar-overlay {
    display: none !important;
  }

  #app {
    display: block;
  }

  .panel {
    display: block !important;
    page-break-after: always;
    padding: 0;
  }

  .panel.active {
    display: block !important;
  }

  body {
    overflow: visible;
  }

  .main-area {
    height: auto;
    overflow: visible;
  }
}

/* -------- REDUCED MOTION -------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
