/* ── LensReport Web Viewer — Apple-Minimal Design ──────────────────────── */

:root {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --text: #1A2332;
  --text-secondary: #8892A0;
  --text-muted: #B0B8C4;
  --border: #E5E7EB;
  --border-light: #F0F1F3;
  --brand: #4CAF7D;
  --brand-dark: #3A9468;
  --brand-light: #E8F5EE;
  --totals-bg: #F7FBF9;
  --alt-row: #FAFBFC;
  --hover-row: #F5F6F8;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
  --radius: 12px;
  --container: 900px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ── Navigation ──────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--container);
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.nav-logo {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-name {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.2px;
}

.nav-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand);
  text-decoration: none;
  transition: opacity 0.15s;
}

.nav-link:hover { opacity: 0.8; }
.nav-arrow { transition: transform 0.15s; display: inline-block; }
.nav-link:hover .nav-arrow { transform: translateX(2px); }

/* ── Report Content ──────────────────────────────────────────────────── */

.report-content { padding-bottom: 20px; }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Report Header ───────────────────────────────────────────────────── */

.report-header {
  padding: 36px 0 24px;
}

.report-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 8px;
}

.report-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.4px;
  line-height: 1.25;
  margin-bottom: 8px;
}

.report-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.meta-dot { color: var(--text-muted); }

.report-shared-by {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.report-shared-by:empty { display: none; }

/* ── Tab Bar ─────────────────────────────────────────────────────────── */

.tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 3px;
  background: var(--surface);
  border-radius: 10px;
  border: 1px solid var(--border);
  width: fit-content;
}

.tab {
  padding: 7px 18px;
  border: none;
  background: transparent;
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s ease;
}

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

.tab.active {
  background: var(--brand);
  color: white;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(76,175,125,0.3);
}

.tab.hidden { display: none; }

/* ── Tab Content ─────────────────────────────────────────────────────── */

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Data Table ──────────────────────────────────────────────────────── */

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

.report-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--alt-row);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
}

.report-table tbody td {
  padding: 11px 16px;
  color: var(--text);
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}

.report-table tbody tr:hover td { background: var(--hover-row); }
.report-table tbody tr:last-child td { border-bottom: none; }

.row-num {
  color: var(--text-muted) !important;
  font-size: 12px;
  width: 40px;
  text-align: center;
}

.cell-currency, .cell-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.empty-cell { color: var(--text-muted) !important; }

.totals-row td {
  background: var(--totals-bg) !important;
  border-top: 2px solid var(--brand) !important;
  border-bottom: none !important;
  font-weight: 700;
  color: var(--text);
}

.totals-row .row-num {
  font-weight: 700;
  color: var(--text) !important;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

/* ── Dashboard ───────────────────────────────────────────────────────── */

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  box-shadow: var(--shadow-sm);
}

.kpi-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 6px;
}

.kpi-value {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.kpi-count {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.dashboard-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.dashboard-card h3 {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  letter-spacing: -0.1px;
}

/* Category Breakdown */

.category-row { margin-bottom: 14px; }
.category-row:last-child { margin-bottom: 0; }

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.category-name {
  font-size: 13px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.category-value {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-bar {
  height: 6px;
  background: var(--alt-row);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease-out;
}

/* Charts */

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.chart-card canvas {
  max-height: 280px;
}

/* Merchants */

.merchant-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
}

.merchant-row:last-child { border-bottom: none; }

.merchant-rank {
  width: 24px;
  height: 24px;
  background: var(--alt-row);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.merchant-info { flex: 1; min-width: 0; }

.merchant-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: block;
}

.merchant-meta {
  font-size: 11px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.merchant-bar {
  width: 80px;
  flex-shrink: 0;
}

/* Insights */

.insights-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-tile {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.insight-icon {
  flex-shrink: 0;
  font-size: 14px;
  margin-top: 1px;
}

.insight-positive { background: #F0FDF4; color: #166534; }
.insight-negative { background: #FEF2F2; color: #991B1B; }
.insight-neutral  { background: var(--alt-row); color: var(--text-secondary); }
.insight-info     { background: #EFF6FF; color: #1E40AF; }

/* ── Loading State ───────────────────────────────────────────────────── */

.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 40px 24px;
}

.loader-logo {
  margin-bottom: 20px;
}

.loader-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800;
  font-size: 22px;
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.92); opacity: 0.7; }
}

.loader-text {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ── Error State ─────────────────────────────────────────────────────── */

.error-content {
  text-align: center;
  max-width: 400px;
}

.error-icon {
  font-size: 40px;
  margin-bottom: 16px;
  opacity: 0.8;
}

.error-title {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.error-message {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ── CTA ─────────────────────────────────────────────────────────────── */

.cta-pill {
  display: inline-block;
  background: var(--brand);
  color: white;
  padding: 10px 28px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px rgba(76,175,125,0.25);
}

.cta-pill:hover {
  background: var(--brand-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(76,175,125,0.3);
}

.cta-tagline {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

/* ── Footer ──────────────────────────────────────────────────────────── */

.footer {
  padding: 40px 24px 48px;
  text-align: center;
}

.footer-inner {
  max-width: 400px;
  margin: 0 auto;
}

.footer-prepared {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
  letter-spacing: 0.3px;
}

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  :root { --container: 100%; }

  .nav-inner { padding: 10px 16px; }
  .container { padding: 0 16px; }

  .report-header { padding: 24px 0 16px; }
  .report-title { font-size: 19px; }
  .report-meta { font-size: 12px; gap: 4px; }
  .report-label { font-size: 10px; }

  .tab-bar { margin-bottom: 16px; }
  .tab { padding: 6px 14px; font-size: 12px; }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .kpi-card { padding: 14px 16px; }
  .kpi-value { font-size: 18px; }

  .dashboard-card { padding: 18px 16px; }

  .footer { padding: 32px 16px 40px; }

  .report-table { font-size: 12px; }
  .report-table thead th { padding: 10px 12px; }
  .report-table tbody td { padding: 9px 12px; }
}

@media (min-width: 641px) and (max-width: 1024px) {
  :root { --container: 800px; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .chart-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1025px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .chart-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Print ────────────────────────────────────────────────────────────── */

@media print {
  .nav, .tab-bar, .footer, .cta-pill, .cta-tagline { display: none; }
  body { background: white; }
  .table-scroll { box-shadow: none; border: 1px solid #ddd; }
}
