:root {
  --color-primary: #1a1a2e;
  --color-accent: #4361ee;
  --color-accent-hover: #3451d1;
  --color-bg: #ffffff;
  --color-bg-alt: #f8f9fa;
  --color-text: #333333;
  --color-text-secondary: #666666;
  --color-border: #e0e0e0;
  --font-stack: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  --max-width: 1200px;
  --nav-height: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-stack);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Brand Bar (above nav) ---- */
.brand-bar {
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
  padding: 0.35rem 2rem;
}
.brand-bar-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
}
.brand-bar img { height: 18px; width: auto; opacity: 0.7; }
.brand-bar span { font-size: 0.75rem; color: var(--color-text-secondary); }

/* ---- Navigation ---- */
.nav {
  background: var(--color-primary);
  height: var(--nav-height);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  text-decoration: none;
}
.nav-links { display: flex; gap: 0.25rem; list-style: none; }
.nav-links a {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
}

/* ---- Main ---- */
.main {
  flex: 1;
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: 2rem;
}
.page-header {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
}
.page-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--color-primary); margin-bottom: 0.5rem; }
.page-header p { color: var(--color-text-secondary); }

/* ---- Cards ---- */
.card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}
.card h2 { font-size: 1.2rem; margin-bottom: 0.75rem; color: var(--color-primary); }
.card p { color: var(--color-text-secondary); font-size: 0.95rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  font-family: var(--font-stack);
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-outline { background: transparent; color: var(--color-accent); border: 1px solid var(--color-accent); }
.btn-outline:hover { background: var(--color-accent); color: #fff; }

/* ---- Grids ---- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }

/* ---- Stat Cards ---- */
.stat-card {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--color-primary); }
.stat-card .stat-label { font-size: 0.85rem; color: var(--color-text-secondary); margin-top: 0.25rem; }

/* ---- Footer ---- */
.footer {
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 2rem;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-secondary);
}
.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.footer-brand img { height: 20px; width: auto; opacity: 0.6; }
.footer-brand span { font-size: 0.8rem; color: var(--color-text-secondary); }

/* ---- Login Page ---- */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-bg-alt);
  flex-direction: column;
  gap: 2rem;
}
.login-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 3rem;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.login-box h1 { font-size: 1.5rem; color: var(--color-primary); margin-bottom: 0.5rem; }
.login-box p { color: var(--color-text-secondary); margin-bottom: 1.5rem; font-size: 0.95rem; }
.login-box input[type="password"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 1rem;
  margin-bottom: 1rem;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font-stack);
}
.login-box input[type="password"]:focus { border-color: var(--color-accent); }
.login-box .btn { width: 100%; justify-content: center; padding: 0.75rem; }
.login-error { color: #dc3545; font-size: 0.85rem; margin-top: 0.75rem; display: none; }
.login-powered-by {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  opacity: 0.5;
}
.login-powered-by img { height: 18px; width: auto; }
.login-powered-by span { font-size: 0.75rem; color: var(--color-text-secondary); }
.login-loading { display: none; flex-direction: column; align-items: center; gap: 12px; margin-top: 1rem; }
.login-spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tabs (dashboards page) ---- */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--color-border);
}
.tab-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.95rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
  font-family: var(--font-stack);
}
.tab-btn:hover { color: var(--color-text); }
.tab-btn.active { color: var(--color-accent); border-bottom-color: var(--color-accent); font-weight: 500; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Report list (email reports page) ---- */
.report-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: border-color 0.2s;
}
.report-item:hover { border-color: var(--color-accent); }
.report-info h3 { font-size: 1.05rem; color: var(--color-primary); margin-bottom: 0.25rem; }
.report-info p { font-size: 0.85rem; color: var(--color-text-secondary); }

/* ---- Nav cards (overview page) ---- */
.nav-card {
  display: block;
  padding: 1.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}
.nav-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px rgba(67,97,238,0.1);
  transform: translateY(-2px);
}
.nav-card h3 { font-size: 1.05rem; color: var(--color-primary); margin-bottom: 0.5rem; }
.nav-card p { font-size: 0.9rem; color: var(--color-text-secondary); }
.nav-card .card-arrow { color: var(--color-accent); font-size: 0.9rem; margin-top: 0.75rem; display: inline-block; }

/* ---- Hero (overview page) ---- */
.hero {
  background: var(--color-primary);
  color: #fff;
  padding: 3rem 2rem;
  border-radius: 12px;
  margin-bottom: 2rem;
}
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; color: #fff; }
.hero p { color: rgba(255,255,255,0.8); font-size: 1.05rem; max-width: 600px; }

/* ---- Key findings (overview page) ---- */
.key-findings {
  background: var(--color-bg-alt);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2.5rem;
}
.key-findings ul { list-style: none; }
.key-findings li {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.95rem;
  display: flex;
  gap: 0.75rem;
}
.key-findings li:last-child { border-bottom: none; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav { padding: 0 1rem; }
  .nav-links a { padding: 0.5rem 0.6rem; font-size: 0.8rem; }
  .main { padding: 1.5rem 1rem; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .hero { padding: 2rem 1.5rem; }
  .hero h1 { font-size: 1.5rem; }
}

/* ---- Email Reports Page ---- */

/* Featured Report Card */
.featured-card {
  background: var(--color-bg);
  border: 2px solid var(--color-accent);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2.5rem;
  transition: box-shadow 0.2s;
}
.featured-card:hover {
  box-shadow: 0 4px 12px rgba(67,97,238,0.15);
}
.featured-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.featured-card-icon {
  font-size: 2rem;
  line-height: 1;
}
.featured-card-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
}
.featured-card-subtitle {
  font-size: 1rem;
  color: var(--color-text-secondary);
}
.featured-card-description {
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.featured-card-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Section Header */
.section-header {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 2rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

/* Report Card Grid */
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}
@media (max-width: 1024px) {
  .report-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .report-grid { grid-template-columns: 1fr; }
}

/* Individual Report Card */
.report-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}
.report-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 4px 8px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}
.report-card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.report-card-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.report-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary);
}
.report-card-email {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  font-family: monospace;
  background: var(--color-bg-alt);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  word-break: break-all;
}
.report-card-dates {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
  flex-grow: 1;
}
.report-card-actions {
  display: flex;
  gap: 0.5rem;
}
.report-card-actions .btn {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}
.btn-icon-only {
  padding: 0.5rem 0.75rem !important;
}

/* PDF Viewer Container */
.pdf-viewer-container {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-top: 2rem;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}
.pdf-viewer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--color-bg-alt);
  border-bottom: 1px solid var(--color-border);
}
.pdf-viewer-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-primary);
  margin: 0;
}
.pdf-viewer-content {
  background: #f0f0f0;
}
.pdf-viewer-content iframe {
  display: block;
  width: 100%;
  height: 800px;
  border: none;
}
.pdf-viewer-footer {
  padding: 1rem 1.5rem;
  background: var(--color-bg-alt);
  border-top: 1px solid var(--color-border);
  display: flex;
  gap: 0.75rem;
}

/* Button Close */
.btn-close {
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--color-text-secondary);
  transition: all 0.2s;
}
.btn-close:hover {
  background: var(--color-bg-alt);
  color: var(--color-text);
  border-color: var(--color-text-secondary);
}

/* Responsive adjustments for featured card */
@media (max-width: 640px) {
  .featured-card { padding: 1.5rem; }
  .featured-card-title { font-size: 1.25rem; }
  .featured-card-actions { flex-direction: column; }
  .featured-card-actions .btn { width: 100%; justify-content: center; }
  .pdf-viewer-content iframe { height: 500px; }
}
