:root {
  --bg-base: #030305;
  --bg-surface: #0a0a0e;
  --bg-el: #121218;
  --primary: #6c47ff;
  --ph: #5835e5;
  --cyan: #00e5ff;
  --green: #00e676;
  --red: #ff3366;
  --tm: #fff;
  --tmuted: #a0a0ab;
  --border: rgba(255, 255, 255, 0.08);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  overflow-x: clip; 
}

body {
  background: var(--bg-base);
  font-family: 'Outfit', sans-serif;
  color: var(--tm);
}

/* 3D Canvas Background - FIXED SCROLLBAR ISSUE */
#grid-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  opacity: 0.3;
  pointer-events: none;
  display: block; /* Removes inline 4px phantom margin */
}

/* Main Wrapper - FIXED HEIGHT ISSUE */
.wrap {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 80px 24px 32px;
  min-height: 100vh; /* Changed from calc to fix double scroll */
  display: flex;
  flex-direction: column;
}

/* Lighting Effects */
.wrap::before {
  content: ''; position: absolute; top: -150px; right: -150px; width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(108,71,255,0.12), transparent 65%);
  border-radius: 50%; pointer-events: none; z-index: -1;
}
.wrap::after {
  content: ''; position: absolute; bottom: -100px; left: -100px; width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(0,229,255,0.06), transparent 65%);
  border-radius: 50%; pointer-events: none; z-index: -1;
}

/* PAGE HEADER */
.pg-header { text-align: center; margin-bottom: 32px; }
.pg-header h1 { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1.2; margin: 0 0 8px 0; }
.pg-header h1 span { color: var(--primary); }
.pg-header p { color: var(--tmuted); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.15em; margin: 0; }

/* SEARCH PANEL */
.search-panel {
  background: rgba(18, 18, 24, 0.6); backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: 24px; padding: 24px; margin-bottom: 20px;
}
.search-panel label { display: block; font-size: 0.7rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.15em; color: var(--tmuted); margin-bottom: 12px; }
.input-row { display: flex; gap: 12px; flex-wrap: wrap; }
.input-row input {
  flex: 1; min-width: 0; width: 100%; background: rgba(0,0,0,0.5);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px 16px 44px; color: var(--tm); font-family: 'Outfit', sans-serif;
  font-size: 0.9rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; outline: none; transition: 0.3s;
}
.input-row input::placeholder { color: rgba(255,255,255,0.2); font-weight: 400; text-transform: none; letter-spacing: normal; }
.input-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(108,71,255,0.2); }
.input-wrap { position: relative; flex: 1; min-width: 250px; }
.input-wrap svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--tmuted); pointer-events: none; }

.verify-btn {
  padding: 16px 32px; background: var(--primary); border: none; border-radius: 14px;
  color: #fff; font-family: 'Outfit', sans-serif; font-size: 0.85rem; font-weight: 900;
  letter-spacing: 0.15em; text-transform: uppercase; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: 0.3s; white-space: nowrap; flex-shrink: 0;
}
.verify-btn:hover { background: var(--ph); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(108,71,255,0.4); }
.verify-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

@keyframes spin { 100% { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* RESULTS SECTION */
.results-label { font-size: 0.65rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.2em; color: var(--tmuted); margin-bottom: 12px; display: flex; align-items: center; gap: 12px; }
.results-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* RESULT CARD */
.result-card {
  background: rgba(108, 71, 255, 0.04); border: 1px solid rgba(108, 71, 255, 0.2);
  border-radius: 24px; padding: 24px; position: relative; overflow: hidden;
  backdrop-filter: blur(20px);
}
.result-card::before {
  content: ''; position: absolute; inset: 0; border-radius: 24px;
  background: linear-gradient(135deg, rgba(108,71,255,0.04) 0%, transparent 60%, rgba(0,229,255,0.02) 100%); pointer-events: none;
}
.result-inner { display: flex; gap: 24px; align-items: stretch; position: relative; z-index: 1; }

/* CERT PREVIEW */
.cert-preview {
  width: 200px; flex-shrink: 0; background: linear-gradient(145deg, #1a1530, #0e0d1c);
  border: 1px solid rgba(108, 71, 255, 0.3); border-radius: 16px; padding: 18px 16px 16px;
  position: relative; overflow: hidden; display: flex; flex-direction: column;
}
.cert-preview::before { content: ''; position: absolute; bottom: -20px; left: -20px; width: 100px; height: 100px; background: linear-gradient(135deg, var(--primary), var(--cyan)); opacity: 0.15; border-radius: 50%; }
.cert-preview::after { content: ''; position: absolute; top: -10px; right: -10px; width: 60px; height: 60px; background: var(--cyan); opacity: 0.06; border-radius: 50%; }
.cert-top-bar { display: flex; gap: 3px; margin-bottom: 12px; }
.cert-top-bar span { height: 3px; border-radius: 3px; background: var(--border); }
.cert-top-bar span:nth-child(1) { flex: 3; background: var(--primary); }
.cert-top-bar span:nth-child(3) { flex: 2; background: var(--cyan); }
.cert-type { font-size: 0.6rem; font-weight: 900; letter-spacing: 0.2em; text-transform: uppercase; color: var(--tmuted); margin-bottom: 6px; }
.cert-title { font-size: 0.85rem; font-weight: 900; letter-spacing: 0.05em; color: var(--tm); margin-bottom: 12px; line-height: 1.2; }
.cert-awarded { font-size: 0.55rem; color: var(--tmuted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.cert-name { font-size: 1rem; font-weight: 900; color: var(--primary); margin-bottom: 8px; font-style: italic; }
.cert-course { font-size: 0.6rem; font-weight: 700; color: var(--tmuted); text-transform: uppercase; letter-spacing: 0.08em; border-top: 1px solid var(--border); padding-top: 10px; margin-bottom: 12px; flex: 1; }
.cert-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.cert-num { font-size: 0.55rem; color: var(--tmuted); font-family: monospace; }
.cert-qr { display: grid; grid-template-columns: repeat(5, 6px); gap: 1px; }
.cert-qr span { width: 6px; height: 6px; border-radius: 1px; }

/* MAIN INFO */
.result-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.verified-headline { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.verified-headline .v-badge {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(0, 230, 118, 0.08);
  border: 1px solid rgba(0, 230, 118, 0.25); color: var(--green); border-radius: 999px; padding: 6px 16px;
  font-size: 0.65rem; font-weight: 900; letter-spacing: 0.15em; text-transform: uppercase;
}
.v-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: blink 1.5s ease-in-out infinite; }
@keyframes blink { 50% { opacity: 0.3; } }

/* AVATAR */
.student-avatar-wrap {
  width: 80px; height: 80px; border-radius: 16px; background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.12); box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0;
}
.student-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.student-avatar-fallback {
  width: 100%; height: 100%; background: linear-gradient(135deg, rgba(108, 71, 255, 0.25), rgba(0, 229, 255, 0.08));
  color: #c5b8ff; font-size: 1.6rem; font-weight: 900; letter-spacing: 1px; display: flex; align-items: center; justify-content: center; position: relative;
}

.info-name { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; text-transform: uppercase; margin-bottom: 6px; word-wrap: break-word; }
.info-course { font-size: 0.75rem; font-weight: 700; color: var(--tmuted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 20px; line-height: 1.4; }

.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px 12px; }
.meta-lbl { font-size: 0.55rem; color: #777; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; margin-bottom: 4px; }
.meta-val { font-size: 0.85rem; font-weight: 700; color: var(--tm); font-family: monospace; word-break: break-all; }

.status-row { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-lbl { font-size: 0.65rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.15em; color: var(--tmuted); }
.status-valid {
  display: inline-flex; align-items: center; gap: 8px; background: rgba(0, 230, 118, 0.1);
  border: 1px solid rgba(0, 230, 118, 0.3); border-radius: 12px; padding: 8px 16px;
  font-size: 0.8rem; font-weight: 900; letter-spacing: 0.1em; color: var(--green); text-transform: uppercase;
}

/* MINI STATS */
.side-stats { display: flex; flex-direction: column; gap: 12px; width: 140px; flex-shrink: 0; }
.stat-mini { background: rgba(18, 18, 24, 0.6); border: 1px solid var(--border); border-radius: 16px; padding: 16px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; }
.stat-mini-label { font-size: 0.55rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.12em; color: var(--tmuted); margin-bottom: 10px; }
.sparkline { display: flex; align-items: flex-end; gap: 3px; height: 32px; margin-bottom: 8px; }
.spark-bar { border-radius: 2px 2px 0 0; flex: 1; background: rgba(108, 71, 255, 0.3); transition: 0.3s; }
.spark-bar.hi { background: var(--primary); }
.spark-val { font-size: 0.9rem; font-weight: 900; color: var(--tm); margin-bottom: 2px; }
.spark-sub { font-size: 0.55rem; color: var(--green); font-weight: 700; }
.pie-wrap { display: flex; gap: 10px; align-items: center; }
.pie-legend { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.leg-item { display: flex; align-items: center; gap: 6px; font-size: 0.55rem; color: var(--tmuted); font-weight: 700; }
.leg-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ERROR & IDLE STATES */
.error-box { background: rgba(255, 51, 102, 0.05); border: 1px solid rgba(255, 51, 102, 0.25); border-radius: 16px; padding: 24px; display: flex; align-items: flex-start; gap: 16px; }
.err-icon { color: var(--red); font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.err-text { font-size: 0.85rem; font-weight: 900; text-transform: uppercase; letter-spacing: 0.1em; color: var(--red); margin-bottom: 6px; }
.err-sub { font-size: 0.8rem; color: var(--tmuted); font-weight: 400; line-height: 1.4; }

.idle-state { background: rgba(18, 18, 24, 0.6); border: 1px dashed rgba(255, 255, 255, 0.1); border-radius: 20px; padding: 40px 20px; text-align: center; }
.idle-icon { font-size: 2.5rem; margin-bottom: 16px; color: rgba(108, 71, 255, 0.4); }
.idle-text { font-size: 0.8rem; color: var(--tmuted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.15em; }

/* FOOTER */
.vf-footer { margin-top: auto; padding-top: 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; }
.footer-links a { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--tmuted); text-decoration: none; transition: 0.2s; }
.footer-links a:hover, .footer-links a.active { color: var(--primary); }
.social-icons { display: flex; gap: 12px; }
.social-icons button { width: 36px; height: 36px; border-radius: 10px; background: var(--bg-el); border: 1px solid var(--border); color: var(--tmuted); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; }
.social-icons button:hover { border-color: rgba(108, 71, 255, 0.3); color: var(--primary); background: rgba(108, 71, 255, 0.08); transform: translateY(-2px); }

/* RESPONSIVE DESIGN */
@media (max-width: 900px) {
  .result-inner { flex-direction: column; }
  .cert-preview { width: 100%; max-width: 320px; margin: 0 auto; }
  .side-stats { width: 100%; flex-direction: row; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
}

@media (max-width: 600px) {
  .wrap { padding: 40px 16px 24px; }
  
  .input-row { flex-direction: column; }
  .input-wrap { width: 100%; min-width: 0; }
  .verify-btn { width: 100%; padding: 18px; }

  .verified-headline { flex-direction: column-reverse; align-items: center; text-align: center; gap: 12px; }
  .student-avatar-wrap { width: 90px; height: 90px; margin: 0 auto; }
  
  .info-name { text-align: center; }
  .info-course { text-align: center; margin-bottom: 24px; }
  
  .meta-grid { grid-template-columns: 1fr; background: rgba(0,0,0,0.2); padding: 16px; border-radius: 12px; }
  .meta-item { display: flex; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.05); padding-bottom: 8px; }
  .meta-item:last-child { border-bottom: none; padding-bottom: 0; }
  .meta-val { text-align: right; }

  .status-row { justify-content: center; flex-direction: column; }
  .side-stats { grid-template-columns: 1fr; }
  .vf-footer { flex-direction: column; text-align: center; }
}