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

:root {
  --bg:        #F5F5F7;
  --bg-card:   #FFFFFF;
  --bg-sidebar:#FFFFFF;
  --bg-panel:  #FFFFFF;
  --bg-input:  #F2F2F7;

  --border:    #E5E5EA;
  --border-focus: #0071E3;

  --text-primary:   #1D1D1F;
  --text-secondary: #6E6E73;
  --text-tertiary:  #AEAEB2;

  --accent-early:      #FF9F0A;
  --accent-developing: #0071E3;
  --accent-strong:     #30D158;
  --accent-score:      #BF5AF2;

  --shadow-card:  0 2px 16px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-panel: -4px 0 40px rgba(0,0,0,0.10);
  --shadow-hover: 0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  --sidebar-width: 240px;

  --transition: 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 200;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
}

.logo-mark {
  width: 32px;
  height: 32px;
  background: var(--text-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #fff;
  flex-shrink: 0;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-text {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sidebar-nav {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg);
}

.nav-item.active {
  color: var(--text-primary);
  background: var(--bg);
  font-weight: 600;
}

.nav-icon { display: none; }

.sidebar-sources {
  flex: 1;
  padding: 16px 0;
  overflow-y: auto;
}

.sources-label {
  padding: 0 24px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}

.source-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 24px;
  font-size: 13px;
  color: var(--text-secondary);
}

.source-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
}

.source-dot.active {
  background: var(--accent-strong);
}

.source-count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.sidebar-status {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.status-dot.active {
  background: var(--accent-strong);
}

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  flex-shrink: 0;
  z-index: 100;
  background: rgba(245,245,247,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.page-title {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.4px;
  color: var(--text-primary);
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-group {
  display: flex;
  gap: 2px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.filter-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover {
  color: var(--text-primary);
}

.filter-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.select-input, .search-input {
  background: var(--bg-input);
  border: none;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 400;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: background var(--transition), box-shadow var(--transition);
}

.select-input:focus, .search-input:focus {
  background: var(--bg-card);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.search-input {
  width: 220px;
}

.search-input::placeholder {
  color: var(--text-tertiary);
}

/* ── STATS ROW ── */
.stats-row {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.stat-card {
  background: var(--bg-card);
  padding: 20px 32px;
  border-right: 1px solid var(--border);
}

.stat-card:last-child { border-right: none; }

.stat-value {
  font-weight: 700;
  font-size: 30px;
  letter-spacing: -0.5px;
  line-height: 1;
  margin-bottom: 5px;
  color: var(--text-primary);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-tertiary);
}

.accent-early      { color: var(--accent-early); }
.accent-developing { color: var(--accent-developing); }
.accent-strong     { color: var(--accent-strong); }
.accent-score      { color: var(--accent-score); }

/* ── CONTENT SPLIT ── */
.content-area {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.cards-side {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  transition: flex var(--transition);
}

/* ── CARDS GRID ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  padding: 28px 32px;
  align-content: start;
}

/* Infinite scroll sentinel */
.scroll-sentinel {
  grid-column: 1 / -1;
  height: 1px;
}

.load-more-spinner {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 10px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.spinner-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-tertiary);
  animation: bounce 1.2s ease-in-out infinite;
}
.spinner-dot:nth-child(2) { animation-delay: 0.2s; }
.spinner-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1; }
}

.panel-open .cards-grid {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

/* ── STARTUP CARD ── */
.mini-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  box-shadow: var(--shadow-card);
}

.mini-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
  border-color: transparent;
}

.mini-card.active-card {
  border-color: var(--accent-developing);
  box-shadow: 0 0 0 3px rgba(0,113,227,0.12), var(--shadow-hover);
  transform: translateY(-3px);
}

.mc-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mc-signal {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: 20px;
}

.mc-signal.early      { background: rgba(255,159,10,0.12); color: #C07600; }
.mc-signal.developing { background: rgba(0,113,227,0.10); color: #0058B8; }
.mc-signal.strong     { background: rgba(48,209,88,0.12); color: #1A8C3A; }

.mc-score-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--accent-score);
  flex-shrink: 0;
}

.mc-name {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
  line-height: 1.2;
}

.mc-meta {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
}

.mc-sep { margin: 0 5px; opacity: 0.5; }

.mc-divider {
  height: 1px;
  background: var(--border);
  margin: 0 -2px;
}

.mc-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  flex: 1;
}

.mc-kpis {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

.mc-kpis b { color: var(--text-primary); font-weight: 600; }

.mc-country {
  font-size: 12px;
  color: var(--text-tertiary);
}

.mc-sources {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.src-tag {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
}

.src-tag.on  { background: rgba(48,209,88,0.10); color: #1A8C3A; }
.src-tag.off { background: var(--bg); color: var(--text-tertiary); }

.mc-btn {
  width: 100%;
  background: var(--bg);
  border: none;
  color: var(--accent-developing);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  margin-top: 2px;
}

.mc-btn:hover {
  background: rgba(0,113,227,0.08);
}

.empty-msg, .loading-msg {
  grid-column: 1/-1;
  padding: 80px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
}

/* ── DETAIL PANEL ── */
.detail-panel {
  width: 0;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  overflow: hidden;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.detail-panel.open {
  width: 48%;
  min-width: 480px;
  overflow-y: auto;
  overflow-x: hidden;
}

.panel-inner {
  min-width: 480px;
  padding: 0;
}

.panel-close {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--text-secondary);
  transition: background var(--transition);
  line-height: 1;
}

.panel-close-btn:hover {
  background: var(--border);
  color: var(--text-primary);
}

.panel-title {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

/* ── ADMIN NAV (hidden by default, shown via JS when logged in) ── */
.nav-item-admin { display: none; }
.nav-item-admin.visible { display: flex; }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* ════════════════════════════════════════════════════════
   MOBILE  (≤ 768 px)
   ════════════════════════════════════════════════════════ */

/* Hide mobile-only UI on desktop */
.mobile-bottom-nav,
.mobile-overlay,
.mobile-menu-btn { display: none; }

@media (max-width: 768px) {

  /* ── Sidebar → slide-in drawer ── */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 500;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 8px 0 48px rgba(0,0,0,0.20);
  }

  /* ── Dim overlay behind drawer ── */
  .mobile-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.40);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 400;
    opacity: 0; pointer-events: none;
    transition: opacity 0.28s;
  }
  .mobile-overlay.visible { opacity: 1; pointer-events: all; }

  /* ── Main: full width ── */
  .main { margin-left: 0; }

  /* ── Topbar: two rows ── */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 14px 8px;
    gap: 8px;
  }
  .topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  /* ── Hamburger ── */
  .mobile-menu-btn {
    display: flex;
    align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg-input);
    border: none; border-radius: 9px;
    cursor: pointer; flex-shrink: 0;
    color: var(--text-secondary);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-menu-btn:active { background: var(--border); }

  /* ── Filters & search ── */
  .topbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }
  .filter-group {
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .filter-group::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; font-size: 12px; padding: 6px 12px; }
  .select-input { flex: 1; min-width: 120px; font-size: 13px; }
  .search-input { flex: 1; min-width: 0; width: auto; font-size: 13px; }

  /* ── Stats row: horizontal scroll ── */
  .stats-row {
    display: flex;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    border-bottom: 1px solid var(--border);
    gap: 0;
  }
  .stats-row::-webkit-scrollbar { display: none; }
  .stat-card {
    flex: 0 0 auto;
    min-width: 88px;
    padding: 12px 14px;
    border-right: 1px solid var(--border);
    border-bottom: none;
  }
  .stat-value { font-size: 22px; }

  /* ── Cards: single column ── */
  .cards-grid {
    grid-template-columns: 1fr;
    padding: 12px 12px 72px;
    gap: 10px;
  }
  .panel-open .cards-grid { grid-template-columns: 1fr; }
  .mini-card { border-radius: 16px; }
  .mc-name { font-size: 16px; }

  /* ── Detail panel: full-screen slide-up ── */
  .detail-panel {
    position: fixed !important;
    inset: 0 !important;
    width: 100% !important;
    min-width: unset !important;
    border-left: none !important;
    border-top: 1px solid var(--border);
    z-index: 300;
    overflow: hidden !important;
    transform: translateY(100%) !important;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
  }
  .detail-panel.open {
    transform: translateY(0) !important;
    overflow-y: auto !important;
  }
  .panel-inner { min-width: unset !important; }
  .panel-close { padding: 12px 16px; }
  .panel-close-btn { width: 34px; height: 34px; font-size: 17px; }

  /* Drag handle hint above panel */
  .panel-close::before {
    content: '';
    display: block;
    position: absolute;
    top: 8px; left: 50%;
    transform: translateX(-50%);
    width: 36px; height: 4px;
    background: var(--border);
    border-radius: 2px;
  }
  .panel-close { position: relative; }

  /* ── Bottom navigation bar ── */
  .mobile-bottom-nav {
    display: flex;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255,255,255,0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid var(--border);
    z-index: 200;
  }
  .mob-nav-item {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-tertiary);
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.02em;
    transition: color 0.18s;
    -webkit-tap-highlight-color: transparent;
  }
  .mob-nav-item.active { color: var(--accent-developing); }
  .mob-nav-item svg { width: 22px; height: 22px; }
  .mob-nav-admin { display: none; }
  .mob-nav-admin.visible { display: flex; }

  /* ── page-title smaller on mobile ── */
  .page-title { font-size: 18px; }
  .page-subtitle { font-size: 12px; }

  /* ── Topbar back-btn ── */
  .back-btn { font-size: 13px; }
}
