/* =====================================================================
   Дашборд CRM — Soft Structuralism + Ethereal Glass accents
   Шрифт: Geist (variable). Палитра: warm cream → ink → blue accent.
   Архитектура карточек: Double-Bezel (outer shell + inner core).
   Анимации: cubic-bezier(0.32, 0.72, 0, 1) — премиальное замедление.
   ===================================================================== */

:root {
  --bz-shell: rgba(24, 24, 27, 0.04);
  --bz-ring:  rgba(24, 24, 27, 0.06);
  --bz-inner-bg: #FFFFFF;
  --bz-inset: inset 0 1px 1.5px rgba(255, 255, 255, 0.9), inset 0 -1px 1px rgba(24, 24, 27, 0.02);
  --bz-shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 8px 24px -8px rgba(24, 24, 27, 0.06);
  --bz-shadow-hover: 0 2px 4px rgba(24, 24, 27, 0.06), 0 16px 40px -12px rgba(24, 24, 27, 0.12);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

html {
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Geist', system-ui, sans-serif;
  letter-spacing: -0.005em;
}

/* ===== Шум как фиксированный слой ===== */
.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.022;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
}

/* ===== Декоративные ауры ===== */
.aura {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  width: 720px;
  height: 720px;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
}
.aura-blue {
  top: -300px;
  left: -200px;
  background: radial-gradient(circle, #60A5FA, transparent 70%);
}
.aura-rose {
  top: 200px;
  right: -300px;
  background: radial-gradient(circle, #F0ABFC, transparent 70%);
  opacity: 0.10;
}

/* ===== Eyebrow ===== */
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.04);
  color: #57534E;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-feature-settings: 'tnum';
}

/* ===== Double-Bezel ===== */
.bezel {
  position: relative;
  padding: 5px;
  border-radius: 28px;
  background: var(--bz-shell);
  box-shadow: 0 0 0 1px var(--bz-ring), var(--bz-shadow);
  transition: box-shadow 600ms var(--ease), transform 600ms var(--ease);
}
.bezel.clickable {
  cursor: pointer;
}
.bezel.clickable:hover {
  box-shadow: 0 0 0 1px var(--bz-ring), var(--bz-shadow-hover);
  transform: translateY(-1px);
}
.bezel.clickable:active {
  transform: translateY(0) scale(0.997);
}
.bezel__inner {
  background: var(--bz-inner-bg);
  border-radius: 23px;
  box-shadow: var(--bz-inset);
  overflow: hidden;
}

/* ===== KPI card ===== */
.kpi-card {
  padding: 24px 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-eyebrow {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #78716C;
  font-weight: 500;
}
.kpi-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.025em;
  font-feature-settings: 'tnum', 'ss01';
  line-height: 1.05;
  color: #18181B;
  margin-top: 4px;
}
.kpi-sub {
  font-size: 12px;
  color: #78716C;
  font-feature-settings: 'tnum';
}

/* ===== Pills / Chips ===== */
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(24, 24, 27, 0.08);
  background: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
  color: #3F3D3A;
  cursor: pointer;
  transition: all 300ms var(--ease);
  box-shadow: 0 1px 0 rgba(24, 24, 27, 0.02);
}
.chip:hover {
  background: #FAFAFA;
  border-color: rgba(24, 24, 27, 0.12);
}
.chip.active {
  background: #18181B;
  color: #FAFAFA;
  border-color: #18181B;
}

.topic-chip {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(24, 24, 27, 0.08);
  background: #FAFAFA;
  font-size: 11px;
  font-weight: 500;
  color: #57534E;
  cursor: pointer;
  transition: all 280ms var(--ease);
  white-space: nowrap;
}
.topic-chip:hover {
  background: #F5F5F4;
  color: #18181B;
  border-color: rgba(24, 24, 27, 0.16);
}
.topic-chip.active {
  background: #DBEAFE;
  color: #1D4ED8;
  border-color: #93C5FD;
}
.topics-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.date-input {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid rgba(24, 24, 27, 0.10);
  background: #FFFFFF;
  font-size: 12px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  color: #18181B;
  outline: none;
  transition: border-color 240ms var(--ease);
}
.date-input:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.select-pill {
  padding: 6px 32px 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(24, 24, 27, 0.08);
  background: #FFFFFF;
  font-size: 12px;
  font-weight: 500;
  color: #18181B;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%2378716C' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  appearance: none;
}

.btn-mini {
  padding: 6px 14px;
  border-radius: 8px;
  background: #18181B;
  color: #FAFAFA;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 240ms var(--ease);
}
.btn-mini:hover { background: #27272A; }

.btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 6px 10px 18px;
  border-radius: 999px;
  background: #18181B;
  color: #FAFAFA;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all 400ms var(--ease);
}
.btn-pill:hover { background: #27272A; }
.btn-pill:active { transform: scale(0.985); }
.btn-pill__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: transform 360ms var(--ease), background-color 240ms var(--ease);
}
.btn-pill:hover .btn-pill__icon {
  background: rgba(255, 255, 255, 0.20);
  transform: rotate(-30deg);
}

/* ===== Tabs ===== */
.tab-bar {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.04);
  box-shadow: 0 0 0 1px var(--bz-ring);
  gap: 2px;
}
.tab {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: #57534E;
  cursor: pointer;
  transition: all 320ms var(--ease);
  letter-spacing: -0.005em;
}
.tab:hover { color: #18181B; }
.tab.active {
  background: #FFFFFF;
  color: #18181B;
  box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04), 0 4px 12px -4px rgba(24, 24, 27, 0.06);
}

/* ===== Воронка ===== */
.funnel-row {
  cursor: pointer;
  border-radius: 12px;
  padding: 8px;
  margin: -8px;
  transition: background-color 240ms var(--ease);
}
.funnel-row:hover { background: rgba(24, 24, 27, 0.03); }
.funnel-bar-track {
  position: relative;
  height: 26px;
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.04);
  overflow: hidden;
}
.funnel-bar-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #1E3A8A, #3B82F6 65%, #60A5FA);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
  transition: width 700ms var(--ease);
  will-change: width;
}

/* ===== Stage times ===== */
.stage-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}
.stage-bar-track {
  height: 6px;
  border-radius: 6px;
  background: rgba(24, 24, 27, 0.04);
  overflow: hidden;
}
.stage-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #D97706, #F59E0B);
  border-radius: 6px;
  transition: width 700ms var(--ease);
}

/* ===== Heatmap ===== */
.heatmap {
  display: grid;
  grid-template-columns: 28px repeat(24, minmax(0, 1fr));
  grid-template-rows: 18px repeat(7, minmax(20px, 24px));
  gap: 2px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 9px;
  color: #A8A29E;
}
.heatmap .hm-cell {
  border-radius: 3px;
  background: rgba(24, 24, 27, 0.04);
  transition: transform 200ms var(--ease), filter 200ms var(--ease);
  position: relative;
  cursor: pointer;
}
.heatmap .hm-cell:hover {
  transform: scale(1.4);
  filter: brightness(1.1);
  z-index: 5;
}
.heatmap .hm-cell[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: #18181B;
  color: #FAFAFA;
  font-family: 'Geist', sans-serif;
  font-size: 11px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}
.heatmap .hm-h, .heatmap .hm-d {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== Users list ===== */
.user-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 8px;
  border-radius: 10px;
  font-size: 13px;
  transition: background-color 240ms var(--ease);
}
.user-row:hover { background: rgba(24, 24, 27, 0.03); }
.user-row + .user-row { border-top: 1px solid rgba(24, 24, 27, 0.04); }
.user-metric {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-feature-settings: 'tnum';
  font-size: 12px;
  color: #57534E;
  text-align: right;
  min-width: 38px;
}

/* ===== Transitions list ===== */
.transition-row {
  display: grid;
  grid-template-columns: 1fr 40px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 8px;
  border-radius: 10px;
  font-size: 13px;
  transition: background-color 240ms var(--ease);
}
.transition-row + .transition-row { border-top: 1px solid rgba(24, 24, 27, 0.04); }
.transition-arrow {
  text-align: center;
  color: #A8A29E;
  font-family: 'Geist Mono';
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(24, 24, 27, 0.40);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: modalFadeIn 280ms var(--ease);
}
@keyframes modalFadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-window {
  width: min(960px, 100%);
  max-height: 85vh;
  animation: modalPop 380ms var(--ease);
}
@keyframes modalPop {
  from { transform: translateY(16px) scale(0.985); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: rgba(24, 24, 27, 0.04);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #57534E;
  cursor: pointer;
  transition: all 240ms var(--ease);
}
.modal-close:hover {
  background: rgba(24, 24, 27, 0.08);
  color: #18181B;
}

/* ===== Tables in modal ===== */
.deals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.deals-table th {
  text-align: left;
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #78716C;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(24, 24, 27, 0.06);
}
.deals-table td {
  padding: 10px;
  border-bottom: 1px solid rgba(24, 24, 27, 0.04);
}
.deals-table tr:hover td { background: rgba(24, 24, 27, 0.02); }
.deals-table a {
  color: #2563EB;
  text-decoration: none;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 12px;
}
.deals-table a:hover { text-decoration: underline; }

/* ===== Reveal animation ===== */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  filter: blur(6px);
  transition: opacity 800ms var(--ease), transform 800ms var(--ease), filter 800ms var(--ease);
  transition-delay: var(--reveal-delay, 0ms);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
  filter: blur(0);
}

/* ===== Doughnut charts ===== */
.doughnut-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 220px;
  margin: 0 auto;
}
.doughnut-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #18181B;
  pointer-events: none;
  font-feature-settings: 'tnum';
}
.legend {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #57534E;
  max-height: 220px;
  overflow-y: auto;
}
.legend-row {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  cursor: pointer;
  padding: 3px 2px;
  border-radius: 6px;
  transition: background-color 200ms var(--ease);
}
.legend-row:hover { background: rgba(24, 24, 27, 0.04); }
.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
.legend-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.legend-count {
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: 11px;
  color: #18181B;
  font-weight: 500;
}

/* ===== Utilities ===== */
.tabular {
  font-variant-numeric: tabular-nums;
}

/* Tailwind iframe-friendly */
@media (max-width: 768px) {
  .aura { display: none; }
  .kpi-value { font-size: 26px; }
}
