/* ── Dashboard CSS ─────────────────────────────────────────────────── */
:root {
  --d-bg: #0F1117;
  --d-surface: #1A1D27;
  --d-surface2: #222536;
  --d-border: rgba(255,255,255,0.07);
  --d-text: #E8EAF0;
  --d-muted: #8B8FA8;
  --d-accent: #6C63FF;
  --d-accent2: #00D4AA;
  --d-danger: #FF5C7C;
  --d-warning: #FFB547;
  --d-success: #00D4AA;
  --d-chart1: #6C63FF;
  --d-chart2: #00D4AA;
  --d-chart3: #FF6B8A;
  --d-chart4: #FFB547;
  --font: 'Inter', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: var(--font); background: var(--d-bg); color: var(--d-text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }

/* ── Layout ── */
.dash-layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }

/* ── Sidebar ── */
.dash-sidebar { background: var(--d-surface); border-right: 1px solid var(--d-border); display: flex; flex-direction: column; padding: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-logo { padding: 24px 20px 20px; border-bottom: 1px solid var(--d-border); }
.sidebar-logo-name { font-size: 16px; font-weight: 700; color: var(--d-text); letter-spacing: -0.02em; }
.sidebar-logo-sub { font-size: 11px; color: var(--d-muted); margin-top: 2px; }
.sidebar-badge { display: inline-flex; align-items: center; gap: 5px; background: rgba(108,99,255,0.15); border: 1px solid rgba(108,99,255,0.25); color: var(--d-accent); font-size: 10px; padding: 2px 8px; border-radius: 999px; margin-top: 8px; font-weight: 500; }

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--d-muted); padding: 0 8px; margin-bottom: 6px; margin-top: 12px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; font-size: 14px; color: var(--d-muted); transition: background 150ms, color 150ms; cursor: pointer; }
.nav-item:hover { background: var(--d-surface2); color: var(--d-text); }
.nav-item.active { background: rgba(108,99,255,0.15); color: var(--d-accent); font-weight: 500; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--d-border); font-size: 12px; color: var(--d-muted); }

/* ── Main ── */
.dash-main { display: flex; flex-direction: column; min-height: 100vh; overflow: hidden; }
.dash-topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; border-bottom: 1px solid var(--d-border); background: var(--d-surface); }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--d-muted); }
.topbar-avatar { width: 32px; height: 32px; background: var(--d-accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; color: #fff; }

.dash-content { flex: 1; padding: 28px 32px; overflow-y: auto; }

/* ── KPI Cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.kpi-card { background: var(--d-surface); border: 1px solid var(--d-border); border-radius: 12px; padding: 20px; position: relative; overflow: hidden; }
.kpi-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; }
.kpi-card.blue::before  { background: var(--d-accent); }
.kpi-card.green::before { background: var(--d-accent2); }
.kpi-card.red::before   { background: var(--d-danger); }
.kpi-card.yellow::before{ background: var(--d-warning); }
.kpi-label { font-size: 12px; color: var(--d-muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 500; margin-bottom: 10px; }
.kpi-value { font-size: 32px; font-weight: 800; line-height: 1; letter-spacing: -0.03em; }
.kpi-sub { font-size: 12px; color: var(--d-muted); margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.kpi-delta { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; padding: 2px 6px; border-radius: 4px; }
.kpi-delta.up   { color: var(--d-success); background: rgba(0,212,170,0.1); }
.kpi-delta.down { color: var(--d-danger);  background: rgba(255,92,124,0.1); }
.kpi-delta.flat { color: var(--d-muted);   background: rgba(139,143,168,0.1); }
.kpi-icon { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 36px; opacity: 0.12; }

/* ── Chart Cards ── */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.chart-card { background: var(--d-surface); border: 1px solid var(--d-border); border-radius: 12px; padding: 20px; }
.chart-card.wide { grid-column: 1 / -1; }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.chart-title { font-size: 14px; font-weight: 600; }
.chart-subtitle { font-size: 12px; color: var(--d-muted); margin-top: 2px; }
.chart-legend { display: flex; align-items: center; gap: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--d-muted); }
.legend-dot { width: 8px; height: 8px; border-radius: 50%; }
.chart-wrap { position: relative; height: 220px; }
.chart-wrap.tall { height: 280px; }

/* ── Funnel ── */
.funnel-wrap { padding: 8px 0; }
.funnel-step { margin-bottom: 14px; }
.funnel-meta { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.funnel-name { font-size: 13px; color: var(--d-text); }
.funnel-nums { font-size: 12px; color: var(--d-muted); }
.funnel-bar-bg { height: 8px; background: var(--d-surface2); border-radius: 4px; overflow: hidden; }
.funnel-bar { height: 100%; border-radius: 4px; transition: width 800ms cubic-bezier(0.22,0.61,0.36,1); }

/* ── Users table ── */
.table-card { background: var(--d-surface); border: 1px solid var(--d-border); border-radius: 12px; overflow: hidden; }
.table-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--d-border); gap: 12px; flex-wrap: wrap; }
.table-title { font-size: 15px; font-weight: 600; }
.table-search { display: flex; align-items: center; gap: 8px; }
.search-input { background: var(--d-surface2); border: 1px solid var(--d-border); color: var(--d-text); padding: 8px 14px; border-radius: 8px; font-size: 13px; outline: none; width: 220px; }
.search-input:focus { border-color: var(--d-accent); }
.search-btn { background: var(--d-accent); border: none; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; font-weight: 500; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab { padding: 6px 14px; border-radius: 6px; font-size: 13px; color: var(--d-muted); cursor: pointer; border: 1px solid transparent; transition: all 150ms; }
.filter-tab:hover { color: var(--d-text); background: var(--d-surface2); }
.filter-tab.active { background: rgba(108,99,255,0.15); color: var(--d-accent); border-color: rgba(108,99,255,0.25); }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { padding: 11px 16px; text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--d-muted); border-bottom: 1px solid var(--d-border); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--d-border); transition: background 100ms; }
tbody tr:hover { background: var(--d-surface2); }
tbody tr:last-child { border-bottom: none; }
td { padding: 12px 16px; color: var(--d-text); vertical-align: middle; }
.td-user { display: flex; align-items: center; gap: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--d-accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-name { font-weight: 500; }
.user-username { font-size: 12px; color: var(--d-muted); }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 500; }
.badge-active  { background: rgba(0,212,170,0.12); color: var(--d-success); }
.badge-blocked { background: rgba(255,92,124,0.12); color: var(--d-danger); }
.td-mono { font-family: 'Courier New', monospace; font-size: 12px; color: var(--d-muted); }
.td-date { font-size: 12px; color: var(--d-muted); white-space: nowrap; }

/* ── Pagination ── */
.table-footer { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-top: 1px solid var(--d-border); }
.page-info { font-size: 13px; color: var(--d-muted); }
.page-btns { display: flex; gap: 6px; }
.page-btn { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--d-border); border-radius: 6px; font-size: 13px; background: transparent; color: var(--d-muted); cursor: pointer; transition: all 150ms; }
.page-btn:hover { border-color: var(--d-accent); color: var(--d-accent); }
.page-btn.active { background: var(--d-accent); color: #fff; border-color: var(--d-accent); }
.page-btn.disabled { opacity: 0.3; pointer-events: none; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--d-bg); }
.login-card { background: var(--d-surface); border: 1px solid var(--d-border); border-radius: 16px; padding: 40px; width: 380px; }
.login-title { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 14px; color: var(--d-muted); margin-bottom: 28px; }
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--d-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.form-input { width: 100%; background: var(--d-surface2); border: 1px solid var(--d-border); color: var(--d-text); padding: 12px 14px; border-radius: 8px; font-size: 14px; outline: none; transition: border-color 150ms; }
.form-input:focus { border-color: var(--d-accent); }
.login-btn { width: 100%; background: var(--d-accent); border: none; color: #fff; padding: 13px; border-radius: 8px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px; transition: opacity 150ms; }
.login-btn:hover { opacity: 0.9; }
.login-error { background: rgba(255,92,124,0.1); border: 1px solid rgba(255,92,124,0.25); color: var(--d-danger); padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.login-demo { font-size: 12px; color: var(--d-muted); text-align: center; margin-top: 16px; }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { display: none; }
  .dash-content { padding: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Фиксы навигации ── */
.nav-item--disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.nav-soon { margin-left: auto; font-size: 10px; background: rgba(255,255,255,0.07); padding: 2px 6px; border-radius: 4px; color: var(--d-muted); }

.sidebar-footer { padding: 16px 20px; border-top: 1px solid var(--d-border); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sidebar-footer-link { font-size: 12px; color: var(--d-muted); transition: color 150ms; }
.sidebar-footer-link:hover { color: var(--d-text); }
.sidebar-footer-link--logout { color: rgba(255,92,124,0.7); }
.sidebar-footer-link--logout:hover { color: var(--d-danger); }

.topbar-logout { font-size: 13px; color: var(--d-muted); padding: 6px 12px; border: 1px solid var(--d-border); border-radius: 6px; transition: all 150ms; }
.topbar-logout:hover { color: var(--d-danger); border-color: var(--d-danger); }

/* ── Фикс layout — main не должен уходить за экран ── */
.dash-layout { min-width: 0; }
.dash-main { min-width: 0; overflow: hidden; }
.dash-content { min-width: 0; }

/* ── Фикс аватаров — убираем динамический hsl() из шаблона ── */
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--d-accent); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; color: #fff; }
