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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-hover: #222632;
  --border: #2a2e3a;
  --text: #e4e5e9;
  --text-muted: #8b8d97;
  --accent: #6366f1;
  --accent-soft: rgba(99,102,241,.12);
  --green: #22c55e;
  --green-soft: rgba(34,197,94,.12);
  --red: #ef4444;
  --red-soft: rgba(239,68,68,.12);
  --font: 'Inter', -apple-system, system-ui, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 24px 0;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 10;
}

.sidebar-logo {
  padding: 0 24px 24px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -.3px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon { color: var(--accent); font-size: 22px; }

.sidebar-nav { list-style: none; flex: 1; }

.sidebar-nav li a {
  display: block;
  padding: 10px 24px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  transition: all .15s;
}

.sidebar-nav li a:hover { color: var(--text); background: var(--surface-hover); }
.sidebar-nav li.active a { color: var(--text); background: var(--accent-soft); border-right: 2px solid var(--accent); }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.user-name { font-weight: 500; font-size: 13px; }
.user-role { color: var(--text-muted); font-size: 12px; }

/* ---- Main ---- */
.main {
  margin-left: 240px;
  flex: 1;
  padding: 32px;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.topbar h1 { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 13px;
}

.status-dot {
  width: 8px; height: 8px;
  background: var(--green);
  border-radius: 50%;
  display: inline-block;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.metric-label { color: var(--text-muted); font-size: 13px; margin-bottom: 8px; }
.metric-value { font-size: 28px; font-weight: 700; letter-spacing: -.5px; margin-bottom: 6px; }
.metric-change { font-size: 12px; font-weight: 500; }
.metric-change.up { color: var(--green); }
.metric-change.down { color: var(--red); }

/* ---- Panels ---- */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.panel h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ---- Chart ---- */
.chart-panel { grid-column: 1 / -1; }

.chart {
  height: 200px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding-top: 10px;
}

.chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  min-height: 8px;
  transition: background .15s;
}

.chart-bar:hover { background: #818cf8; }

/* ---- Report Card ---- */
.report-card {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px 28px;
  border: 1px solid var(--accent);
  background: linear-gradient(135deg, var(--surface) 0%, rgba(99,102,241,.06) 100%);
}

.report-icon { font-size: 36px; flex-shrink: 0; }

.report-info { flex: 1; }
.report-info h2 { margin-bottom: 6px; }
.report-info p { color: var(--text-muted); font-size: 13px; line-height: 1.5; margin-bottom: 8px; }

.report-meta {
  display: flex;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.btn-lg {
  padding: 12px 28px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ---- Tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

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

/* ---- Plan Bars ---- */
.plan-bars { display: flex; flex-direction: column; gap: 14px; }

.plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.plan-name { font-size: 13px; width: 80px; color: var(--text-muted); }
.plan-pct { font-size: 13px; font-weight: 600; width: 40px; text-align: right; }

.plan-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.plan-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .6s ease;
}

.free-fill { background: var(--text-muted); }
.pro-fill { background: var(--accent); }
.ent-fill { background: var(--green); }

/* ---- Activity Log ---- */
.activity-log { list-style: none; }

.activity-log li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.activity-log li:last-child { border-bottom: none; }
.activity-time { color: var(--text-muted); font-size: 12px; white-space: nowrap; margin-left: 12px; }

/* ---- Buttons ---- */
.btn {
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #4f46e5; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-hover); }

/* ---- Export Dialog ---- */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

.dialog-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.dialog-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 32px;
  max-width: 480px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.dialog-icon {
  width: 40px; height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: 16px;
}

.dialog-icon.insight { background: var(--accent-soft); color: var(--accent); }

.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }

.dialog-body {
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 20px;
}

.dialog-body strong { color: var(--text); font-weight: 500; }

.dialog-detail {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.dialog-detail .detail-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.dialog-detail .detail-label { color: var(--text-muted); }
.dialog-detail .detail-value { color: var(--text); font-weight: 500; }

.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ---- Export Confirmation Banner ---- */
.export-banner {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  z-index: 3000;
  max-width: 420px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  transform: translateY(-20px);
  opacity: 0;
  transition: all .3s ease;
}

.export-banner.visible { transform: translateY(0); opacity: 1; }

.export-banner-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-banner-body {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---- Download link (after export) ---- */
.download-ready {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding: 12px 16px;
  background: var(--green-soft);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 8px;
}

.download-ready a {
  color: var(--green);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}

.download-ready span {
  color: var(--text-muted);
  font-size: 12px;
}
