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

:root {
  --bg-page: #eef2f6;
  --bg-card: #ffffff;
  --sidebar-bg: #ffffff;
  --border-glass: #e2e8f0;
  --accent-blue: #2563eb;
  --accent-blue-bg: #eff6ff;
  --accent-amber: #d97706;
  --accent-amber-bg: #fffbeb;
  --accent-emerald: #059669;
  --accent-emerald-bg: #ecfdf5;
  --font-main: 'Plus Jakarta Sans', Inter, sans-serif;
  --font-heading: 'Outfit', sans-serif;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --sidebar-width: 300px;
  --navy: #0b1b3a;
  --teal: #14b8a6;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
  height: 100%;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  min-height: 100vh;
  overflow: hidden;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-page); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

#sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 1rem;
  position: fixed;
  height: 100vh;
  z-index: 100;
  box-shadow: 2px 0 12px rgba(0, 0, 0, 0.02);
  overflow-y: auto;
}

.sidebar-context {
  padding: 0.35rem 0.35rem 0.95rem;
  margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 110px;
  object-fit: contain;
  object-position: left center;
}

.nav-price {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--teal);
  white-space: nowrap;
}

.nav-group-label {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 10px 12px 4px;
}

.user-status-note {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.insight-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.insight-card {
  background: #fff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
}

.insight-rank {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ecfdf5;
  color: #059669;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.insight-card h3 {
  margin: 12px 0 8px;
  font-family: var(--font-heading);
  font-size: 1.25rem;
}

.insight-source {
  font-size: 0.78rem;
  color: var(--accent-blue);
  font-weight: 600;
  margin-bottom: 8px;
}

.insight-card p {
  color: var(--text-muted);
  line-height: 1.65;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-mini {
  background: #fff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.kpi-mini .k {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.kpi-mini .v {
  margin-top: 6px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--navy);
}

.kpi-mini .h {
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.context-kicker {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--accent-blue);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.context-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.02rem;
  color: var(--text-main);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.context-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 1rem;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0.7rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.88rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.nav-item:hover {
  background: #f8fafc;
  color: var(--text-main);
  border-color: var(--border-glass);
}

.nav-item.active {
  background: #eff6ff;
  color: var(--accent-blue);
  font-weight: 600;
  border-color: rgba(37, 99, 235, 0.18);
}

.nav-item .nav-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-item i { font-size: 0.95rem; }

.nav-caret {
  font-size: 0.7rem;
  transition: transform 0.2s ease;
}

.nav-item.expanded .nav-caret {
  transform: rotate(180deg);
}

.nav-group .nav-subitem {
  padding-left: 1.35rem;
}

.nav-subhead {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.35;
}

.nav-subhead .nav-price {
  margin-top: 1px;
}

.nav-children {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 2px 0 6px 18px;
}

.nav-children.open {
  display: flex;
}

.nav-subitem {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 0.55rem 0.9rem;
  border-radius: 10px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
}

.nav-subitem > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
}

.nav-subitem .nav-price {
  flex-shrink: 0;
  margin-top: 1px;
}

.nav-subitem:hover {
  background: #f8fafc;
  color: var(--text-main);
}

.nav-subitem.active {
  background: #eff6ff;
  color: var(--accent-blue);
  font-weight: 600;
  border-color: rgba(37, 99, 235, 0.16);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.completed { background: #10b981; }
.status-dot.pending { background: #f59e0b; }

.sidebar-footer { padding: 0.5rem; }

.user-status-card {
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.user-status-title {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.user-status-val {
  font-size: 0.8rem;
  color: var(--text-main);
  font-weight: 600;
}

main {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  width: calc(100vw - var(--sidebar-width));
  overflow: hidden;
}

main.chromeless header {
  display: none;
}

main.chromeless .content-body {
  padding-top: 0.75rem;
}

#app-container.no-sidebar #sidebar {
  display: none;
}

#app-container.no-sidebar main {
  margin-left: 0;
  width: 100vw;
}

#app-container.no-sidebar main.chromeless .content-body {
  padding: 0;
}

#app-container.no-sidebar .embed-frame {
  border: 0;
  border-radius: 0;
}

header {
  background: linear-gradient(135deg, #0b132b 0%, #1c2541 100%);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  margin: 1.5rem 2rem 0;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 10px 30px rgba(11, 19, 43, 0.12);
  flex-shrink: 0;
}

.header-title-group h1 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: #ffffff;
}

.header-subtitle {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-tag {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  color: #ffffff;
}

.status-tag span {
  color: #60a5fa;
  font-weight: 600;
}

.content-body {
  padding: 1.25rem 2rem 1.5rem;
  flex-grow: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.db-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.db-tab {
  border: 1px solid var(--border-glass);
  background: #fff;
  color: var(--text-muted);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.db-tab:hover { color: var(--text-main); border-color: #cbd5e1; }

.db-tab.active {
  background: #eff6ff;
  color: var(--accent-blue);
  border-color: rgba(37, 99, 235, 0.28);
}

.db-tab .db-tab-sub {
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 6px;
}

.hidden { display: none !important; }

#view-root {
  flex-grow: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.embed-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
  flex: 1 1 auto;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  background: #f0f4f8;
}

.empty-state,
.placeholder-page {
  background: #fff;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  padding: 36px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.empty-badge,
.pending-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent-amber-bg);
  color: var(--accent-amber);
  border: 1px solid #fde68a;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.completed-badge {
  background: var(--accent-emerald-bg);
  color: var(--accent-emerald);
  border: 1px solid #a7f3d0;
}

.empty-state h2,
.placeholder-page h2 {
  margin: 16px 0 8px;
  font-family: var(--font-heading);
  font-size: 1.6rem;
}

.empty-state p,
.placeholder-page p {
  color: var(--text-muted);
  line-height: 1.6;
}

.placeholder-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.placeholder-card {
  background: #f8fafc;
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.placeholder-card.wide { grid-column: 1 / -1; }

.placeholder-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.placeholder-value {
  font-size: 15px;
  font-weight: 700;
  color: #94a3b8;
  background: #fff;
  border: 1.5px dashed #cbd5e1;
  border-radius: 10px;
  padding: 14px 16px;
  min-height: 52px;
  display: flex;
  align-items: center;
}

.placeholder-value.filled {
  color: var(--text-main);
  border-style: solid;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.chart-placeholder {
  min-height: 220px;
  border: 1.5px dashed #cbd5e1;
  background: #f8fafc;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 8px;
  overflow: hidden;
}

.chart-placeholder img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
}

.chart-placeholder i { font-size: 28px; }

.improvement-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .placeholder-grid,
  .improvement-row,
  .kpi-row { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 900px) {
  #sidebar { width: 260px; }
  main { margin-left: 260px; width: calc(100vw - 260px); }
}
