/* ================================================================
   IIEC Certificate Telemetry & Analytics Dashboard
   Next Gen Pitch Design System (Light High-Contrast Theme)
   ================================================================ */

:root {
  /* Core Palette */
  --bg: #f5f5f0;
  --bg-subtle: #eeeee8;
  --ink: #111111;
  --ink-secondary: #444440;
  --card: #ffffff;
  --card-subtle: #fbfbf9;
  --muted: #66665f;
  --line: #d8d8d0;
  --line-light: #e8e8e0;

  /* Accent Scale */
  --accent: #ff5a1f;
  --accent-dark: #dc4310;
  --accent-light: #ffece4;
  --accent-border: #ffc7b0;
  --accent-glow: rgba(255, 90, 31, 0.2);

  /* Metric Tints */
  --blue: #2563eb;
  --blue-bg: #eff6ff;
  --blue-border: #bfdbfe;

  --green: #16a34a;
  --green-bg: #f0fdf4;
  --green-border: #bbf7d0;

  --purple: #7c3aed;
  --purple-bg: #f5f3ff;
  --purple-border: #ddd6fe;

  --orange: #ea580c;
  --orange-bg: #fff7ed;
  --orange-border: #ffedd5;

  --red: #dc2626;
  --red-bg: #fef2f2;
  --red-border: #fecaca;

  /* Typography & Layout */
  --font-sans: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --container-max: 1320px;
  --nav-height: 72px;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --radius-pill: 999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.08);
}

/* ----------------------------------------------------------------
   1. Base & Global Reset
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(17, 17, 17, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
  z-index: -1;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
}

/* ----------------------------------------------------------------
   2. Sticky Frosted Header
   ---------------------------------------------------------------- */
.nav-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(245, 245, 240, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

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

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.nav-logo-wrap {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.nav-logo-wrap img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.nav-brand-text {
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.nav-menu {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-item {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-secondary);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: #ffffff;
}

/* ----------------------------------------------------------------
   3. Loading Overlay
   ---------------------------------------------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(245, 245, 240, 0.7);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 44px;
  height: 44px;
  border: 3.5px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------
   4. Login Screen
   ---------------------------------------------------------------- */
.dashboard-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.login-card {
  max-width: 440px;
  margin: 60px auto;
  padding: 44px 36px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  text-align: center;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--accent) 0%, #ff8c5a 100%);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

.login-title {
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 0.925rem;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 28px;
}

.form-group {
  text-align: left;
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--bg-subtle);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  transition: all 0.2s ease;
}

.form-input:focus {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}

.login-btn {
  width: 100%;
  height: 50px;
  background: var(--accent);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.login-btn:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(255, 90, 31, 0.35);
}

.login-error {
  display: none;
  margin-top: 16px;
  padding: 10px 14px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ----------------------------------------------------------------
   5. Dashboard Header & Actions
   ---------------------------------------------------------------- */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 36px;
  flex-wrap: wrap;
  gap: 20px;
}

.dashboard-title-group {
  max-width: 600px;
}

.dashboard-pill-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-secondary);
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

.dashboard-title {
  font-size: clamp(1.85rem, 4vw, 2.6rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  color: var(--ink);
  line-height: 1.15;
}

.dashboard-title span {
  color: var(--accent);
}

.dashboard-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-top: 6px;
}

.dashboard-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.refresh-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  background: #ffffff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.refresh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

.refresh-btn.loading svg {
  animation: spin 0.8s linear infinite;
}

/* ----------------------------------------------------------------
   6. Stats Grid (Bento Metric Cards)
   ---------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.stat-card--searches::before { background: var(--blue); }
.stat-card--downloads::before { background: var(--green); }
.stat-card--verifications::before { background: var(--purple); }
.stat-card--qr::before { background: var(--orange); }

.stat-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.stat-card--searches .stat-icon-wrap { background: var(--blue-bg); color: var(--blue); }
.stat-card--downloads .stat-icon-wrap { background: var(--green-bg); color: var(--green); }
.stat-card--verifications .stat-icon-wrap { background: var(--purple-bg); color: var(--purple); }
.stat-card--qr .stat-icon-wrap { background: var(--orange-bg); color: var(--orange); }

.stat-icon-wrap svg {
  width: 22px;
  height: 22px;
}

.stat-value {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 12px;
}

.stat-today {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
}

.stat-card--searches .stat-today { background: var(--blue-bg); color: var(--blue); }
.stat-card--downloads .stat-today { background: var(--green-bg); color: var(--green); }
.stat-card--verifications .stat-today { background: var(--purple-bg); color: var(--purple); }
.stat-card--qr .stat-today { background: var(--orange-bg); color: var(--orange); }

/* ----------------------------------------------------------------
   7. Chart Section
   ---------------------------------------------------------------- */
.chart-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
  margin-bottom: 36px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.section-title svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.chart-wrapper {
  position: relative;
  width: 100%;
}

.chart-container {
  width: 100%;
  min-height: 250px;
}

.chart-svg {
  width: 100%;
  height: 250px;
  overflow: visible;
}

.chart-grid-line {
  stroke: var(--line-light);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-y-label {
  font-size: 0.75rem;
  fill: #888880;
  font-family: inherit;
  font-weight: 600;
  text-anchor: end;
}

.chart-label {
  font-size: 0.75rem;
  fill: #888880;
  font-family: inherit;
  font-weight: 600;
  text-anchor: middle;
}

.chart-value-label {
  font-size: 0.72rem;
  fill: var(--ink);
  font-family: inherit;
  font-weight: 800;
  text-anchor: middle;
}

/* SVG Line & Area */
.chart-area--searches { fill: rgba(37, 99, 235, 0.08); }
.chart-area--downloads { fill: rgba(22, 163, 74, 0.08); }
.chart-area--verifications { fill: rgba(124, 58, 237, 0.08); }

.chart-line--searches { stroke: var(--blue); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart-line--downloads { stroke: var(--green); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.chart-line--verifications { stroke: var(--purple); stroke-width: 2.5; fill: none; stroke-linecap: round; stroke-linejoin: round; }

.chart-point {
  fill: #ffffff;
  stroke-width: 2.5;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.chart-point:hover {
  transform: scale(1.4);
}

.chart-point--searches { stroke: var(--blue); }
.chart-point--downloads { stroke: var(--green); }
.chart-point--verifications { stroke: var(--purple); }

/* Chart Tooltip */
.chart-tooltip {
  position: absolute;
  display: none;
  background: var(--ink);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  pointer-events: none;
  z-index: 10;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.chart-tooltip.active {
  display: block;
}

.chart-tooltip-title {
  font-weight: 700;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 4px;
}

.chart-tooltip-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
}

.chart-tooltip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  margin-top: 18px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot--searches { background: var(--blue); }
.legend-dot--downloads { background: var(--green); }
.legend-dot--verifications { background: var(--purple); }

/* ----------------------------------------------------------------
   8. Activity Log Table
   ---------------------------------------------------------------- */
.activity-section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-md);
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.filter-pills {
  display: flex;
  gap: 8px;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
}

.filter-pill {
  padding: 6px 16px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--muted);
  border-radius: var(--radius-pill);
  transition: all 0.2s ease;
}

.filter-pill.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.activity-table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.activity-table th {
  background: var(--bg-subtle);
  color: var(--ink);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.72rem;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.activity-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-light);
  color: var(--ink);
  vertical-align: middle;
}

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

.activity-table tbody tr {
  transition: background 0.15s ease;
}

.activity-table tbody tr:hover {
  background: var(--bg-subtle);
}

/* Badges in table */
.action-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.action-badge--search { background: var(--blue-bg); color: var(--blue); border: 1px solid var(--blue-border); }
.action-badge--download { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.action-badge--verify { background: var(--purple-bg); color: var(--purple); border: 1px solid var(--purple-border); }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 700;
}

.status-badge--success { background: var(--green-bg); color: var(--green); }
.status-badge--not-found { background: var(--red-bg); color: var(--red); }

.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--bg-subtle);
  border: 1px solid var(--line);
}

.source-badge--qr {
  background: var(--orange-bg);
  color: var(--orange);
  border-color: var(--orange-border);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-state svg {
  width: 44px;
  height: 44px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.load-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 24px auto 0;
  padding: 10px 24px;
  background: #ffffff;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
  transition: all 0.2s ease;
}

.load-more-btn:hover {
  border-color: var(--ink);
  background: var(--bg-subtle);
}

.last-updated {
  text-align: right;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 18px;
}

/* ----------------------------------------------------------------
   9. Official University Footer
   ---------------------------------------------------------------- */
.site-footer {
  background: #ffffff;
  border-top: 1px solid var(--line);
  padding: 32px 24px;
  margin-top: auto;
}

.site-footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}

.site-footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-footer-logo {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: contain;
}

.site-footer-copy {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

.site-footer-copy strong {
  color: var(--ink);
  font-weight: 700;
}

.site-footer-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.site-footer-links a {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.2s ease;
}

.site-footer-links a:hover {
  color: var(--accent);
}

/* ----------------------------------------------------------------
   10. Responsive
   ---------------------------------------------------------------- */
@media (max-width: 1080px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .hide-mobile {
    display: none;
  }

  .chart-section,
  .activity-section {
    padding: 24px 16px;
  }

  .site-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }
}