/* ═══════════════════════════════════════════════
   FAROCARO Dashboard — Enhanced Design v2
   Подключается поверх основного <style> в index.html
   Не трогает JS-логику — только визуал
   ═══════════════════════════════════════════════ */

/* ─── Палитра ─── */
:root {
  --bg: #07091a;
  --surface: rgba(255,255,255,0.05);
  --surface2: rgba(255,255,255,0.09);
  --border: rgba(120,140,255,0.15);
  --accent: #7b8cf5;
  --accent2: #2fd49a;
  --accent3: #ef6e6e;
  --accent4: #b87cf0;
  --accent5: #f7923c;
  --text: #e8ebff;
  --text-muted: rgba(190,200,255,0.5);
  --green: #2fd49a;
  --red: #ef6e6e;
  --yellow: #f5c840;

  --grad-main: linear-gradient(135deg, #7b8cf5 0%, #b87cf0 100%);
  --grad-green: linear-gradient(135deg, #2fd49a 0%, #20c0b0 100%);
  --grad-red: linear-gradient(135deg, #ef6e6e 0%, #f09040 100%);
  --grad-blue: linear-gradient(135deg, #5c7cf8 0%, #7b8cf5 100%);
  --glow: 0 0 24px rgba(123,140,245,0.22);
  --glow-green: 0 0 20px rgba(47,212,154,0.18);
  --glow-red: 0 0 20px rgba(239,110,110,0.18);
}

/* ─── Фон ─── */
body {
  background:
    radial-gradient(ellipse at 15% 5%,  rgba(80,60,220,0.13) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 90%, rgba(110,50,210,0.09) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 50%, rgba(30,20,80,0.4)   0%, transparent 70%),
    linear-gradient(160deg, #07091a 0%, #0b0e24 50%, #080e20 100%);
  background-attachment: fixed;
}

/* ─── Header ─── */
.header {
  background: rgba(7,9,26,0.90);
  border-bottom: 1px solid rgba(123,140,245,0.18);
  box-shadow: 0 1px 40px rgba(0,0,0,0.6), 0 0 0 0.5px rgba(123,140,245,0.08);
}
.header-logo {
  background: var(--grad-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 21px;
}

/* ─── Sidebar ─── */
.sidebar {
  background: rgba(7,9,26,0.65);
  border-right: 1px solid rgba(123,140,245,0.1);
}
.tab {
  transition: all 0.18s ease;
}
.tab:hover {
  color: var(--text);
  background: rgba(123,140,245,0.1);
  padding-left: 24px;
}
.tab.active {
  background: linear-gradient(90deg, rgba(123,140,245,0.22) 0%, rgba(123,140,245,0.05) 100%);
  border-left-color: var(--accent);
  color: #b0baff;
  box-shadow: inset 4px 0 12px rgba(123,140,245,0.08);
}

/* ─── Анимация секций ─── */
.section.active {
  animation: fadeSlideIn 0.22s ease forwards;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── KPI Cards ─── */
.kpi-card {
  background: linear-gradient(150deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.025) 100%);
  border: 1px solid rgba(123,140,245,0.2);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.07);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 60%;
  background: radial-gradient(ellipse at 50% -30%, rgba(123,140,245,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.kpi-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 20px 48px rgba(0,0,0,0.55), var(--glow);
  border-color: rgba(123,140,245,0.38);
}
.kpi-value {
  background: linear-gradient(135deg, #dde3ff 0%, var(--accent) 120%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-value.color-green {
  background: var(--grad-green) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}
.kpi-value.color-red {
  background: var(--grad-red) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}
.kpi-value.color-purple {
  background: var(--grad-main) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

/* ─── Svod cards ─── */
.svod-card {
  background: linear-gradient(150deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.025) 100%);
  border: 1px solid rgba(123,140,245,0.16);
  border-radius: 14px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.svod-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(0,0,0,0.45), var(--glow);
  border-color: rgba(123,140,245,0.32);
}
.svod-card-value {
  background: linear-gradient(135deg, #e8ebff 0%, var(--accent) 130%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Chart cards ─── */
.chart-card,
.svod-chart-card,
.svod-table-card,
.adv-card {
  background: linear-gradient(155deg, rgba(255,255,255,0.065) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(123,140,245,0.12);
  border-radius: 14px;
  box-shadow: 0 6px 28px rgba(0,0,0,0.32);
  transition: box-shadow 0.2s ease;
}
.chart-card:hover,
.svod-chart-card:hover {
  box-shadow: 0 10px 36px rgba(0,0,0,0.42), 0 0 0 1px rgba(123,140,245,0.22);
}

/* ─── Table wrap ─── */
.table-wrap,
.dds-table-wrap,
.analytics-wrap {
  background: linear-gradient(160deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(123,140,245,0.12);
  border-radius: 14px;
}

/* ─── Table headers ─── */
.data-table th,
.wb-sales-table th,
.wb-stocks-table th,
.control-table th,
.ozon-table th,
.svod-table th,
.ops-purchases-table th {
  background: linear-gradient(90deg, rgba(123,140,245,0.12) 0%, rgba(184,124,240,0.06) 100%);
  color: rgba(170,185,255,0.75);
  letter-spacing: 0.3px;
}

/* ─── Table rows hover ─── */
.data-table tr:hover td,
.wb-sales-table tr:hover td,
.wb-stocks-table tr:hover td,
.control-table tr:hover td,
.ozon-table tr:hover td,
.ops-purchases-table tr:hover td {
  background: rgba(123,140,245,0.07);
  transition: background 0.12s;
}

/* ─── Buttons (period/filter toggles) ─── */
.svod-period-btn,
.fin-period-btn,
.dds-view-btn,
.filter-btn,
.exp-period-btn,
.year-btn,
.mult-btn {
  transition: all 0.18s ease;
}
.svod-period-btn.active, .svod-period-btn:hover,
.fin-period-btn.active,  .fin-period-btn:hover,
.dds-view-btn.active,    .dds-view-btn:hover,
.filter-btn.active,      .filter-btn:hover,
.exp-period-btn.active,  .exp-period-btn:hover,
.year-btn.active,        .year-btn:hover {
  background: linear-gradient(135deg, rgba(123,140,245,0.22) 0%, rgba(184,124,240,0.14) 100%);
  border-color: var(--accent);
  color: #b0baff;
  box-shadow: 0 2px 14px rgba(123,140,245,0.2);
}

/* ─── Action button ─── */
.ops-btn {
  background: var(--grad-main);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(123,140,245,0.3);
  transition: all 0.2s ease;
}
.ops-btn:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(123,140,245,0.45);
}

/* ─── Select inputs ─── */
.dds-period-selector select,
.ops-form-field input {
  background: rgba(20,25,50,0.7);
  border: 1px solid rgba(123,140,245,0.2);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dds-period-selector select:focus,
.ops-form-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123,140,245,0.15);
  outline: none;
}

/* ─── Loading badge pulse ─── */
.loading-badge.show {
  background: var(--grad-main);
  animation: pulseBadge 1.6s ease-in-out infinite;
}
@keyframes pulseBadge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(123,140,245,0.5); opacity: 1; }
  50%       { box-shadow: 0 0 0 8px rgba(123,140,245,0); opacity: 0.85; }
}

/* ─── Spinner ─── */
.spinner-circle {
  border: 2.5px solid rgba(123,140,245,0.15);
  border-top-color: var(--accent4);
  border-right-color: var(--accent);
  width: 36px;
  height: 36px;
}

/* ─── Alert boxes ─── */
.alert-warn, .alert-danger, .alert-ok {
  border-radius: 12px;
  backdrop-filter: blur(12px);
}
.alert-warn   { background: rgba(245,200,64,0.09); border-color: rgba(245,200,64,0.4); }
.alert-danger { background: rgba(239,110,110,0.09); border-color: rgba(239,110,110,0.4); }
.alert-ok     { background: rgba(47,212,154,0.09); border-color: rgba(47,212,154,0.4); }

/* ─── Error box ─── */
.error-box {
  border-radius: 12px;
  background: rgba(239,110,110,0.08);
  border-color: rgba(239,110,110,0.35);
  backdrop-filter: blur(8px);
}

/* ─── AB dropzone ─── */
.ab-dropzone {
  border: 2px dashed rgba(123,140,245,0.2);
  background: rgba(123,140,245,0.04);
  transition: all 0.2s ease;
}
.ab-dropzone:hover {
  border-color: var(--accent);
  background: rgba(123,140,245,0.08);
}

/* ─── Sidebar group header ─── */
.sidebar-group-header {
  color: rgba(140,155,255,0.45);
  letter-spacing: 1px;
  transition: color 0.15s;
}
.sidebar-group-header:hover {
  color: rgba(180,195,255,0.75);
}

/* ─── Funnel arrows ─── */
.ads-funnel-step {
  background: linear-gradient(150deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.03) 100%);
  border: 1px solid rgba(123,140,245,0.15);
  border-radius: 12px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.ads-funnel-step:hover {
  transform: translateY(-2px);
  box-shadow: var(--glow);
}
.ads-funnel-num {
  background: var(--grad-blue);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Ozon tag ─── */
.ozon-tag {
  background: linear-gradient(135deg, rgba(123,140,245,0.18), rgba(184,124,240,0.12));
  color: #b0baff;
  border: 1px solid rgba(123,140,245,0.25);
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: rgba(255,255,255,0.02); border-radius: 3px; }
::-webkit-scrollbar-thumb  { background: rgba(123,140,245,0.28); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(123,140,245,0.48); }

/* ─── Mobile ─── */
@media (max-width: 768px) {
  .svod-cards-3,
  .svod-cards-5 {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .svod-tables-row {
    grid-template-columns: 1fr;
  }
  .kpi-card {
    padding: 12px 14px;
  }
  .kpi-value {
    font-size: 20px;
  }
  .chart-grid {
    grid-template-columns: 1fr;
  }
  .ads-funnel {
    flex-wrap: wrap;
  }
  .ads-funnel-step {
    min-width: calc(50% - 8px);
  }
  .ads-funnel-arrow {
    display: none;
  }
  .sidebar {
    gap: 2px;
    padding: 6px;
  }
  .tab {
    font-size: 11px;
    padding: 5px 10px;
  }
  .table-wrap,
  .dds-table-wrap,
  .analytics-wrap {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  .data-table,
  .wb-sales-table,
  .wb-stocks-table {
    min-width: 600px;
  }
  .svod-chart-card,
  .chart-card {
    padding: 12px;
  }
  .svod-card-value {
    font-size: 18px;
  }
  .header {
    padding: 12px 16px;
  }
  .header-sub {
    display: none;
  }
}

@media (max-width: 480px) {
  .svod-cards-3,
  .svod-cards-5,
  .kpi-grid,
  .exp-kpi-grid,
  .dds-kpi-grid {
    grid-template-columns: 1fr;
  }
  .main {
    padding: 10px;
  }
}
