/* ── Fonts (APAN Design System: Inter + JetBrains Mono) ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─────────────────────────────────────────────
   Light theme (DEFAULT — APAN Design System)
   ───────────────────────────────────────────── */
:root {
  --bg:      #FFFFFF;          /* page canvas */
  --sf:      #FAFAFB;          /* card surface */
  --sf2:     #F4F4F5;          /* nested / chips */
  --bd:      #EAEAEC;          /* default border */
  --bd2:     #D6D6DA;          /* strong border */
  --ac:      #2C5BFF;          /* accent blue (▲ delta, links, focus) */
  --ac-dim:  rgba(44,91,255,.10);
  --ac2:     #FF2BAA;          /* magenta (▼ delta, danger highlight) */
  --gr:      #10b981;          /* success / OK state */
  --rd:      #FF2BAA;          /* danger = magenta per design system */
  --yw:      #F5A524;          /* warn / amber */
  --pu:      #0E0E0F;          /* brand pure-dark (primary CTA) */
  --tx:      #0E0E0F;          /* primary text, KPI numbers */
  --tx2:     #5A5A5E;          /* secondary text, labels */
  --mu:      #9A9A9F;          /* placeholder, disabled */
  --fn:      'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:    'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --radius:  16px;             /* card / tile */
  --radius-s: 10px;            /* input / small */
  --shadow:  0 1px 2px rgba(15,18,36,.04), 0 1px 0 rgba(15,18,36,.02);
  --shadow-hover: 0 6px 24px rgba(15,18,36,.08);
  --shadow-pop:   0 12px 40px rgba(15,18,36,.12);
  --hdr1:    #FFFFFF;
  --hdr2:    #FAFAFB;
}

/* ─────────────────────────────────────────────
   Dark theme — opt-in via body.theme-dark
   (legacy class .theme-light retained as no-op
    for backward compat with stored prefs)
   ───────────────────────────────────────────── */
body.theme-dark {
  --bg:      #0D1224;
  --sf:      #171C32;
  --sf2:     #1F2541;
  --bd:      #262C49;
  --bd2:     #3A4170;
  --ac:      #2C5BFF;
  --ac-dim:  rgba(44,91,255,.18);
  --ac2:     #FF2BAA;
  --gr:      #10b981;
  --rd:      #FF2BAA;
  --yw:      #F5A524;
  --pu:      #FFFFFF;          /* invert: light primary CTA on dark */
  --tx:      #F2F3F8;
  --tx2:     #9CA0B5;
  --mu:      #5A607A;
  --hdr1:    #0D1224;
  --hdr2:    #171C32;
  --shadow:  inset 0 1px 0 rgba(255,255,255,.04);
  --shadow-hover: 0 8px 32px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.04);
  --shadow-pop:   0 16px 48px rgba(0,0,0,.55);
}

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  min-width: 0;
}

html, body {
  height: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--tx);
  font-family: var(--fn);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

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

img, svg { display: block; max-width: 100%; }

/* ── Typography (design system scale) ── */
h1 { font-size: 24px; font-weight: 600; letter-spacing: -.3px; line-height: 1.25; }
h2 { font-size: 18px; font-weight: 600; letter-spacing: -.2px; }
h3 { font-size: 15px; font-weight: 600; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── Section header (UPPERCASE per design system) ── */
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--tx2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--bd);
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bd2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--mu); }

/* ── Utility ── */
.up   { color: var(--ac); }   /* ▲ delta = blue per design system */
.dn   { color: var(--ac2); }  /* ▼ delta = magenta */
.muted{ color: var(--mu); }
.text-mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.hidden { display: none !important; }
.flex   { display: flex; }
.gap-6  { gap: 6px; }
.gap-8  { gap: 8px; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ── Animation (design system: 150ms ease-out, no bounce) ── */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .3; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Loader overlay ── */
#pageLoader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  color: var(--tx2);
}
#pageLoader.hidden { display: none; }
.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bd);
  border-top-color: var(--ac);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

/* Тихий индикатор обновления — без полноэкранного оверлея */
.sync-busy { animation: pulse 1s ease-in-out infinite; color: var(--ac); }
.is-busy { opacity: .7; pointer-events: none; }
