/* ============================================================
   GFK Аналитика — Design Tokens
   Dark, data-dense, Linear/Vercel-influenced
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Geist:wght@300;400;500;600;700&family=Geist+Mono:wght@400;500;600&display=swap');

:root {
  /* Surfaces */
  --bg:           #0d0f18;
  --bg-2:         #10131c;
  --surface:      #13161f;
  --surface-2:    #181c27;
  --raised:       #1c2030;
  --hover:        #20253a;

  /* Borders */
  --border:       rgba(255,255,255,0.06);
  --border-2:     rgba(255,255,255,0.10);
  --border-strong:rgba(255,255,255,0.14);

  /* Text */
  --text:         #e8eaf2;
  --text-2:       #aeb4c6;
  --text-3:       #6b7184;
  --text-4:       #464c5e;

  /* Accents */
  --indigo:       #6366f1;
  --indigo-2:     #818cf8;
  --indigo-dim:   rgba(99,102,241,0.14);
  --cyan:         #06b6d4;
  --cyan-2:       #22d3ee;
  --cyan-dim:     rgba(6,182,212,0.14);
  --green:        #22c55e;
  --green-dim:    rgba(34,197,94,0.14);
  --amber:        #f59e0b;
  --amber-dim:    rgba(245,158,11,0.14);
  --red:          #ef4444;
  --red-dim:      rgba(239,68,68,0.14);
  --violet:       #a855f7;
  --violet-dim:   rgba(168,85,247,0.14);
  --pink:         #ec4899;
  --pink-dim:     rgba(236,72,153,0.14);

  /* Theme-adapting tints */
  --track:        rgba(255,255,255,0.04);
  --grid:         rgba(255,255,255,0.05);
  --row-stripe:   rgba(255,255,255,0.018);
  --tooltip-bg:   #0d0f18;
  --metric-grad:  linear-gradient(180deg, #e8eaf2, #6366f1);
  --canvas-bg:    #f0eee9;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* Shadows */
  --shadow-card: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.3);
  --shadow-pop:  0 16px 40px -12px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.06);

  font-feature-settings: "ss01","cv11","tnum";
}

/* ====== Light theme overrides ====== */
[data-theme="light"] {
  --bg:           #fafaf9;
  --bg-2:         #f5f5f4;
  --surface:      #ffffff;
  --surface-2:    #f7f7f8;
  --raised:       #ffffff;
  --hover:        #f1f1f3;

  --border:       rgba(15, 17, 28, 0.08);
  --border-2:     rgba(15, 17, 28, 0.12);
  --border-strong:rgba(15, 17, 28, 0.18);

  --text:         #0d0f18;
  --text-2:       #3d4356;
  --text-3:       #6b7184;
  --text-4:       #9aa0b2;

  --indigo:       #6366f1;
  --indigo-2:     #4f46e5;
  --indigo-dim:   rgba(99,102,241,0.10);
  --cyan:         #0891b2;
  --cyan-2:       #0e7490;
  --cyan-dim:     rgba(6,182,212,0.12);
  --green:        #16a34a;
  --green-dim:    rgba(34,197,94,0.13);
  --amber:        #d97706;
  --amber-dim:    rgba(245,158,11,0.16);
  --red:          #dc2626;
  --red-dim:      rgba(239,68,68,0.10);
  --violet:       #7c3aed;
  --violet-dim:   rgba(168,85,247,0.10);
  --pink:         #db2777;
  --pink-dim:     rgba(236,72,153,0.10);

  --track:        rgba(15, 17, 28, 0.06);
  --grid:         rgba(15, 17, 28, 0.07);
  --row-stripe:   rgba(15, 17, 28, 0.018);
  --tooltip-bg:   #ffffff;
  --metric-grad:  linear-gradient(180deg, #0d0f18, #6366f1);
  --canvas-bg:    #e9e7e2;

  --shadow-card:  0 1px 0 rgba(255,255,255,0.6) inset, 0 1px 2px rgba(15,17,28,0.05);
  --shadow-pop:   0 16px 40px -12px rgba(15,17,28,0.18), 0 0 0 1px rgba(15,17,28,0.06);
}

* { box-sizing: border-box; }

body {
  font-family: 'Geist', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01","cv11";
}

.mono { font-family: 'Geist Mono', ui-monospace, monospace; font-feature-settings: "tnum","zero"; }
.tnum { font-variant-numeric: tabular-nums; }

/* ====== Screen shell — fixed 1440 desktop frame ====== */
.screen {
  width: 1440px;
  background: var(--bg);
  color: var(--text);
  position: relative;
  font-family: 'Geist', sans-serif;
  overflow: hidden;
}
.screen-mobile {
  width: 390px;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist', sans-serif;
  position: relative;
  overflow: hidden;
}

/* ====== Sidebar ====== */
.sidebar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 224px;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 18px 12px 16px;
  display: flex; flex-direction: column;
  z-index: 5;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-glyph {
  width: 28px; height: 28px;
  border-radius: 7px;
  background: conic-gradient(from 220deg, var(--indigo) 0deg, var(--cyan) 180deg, var(--indigo) 360deg);
  position: relative;
  display: grid; place-items: center;
}
.brand-glyph::after {
  content: ""; position: absolute; inset: 4px;
  border-radius: 4px;
  background: var(--bg-2);
}
.brand-glyph svg { position: relative; z-index: 1; }
.brand-name {
  font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11px; color: var(--text-3); letter-spacing: 0.04em; text-transform: uppercase;
  margin-top: 1px;
}

.nav-section {
  font-size: 10.5px; color: var(--text-4); letter-spacing: 0.08em;
  text-transform: uppercase; padding: 14px 10px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px;
  border-radius: 7px;
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  margin-bottom: 1px;
  position: relative;
}
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active {
  background: var(--indigo-dim);
  color: var(--text);
  font-weight: 500;
}
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 2px; background: var(--indigo); border-radius: 0 2px 2px 0;
}
.nav-item .nav-ic { color: var(--text-3); }
.nav-item.active .nav-ic { color: var(--indigo-2); }
.nav-badge {
  margin-left: auto;
  font-size: 10.5px; color: var(--text-3);
  background: var(--surface-2);
  padding: 1px 6px; border-radius: 999px;
  font-family: 'Geist Mono', monospace;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px;
  border-radius: 8px;
  margin-bottom: 4px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--cyan));
  display: grid; place-items: center;
  font-size: 11px; font-weight: 600; color: #0d0f18;
}
.user-name { font-size: 12.5px; }
.user-role { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

/* ====== Top bar / filter row ====== */
.topbar {
  padding: 18px 32px 0 32px;
  display: flex; align-items: flex-end; justify-content: space-between;
}
.crumb {
  font-size: 11.5px; color: var(--text-3); letter-spacing: 0.04em;
  text-transform: uppercase; margin-bottom: 6px;
}
.page-title {
  font-size: 22px; font-weight: 600; letter-spacing: -0.015em;
}
.page-sub {
  font-size: 13px; color: var(--text-3); margin-top: 4px;
}

.filterbar {
  margin: 18px 32px 0;
  display: flex; align-items: center; gap: 8px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.filter-chunk {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  user-select: none;
  border: 1px solid transparent;
}
.filter-chunk:hover { background: var(--hover); color: var(--text); }
.filter-label {
  color: var(--text-4);
  font-size: 11px; letter-spacing: 0.04em;
  text-transform: uppercase;
}
.filter-value { font-weight: 500; color: var(--text); }
.filter-divider { width: 1px; background: var(--border); align-self: stretch; margin: 2px 0; }

.seg {
  display: flex; padding: 3px;
  background: var(--surface-2); border-radius: 8px;
  border: 1px solid var(--border);
}
.seg-item {
  padding: 5px 11px;
  font-size: 12px;
  color: var(--text-3);
  border-radius: 6px;
  cursor: pointer;
}
.seg-item.active {
  background: var(--raised);
  color: var(--text);
  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 1px 2px rgba(0,0,0,0.4);
}

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  font-size: 12.5px; font-weight: 500;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { background: var(--hover); }
.btn-primary {
  background: var(--indigo);
  color: white;
  border-color: var(--indigo);
}
.btn-primary:hover { background: var(--indigo-2); }
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

/* ====== Cards / panels ====== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  position: relative;
}
.card-pad { padding: 18px 20px; }

.card-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px 0;
}
.card-title {
  font-size: 13px; font-weight: 500; color: var(--text);
  letter-spacing: -0.005em;
}
.card-sub {
  font-size: 11.5px; color: var(--text-3); margin-top: 2px;
}
.card-actions { display: flex; gap: 6px; }

/* ====== KPI card ====== */
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px 16px;
  position: relative;
  overflow: hidden;
}
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text-3); font-size: 11.5px; letter-spacing: 0.02em;
  text-transform: uppercase;
  font-weight: 500;
}
.kpi-icon {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 6px;
  color: var(--text-3);
  background: var(--track);
}
.kpi-value {
  font-size: 30px; font-weight: 600;
  letter-spacing: -0.025em;
  margin-top: 10px;
  font-family: 'Geist', sans-serif;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.kpi-unit {
  font-size: 14px; color: var(--text-3); font-weight: 500;
  margin-left: 4px;
}
.kpi-foot {
  display: flex; align-items: center; gap: 8px;
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-3);
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: 'Geist Mono', monospace;
  font-weight: 500; font-size: 11px;
  padding: 2px 6px; border-radius: 5px;
}
.kpi-delta.up { color: var(--green); background: var(--green-dim); }
.kpi-delta.down { color: var(--red); background: var(--red-dim); }
.kpi-spark { position: absolute; right: 0; bottom: 0; opacity: .9; }

/* ====== Tables ====== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl thead th {
  text-align: left;
  font-size: 10.5px; color: var(--text-3);
  letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 500;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--surface);
  white-space: nowrap;
}
.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  white-space: nowrap;
}
.tbl tbody tr:hover td {
  background: var(--row-stripe);
  color: var(--text);
}
.tbl .num { font-variant-numeric: tabular-nums; text-align: right; font-family: 'Geist Mono', monospace; font-size: 12px; color: var(--text); }
.tbl .strong { color: var(--text); font-weight: 500; }

.th-sort {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer;
}
.th-sort.active { color: var(--text); }

/* ====== Badges ====== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  font-family: 'Geist Mono', monospace;
  letter-spacing: 0.02em;
}
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.b-ok    { color: var(--green); background: var(--green-dim); }
.badge.b-warn  { color: var(--amber); background: var(--amber-dim); }
.badge.b-err   { color: var(--red);   background: var(--red-dim); }
.badge.b-info  { color: var(--cyan);  background: var(--cyan-dim); }
.badge.b-muted { color: var(--text-3);background: var(--track); }
.badge.b-pri   { color: var(--indigo-2); background: var(--indigo-dim); }
.badge.b-vio   { color: var(--violet);   background: var(--violet-dim); }

/* ====== Share / progress bars ====== */
.share-bar {
  position: relative;
  height: 6px;
  background: var(--track);
  border-radius: 3px;
  overflow: hidden;
}
.share-bar > span {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--indigo), var(--cyan));
}

/* ====== Rank dot (colored) ====== */
.rank-dot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  font-family: 'Geist Mono', monospace;
  font-size: 10.5px; font-weight: 600;
  color: var(--bg);
  margin-right: 8px;
}

/* ====== Scrollbar (subtle) ====== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ====== Misc helpers ====== */
.row { display: flex; }
.col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; } .gap-6 { gap: 24px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; }
.flex-1 { flex: 1; }
.center { display: grid; place-items: center; }

.divider { height: 1px; background: var(--border); }

/* Subtle vignette behind hero metrics */
.glow-indigo::before {
  content: ""; position: absolute; inset: -1px;
  background: radial-gradient(120% 60% at 0% 0%, rgba(99,102,241,0.10), transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}
.glow-cyan::before {
  content: ""; position: absolute; inset: -1px;
  background: radial-gradient(120% 60% at 0% 0%, rgba(6,182,212,0.10), transparent 60%);
  border-radius: inherit;
  pointer-events: none;
}

/* Stripe placeholder for unset cells */
.stripe-ph {
  background-image: repeating-linear-gradient(
    -45deg, var(--row-stripe) 0 6px, transparent 6px 12px
  );
}
