/* Buddi Mission Control — "the agent office"
   Dark, premium, alive. Deliberate dark-only direction (matches Buddi's brand:
   background #0a0a1a / accent #818cf8), layered with depth for an investor-grade
   control room rather than a flat dashboard-by-numbers template. */

/* The HTML `hidden` attribute must always win. Without this, `.gate { display:
   flex }` (author origin) beats the UA `[hidden] { display: none }` rule, so the
   fixed full-screen gate overlay never disappears after a correct code is
   entered — the dashboard renders underneath but the gate keeps covering it,
   which reads as "the code was rejected / nothing happens". */
[hidden] {
  display: none !important;
}

:root {
  --bg: #07070f;
  --bg-elevated: #12111f;
  --bg-panel: #14132400;
  --surface: rgba(255, 255, 255, 0.035);
  --surface-strong: rgba(255, 255, 255, 0.06);
  --border: rgba(129, 140, 248, 0.16);
  --border-strong: rgba(129, 140, 248, 0.32);

  --accent: #818cf8;
  --accent-soft: #a5b4fc;
  --cyan: #22d3ee;
  --violet: #a78bfa;
  --amber: #f59e0b;
  --success: #22c55e;
  --danger: #ef4444;

  --text: #f4f4fb;
  --text-dim: #9d9db4;
  --text-faint: #6b6b83;

  --font-display: "Quicksand", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --space-section: clamp(2.5rem, 2rem + 2vw, 5rem);
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(129, 140, 248, 0.16), transparent),
    radial-gradient(ellipse 60% 40% at 90% 10%, rgba(34, 211, 238, 0.08), transparent),
    var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-particles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

/* ── Access gate ─────────────────────────────────────────────────────── */

.gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 70% 50% at 50% 20%, rgba(129, 140, 248, 0.14), transparent), var(--bg);
  padding: 1.5rem;
}

.gate-card {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem 2rem;
  text-align: center;
  backdrop-filter: blur(16px);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.6);
  animation: gate-rise 0.6s var(--ease-out-expo) both;
}

@keyframes gate-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.gate-logo {
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-weight: 700;
}

.gate-logo span {
  background: linear-gradient(135deg, var(--accent-soft), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.gate-card h1 {
  font-size: 1.6rem;
  margin: 0.5rem 0 0.25rem;
  font-weight: 700;
}

.gate-sub {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin: 0 0 1.5rem;
}

#gate-form {
  display: flex;
  gap: 0.5rem;
}

#gate-code {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s var(--ease-out-expo), box-shadow 0.2s var(--ease-out-expo);
}

#gate-code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.gate-card button {
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: #08080f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 0.75rem 1.1rem;
  cursor: pointer;
  font-family: var(--font-display);
  transition: transform 0.15s var(--ease-out-expo), filter 0.15s var(--ease-out-expo);
}

.gate-card button:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.gate-card button:active {
  transform: translateY(0);
}

.gate-error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 0.9rem 0 0;
}

/* ── App shell ───────────────────────────────────────────────────────── */

.app {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(7, 7, 15, 0.7);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.brand span:first-of-type {
  background: linear-gradient(135deg, var(--accent-soft), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.brand-sep {
  color: var(--text-faint);
  font-weight: 400;
}

.brand-sub {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.95rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.clock {
  font-family: var(--font-mono);
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: var(--font-display);
  transition: border-color 0.2s, color 0.2s;
}

.ghost-btn:hover {
  border-color: var(--border-strong);
  color: var(--text);
}

main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 3vw, 2.5rem) var(--space-section);
}

/* ── Hero: system heartbeat ─────────────────────────────────────────── */

.hero {
  display: flex;
  align-items: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  padding: var(--space-section) 0 clamp(2rem, 4vw, 3rem);
  flex-wrap: wrap;
}

.hero-pulse-wrap {
  flex: none;
}

.hero-pulse {
  position: relative;
  width: 140px;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pulse-core {
  position: relative;
  z-index: 2;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  background: radial-gradient(circle at 35% 30%, #1c1b30, #0a0a16);
  border: 1px solid var(--border-strong);
  box-shadow: 0 0 40px rgba(34, 197, 94, 0.35), inset 0 0 20px rgba(34, 197, 94, 0.12);
  transition: box-shadow 0.6s var(--ease-out-expo);
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(34, 197, 94, 0.55);
  animation: pulse-out 2.6s var(--ease-out-expo) infinite;
}

.pulse-ring.r2 { animation-delay: 0.6s; }
.pulse-ring.r3 { animation-delay: 1.2s; }

@keyframes pulse-out {
  0% { transform: scale(0.55); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}

.hero-pulse[data-status="red"] .pulse-core {
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.4), inset 0 0 20px rgba(239, 68, 68, 0.15);
}

.hero-pulse[data-status="red"] .pulse-ring {
  border-color: rgba(239, 68, 68, 0.6);
  animation-duration: 1.3s;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--text-faint);
  margin: 0 0 0.4rem;
  font-family: var(--font-mono);
}

.hero h1 {
  font-size: clamp(2.4rem, 3vw + 1.5rem, 4.2rem);
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text), var(--accent-soft) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-meta {
  color: var(--text-dim);
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}

.hero-meta strong {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
}

/* ── Panels (shared) ─────────────────────────────────────────────────── */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.5rem 1.6rem;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(129, 140, 248, 0.08), transparent 55%);
  pointer-events: none;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 1.1rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 700;
}

.panel-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── CEO layer ───────────────────────────────────────────────────────── */

.ceo-layer {
  display: grid;
  grid-template-columns: 1fr 1.3fr 1fr;
  gap: 1.1rem;
  margin-bottom: var(--space-section);
}

.ns-numbers {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1.2rem;
  flex-wrap: wrap;
}

.ns-metric {
  display: flex;
  flex-direction: column;
}

.ns-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--accent-soft);
}

.ns-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.ns-progress-track {
  height: 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.ns-progress-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 99px;
  transition: width 1.4s var(--ease-out-expo);
}

.ns-progress-label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.ns-progress-label strong {
  color: var(--text);
  font-family: var(--font-mono);
}

.money-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.money-col {
  display: flex;
  flex-direction: column;
  padding: 0.85rem 0.9rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
}

.money-col-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.money-big {
  font-family: var(--font-mono);
  font-size: 1.55rem;
  font-weight: 700;
  margin-top: 0.3rem;
}

.money-revenue .money-big { color: var(--success); }
.money-costs .money-big { color: var(--amber); }
.money-net .money-big { color: var(--accent-soft); }

.money-sub {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

.money-sub-line {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  font-family: var(--font-mono);
}

.engagement-grid {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.engagement-metric {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.engagement-label {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.engagement-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--cyan);
}

.sparkline {
  width: 100%;
  height: 40px;
}

/* ── Agent quadrant ──────────────────────────────────────────────────── */

.agent-quadrant {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.1rem;
  margin-bottom: var(--space-section);
}

.agent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: border-color 0.35s var(--ease-out-expo), transform 0.35s var(--ease-out-expo);
}

.agent-card::after {
  content: "";
  position: absolute;
  inset: -40% -40% auto auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  pointer-events: none;
}

.agent-council::after { background: var(--violet); }
.agent-sentinel::after { background: var(--success); }
.agent-chat::after { background: var(--cyan); }
.agent-planner::after { background: var(--amber); }

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

.agent-avatar {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  margin-bottom: 0.9rem;
}

.agent-emoji {
  font-size: 1.6rem;
  animation: agent-idle 4.5s ease-in-out infinite;
}

@keyframes agent-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-3deg); }
}

.agent-glow {
  position: absolute;
  inset: -4px;
  border-radius: 18px;
  border: 1.5px solid transparent;
  opacity: 0;
  transition: opacity 0.4s var(--ease-out-expo);
}

/* "working" state: agent updated in the last 24h — card visibly pulses */
.agent-card.is-active .agent-glow {
  opacity: 1;
  animation: agent-active-glow 1.8s ease-in-out infinite;
}

.agent-council.is-active .agent-glow { border-color: var(--violet); }
.agent-sentinel.is-active .agent-glow { border-color: var(--success); }
.agent-chat.is-active .agent-glow { border-color: var(--cyan); }
.agent-planner.is-active .agent-glow { border-color: var(--amber); }

@keyframes agent-active-glow {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 0.9; }
  50% { box-shadow: 0 0 14px 2px currentColor; opacity: 0.5; }
}

.agent-card h3 {
  margin: 0 0 0.1rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.agent-role {
  margin: 0 0 1rem;
  font-size: 0.75rem;
  color: var(--text-faint);
  font-family: var(--font-mono);
  text-transform: lowercase;
}

.agent-stats {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem 1rem;
}

.agent-stats li {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.1rem;
}

/* ── Growth strip ────────────────────────────────────────────────────── */

.growth-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: var(--space-section);
}

.growth-metric {
  text-align: center;
  padding: 1.4rem 1rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(160deg, rgba(129, 140, 248, 0.08), rgba(34, 211, 238, 0.03));
  border: 1px solid var(--border);
}

.growth-value {
  display: block;
  font-family: var(--font-mono);
  font-size: clamp(1.8rem, 1.4rem + 1.5vw, 2.6rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--text), var(--accent-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.growth-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* ── Engineering velocity ────────────────────────────────────────────── */

.eng-velocity {
  margin-bottom: var(--space-section);
}

.eng-grid {
  display: flex;
  gap: 2rem;
  align-items: center;
  flex-wrap: wrap;
}

.eng-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent-soft);
  display: block;
}

.eng-label {
  color: var(--text-dim);
  font-size: 0.78rem;
}

.eng-functions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
}

.eng-fn-chip {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.3rem 0.6rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.eng-fn-chip strong {
  color: var(--accent-soft);
}

/* ── Roadmap ticker ──────────────────────────────────────────────────── */

.roadmap-section {
  margin-bottom: 2rem;
}

.roadmap-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.roadmap-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: roadmap-blink 1.6s ease-in-out infinite;
}

@keyframes roadmap-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.roadmap-ticker {
  overflow: hidden;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 0;
  mask-image: linear-gradient(90deg, transparent, black 6%, black 94%, transparent);
}

.roadmap-track {
  display: flex;
  gap: 2.5rem;
  width: max-content;
  animation: roadmap-scroll 40s linear infinite;
}

@keyframes roadmap-scroll {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

.roadmap-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
  font-size: 0.9rem;
  color: var(--text-dim);
}

.roadmap-item strong {
  color: var(--text);
  font-weight: 600;
}

.roadmap-item .roadmap-status {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--accent-soft);
  text-transform: uppercase;
}

/* ── Footer ──────────────────────────────────────────────────────────── */

.app-footer {
  display: flex;
  justify-content: space-between;
  padding: 1.5rem clamp(1rem, 3vw, 2.5rem) 2.5rem;
  color: var(--text-faint);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  max-width: 1280px;
  margin: 0 auto;
}

/* ── Count-up shimmer (fires briefly on load) ───────────────────────── */

[data-countup] {
  display: inline-block;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .ceo-layer {
    grid-template-columns: 1fr;
  }
  .money-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .agent-quadrant {
    grid-template-columns: 1fr;
  }
  .growth-strip {
    grid-template-columns: 1fr;
  }
  .hero {
    flex-direction: column;
    text-align: center;
  }
  .hero-meta {
    line-height: 1.8;
  }
  .agent-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 420px) {
  .gate-card {
    padding: 1.75rem 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
