/* Hanami Social Dashboard — Design System */

:root {
  --bg: #0a0a0f;
  --card: #12121a;
  --card-border: #1e1e2e;
  --text: #e4e4e7;
  --text-dim: #71717a;
  --text-bright: #fafafa;
  --accent: #6366f1;
  --accent-dim: #4f46e5;
  --green: #22c55e;
  --green-dim: #16a34a;
  --amber: #f59e0b;
  --red: #ef4444;
  --pink: #ec4899;
  --cyan: #06b6d4;
  --purple: #a855f7;
  --orange: #f97316;
  --sidebar-width: 240px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

#sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--card);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  border-bottom: 1px solid var(--card-border);
}

.sidebar-brand h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
}

.sidebar-brand .handle { color: var(--accent); }

.sidebar-subtitle {
  color: var(--text-dim);
  font-size: 12px;
  margin-top: 2px;
}

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

.nav-item {
  display: block;
  padding: 8px 20px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(99, 102, 241, 0.06);
}

.nav-item.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(99, 102, 241, 0.08);
  font-weight: 600;
}

#sidebar-northstar {
  padding: 16px 20px;
  flex: 1;
}

.northstar-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 600;
}

.northstar-item { margin-bottom: 10px; }

.northstar-label {
  font-size: 11px;
  color: var(--text-dim);
}

.northstar-row {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.northstar-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
}

.northstar-value.northstar-warn { color: var(--red); }

.northstar-target {
  font-size: 11px;
  color: var(--text-dim);
}

#sidebar-freshness {
  padding: 12px 20px;
  border-top: 1px solid var(--card-border);
}

.freshness {
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.freshness.stale { color: var(--amber); }

.stale-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  background: rgba(239, 68, 68, 0.15);
  color: var(--red);
  text-transform: uppercase;
  width: fit-content;
}

.freshness-hours { color: var(--text-dim); }

/* ============================================================
   MAIN CONTENT
   ============================================================ */

#main {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px 32px;
  max-width: 1200px;
}

#view-container { min-height: 80vh; }

#mobile-nav { display: none; }

/* ============================================================
   SUB-TABS
   ============================================================ */

.sub-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--card-border);
  margin-bottom: 24px;
  overflow-x: auto;
}

.sub-tab {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.sub-tab:hover { color: var(--text); }

.sub-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.sub-tab-content { min-height: 400px; }

/* ============================================================
   VIEW SECTION TITLES
   ============================================================ */

.view-section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-bright);
  margin: 28px 0 12px 0;
}

.view-section-title:first-child { margin-top: 0; }

/* ============================================================
   SECTION HEADERS
   ============================================================ */

.section-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header:first-child { margin-top: 0; }

.badge {
  font-size: 9px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-data { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-insight { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-action { background: rgba(34,197,94,0.15); color: var(--green); }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}

/* ============================================================
   HERO METRICS GRID
   ============================================================ */

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.hero-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
}

.hero-card.warn { border-color: rgba(239, 68, 68, 0.3); }

.hero-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.hero-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-bright);
}

.hero-value.green { color: var(--green); }
.hero-value.warn { color: var(--red); }

.hero-delta {
  font-size: 12px;
  margin-top: 4px;
  color: var(--text-dim);
}

/* ============================================================
   CLIENT CARDS
   ============================================================ */

.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.client-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.15s;
}

.client-card:hover { border-color: var(--accent); }

.client-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 4px;
}

.client-vertical {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.client-stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.client-stat-label { color: var(--text-dim); }
.client-stat-value { color: var(--text-bright); font-weight: 600; }

/* ============================================================
   ALERT BANNER
   ============================================================ */

.alert-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 24px;
}

.alert-banner-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 8px;
}

.alert-banner-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(239, 68, 68, 0.1);
}

.alert-banner-item:last-child { border-bottom: none; }

.alert-banner-client { color: var(--text); }
.alert-banner-amount { color: var(--red); font-weight: 600; }
.alert-banner-note { color: var(--text-dim); font-size: 11px; }

/* ============================================================
   PIPELINE FUNNEL
   ============================================================ */

.funnel-stage {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--card-border);
}

.funnel-stage:last-child { border-bottom: none; }

.funnel-name {
  width: 120px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.funnel-bar-bg {
  flex: 1;
  height: 24px;
  background: rgba(99, 102, 241, 0.08);
  border-radius: 6px;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.3s;
  display: flex;
  align-items: center;
  padding-left: 8px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-bright);
}

.funnel-count {
  width: 40px;
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-bright);
}

/* ============================================================
   DATA TABLE
   ============================================================ */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
}

.data-table td {
  padding: 10px 12px;
  color: var(--text);
  border-bottom: 1px solid var(--card-border);
}

.data-table tr:last-child td { border-bottom: none; }

.data-table tr:hover td { background: rgba(99, 102, 241, 0.04); }

/* ============================================================
   CHART CONTAINERS
   ============================================================ */

.chart-container {
  position: relative;
  height: 300px;
  margin-bottom: 24px;
}

.chart-container-sm {
  position: relative;
  height: 200px;
  margin-bottom: 16px;
}

/* ============================================================
   ZONE CARDS (Traffic view)
   ============================================================ */

.zone-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.zone-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 20px;
}

.zone-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 12px;
}

.zone-stat {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.zone-stat-label { color: var(--text-dim); }
.zone-stat-value { color: var(--text-bright); font-weight: 600; }

/* ============================================================
   LOADING
   ============================================================ */

.view-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 300px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   COMPARE GRID
   ============================================================ */

.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.compare-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
}

.compare-account {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.compare-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
}

.compare-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 768px) {
  #sidebar { display: none; }

  #main {
    margin-left: 0;
    padding: 16px;
  }

  #mobile-nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding: 8px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--card-border);
  }

  .mobile-nav-item {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-dim);
    text-decoration: none;
    white-space: nowrap;
    border-radius: 6px;
    transition: all 0.15s;
  }

  .mobile-nav-item.active {
    color: var(--accent);
    background: rgba(99, 102, 241, 0.1);
  }

  .hero-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .client-grid {
    grid-template-columns: 1fr;
  }

  .zone-grid {
    grid-template-columns: 1fr;
  }
}
