:root {
  --bg-primary: #0F172A;
  --bg-secondary: #1E293B;
  --bg-tertiary: #334155;
  --text-primary: #FFFFFF;
  --text-muted: #94A3B8;
  --text-subtle: #CBD5E1;
  --accent-blue: #3B82F6;
  --accent-indigo: #6366F1;
  --accent-emerald: #22C55E;
  --accent-amber: #F97316;
  --accent-rose: #EC4899;
  --border: rgba(148, 163, 184, 0.15);
  --card-bg: rgba(30, 41, 59, 0.5);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 40%);
}

.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-blue));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.02em;
}

.brand-name { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.08em; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-link {
  padding: 9px 12px;
  color: var(--text-subtle);
  text-decoration: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--card-bg);
  color: var(--text-primary);
}

.nav-link.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-indigo);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.6;
}

.footer-line a { color: var(--text-subtle); text-decoration: none; }
.footer-line a:hover { color: var(--accent-blue); }

/* Content */
.content {
  padding: 40px 48px;
  max-width: 1400px;
  width: 100%;
}

.loading { color: var(--text-muted); padding: 60px 0; text-align: center; }

.page-header { margin-bottom: 32px; }
.page-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-subtitle { color: var(--text-muted); font-size: 14px; }

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 8px 0 4px;
  background: linear-gradient(135deg, var(--text-primary), var(--text-subtle));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.section { margin-bottom: 40px; }
.section-title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

/* Status pills */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.status-accepted { background: rgba(34, 197, 94, 0.15); color: var(--accent-emerald); }
.status-proposed { background: rgba(249, 115, 22, 0.15); color: var(--accent-amber); }
.status-shipped { background: rgba(34, 197, 94, 0.15); color: var(--accent-emerald); }
.status-superseded { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); }
.status-unknown { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }
.status-completed { background: rgba(34, 197, 94, 0.15); color: var(--accent-emerald); }
.status-completed_partial { background: rgba(249, 115, 22, 0.15); color: var(--accent-amber); }
.status-failed { background: rgba(236, 72, 153, 0.15); color: var(--accent-rose); }

/* Agent matrix */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  transition: transform 0.15s, border-color 0.15s;
}

.agent-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-indigo);
}

.agent-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-blue));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}

.agent-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.agent-desc { color: var(--text-muted); font-size: 13px; line-height: 1.5; }

/* Tables */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  background: var(--card-bg);
}
.table tr:hover td { background: rgba(99, 102, 241, 0.05); }

/* Commits feed */
.commit {
  display: grid;
  grid-template-columns: 80px 160px 1fr;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  align-items: center;
}
.commit-hash { font-family: 'SF Mono', Menlo, monospace; font-size: 12px; color: var(--accent-blue); }
.commit-date { color: var(--text-muted); font-size: 12px; }
.commit-msg { color: var(--text-subtle); }

/* Roadmap kanban */
.kanban {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.kanban-col {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.kanban-col-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.kanban-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.kanban-card-num { color: var(--accent-blue); font-size: 11px; font-weight: 600; font-family: 'SF Mono', Menlo, monospace; }
.kanban-card-title { margin-top: 4px; color: var(--text-primary); line-height: 1.4; }

/* Chart wrapper */
.chart-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  height: 320px;
}

/* Pipeline diagram (for /pipeline) */
.pipeline-svg { width: 100%; height: auto; max-height: 600px; }

/* Responsive */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 24px 20px; }
  .commit { grid-template-columns: 70px 1fr; }
  .commit-date { display: none; }
}

.agent-icon img.agent-icon-img {
  width: 28px;
  height: 28px;
  display: block;
}

/* Agent avatars (historical figures) */
.agent-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.agent-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid var(--accent-indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  background: var(--bg-secondary);
}

.agent-card.m2-card .agent-avatar {
  border-color: var(--accent-rose);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.12);
}

.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 20%;
  display: block;
}

.agent-names {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.agent-figure {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.2;
  margin-bottom: 3px;
}

.agent-role {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: capitalize;
  font-weight: 500;
  letter-spacing: 0.01em;
}

/* Agent card v2 — vertical museum-plaque layout */
.agent-card-v2 {
  padding: 24px 20px 22px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.agent-avatar-lg {
  width: 128px;
  height: 128px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--accent-indigo);
  box-shadow:
    0 0 0 4px rgba(99, 102, 241, 0.10),
    0 8px 24px rgba(0, 0, 0, 0.4);
  background: var(--bg-secondary);
  margin-bottom: 16px;
  flex-shrink: 0;
}

.agent-card-v2.m2-card .agent-avatar-lg {
  border-color: var(--accent-rose);
  box-shadow:
    0 0 0 4px rgba(236, 72, 153, 0.10),
    0 8px 24px rgba(0, 0, 0, 0.4);
}

.agent-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  display: block;
}

.agent-card-v2 .agent-figure {
  font-weight: 700;
  font-size: 18px;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin-bottom: 4px;
}

.agent-card-v2 .agent-role {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.1em;
  margin-bottom: 14px;
}

.agent-card-v2 .agent-desc {
  color: var(--text-subtle);
  font-size: 13px;
  line-height: 1.55;
  text-align: left;
  width: 100%;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Grid: allow cards a bit more width for the bigger avatar */
.agent-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* Order page — hierarchy tree */
.order-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  overflow: hidden;
}

.order-svg {
  width: 100%;
  height: auto;
  max-height: 80vh;
  display: block;
}

.order-monogram {
  font-family: 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 600;
  fill: var(--accent-indigo);
  fill-opacity: 0.7;
  letter-spacing: 0.08em;
}

.order-label-figure {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 600;
  fill: var(--text-primary);
}

.order-label-role {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 600;
  fill: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.order-node {
  cursor: default;
  transition: transform 0.2s ease;
  transform-origin: center;
  transform-box: fill-box;
}

.order-node:hover {
  transform: scale(1.08);
}

.order-node:hover .order-ring {
  stroke-width: 3;
  filter: drop-shadow(0 0 6px currentColor);
}

.order-legend {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.order-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.order-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
