.dashboard-layout {
  display: flex; min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-default);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar-logo {
  padding: 1.25rem 1.5rem; font-size: 1.1rem; font-weight: 800;
  text-decoration: none; color: var(--text-primary);
  border-bottom: 1px solid var(--border-default);
  display: flex; align-items: center; gap: 0.5rem;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
.sidebar-logo:hover { opacity: 0.85; }
.sidebar-logo span { color: var(--primary-500); }
.sidebar-nav { flex: 1; min-height: 0; overflow-y: auto; padding: 0.75rem 0.625rem; display: flex; flex-direction: column; gap: 0.15rem; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.875rem; border-radius: var(--radius-md);
  color: var(--text-muted); text-decoration: none; font-size: 0.855rem; font-weight: 500;
  transition: all 0.18s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  border-left: 2px solid transparent;
}
.sidebar-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-left-color: var(--border-hover);
  padding-left: calc(0.875rem + 2px);
}
.sidebar-link:hover svg { transform: scale(1.12); color: var(--primary-400); }
.sidebar-link.active {
  background: rgba(255,107,44,0.08);
  color: var(--primary-500);
  border-left-color: var(--primary-500);
  font-weight: 600;
  padding-left: calc(0.875rem + 2px);
}
.sidebar-link.active svg { color: var(--primary-500); }
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; transition: transform 0.18s ease, color 0.18s ease; }
.sidebar-section-label {
  font-size: 0.68rem; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.09em;
  padding: 0.875rem 0.875rem 0.3rem;
  opacity: 0.6;
}
.sidebar-user {
  padding: 1rem 0.75rem; border-top: 1px solid var(--border-default);
  display: flex; align-items: center; gap: 0.75rem;
  flex-shrink: 0;
}
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient-primary); display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name { font-size: 0.825rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.7rem; color: var(--text-muted); }

/* Language switcher in sidebar */
.sidebar-lang {
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--border-default);
  display: flex; gap: 0.25rem;
  flex-shrink: 0;
}
.sidebar-lang-btn {
  flex: 1; padding: 0.3rem 0.2rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-default); background: transparent;
  color: var(--text-muted); font-size: 0.68rem; font-weight: 700;
  cursor: pointer; transition: all 0.15s; text-align: center; line-height: 1;
}
.sidebar-lang-btn:hover { border-color: var(--border-hover); color: var(--text-primary); }
.sidebar-lang-btn.active { border-color: var(--primary-500); color: var(--primary-500); background: rgba(255,107,44,0.08); }

/* ── Main content ── */
.main-content {
  flex: 1; min-width: 0;
  padding: 2rem; overflow-y: auto;
}
.page-header { margin-bottom: 2rem; }
.page-header h1 {
  font-family: var(--font-display);
  font-size: 1.75rem; font-weight: 800; letter-spacing: -0.02em;
  background: linear-gradient(100deg, var(--text-primary) 40%, rgba(244,242,238,0.6) 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.page-header p { color: var(--text-muted); margin-top: 0.3rem; font-size: 0.9rem; }

/* ── Stats cards ── */
.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); padding: 1.25rem;
  transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,107,44,0.03) 0%, transparent 60%);
  pointer-events: none;
}
.stat-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.stat-card-label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 0.5rem; }
.stat-card-value { font-size: 2rem; font-weight: 800; line-height: 1; margin-bottom: 0.35rem; letter-spacing: -0.02em; }
.stat-card-sub { font-size: 0.8rem; color: var(--text-muted); }
.stat-card-icon {
  width: 40px; height: 40px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; margin-bottom: 0.875rem;
  transition: transform 0.2s ease;
}
.stat-card:hover .stat-card-icon { transform: scale(1.08); }
.stat-card-icon.orange { background: rgba(255,107,44,0.12); color: var(--primary-500); box-shadow: 0 0 0 1px rgba(255,107,44,0.2); }
.stat-card-icon.blue { background: var(--info-bg); color: var(--info); box-shadow: 0 0 0 1px rgba(59,130,246,0.2); }
.stat-card-icon.green { background: var(--success-bg); color: var(--success); box-shadow: 0 0 0 1px rgba(34,197,94,0.2); }
.stat-card-icon.yellow { background: var(--warning-bg); color: var(--warning); box-shadow: 0 0 0 1px rgba(245,158,11,0.2); }

/* ── Report cards ── */
.report-card {
  background: var(--bg-secondary); border: 1px solid var(--border-default);
  border-radius: var(--radius-xl); padding: 1.25rem;
  transition: all 0.22s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; gap: 0.75rem;
  position: relative; overflow: hidden;
}
.report-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--gradient-primary);
  transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s ease;
}
.report-card:hover {
  border-color: rgba(255,107,44,0.3);
  transform: translateY(-3px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}
.report-card:hover::after { transform: scaleX(1); }
.report-card-title { font-weight: 600; }
.report-card-domain { font-size: 0.8rem; color: var(--text-muted); }
.report-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.score-ring {
  width: 48px; height: 48px; border-radius: 50%;
  background: conic-gradient(var(--primary-500) calc(var(--score, 0) * 1%), var(--bg-elevated) 0);
  display: flex; align-items: center; justify-content: center; position: relative;
}
.score-ring::before {
  content: ''; position: absolute; inset: 6px; border-radius: 50%; background: var(--bg-secondary);
}
.score-ring-value { position: relative; font-size: 0.7rem; font-weight: 700; }

/* ── Charts grid ── */
#charts-grid {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 0.75rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .main-content { padding: 1rem; }

  #charts-grid {
    grid-template-columns: 1fr;
  }

  #charts-grid .card {
    min-height: 180px;
  }

  #radar-chart {
    max-height: 220px;
  }

  #timeline-chart {
    max-height: 200px;
  }

  #competitor-chart-wrap {
    overflow: hidden;
  }
}

/* ── Apex Gig dashboard widget ── */
.ag-dash-widget { margin-bottom: 1.5rem; }
.ag-dash-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.ag-dash-title { font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); display: flex; align-items: center; gap: 0.5rem; }
.ag-dash-title svg { color: var(--primary-500); }
.ag-dash-edit-btn { font-size: 0.8rem; font-weight: 700; color: var(--primary-500); background: rgba(255,107,44,0.08); border: 1px solid rgba(255,107,44,0.25); padding: 0.3rem 0.75rem; border-radius: 2px; cursor: pointer; font-family: inherit; transition: all 0.15s; display: flex; align-items: center; gap: 0.35rem; }
.ag-dash-edit-btn:hover { background: rgba(255,107,44,0.14); }

/* No-profile CTA card */
.ag-dash-cta { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ag-dash-cta-text h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.2rem; }
.ag-dash-cta-text p { font-size: 0.82rem; color: var(--text-muted); }
.ag-dash-create-btn { background: var(--gradient-primary); color: #fff; border: none; cursor: pointer; font-size: 0.85rem; font-weight: 700; padding: 0.55rem 1.1rem; border-radius: 2px; white-space: nowrap; flex-shrink: 0; font-family: inherit; transition: all 0.15s; box-shadow: 0 0 16px rgba(255,107,44,0.25); }
.ag-dash-create-btn:hover { box-shadow: 0 0 24px rgba(255,107,44,0.4); }

/* Profile preview card */
.ag-dash-profile { display: flex; gap: 1rem; }
.ag-dash-avatar { width: 52px; height: 52px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1rem; color: #fff; }
.ag-dash-info { flex: 1; min-width: 0; }
.ag-dash-name { font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ag-dash-meta { font-size: 0.78rem; color: var(--text-muted); margin: 0.15rem 0 0.35rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ag-dash-plan { font-size: 0.62rem; font-weight: 700; letter-spacing: 0.08em; border: 1px solid; padding: 0.1rem 0.4rem; border-radius: 2px; }
.ag-dash-bio { font-size: 0.82rem; color: var(--text-secondary); line-height: 1.5; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin-bottom: 0.6rem; }
.ag-dash-specs { display: flex; flex-wrap: wrap; gap: 0.3rem; margin-bottom: 0.75rem; }
.ag-dash-spec-tag { font-size: 0.68rem; font-weight: 600; background: rgba(255,107,44,0.07); border: 1px solid rgba(255,107,44,0.18); color: var(--primary-500); padding: 0.18rem 0.45rem; border-radius: 2px; }
.ag-dash-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; padding-top: 0.75rem; border-top: 1px solid var(--border-default); }
.ag-dash-lupas { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; }
.ag-dash-lupas strong { color: var(--primary-500); font-weight: 800; }
.ag-dash-actions { display: flex; gap: 0.4rem; }
.ag-dash-action { font-size: 0.78rem; font-weight: 600; padding: 0.35rem 0.7rem; border-radius: 2px; border: 1px solid var(--border-default); color: var(--text-secondary); text-decoration: none; background: var(--bg-elevated); cursor: pointer; font-family: inherit; transition: all 0.15s; display: flex; align-items: center; gap: 0.3rem; }
.ag-dash-action:hover { border-color: rgba(255,107,44,0.3); color: var(--primary-500); }
.ag-dash-action.primary { background: rgba(255,107,44,0.08); border-color: rgba(255,107,44,0.3); color: var(--primary-500); }

/* ── Profile quick-edit modal (dashboard) ── */
.ag-qe-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); z-index: 500; display: none; align-items: flex-start; justify-content: center; padding: 1.5rem 1rem; overflow-y: auto; }
.ag-qe-overlay.open { display: flex; }
.ag-qe-box { background: var(--bg-secondary); border: 1px solid var(--border-default); border-radius: 6px; width: 100%; max-width: 560px; overflow: hidden; animation: qe-pop 0.22s ease; margin: auto; }
@keyframes qe-pop { from{opacity:0;transform:translateY(-14px) scale(0.97)} to{opacity:1;transform:translateY(0) scale(1)} }
.ag-qe-bar { height: 4px; background: linear-gradient(100deg,#C2410C,#FF6B2C 55%,#FFB347); }
.ag-qe-head { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 0; }
.ag-qe-head h3 { font-size: 1.1rem; font-weight: 900; letter-spacing: -0.02em; }
.ag-qe-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 0.25rem; border-radius: 2px; transition: color 0.15s; }
.ag-qe-close:hover { color: var(--text-primary); }
.ag-qe-body { padding: 1.25rem 1.5rem 1.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }
.ag-qe-full { grid-column: 1/-1; }
.ag-qe-group { display: flex; flex-direction: column; gap: 0.3rem; }
.ag-qe-group label { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.ag-qe-group label .req { color: var(--primary-500); }
.ag-qe-input, .ag-qe-select, .ag-qe-textarea { width: 100%; padding: 0.55rem 0.75rem; background: var(--bg-elevated); border: 1px solid var(--border-default); border-radius: 2px; color: var(--text-primary); font-size: 0.875rem; font-family: inherit; transition: border-color 0.2s; }
.ag-qe-input:focus, .ag-qe-select:focus, .ag-qe-textarea:focus { outline: none; border-color: rgba(255,107,44,0.5); }
.ag-qe-textarea { resize: vertical; min-height: 75px; }
.ag-qe-specs { display: grid; grid-template-columns: repeat(3,1fr); gap: 0.35rem; }
.ag-qe-check { display: flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.ag-qe-check input { accent-color: var(--primary-500); width: 14px; height: 14px; cursor: pointer; }
.ag-qe-check span { font-size: 0.82rem; color: var(--text-secondary); }
.ag-qe-footer { grid-column: 1/-1; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-default); flex-wrap: wrap; }
.ag-qe-delete { font-size: 0.78rem; color: var(--text-muted); background: none; border: none; cursor: pointer; font-family: inherit; transition: color 0.15s; }
.ag-qe-delete:hover { color: #f87171; }
.ag-qe-save { display: inline-flex; align-items: center; gap: 0.4rem; background: linear-gradient(100deg,#C2410C,#FF6B2C); color: #fff; border: none; cursor: pointer; font-size: 0.875rem; font-weight: 700; padding: 0.6rem 1.4rem; border-radius: 2px; box-shadow: 0 0 18px rgba(255,107,44,0.3); transition: all 0.2s; font-family: inherit; }
.ag-qe-save:hover:not(:disabled) { box-shadow: 0 0 28px rgba(255,107,44,0.45); }
.ag-qe-save:disabled { opacity: 0.55; cursor: wait; }
.ag-qe-msg { font-size: 0.78rem; padding: 0.45rem 0.7rem; border-radius: 2px; grid-column: 1/-1; display: none; }
.ag-qe-msg.error { display: block; background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); color: #f87171; }
.ag-qe-msg.success { display: block; background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2); color: #4ade80; }

[data-theme="light"] .ag-qe-box { background: #fff; }
[data-theme="light"] .ag-qe-input,
[data-theme="light"] .ag-qe-select,
[data-theme="light"] .ag-qe-textarea { background: #F3EEE6; border-color: #E0DACF; }

@media (max-width: 640px) {
  .ag-qe-body { grid-template-columns: 1fr; }
  .ag-qe-specs { grid-template-columns: repeat(2,1fr); }
  .ag-dash-profile { flex-direction: column; }
}
