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

:root {
  --green-900: #063f2b;
  --green-800: #0a5c3e;
  --green-700: #0e7a52;
  --green-600: #12996a;
  --green-50: #ecf7f1;
  --gold: #e8b429;
  --bg: #f2f6f3;
  --card: #ffffff;
  --text: #16281f;
  --muted: #5e7268;
  --border: #dde8e1;
  --red: #b3261e;
  --amber: #a86a00;
  --radius: 14px;
  --control-h: 48px;
  --shadow: 0 4px 18px rgba(6, 63, 43, 0.07);
}

/* the hidden attribute must always win over display rules */
[hidden] { display: none !important; }

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

body {
  font-family: "Poppins", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- compact top bar (keeps the checker above the fold) ---------- */
.topbar {
  background: linear-gradient(120deg, var(--green-900), var(--green-800) 60%, var(--green-700));
  color: #fff;
  border-bottom: 3px solid var(--gold);
}
.topbar-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-mark {
  width: 46px; height: 46px;
  flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 14px;
}
.brand-text h1 { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.3px; line-height: 1.2; }
.brand-text p { font-size: 0.8rem; opacity: 0.85; }

/* ---------- stats strip ---------- */
.stats {
  max-width: 900px;
  margin: 14px auto 0;
  padding: 0 14px;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  box-shadow: var(--shadow);
}
.stat strong { font-size: 1.02rem; color: var(--green-800); line-height: 1.2; }
.stat span:last-child { font-size: 0.7rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-icon { font-size: 1.05rem; line-height: 1; }
.live-dot {
  width: 11px; height: 11px;
  margin: 4px 0 3px;
  border-radius: 50%;
  background: #e33;
  box-shadow: 0 0 0 0 rgba(238, 51, 51, 0.5);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(238, 51, 51, 0.45); }
  70% { box-shadow: 0 0 0 7px rgba(238, 51, 51, 0); }
  100% { box-shadow: 0 0 0 0 rgba(238, 51, 51, 0); }
}

/* ---------- layout ---------- */
main { flex: 1; width: 100%; max-width: 900px; margin: 0 auto; padding: 12px 14px 34px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--green-800);
  margin-bottom: 12px;
}
.step-dot {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: var(--green-700);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 700;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row.actions { align-items: center; margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 200px; }
.field.grow { flex: 1; }
label { font-size: 0.74rem; font-weight: 600; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; }

/* consistent controls: same height, radius, typography */
select, input, button, .btn-link {
  height: var(--control-h);
  border-radius: 11px;
  font-size: 0.96rem;
  font-family: inherit;
}
select, input, textarea {
  padding: 0 14px;
  border: 1.5px solid var(--border);
  background: #fbfdfc;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
textarea { height: auto; padding: 12px 14px; resize: vertical; border-radius: 11px; font-size: 0.96rem; font-family: inherit; }
select { cursor: pointer; appearance: auto; }
select:hover, input:hover, textarea:hover { border-color: #c3d6ca; }
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 4px rgba(18, 153, 106, 0.14);
  background: #fff;
}
:focus-visible { outline: 3px solid rgba(18, 153, 106, 0.55); outline-offset: 2px; }

button, .btn-link {
  padding: 0 22px;
  border: 1.5px solid var(--border);
  background: #fff;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text);
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
button:hover { background: #f6faf7; }
button.primary, .btn-link.primary {
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  border: none;
  color: #fff;
  box-shadow: 0 5px 14px rgba(14, 122, 82, 0.32);
}
button.primary:hover, .btn-link.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 7px 18px rgba(14, 122, 82, 0.4);
}
button.primary:active { transform: translateY(0); }
button:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

/* ---------- tabs ---------- */
.tabs {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 14px;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}
.tab {
  border: none;
  background: none;
  height: 38px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--muted);
}
.tab:hover { background: rgba(18, 153, 106, 0.08); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, var(--green-700), var(--green-600));
  box-shadow: 0 3px 9px rgba(14, 122, 82, 0.3);
}

/* ---------- notes & captcha ---------- */
.note {
  background: #fffaeb;
  border: 1px solid #f3e3ac;
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 10px 13px;
  margin-top: 12px;
  font-size: 0.87rem;
  color: #6b5518;
}

.captcha-box {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 12px;
  background: var(--green-50);
  border: 1px dashed #bcd8c9;
  border-radius: 12px;
}
.captcha-box img {
  height: var(--control-h);
  min-width: 145px;
  border: 1.5px solid var(--border);
  border-radius: 11px;
  background: #fff;
}
.captcha-box button { padding: 0 16px; font-size: 1.1rem; }

/* ---------- results ---------- */
.result-card {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  overflow: hidden;
  box-shadow: var(--shadow);
  animation: rise 0.25s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.result-head { padding: 12px 16px; font-weight: 600; color: #fff; font-size: 0.94rem; }
.result-head.found { background: linear-gradient(135deg, var(--green-700), var(--green-600)); }
.result-head.notfound { background: linear-gradient(135deg, #b07300, #cf9019); }
.result-head.error { background: linear-gradient(135deg, #9c2018, #c03a30); }
.result-body { padding: 16px; }

.kv {
  display: grid;
  grid-template-columns: minmax(140px, auto) 1fr;
  gap: 6px 16px;
  margin-bottom: 12px;
}
.kv .k { color: var(--muted); font-size: 0.84rem; font-weight: 500; padding-top: 2px; }
.kv .v { font-weight: 600; font-size: 0.95rem; }

table.res {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  margin-top: 10px;
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 11px;
  overflow: hidden;
}
table.res th, table.res td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
table.res th { background: var(--green-800); color: #fff; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.3px; }
table.res tr:last-child td { border-bottom: none; }
table.res tr:nth-child(even) td { background: #f6faf7; }

details { margin-top: 12px; }
details summary { cursor: pointer; color: var(--green-700); font-weight: 600; font-size: 0.9rem; }
details summary:hover { color: var(--green-600); }
details iframe { width: 100%; height: 460px; border: 1px solid var(--border); border-radius: 11px; margin-top: 10px; background: #fff; }

/* ---------- explore tiles (after a found result) ---------- */
.explore { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; }
.explore-title { font-size: 0.88rem; font-weight: 600; color: var(--green-800); margin-bottom: 10px; }
.explore-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.explore-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 6px;
  background: var(--green-50);
  border: 1px solid var(--border);
  border-radius: 11px;
  text-decoration: none;
  color: var(--green-800);
  font-size: 0.78rem;
  font-weight: 600;
  text-align: center;
  transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.explore-tile span:first-child { font-size: 1.25rem; }
.explore-tile:hover { transform: translateY(-2px); background: #fff; box-shadow: var(--shadow); }

/* ---------- latest / upcoming sections ---------- */
.section { margin: 20px 0 6px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--green-900); margin-bottom: 10px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  text-decoration: none;
  color: inherit;
  transition: transform 0.12s, box-shadow 0.12s;
  width: 100%;
  height: auto;
}
.mini-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(6, 63, 43, 0.12); background: #fff; }
.mini-card .mc-emoji { flex: none; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--green-50); border-radius: 9px; }
.mini-card .mc-body { min-width: 0; }
.mini-card .mc-board { font-size: 0.78rem; font-weight: 700; color: var(--green-800); }
.mini-card .mc-exam { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }
.mini-card .mc-date { font-size: 0.74rem; font-weight: 600; color: var(--amber); margin-top: 2px; }
.mini-card .mc-go { margin-left: auto; flex: none; color: var(--green-600); font-weight: 700; }
.tiny { font-size: 0.74rem; color: var(--muted); margin-top: 8px; }

/* ---------- bulk ---------- */
.progress { height: 11px; background: #e4ede7; border-radius: 999px; margin-top: 14px; overflow: hidden; }
.progress div { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green-700), var(--green-600)); border-radius: 999px; transition: width 0.3s; }

.status-chip { padding: 3px 12px; border-radius: 999px; font-size: 0.74rem; font-weight: 600; color: #fff; white-space: nowrap; }
.status-chip.found { background: var(--green-600); }
.status-chip.notfound { background: var(--amber); }
.status-chip.error { background: var(--red); }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- footer ---------- */
footer { text-align: center; padding: 16px; color: var(--muted); font-size: 0.78rem; line-height: 1.6; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  html { scroll-behavior: auto; }
}

@media (max-width: 640px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .row { flex-direction: column; align-items: stretch; }
  .row.actions { flex-direction: row; flex-wrap: wrap; }
  .field { min-width: 0; }
  .card { padding: 14px; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 0 10px; }
  button.primary { width: 100%; }
  .row.actions button { width: auto; flex: 1; }
  .cards-grid { grid-template-columns: 1fr; }
  .explore-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 641px) and (max-width: 900px) {
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
