/* 6529 Network State — Minimalist Modern tokens, app shell, components */

/* ---------- Tokens ---------- */

:root {
  --background: #FAFAFA;
  --foreground: #0F172A;
  --muted: #F1F5F9;
  --muted-foreground: #64748B;
  --accent: #0052FF;
  --accent-secondary: #4D7CFF;
  --accent-foreground: #FFFFFF;
  --border: #E2E8F0;
  --card: #FFFFFF;
  --ring: #0052FF;
  --inverted-bg: #0F172A;
  --inverted-fg: #FFFFFF;
  --inverted-muted: rgba(255, 255, 255, 0.62);
  --dot-color: rgba(255, 255, 255, 1);

  --gradient: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  --accent-5: rgba(0, 82, 255, 0.05);
  --accent-8: rgba(0, 82, 255, 0.08);
  --accent-30: rgba(0, 82, 255, 0.30);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.10);
  --shadow-accent: 0 4px 14px rgba(0, 82, 255, 0.25);
  --shadow-accent-lg: 0 8px 24px rgba(0, 82, 255, 0.35);

  --font-display: 'Calistoga', Georgia, serif;
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', Menlo, Consolas, monospace;

  --radius: 12px;
  --radius-lg: 16px;
  --sidebar-w: 248px;
  --gap: 20px;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #09090B;
    --foreground: #FAFAFA;
    --muted: #18181B;
    --muted-foreground: #A1A1AA;
    --accent: #4D7CFF;
    --accent-secondary: #7C9CFF;
    --border: #27272A;
    --card: #111113;
    --ring: #4D7CFF;
    --inverted-bg: #FFFFFF;
    --inverted-fg: #0F172A;
    --inverted-muted: rgba(15, 23, 42, 0.62);
    --dot-color: rgba(15, 23, 42, 1);
    --accent-5: rgba(77, 124, 255, 0.07);
    --accent-8: rgba(77, 124, 255, 0.12);
    --accent-30: rgba(77, 124, 255, 0.35);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --background: #09090B;
  --foreground: #FAFAFA;
  --muted: #18181B;
  --muted-foreground: #A1A1AA;
  --accent: #4D7CFF;
  --accent-secondary: #7C9CFF;
  --border: #27272A;
  --card: #111113;
  --ring: #4D7CFF;
  --inverted-bg: #FFFFFF;
  --inverted-fg: #0F172A;
  --inverted-muted: rgba(15, 23, 42, 0.62);
  --dot-color: rgba(15, 23, 42, 1);
  --accent-5: rgba(77, 124, 255, 0.07);
  --accent-8: rgba(77, 124, 255, 0.12);
  --accent-30: rgba(77, 124, 255, 0.35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}

/* ---------- Base ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

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

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px; }

.mono { font-family: var(--font-mono); }
.dim { color: var(--muted-foreground); }
.hidden { display: none !important; }

.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100dvh;
  position: relative;
}

/* Ambient radial glow, top-right */
.app::before {
  content: '';
  position: absolute;
  top: -240px;
  right: -240px;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.05;
  filter: blur(150px);
  pointer-events: none;
}

/* Sidebar */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 24px 16px;
  border-right: 1px solid var(--border);
  background: var(--card);
  position: relative;
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 22px;
  color: var(--foreground);
}
.brand:hover { color: var(--foreground); }

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--gradient);
  box-shadow: var(--shadow-accent);
  flex-shrink: 0;
  position: relative;
}
.brand-mark::after {
  content: '';
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  border: 2.5px solid #fff;
}

.brand-text {
  display: flex;
  flex-direction: column;
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1;
}
.brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  margin-top: 5px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted-foreground);
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease-out;
}
.nav-item:hover { background: var(--muted); color: var(--foreground); }
.nav-item[aria-current="page"] { background: var(--accent-8); color: var(--accent); }

.nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--muted);
  color: var(--muted-foreground);
  transition: all 0.2s ease-out;
  flex-shrink: 0;
}
.nav-icon svg { width: 16px; height: 16px; }
.nav-item:hover .nav-icon { transform: scale(1.06); }
.nav-item[aria-current="page"] .nav-icon {
  background: var(--gradient);
  color: var(--accent-foreground);
  box-shadow: var(--shadow-accent);
}

.sidebar-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
}

.snapshot { font-size: 11px; color: var(--muted-foreground); line-height: 1.5; }

/* Badge (section label) */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--accent-30);
  background: var(--accent-5);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  width: fit-content;
  white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.badge-live { padding: 6px 12px; }

.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
}

/* Main */

.main {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  padding: 24px 28px 28px;
  gap: 20px;
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.topbar-title { display: flex; flex-direction: column; gap: 12px; }

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(26px, 2.6vw, 36px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.topbar-actions { display: flex; gap: 8px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--muted-foreground);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease-out;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { color: var(--foreground); border-color: var(--accent-30); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.icon-btn:active { transform: scale(0.98); }
.icon-btn .icon-moon { display: none; }
:root[data-theme="dark"] .icon-btn .icon-sun { display: none; }
:root[data-theme="dark"] .icon-btn .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-btn .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-btn .icon-moon { display: block; }
}

/* ---------- Views ---------- */

.view {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: var(--gap);
  min-height: 0;
}

/* Staggered entrance */
.view > * > *, .view > .toolbar, .view > .scroll-area {
  animation: fadeInUp 0.7s var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 70ms + 40ms);
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
  transition: box-shadow 0.3s ease-out, transform 0.3s ease-out;
}
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--accent-5), transparent 60%);
  opacity: 0;
  transition: opacity 0.3s ease-out;
  pointer-events: none;
}
.card:hover { box-shadow: var(--shadow-xl); transform: translateY(-2px); }
.card:hover::after { opacity: 1; }

/* Stats */

.stats { display: grid; gap: var(--gap); }
.stats-3 { grid-template-columns: 1.3fr 1fr 1fr; }
.stats-4 { grid-template-columns: 1.3fr 1fr 1fr 1fr; }

.stat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 22px 24px;
  min-width: 0;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}

.stat-value {
  font-family: var(--font-display);
  font-size: clamp(30px, 2.6vw, 40px);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-foot { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.stat-sub { font-size: 12px; color: var(--muted-foreground); }

/* Inverted hero stat with dot texture and rotating ring */

.stat-hero {
  background: var(--inverted-bg);
  color: var(--inverted-fg);
  border-color: transparent;
}
.stat-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, var(--dot-color) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.05;
  pointer-events: none;
}
.stat-hero::after { background: radial-gradient(circle at 100% 0%, var(--accent-30), transparent 55%); opacity: 0.6; }
.stat-hero .stat-label { color: var(--inverted-muted); }
.stat-hero .stat-sub { color: var(--inverted-muted); }
.stat-hero .stat-value { font-size: clamp(36px, 3.2vw, 52px); }
.stat-hero > * { position: relative; z-index: 1; }

.stat-hero .ring {
  position: absolute;
  right: -44px;
  bottom: -44px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1.5px dashed var(--accent-secondary);
  opacity: 0.55;
  animation: spin 60s linear infinite;
  z-index: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Trend badge */

.trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: var(--gradient);
  color: var(--accent-foreground);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  box-shadow: var(--shadow-accent);
}
.trend:empty { display: none; }
.trend svg { width: 12px; height: 12px; }
.trend.down { background: var(--muted); color: var(--muted-foreground); box-shadow: none; }
.stat-hero .trend.down { background: rgba(127, 127, 127, 0.2); color: var(--inverted-fg); }

/* Panels */

.panels { display: grid; gap: var(--gap); min-height: 0; }
.panels-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panels-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panels-overview { grid-template-columns: 1.1fr 1fr 0.75fr; }
.panels-economy { grid-template-columns: 1.6fr 0.8fr; }

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 22px;
  margin: 0;
  min-height: 0;
  min-width: 0;
}

.panel figcaption, .panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.panel-title { font-weight: 600; font-size: 14px; letter-spacing: -0.01em; }
.panel figcaption .mono, .panel-head .mono { font-size: 11px; }

.chart-plot { flex: 1 1 auto; min-height: 0; position: relative; }
.chart-plot svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-plot .grid { stroke: var(--border); stroke-width: 1; }
.chart-plot .axis-label { font-family: var(--font-mono); font-size: 11px; fill: var(--muted-foreground); }
.chart-plot .value-label { font-family: var(--font-mono); font-size: 11px; fill: var(--foreground); }
.chart-plot .series-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-plot .series-area { fill: url(#areaFill); }
.chart-plot .series-end { fill: var(--accent); stroke: var(--card); stroke-width: 2; }
.chart-plot .bar { fill: url(#barFill); }
.chart-plot .bar.ytd { opacity: 0.45; }
.chart-plot .crosshair { stroke: var(--muted-foreground); stroke-width: 1; stroke-dasharray: 2 3; pointer-events: none; }
.chart-plot .hover-dot { fill: var(--accent); stroke: var(--card); stroke-width: 2; pointer-events: none; }
.chart-plot .hit { fill: transparent; cursor: crosshair; }
.chart-plot .skeleton { fill: var(--muted); }

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--foreground);
  color: var(--background);
  font-size: 12px;
  white-space: nowrap;
  transform: translate(-50%, calc(-100% - 12px));
  box-shadow: var(--shadow-lg);
}

/* Side panel key/value lists */

.side { gap: 14px; overflow: auto; }
.side .panel-head:not(:first-child) { margin-top: 6px; }

.kv-list { display: flex; flex-direction: column; gap: 6px; }
.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--muted);
}
.kv .k { font-size: 12px; color: var(--muted-foreground); }
.kv .v { font-family: var(--font-display); font-size: 20px; line-height: 1; font-variant-numeric: tabular-nums; }

/* ---------- Dashboard view ---------- */

.toolbar { display: flex; flex-direction: column; gap: 10px; }
.toolbar-note { margin: 0; font-size: 13px; color: var(--muted-foreground); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }

.chip {
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease-out;
}
.chip:hover { color: var(--foreground); border-color: var(--accent-30); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.chip[aria-selected="true"] { background: var(--gradient); color: var(--accent-foreground); border-color: transparent; box-shadow: var(--shadow-accent); }

.scroll-area { min-height: 0; overflow: auto; padding: 2px; margin: -2px; }

.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }

.card.entry {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  min-height: 190px;
}
.card.entry.placeholder { border-style: dashed; box-shadow: none; }

.entry-head { display: flex; align-items: center; gap: 12px; }

.entry-pfp {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--gradient);
  flex-shrink: 0;
  object-fit: cover;
  box-shadow: var(--shadow-accent);
  transition: transform 0.3s ease-out;
}
.placeholder .entry-pfp { background: var(--muted); box-shadow: none; }
.card.entry:hover .entry-pfp { transform: scale(1.08); }

.entry-name { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.entry-handle { font-family: var(--font-mono); font-size: 11px; color: var(--muted-foreground); }
.entry-handle a { color: inherit; }
.entry-handle a:hover { color: var(--accent); }

.entry-tagline { font-size: 13px; color: var(--muted-foreground); flex-grow: 1; line-height: 1.6; text-wrap: pretty; }

.entry-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

.entry-cat {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  padding: 5px 10px;
  border: 1px solid var(--accent-30);
  background: var(--accent-5);
  border-radius: 999px;
}

.entry-links { display: flex; gap: 4px; }
.entry-links a {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted-foreground);
  transition: all 0.2s ease-out;
}
.entry-links a:hover { color: var(--accent); background: var(--accent-8); }
.entry-links svg { width: 16px; height: 16px; }

.empty { margin: 0; color: var(--muted-foreground); font-size: 13px; }

/* ---------- Responsive ---------- */

@media (max-width: 1180px) {
  .stats-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-hero { grid-column: 1 / -1; }
  .panels-overview { grid-template-columns: 1fr 1fr; }
  .panels-overview .side { grid-column: 1 / -1; }
  .panels-3 { grid-template-columns: 1fr 1fr; }
  .panels-3 > :last-child { grid-column: 1 / -1; }
  .view { overflow: auto; grid-template-rows: auto auto; }
  .panels .chart { min-height: 240px; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; min-height: 100dvh; }
  .app::before { display: none; }

  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
    border-right: 0;
    border-top: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
  }
  .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; gap: 0; }
  .nav-item { flex-direction: column; gap: 4px; height: 52px; padding: 0 6px; font-size: 10px; flex: 1; }
  .nav-icon { width: 26px; height: 26px; }

  .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); gap: 16px; }
  .topbar { align-items: flex-start; }
  .view { overflow: visible; }

  .stats-3, .stats-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-hero { grid-column: 1 / -1; }
  .stat { padding: 16px 18px; }
  .stat-value { font-size: 28px; }
  .stat-hero .stat-value { font-size: 40px; }

  .panels-2, .panels-3, .panels-overview, .panels-economy { grid-template-columns: 1fr; }
  .panels-3 > :last-child, .panels-overview .side { grid-column: auto; }
  .panels .chart { min-height: 220px; }
  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .pulse, .stat-hero .ring { animation: none; }
  .view > * > *, .view > .toolbar, .view > .scroll-area { animation: none; }
  .card, .chip, .icon-btn, .nav-item, .nav-icon, .entry-pfp { transition: none; }
}
