/* ============================================================
   SMM Dashboard — light theme, Hi-Relax inspired
   ============================================================ */

:root {
  /* Inherit Hi-Relax tokens, but provide light surfaces */
  --bg-page:        #F4F4F6;
  --bg-canvas:      #FFFFFF;
  --bg-card:        #FFFFFF;
  --bg-soft:        #FAFAFB;
  --bg-rail:        #FFFFFF;
  --bg-window:      #ECECEF;

  --line:           rgba(15, 15, 15, 0.07);
  --line-2:         rgba(15, 15, 15, 0.12);
  --line-strong:    rgba(15, 15, 15, 0.18);

  --text-1:         #0E0E10;
  --text-2:         #5C5C66;
  --text-3:         #8B8B95;
  --text-4:         #B7B7BD;

  --yellow:         #FFD700;
  --yellow-glow:    #FFED4E;
  --yellow-bright:  #FFEA00;
  --yellow-soft:    #FFF7C2;
  --yellow-tint:    #FFFBEB;

  --grad-yellow:    linear-gradient(135deg, #FFD700 0%, #FFED4E 100%);

  /* network brand colors */
  --vk-color:       #0077FF;
  --vk-soft:        #E5F0FF;
  --yt-color:       #FF0033;
  --yt-soft:        #FFE5EA;
  --ig-color:       #E1306C;
  --ig-grad:        linear-gradient(135deg, #F58529 0%, #DD2A7B 50%, #8134AF 100%);
  --ig-soft:        #FFE9F0;

  --pos:            #1AA66B;
  --neg:            #E5484D;

  --shadow-sm:      0 1px 2px rgba(15, 15, 15, 0.04), 0 1px 1px rgba(15, 15, 15, 0.03);
  --shadow-md:      0 6px 24px rgba(15, 15, 15, 0.05), 0 2px 6px rgba(15, 15, 15, 0.04);
  --shadow-lg:      0 24px 64px rgba(15, 15, 15, 0.08), 0 8px 24px rgba(15, 15, 15, 0.05);
  --shadow-yellow:  0 12px 40px rgba(255, 215, 0, 0.30);

  --r-xs:           8px;
  --r-sm:           10px;
  --r-md:           14px;
  --r-lg:           18px;
  --r-xl:           24px;
  --r-pill:         999px;

  --ease:           cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Dark theme overrides */
.theme-dark {
  --bg-page:        #0a0a0a;
  --bg-canvas:      #141417;
  --bg-card:        #1A1A1E;
  --bg-soft:        #18181B;
  --bg-rail:        #141417;
  --bg-window:      #050505;

  --line:           rgba(255, 255, 255, 0.07);
  --line-2:         rgba(255, 255, 255, 0.10);
  --line-strong:    rgba(255, 255, 255, 0.18);

  --text-1:         #FFFFFF;
  --text-2:         rgba(255, 255, 255, 0.7);
  --text-3:         rgba(255, 255, 255, 0.5);
  --text-4:         rgba(255, 255, 255, 0.3);

  --yellow-soft:    rgba(255, 215, 0, 0.15);
  --yellow-tint:    rgba(255, 215, 0, 0.08);

  --vk-soft:        rgba(0, 119, 255, 0.18);
  --yt-soft:        rgba(255, 0, 51, 0.18);
  --ig-soft:        rgba(225, 48, 108, 0.18);

  --shadow-sm:      0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md:      0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg:      0 24px 64px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-window);
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01", "ss03";
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }

/* ============================================================
   App shell
   ============================================================ */
.app-shell {
  position: fixed; inset: 16px;
  background: var(--bg-page);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  display: grid;
  grid-template-columns: 72px 240px 1fr 340px;
  grid-template-rows: 64px 1fr;
  grid-template-areas:
    "rail platforms topbar messages"
    "rail platforms canvas messages";
  transition: grid-template-columns var(--ease) 300ms;
}
.app-shell.platforms-hidden { grid-template-columns: 72px 0 1fr 340px; }
.app-shell.messages-hidden  { grid-template-columns: 72px 240px 1fr 0; }
.app-shell.platforms-hidden.messages-hidden { grid-template-columns: 72px 0 1fr 0; }

/* Auto-hide messages on narrow viewports */
@media (max-width: 1280px) {
  .app-shell { grid-template-columns: 72px 224px 1fr 0; }
  .messages { display: none; }
}
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: 72px 0 1fr 0; }
  .platforms { display: none; }
  .messages { display: none; }
}

/* macOS-ish window dots */
.win-dots {
  position: absolute; top: 22px; left: 22px;
  display: flex; gap: 8px; z-index: 10;
}
.win-dots span { width: 12px; height: 12px; border-radius: 50%; }
.win-dots .d-1 { background: #FF5F57; }
.win-dots .d-2 { background: #FEBC2E; }
.win-dots .d-3 { background: #28C840; }

/* ============================================================
   Left icon rail
   ============================================================ */
.rail {
  grid-area: rail;
  background: var(--bg-rail);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  align-items: center;
  padding: 56px 0 20px;
  gap: 8px;
  z-index: 2;
}
.rail-logo {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--grad-yellow);
  color: #0a0a0a;
  display: grid; place-items: center;
  font-weight: 900; font-size: 18px;
  margin-bottom: 12px;
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.4);
}
.rail-btn {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: none;
  background: transparent;
  color: var(--text-3);
  display: grid; place-items: center;
  font-size: 18px;
  transition: all 200ms var(--ease);
  position: relative;
}
.rail-btn:hover { color: var(--text-1); background: var(--bg-soft); }
.rail-btn.active {
  background: var(--grad-yellow);
  color: #0a0a0a;
  box-shadow: 0 6px 20px rgba(255, 215, 0, 0.4);
}
.rail-spacer { flex: 1; }
.rail-mode {
  display: flex; flex-direction: column;
  background: var(--bg-soft);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  margin-bottom: 12px;
}
.rail-mode button {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-3);
  display: grid; place-items: center;
  transition: all 200ms var(--ease);
}
.rail-mode button.active {
  background: var(--bg-card);
  color: var(--text-1);
  box-shadow: var(--shadow-sm);
}

/* ============================================================
   Platforms column
   ============================================================ */
.platforms {
  grid-area: platforms;
  background: var(--bg-page);
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  overflow: hidden;
  display: flex; flex-direction: column;
  gap: 10px;
}
.platforms-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 8px 8px;
}
.platforms-title {
  font-size: 18px; font-weight: 700; color: var(--text-1);
  margin: 0;
}
.platforms-add {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--bg-card);
  color: var(--text-2);
  display: grid; place-items: center;
  transition: all 200ms var(--ease);
}
.platforms-add:hover { border-color: var(--yellow); color: var(--text-1); }

.platform-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-1);
  cursor: pointer;
  transition: all 200ms var(--ease);
  text-align: left;
  position: relative;
}
.platform-item:hover { background: var(--bg-card); }
.platform-item.active {
  background: var(--bg-card);
  border-color: var(--line);
  box-shadow: var(--shadow-sm);
}
.platform-item.active::before {
  content: '';
  position: absolute;
  left: -16px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 24px;
  background: var(--grad-yellow);
  border-radius: 2px;
}
.platform-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid; place-items: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
}
.platform-icon.all      { background: var(--grad-yellow); color: #0a0a0a; }
.platform-icon.vk       { background: var(--vk-color); }
.platform-icon.youtube  { background: var(--yt-color); }
.platform-icon.instagram { background: var(--ig-grad); }
.platform-meta {
  display: flex; flex-direction: column;
  min-width: 0;
}
.platform-name {
  font-size: 15px; font-weight: 600;
}
.platform-sub {
  font-size: 12px; color: var(--text-3);
  margin-top: 1px;
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  grid-area: topbar;
  display: flex; align-items: center;
  gap: 8px;
  padding: 0 24px;
  background: var(--bg-page);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.search-wrap {
  flex: 1; max-width: 480px;
  position: relative;
}
.search-input {
  width: 100%;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  padding: 0 16px 0 44px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: all 200ms var(--ease);
}
.search-input::placeholder { color: var(--text-3); }
.search-input:focus { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.12); }
.search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 14px;
}

.period-switch {
  display: flex; background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.period-switch button {
  border: none; background: transparent;
  padding: 6px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--text-2);
  border-radius: 999px;
  transition: all 200ms var(--ease);
}
.period-switch button.active {
  background: var(--text-1);
  color: var(--bg-card);
}
.period-switch button:not(.active):hover { color: var(--text-1); }

.compare-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  transition: all 200ms var(--ease);
}
.compare-btn:hover { color: var(--text-1); border-color: var(--line-strong); }
.compare-btn.active {
  background: #0E0E10; color: #fff; border-color: #0E0E10;
}
.theme-dark .compare-btn.active { background: var(--yellow); color: #0a0a0a; border-color: var(--yellow); }

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  color: var(--text-2);
  display: grid; place-items: center;
  transition: all 200ms var(--ease);
  position: relative;
  flex-shrink: 0;
}
@media (max-width: 1280px) {
  .topbar .icon-btn.hide-md { display: none; }
}
.icon-btn:hover { color: var(--text-1); border-color: var(--line-strong); }
.icon-btn .badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  background: var(--yt-color);
  color: white;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  padding: 0 4px;
}

.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  transition: all 200ms var(--ease);
}
.user-chip:hover { border-color: var(--line-strong); }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--grad-yellow);
  display: grid; place-items: center;
  font-weight: 700; color: #0a0a0a;
  font-size: 13px;
}

/* ============================================================
   Canvas (main content)
   ============================================================ */
.canvas {
  grid-area: canvas;
  background: var(--bg-page);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px 24px 32px;
  position: relative;
}
.canvas::-webkit-scrollbar { width: 8px; }
.canvas::-webkit-scrollbar-track { background: transparent; }
.canvas::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }

.canvas-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.canvas-header > div:first-child { min-width: 0; flex: 1 1 280px; }
.canvas-title {
  margin: 0;
  font-size: 24px; font-weight: 800;
  color: var(--text-1);
  letter-spacing: -0.02em;
  line-height: 1.2;
}
@media (min-width: 1200px) { .canvas-title { font-size: 28px; } }
.canvas-sub {
  margin: 4px 0 0;
  font-size: 14px; color: var(--text-2);
}
.canvas-actions {
  display: flex; gap: 8px; align-items: center;
}

.network-tabs {
  display: inline-flex; gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 4px;
}
.network-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 13px; font-weight: 600;
  transition: all 200ms var(--ease);
  white-space: nowrap;
}
.network-tab:hover { color: var(--text-1); }
.network-tab .dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.network-tab.active {
  background: var(--text-1);
  color: var(--bg-card);
}
.network-tab.active .dot.all { background: #FFD700; }
.theme-dark .network-tab.active { background: var(--yellow); color: #0a0a0a; }

/* ============================================================
   Widget grid (drag/drop reorder via flex order)
   ============================================================ */
.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: start;
}
.widget {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  display: flex; flex-direction: column;
  min-width: 0;
  transition: box-shadow 200ms var(--ease), border-color 200ms var(--ease), transform 200ms var(--ease);
}
.widget:hover { box-shadow: var(--shadow-md); }
.widget.dragging { opacity: 0.4; }
.widget.drag-over { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255,215,0,0.2); }

/* Sizes (col-spans) */
.w-3 { grid-column: span 3; }
.w-4 { grid-column: span 4; }
.w-6 { grid-column: span 6; }
.w-8 { grid-column: span 8; }
.w-9 { grid-column: span 9; }
.w-12 { grid-column: span 12; }

/* On medium widths collapse to a 6-col grid */
@media (max-width: 1400px) {
  .grid { grid-template-columns: repeat(6, 1fr); }
  .w-3 { grid-column: span 3; }
  .w-4 { grid-column: span 3; }
  .w-6 { grid-column: span 6; }
  .w-8 { grid-column: span 6; }
  .w-9 { grid-column: span 6; }
  .w-12 { grid-column: span 6; }
}
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .w-3, .w-4, .w-6, .w-8, .w-9, .w-12 { grid-column: span 2; }
}

.widget-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}
.widget-title-wrap {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
.widget-title {
  font-size: 15px; font-weight: 700;
  color: var(--text-1);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.widget-sub {
  font-size: 12px; color: var(--text-3);
  margin-top: 2px;
}
.widget-handle {
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid; place-items: center;
  color: var(--text-3);
  cursor: grab;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.widget:hover .widget-handle { opacity: 1; }
.widget-handle:active { cursor: grabbing; }
.widget-actions { display: flex; gap: 4px; align-items: center; }
.widget-actions button {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-3);
  display: grid; place-items: center;
  transition: all 200ms var(--ease);
}
.widget-actions button:hover {
  background: var(--bg-soft); color: var(--text-1);
}
.widget-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}

/* Resize handle */
.resize-handle {
  position: absolute; right: 6px; bottom: 6px;
  width: 16px; height: 16px;
  cursor: se-resize;
  color: var(--text-4);
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.widget:hover .resize-handle { opacity: 1; }
.resize-handle:hover { color: var(--text-1); }

/* ============================================================
   KPI tile
   ============================================================ */
.kpi { padding: 18px 20px; }
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.kpi-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 18px;
}
.kpi-icon.purple { background: #EFE9FF; color: #6938EF; }
.kpi-icon.peach  { background: #FFE5DA; color: #F46036; }
.kpi-icon.blue   { background: #DCEEFF; color: #1E88E5; }
.kpi-icon.green  { background: #DCFCE7; color: #16A34A; }
.kpi-icon.yellow { background: var(--yellow-soft); color: #8A6E0C; }
.theme-dark .kpi-icon.purple { background: rgba(105,56,239,0.18); color: #A98CFF; }
.theme-dark .kpi-icon.peach  { background: rgba(244,96,54,0.18); color: #FF8B6B; }
.theme-dark .kpi-icon.blue   { background: rgba(30,136,229,0.18); color: #6FB8FF; }
.theme-dark .kpi-icon.green  { background: rgba(22,163,74,0.20); color: #5BD68C; }
.theme-dark .kpi-icon.yellow { background: rgba(255,215,0,0.18); color: var(--yellow); }

.kpi-trend {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
}
.kpi-trend.pos { color: var(--pos); background: rgba(26, 166, 107, 0.10); }
.kpi-trend.neg { color: var(--neg); background: rgba(229, 72, 77, 0.10); }
.kpi-value {
  font-size: 30px; font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1.1;
  margin-bottom: 4px;
}
.kpi-label {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 8px;
}
.kpi-foot {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 6px;
}
.kpi-spark {
  height: 36px; margin-top: 10px;
}

/* ============================================================
   Charts
   ============================================================ */
.chart-wrap { width: 100%; flex: 1; min-height: 0; }
.chart-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-2);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

.chart-summary {
  display: flex; align-items: baseline; gap: 12px;
  margin-bottom: 16px;
}
.chart-summary .big {
  font-size: 32px; font-weight: 800; color: var(--text-1);
  letter-spacing: -0.02em;
}

/* ============================================================
   Demographics list
   ============================================================ */
.demo-row {
  display: grid;
  grid-template-columns: 56px 1fr 48px;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.demo-row + .demo-row { border-top: 1px solid var(--line); }
.demo-label { font-size: 13px; color: var(--text-1); font-weight: 600; }
.demo-bar {
  position: relative;
  height: 8px;
  background: var(--bg-soft);
  border-radius: 4px;
  overflow: hidden;
}
.demo-bar > span {
  position: absolute; inset: 0 auto 0 0;
  background: var(--grad-yellow);
  border-radius: 4px;
}
.demo-bar.vk > span { background: var(--vk-color); }
.demo-bar.yt > span { background: var(--yt-color); }
.demo-bar.ig > span { background: var(--ig-grad); }
.demo-val { font-size: 13px; color: var(--text-2); font-weight: 600; text-align: right; }

/* Gender donut */
.gender-card { display: grid; grid-template-columns: 140px 1fr; gap: 20px; align-items: center; }
.gender-svg { width: 140px; height: 140px; position: relative; }
.gender-svg .gender-center {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
}
.gender-center .gc-num { font-size: 22px; font-weight: 800; color: var(--text-1); }
.gender-center .gc-sub { font-size: 11px; color: var(--text-3); }
.gender-legend { display: flex; flex-direction: column; gap: 10px; }
.gender-legend .gl-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
}
.gl-pill { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text-1); }
.gl-pill .ldot { width: 10px; height: 10px; border-radius: 50%; }
.gl-val { font-size: 14px; font-weight: 800; color: var(--text-1); }

/* ============================================================
   Geo
   ============================================================ */
.geo-list { display: flex; flex-direction: column; gap: 12px; }
.geo-row { display: grid; grid-template-columns: 28px 1fr auto; gap: 12px; align-items: center; }
.geo-flag {
  width: 28px; height: 20px;
  border-radius: 4px;
  display: grid; place-items: center;
  font-size: 14px;
  background: var(--bg-soft);
  overflow: hidden;
}
.geo-city {
  font-size: 13px; font-weight: 600; color: var(--text-1);
}
.geo-country { font-size: 11px; color: var(--text-3); }
.geo-bar {
  position: relative;
  height: 6px;
  background: var(--bg-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 6px;
}
.geo-bar > span { position: absolute; inset: 0 auto 0 0; background: var(--grad-yellow); border-radius: 3px; }
.geo-val { font-size: 12px; font-weight: 700; color: var(--text-2); }

/* ============================================================
   Sources
   ============================================================ */
.sources-stack {
  height: 24px;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  margin-bottom: 16px;
}
.sources-stack > span { display: block; height: 100%; transition: flex 300ms var(--ease); }
.sources-legend { display: flex; flex-direction: column; gap: 10px; }
.sources-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 6px 0;
}
.sources-row + .sources-row { border-top: 1px solid var(--line); }
.sources-row .label { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; color: var(--text-1); }
.sources-row .pct { font-size: 13px; color: var(--text-2); font-weight: 600; }
.sources-row .delta { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.sources-row .delta.pos { color: var(--pos); background: rgba(26,166,107,0.10); }
.sources-row .delta.neg { color: var(--neg); background: rgba(229,72,77,0.10); }

/* ============================================================
   Top posts
   ============================================================ */
.posts-list { display: flex; flex-direction: column; gap: 8px; }
.post-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 12px; align-items: center;
  padding: 10px;
  border-radius: 12px;
  transition: background 200ms var(--ease);
}
.post-row:hover { background: var(--bg-soft); }
.post-thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--bg-soft);
  background-size: cover; background-position: center;
  position: relative;
  flex-shrink: 0;
}
.post-thumb .pt-badge {
  position: absolute; left: -4px; top: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  display: grid; place-items: center; color: white;
  font-size: 10px;
  border: 2px solid var(--bg-card);
}
.post-meta { min-width: 0; }
.post-title {
  font-size: 13px; font-weight: 600; color: var(--text-1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.post-sub { font-size: 11px; color: var(--text-3); display: flex; gap: 10px; }
.post-sub span { display: inline-flex; gap: 4px; align-items: center; }
.post-engagement {
  font-size: 13px; font-weight: 800; color: var(--text-1);
  text-align: right;
}
.post-engagement small { font-size: 11px; font-weight: 600; color: var(--text-3); display: block; }

/* ============================================================
   Comparison widget
   ============================================================ */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.compare-cell {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex; flex-direction: column;
}
.compare-cell-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.compare-cell-head .platform-icon { width: 28px; height: 28px; border-radius: 8px; font-size: 13px; }
.compare-cell-rows { display: flex; flex-direction: column; gap: 8px; }
.compare-cell-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
  align-items: baseline;
}
.compare-cell-row .lab { color: var(--text-3); font-size: 12px; }
.compare-cell-row .val { font-weight: 700; color: var(--text-1); font-size: 14px; }
.compare-cell-row .delta { font-size: 11px; font-weight: 700; padding: 1px 5px; border-radius: 4px; margin-left: 6px; }
.compare-cell-row .delta.pos { color: var(--pos); background: rgba(26,166,107,0.10); }
.compare-cell-row .delta.neg { color: var(--neg); background: rgba(229,72,77,0.10); }

/* ============================================================
   Stories / recent posts strip
   ============================================================ */
.stories-strip {
  display: flex; gap: 12px; overflow-x: auto;
  padding-bottom: 4px;
}
.stories-strip::-webkit-scrollbar { height: 6px; }
.stories-strip::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.story {
  flex: 0 0 96px;
  height: 128px;
  border-radius: 14px;
  background: var(--bg-soft);
  background-size: cover; background-position: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 200ms var(--ease);
}
.story:hover { transform: translateY(-3px); }
.story::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0,0,0,0.7) 100%);
}
.story .story-platform {
  position: absolute; top: 8px; left: 8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: white;
  font-size: 10px;
  z-index: 1;
  border: 2px solid white;
}
.story .story-name {
  position: absolute; bottom: 8px; left: 8px; right: 8px;
  color: white; font-size: 11px; font-weight: 600;
  z-index: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.story.add {
  background: var(--bg-card);
  border: 1.5px dashed var(--line-2);
  display: grid; place-items: center;
  color: var(--text-3);
}
.story.add::after { display: none; }
.story.add .add-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
}
.story.add .add-icon {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--grad-yellow);
  color: #0a0a0a;
  display: grid; place-items: center;
  font-size: 14px;
}

/* ============================================================
   Right messages panel
   ============================================================ */
.messages {
  grid-area: messages;
  background: var(--bg-page);
  border-left: 1px solid var(--line);
  padding: 24px 20px;
  display: flex; flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
.messages-search {
  position: relative;
}
.messages-search input {
  width: 100%; height: 38px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-card);
  padding: 0 14px 0 40px;
  font-size: 13px;
  color: var(--text-1);
  outline: none;
}
.messages-search input::placeholder { color: var(--text-3); }
.messages-search i {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 13px;
}
.messages-section-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 15px; font-weight: 700; color: var(--text-1);
}
.messages-section-head a { font-size: 12px; color: var(--text-3); font-weight: 600; cursor: pointer; text-decoration: none; }
.messages-section-head a:hover { color: var(--yellow-bright); }
.messages-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.messages-list::-webkit-scrollbar { width: 4px; }
.messages-list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 2px; }

.msg-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 200ms var(--ease);
}
.msg-row:hover { background: var(--bg-card); }
.msg-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--bg-soft);
  background-size: cover; background-position: center;
  position: relative;
  display: grid; place-items: center;
  font-weight: 700;
  color: var(--text-1);
  font-size: 13px;
}
.msg-avatar.vk { background: var(--vk-color); color: white; }
.msg-avatar.yt { background: var(--yt-color); color: white; }
.msg-avatar.ig { background: var(--ig-grad); color: white; }
.msg-avatar .status {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--pos);
  border: 2px solid var(--bg-page);
}
.msg-meta { min-width: 0; }
.msg-name { font-size: 13px; font-weight: 700; color: var(--text-1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-preview { font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.msg-right { text-align: right; }
.msg-time { font-size: 10px; color: var(--text-3); }
.msg-unread {
  background: var(--yt-color); color: white;
  border-radius: 999px;
  min-width: 16px; height: 16px;
  font-size: 10px; font-weight: 700;
  display: inline-grid; place-items: center;
  padding: 0 5px;
  margin-top: 2px;
}
.msg-read { color: var(--text-3); font-size: 11px; margin-top: 2px; }

.add-group {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 13px; font-weight: 600; color: var(--text-1);
  cursor: pointer; transition: all 200ms var(--ease);
}
.add-group:hover { border-color: var(--yellow); }
.add-group .plus {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--grad-yellow);
  color: #0a0a0a;
  display: grid; place-items: center;
  font-size: 12px;
}

/* ============================================================
   Widget library (drawer)
   ============================================================ */
.lib-fab {
  position: absolute;
  right: 24px; bottom: 24px;
  height: 48px;
  padding: 0 18px 0 14px;
  border-radius: 999px;
  background: var(--grad-yellow);
  color: #0a0a0a;
  border: none;
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-yellow);
  z-index: 5;
  transition: transform 200ms var(--ease);
}
.lib-fab:hover { transform: translateY(-2px); }

.lib-drawer {
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 360px;
  background: var(--bg-card);
  border-left: 1px solid var(--line);
  box-shadow: -16px 0 48px rgba(0,0,0,0.08);
  z-index: 10;
  transform: translateX(110%);
  transition: transform 300ms var(--ease);
  display: flex; flex-direction: column;
  padding: 20px;
  gap: 14px;
}
.lib-drawer.open { transform: translateX(0); }
.lib-head {
  display: flex; justify-content: space-between; align-items: center;
}
.lib-head h3 { margin: 0; font-size: 18px; font-weight: 800; }
.lib-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  overflow-y: auto;
  margin-top: 4px;
}
.lib-card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  cursor: grab;
  display: flex; flex-direction: column; gap: 8px;
  transition: all 200ms var(--ease);
  user-select: none;
}
.lib-card:hover { border-color: var(--yellow); transform: translateY(-2px); }
.lib-card:active { cursor: grabbing; }
.lib-card.disabled { opacity: 0.4; pointer-events: none; }
.lib-card .lib-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--yellow-soft);
  color: #8A6E0C;
  display: grid; place-items: center;
  font-size: 14px;
}
.theme-dark .lib-card .lib-icon { background: rgba(255,215,0,0.15); color: var(--yellow); }
.lib-card .lib-title { font-size: 13px; font-weight: 700; color: var(--text-1); }
.lib-card .lib-sub { font-size: 11px; color: var(--text-3); }

/* ============================================================
   Date popover
   ============================================================ */
.date-pop {
  position: absolute;
  top: 56px; right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 16px;
  width: 320px;
  z-index: 10;
}
.date-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.date-pop-month { font-weight: 700; font-size: 14px; }
.date-pop-nav { display: flex; gap: 4px; }
.date-pop-nav button {
  width: 28px; height: 28px; border-radius: 8px; border: none;
  background: var(--bg-soft); color: var(--text-2);
}
.date-pop-nav button:hover { background: var(--line); color: var(--text-1); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { font-size: 10px; font-weight: 700; color: var(--text-3); text-align: center; padding: 6px 0; }
.cal-day {
  height: 34px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-1);
  font-size: 13px;
  font-weight: 500;
  transition: background 150ms var(--ease);
}
.cal-day:hover { background: var(--bg-soft); }
.cal-day.muted { color: var(--text-4); }
.cal-day.in-range { background: var(--yellow-soft); border-radius: 0; }
.theme-dark .cal-day.in-range { background: rgba(255,215,0,0.12); }
.cal-day.range-start { background: var(--yellow); color: #0a0a0a; font-weight: 700; border-top-left-radius: 8px; border-bottom-left-radius: 8px; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.cal-day.range-end   { background: var(--yellow); color: #0a0a0a; font-weight: 700; border-top-right-radius: 8px; border-bottom-right-radius: 8px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.cal-day.range-start.range-end { border-radius: 8px; }
.date-pop-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.date-pop-presets button {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 11px; font-weight: 600; color: var(--text-2);
}
.date-pop-presets button.active { background: var(--text-1); color: var(--bg-card); border-color: var(--text-1); }
.date-pop-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.date-pop-foot .range-text { font-size: 12px; color: var(--text-2); }
.date-pop-foot button.apply {
  background: var(--text-1); color: var(--bg-card);
  border: none; padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
}

/* ============================================================
   Helpers
   ============================================================ */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ghost while dragging widgets between slots */
.drop-indicator {
  position: absolute;
  border: 2px dashed var(--yellow);
  border-radius: 20px;
  background: rgba(255, 215, 0, 0.08);
  pointer-events: none;
  z-index: 4;
}
