/* RBNT Analytics - Kinetic Consensus design system */

:root {
  --accent: #EF5350;
  --accent-text: #ffb3ae;
  --surface-lowest: #0a1216;
  --bg: #0f181d;
  --bg-deep: #121b20;
  --card: #1e2a31;
  --container-high: #27323a;
  --outline: #3a4650;
  --outline-variant: #93a4ae;
  --text: #e4ebf0;
  --text-secondary: #b8c4cc;
  --muted: #93a4ae;
  --ok: #86EFAC;
  --warn: #FCD34D;
  --destructive: #DC2626;
  --r-sm: 4px;
  --r-lg: 8px;
  --gutter: 24px;
  --grid-line: #22303a;
}

[data-theme="light"] {
  --accent-text: #B3272A;
  --surface-lowest: #eef1f3;
  --bg: #F6F7F8;
  --bg-deep: #eceff1;
  --card: #FFFFFF;
  --container-high: #f1f4f6;
  --outline: #d5dce1;
  --outline-variant: #8a99a3;
  --text: #16202A;
  --text-secondary: #33414c;
  --muted: #66757f;
  --ok: #1a7f37;
  --warn: #946800;
  --destructive: #DC2626;
  --grid-line: #dde4e9;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  font-family: 'Be Vietnam Pro', sans-serif;
  color: var(--text);
  line-height: 1.5;
  font-size: 16px;
  background:
    linear-gradient(180deg, var(--surface-lowest) 0%, var(--bg) 320px);
  min-height: 100vh;
}
code, .mono, .num {
  font-family: 'JetBrains Mono', monospace;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: var(--gutter);
  flex-wrap: wrap;
  padding: 16px 16px;
  border-bottom: 1px solid var(--outline);
  background: color-mix(in srgb, var(--surface-lowest) 78%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-sm);
  background: var(--accent);
  clip-path: polygon(0 0, 100% 0, 100% 66%, 66% 100%, 0 100%);
}
.brand-name { font-weight: 700; letter-spacing: 0.02em; }

.nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; margin-left: auto; position: relative; }
#navIndicator {
  position: absolute; left: 0; top: 50%; height: 34px;
  transform: translate(0, -50%); width: 0;
  background: var(--card); border: 1px solid var(--outline);
  border-radius: var(--r-sm);
  opacity: 0;
  transition: transform .35s cubic-bezier(.22,.61,.36,1), width .35s cubic-bezier(.22,.61,.36,1), opacity .25s ease;
  pointer-events: none;
}
.nav > a { position: relative; z-index: 1; }
.nav a {
  color: var(--text-secondary); text-decoration: none;
  padding: 8px 12px; border-radius: var(--r-sm);
  font-size: 15px;
}
.nav a:hover { color: var(--accent-text); background: transparent; }
.nav a.active { color: var(--text); background: transparent; }

.search input {
  font-family: 'JetBrains Mono', monospace; font-size: 13px;
  width: 240px; max-width: 60vw;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  padding: 8px 10px;
}
.search input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(239, 83, 80, 0.35);
}

/* ---------- layout ---------- */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}
@media (min-width: 900px) { .page { padding-left: 64px; padding-right: 64px; } }

.footer {
  max-width: 1280px; margin: 0 auto;
  padding: 24px 16px 48px;
}
@media (min-width: 900px) { .footer { padding-left: 64px; padding-right: 64px; } }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

h1 { font-size: 28px; margin: 8px 0 16px; }
h2 { font-size: 20px; margin: 32px 0 12px; }
h3 { font-size: 16px; margin: 16px 0 8px; }
p { max-width: 72ch; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.accent-link { color: var(--accent-text); text-decoration: none; }
.accent-link:hover { text-decoration: underline; }

/* ---------- cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: var(--r-lg);
  padding: 16px;
}
.card.raised { background: var(--container-high); border-color: #334049; }
.card h3:first-child { margin-top: 0; }

.stat .label { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.stat .value { font-family: 'JetBrains Mono', monospace; font-size: 24px; font-weight: 500; }
.stat .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; border: 1px solid var(--outline); border-radius: var(--r-lg); background: var(--card); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--outline); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-deep); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: 'JetBrains Mono', monospace; font-size: 14px; }

.addr { font-family: 'JetBrains Mono', monospace; font-size: 14px; color: var(--text-secondary); }

/* ---------- status dot pattern ---------- */
.status { display: inline-flex; align-items: center; gap: 8px; }
.status .dot { width: 8px; height: 8px; border-radius: 9999px; flex: none; }
.status .lbl { font-family: 'JetBrains Mono', monospace; font-size: 13px; }
.status.ok .dot { background: var(--ok); }
.status.ok .lbl { color: var(--ok); }
.status.warn .dot { background: var(--warn); }
.status.warn .lbl { color: var(--warn); }
.status.bad .dot { background: var(--destructive); }
.status.bad .lbl { color: #f08c89; }
.status.neutral .dot { background: var(--outline-variant); }
.status.neutral .lbl { color: var(--muted); }

/* ---------- buttons + inputs ---------- */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  border-radius: var(--r-sm); padding: 10px 16px; cursor: pointer;
  border: 1px solid transparent;
}
.btn.primary { background: var(--accent); color: #ffffff; }
.btn.primary:hover { background: #f05552; }
.btn.ghost { background: transparent; color: var(--text-secondary); border-color: var(--outline); }
.btn.ghost:hover { color: var(--accent-text); border-color: var(--accent-text); }
.btn.destructive { background: var(--destructive); color: #fff; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.field input, .field select {
  font-family: 'JetBrains Mono', monospace; font-size: 15px;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  padding: 10px 12px;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(239, 83, 80, 0.35);
}
.field .error { color: #f08c89; font-size: 13px; display: none; }
.field.invalid input { border-color: var(--destructive); }
.field.invalid .error { display: block; }

/* ---------- banners ---------- */
.banner {
  border: 1px solid var(--outline); border-left: 3px solid var(--warn);
  background: var(--bg-deep); border-radius: var(--r-lg);
  padding: 12px 16px; color: var(--text-secondary); font-size: 15px;
  margin: 16px 0;
}
.banner.info { border-left-color: var(--outline-variant); }

.notice {
  border: 1px solid var(--outline); border-left: 3px solid var(--accent);
  background: var(--bg-deep); border-radius: var(--r-lg);
  padding: 12px 16px; margin: 16px 0;
}

/* ---------- misc ---------- */
.tag {
  display: inline-block; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--muted); border: 1px solid var(--outline); border-radius: var(--r-sm);
  padding: 2px 8px;
}
.tag.inferred { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.bar { height: 6px; border-radius: 9999px; background: var(--bg-deep); overflow: hidden; display: flex; }
.bar > i { display: block; height: 100%; }
.bar .ok { background: var(--ok); }
.bar .hold { background: var(--warn); }
.bar .none { background: var(--outline); }

.refresh-note { color: var(--muted); font-size: 13px; font-family: 'JetBrains Mono', monospace; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }

/* pagination */
.pager { display: flex; align-items: center; gap: 12px; padding: 10px 4px; flex-wrap: wrap; }
.pager .btn { padding: 6px 12px; font-size: 14px; }
.field-select {
  font-family: 'JetBrains Mono', monospace; font-size: 14px;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--r-sm); padding: 8px 10px;
}
.field-select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(239,83,80,0.35); }
details summary { color: var(--accent-text); }

/* ---------- theme toggle ---------- */
.theme-toggle { padding: 6px 10px; font-size: 13px; }

/* ---------- home / hero ---------- */
.hero { padding: 40px 0 8px; }
.hero h1 { font-size: 34px; line-height: 1.25; margin: 0 0 12px; max-width: 30ch; }
.hero p { font-size: 18px; color: var(--text-secondary); max-width: 68ch; }
.hero-stats { margin-top: 24px; }

/* ---------- flip cards ---------- */
.flip-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin: 24px 0 8px; }
.flip-card {
  perspective: 1000px;
  height: 190px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 300ms ease;
}
.flip-card:hover .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  overflow: hidden;                 /* copy can never inflate the card */
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  will-change: transform, opacity;
  background: var(--card);
  border: 1px solid var(--outline);
  border-radius: var(--r-lg);
  padding: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
.flip-front h3 { margin: 0; font-size: 18px; text-align: center; }
.flip-back { transform: rotateY(180deg); justify-content: flex-start; align-items: flex-start; }
.flip-back h3 { margin: 0; font-size: 15px; }
.flip-back p { margin: 0; font-size: 13.5px; line-height: 1.45; color: var(--text-secondary); }
.anim-slot { width: 84px; height: 64px; display: block; flex: none; }

/* ambient animations - transform and opacity only */
@keyframes meshPulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }
.mesh-dot { animation: meshPulse 2.6s ease-in-out infinite; transform-origin: center; }
.mesh-line { stroke: var(--outline-variant); opacity: .5; }

@keyframes glowPulse { 0%,100% { opacity: .25; } 50% { opacity: .85; } }
.vault-glow { animation: glowPulse 3s ease-in-out infinite; transform-origin: center; }

@keyframes flowDash { to { stroke-dashoffset: -24; } }
.flow-arrow { stroke-dasharray: 6 6; animation: flowDash 1.4s linear infinite; }

@keyframes tickDraw { 0% { stroke-dashoffset: 140; } 55%,100% { stroke-dashoffset: 0; } }
.tick-line { stroke-dasharray: 140; animation: tickDraw 3.2s ease-in-out infinite; }

@keyframes orbit { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.orbit-group { animation: orbit 9s linear infinite; transform-origin: 42px 32px; }

@media (prefers-reduced-motion: reduce) {
  .mesh-dot, .vault-glow, .flow-arrow, .tick-line, .orbit-group { animation: none; }
  .flip-inner { transition: none; }
}

/* ---------- chart hover tooltip + markers ---------- */
.chart-wrap { position: relative; }
.chart-svg { width: 100%; max-width: 720px; background: var(--bg-deep); border: 1px solid var(--outline); border-radius: var(--r-lg); }
.chart-pt { r: 3.5; fill: var(--accent); stroke: var(--card); stroke-width: 1.5; cursor: crosshair; }
.chart-pt:hover { r: 5.5; }
.chart-tip {
  position: fixed; z-index: 90; pointer-events: none;
  background: var(--container-high); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  padding: 8px 10px; font-family: 'JetBrains Mono', monospace; font-size: 12.5px;
  box-shadow: none; white-space: nowrap;
}

/* pager first/last share ghost button styling already defined */

/* ---------- diagram primitives ---------- */
.diagram { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut-wrap { position: relative; width: 230px; height: 230px; flex: none; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-seg { cursor: crosshair; transition: opacity 120ms ease; }
.donut-seg:hover { opacity: .82; }
.legend { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.legend-chip { width: 10px; height: 10px; border-radius: 9999px; flex: none; }
.legend-val { margin-left: auto; font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--text-secondary); }

/* vertical diverging bars */
.vbars-wrap { position: relative; }
.vbar-hit { fill: transparent; cursor: crosshair; }

/* ---------- route transitions ---------- */
@keyframes pageEnter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.page-enter { animation: pageEnter 260ms ease-out both; }

.route-loading::after {
  content: ""; display: block; height: 3px; border-radius: 9999px;
  background: linear-gradient(90deg, transparent, #EF5350, transparent);
  animation: shimmer 1s ease-in-out infinite;
}
@keyframes shimmer { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- scoped table search ---------- */
.tsearch { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; max-width: 460px; }
.tsearch input {
  flex: 1; font-family: 'JetBrains Mono', monospace; font-size: 14px;
  background: var(--bg-deep); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--r-sm);
  padding: 8px 12px;
}
.tsearch input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(239,83,80,.35); }
.tsearch .ts-clear {
  flex: none; width: 32px; height: 32px; border-radius: var(--r-sm);
  border: 1px solid var(--outline); background: transparent; color: var(--muted);
  cursor: pointer; font-size: 16px; line-height: 1;
}
.tsearch .ts-clear:hover { color: var(--accent-text); border-color: var(--accent-text); }
.tsearch .ts-clear[hidden] { display: none; }

/* ---------- flip card upgrades ---------- */
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-hl { list-style: none; margin: 8px 0 0; padding: 0; }
.flip-hl li { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; color: var(--muted); }
.flip-hl li::before { content: ""; width: 5px; height: 5px; border-radius: 9999px; background: var(--accent); flex: none; margin-top: 6px; }
.flip-cta { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-text); font-size: 13px; font-weight: 600; margin-top: auto; }

/* ---------- donut polish ---------- */
@keyframes segIn { from { opacity: 0; } to { opacity: 1; } }
.donut-seg { animation: segIn .45s ease-out both; }
.donut-seg:hover { filter: brightness(1.18); }

/* ---------- orbital nav (ported radial-orbital-timeline, themed) ---------- */
.orbital {
  position: relative; width: 100%; height: 480px; overflow: hidden;
  border: 1px solid var(--outline); border-radius: var(--r-lg);
  background: var(--bg-deep); margin: 24px 0 8px;
}
@media (max-width: 640px) { .orbital { height: 380px; } }
.orbital-stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; perspective: 1000px; }
.orb-center {
  position: absolute; width: 64px; height: 64px; border-radius: 9999px; z-index: 10;
  background: radial-gradient(circle at 32% 28%, #EF5350 0%, #7a2e2d 58%, var(--card) 100%);
}
.orb-center::after {
  content: ""; position: absolute; inset: 18px; border-radius: 9999px;
  background: var(--bg-deep); opacity: .9;
}
@keyframes orbPing { 75%, 100% { transform: scale(2); opacity: 0; } }
.orb-ping {
  position: absolute; inset: -6px; border-radius: 9999px;
  border: 1px solid var(--accent);
  animation: orbPing 1.8s cubic-bezier(0, 0, .2, 1) infinite; opacity: .55; pointer-events: none;
}
.orb-ring {
  position: absolute; width: 420px; height: 420px; border-radius: 9999px;
  border: 1px solid color-mix(in srgb, var(--outline-variant) 35%, transparent);
  pointer-events: none;
}
@media (max-width: 900px) { .orb-ring { width: 300px; height: 300px; } }
.orb-node {
  position: absolute; left: 50%; top: 50%; margin: -22px 0 0 -22px; width: 44px;
  cursor: pointer; text-align: center;
  transition: transform .7s cubic-bezier(.22, 1, .36, 1), opacity .5s ease;
}
.orb-node-icon {
  width: 44px; height: 44px; border-radius: 9999px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 2px solid var(--outline); color: var(--text-secondary);
  margin: 0 auto; transition: background .25s ease, border-color .25s ease, color .25s ease, box-shadow .25s ease, transform .3s ease;
}
.orb-node:hover .orb-node-icon {
  border-color: var(--accent); background: var(--accent); color: #fff;
  box-shadow: 0 0 18px rgba(239, 83, 80, .45);
}
.orb-node.expanded .orb-node-icon {
  transform: scale(1.28); border-color: var(--accent); background: var(--accent);
  color: #fff; box-shadow: 0 0 26px rgba(239, 83, 80, .5);
}
.orb-node-title {
  margin-top: 7px; font-size: 12px; font-weight: 600; letter-spacing: .03em;
  color: var(--muted); white-space: nowrap;
  transition: color .3s ease;
}
.orb-node:hover .orb-node-title, .orb-node.expanded .orb-node-title { color: var(--text); }
.orb-card {
  position: absolute; top: 66px; left: 50%; transform: translateX(-50%);
  width: 232px; z-index: 70; text-align: left;
  background: color-mix(in srgb, var(--card) 94%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--outline); border-radius: var(--r-lg); padding: 12px 14px;
}
.orb-card[hidden] { display: none; }
.orb-card .orb-desc { font-size: 12.5px; color: var(--text-secondary); line-height: 1.45; margin: 0 0 8px; }
.orb-card .stat-line {
  display: flex; justify-content: space-between; font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px; color: var(--muted); margin-bottom: 4px;
}
.orb-card .stat-line b { color: var(--text-secondary); font-weight: 500; }
.orb-energy { height: 4px; background: var(--bg-deep); border-radius: 9999px; overflow: hidden; }
.orb-energy > i { display: block; height: 100%; background: linear-gradient(90deg, #EF5350, #FCD34D); }
.orb-cta {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 10px;
  color: var(--accent-text); font-size: 12.5px; font-weight: 600; text-decoration: none;
}
.orb-cta svg { transition: transform .2s ease; }
.orb-cta:hover svg { transform: translateX(2px); }
@media (prefers-reduced-motion: reduce) {
  .orb-ping { animation: none; opacity: .3; }
  .orb-node { transition: none; }
}

/* ---------- unified chart module ---------- */
@keyframes barGrowY { from { transform: scaleY(0); } }
@keyframes barGrowX { from { transform: scaleX(0); } }
.bar-rect { transform-box: fill-box; }
.bar-rect.gy { transform-origin: bottom center; animation: barGrowY .48s ease-out both; }
.bar-rect.gx { transform-origin: left center; animation: barGrowX .48s ease-out both; }
@media (prefers-reduced-motion: reduce) { .bar-rect.gy, .bar-rect.gx { animation: none; } }
.chart-legend { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-secondary); }
.chart-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
