:root {
  --bd-green: #006a4e;
  --bd-green-dark: #004d38;
  --bd-red: #f42a41;
  --ink: #111827;
  --muted: #4b5563;
  --line: #e2e8f0;
  --bg: #eef1ee;
  --card: #ffffff;
  --live: #dc2626;
  --soon: #b45309;
  --done: #475569;
}

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

body {
  font-family: 'Noto Sans Bengali', 'Kalpurush', 'SolaimanLipi', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 15px;
}

a { color: var(--bd-green); }

.toolbar {
  position: sticky; top: 0; z-index: 50;
  background: linear-gradient(90deg, var(--bd-green-dark), var(--bd-green));
  color: #fff;
  padding: 10px 18px;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  border-bottom: 3px solid var(--bd-red);
  box-shadow: 0 3px 12px rgba(0,0,0,0.18);
}
.tb-left { display: flex; align-items: center; gap: 12px; }
.tb-title { font-weight: 700; font-size: 17px; }
.clock { font-variant-numeric: tabular-nums; font-size: 13px; opacity: 0.9; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; border: 1px solid transparent;
  font-family: inherit; font-weight: 600; font-size: 14px; cursor: pointer;
  text-decoration: none; transition: 0.15s; line-height: 1.3;
}
.btn.primary { background: var(--bd-green); color: #fff; }
.btn.primary:hover { background: var(--bd-green-dark); }
.btn.danger { background: var(--bd-red); color: #fff; }
.btn.danger:hover { background: #d91e34; }
.btn.ghost { background: #fff; color: #1e293b; border-color: #cbd5e1; }
.btn.ghost:hover { background: #f1f5f9; }
.btn.light { background: rgba(255,255,255,0.14); color: #fff; border-color: rgba(255,255,255,0.35); }
.btn.light:hover { background: rgba(255,255,255,0.25); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.sm { padding: 5px 10px; font-size: 13px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 20px 16px 60px; }

.hero {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
}
.hero h1 { font-size: 21px; color: var(--bd-green-dark); }
.hero p { color: var(--muted); font-size: 14px; }

.section-title { font-size: 17px; font-weight: 700; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.empty { background: var(--card); border: 1px dashed #cbd5e1; border-radius: 12px; padding: 22px; text-align: center; color: var(--muted); }

.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.exam-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.exam-card.is-live { border-color: #fca5a5; box-shadow: 0 0 0 3px rgba(220,38,38,0.08); }
.exam-card h3 { font-size: 16px; line-height: 1.45; }
.exam-org { font-size: 13px; color: var(--muted); }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 13px; color: #334155; }
.meta b { color: var(--ink); }
.notice { font-size: 13px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; padding: 8px 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; width: fit-content; }
.badge.LIVE { background: #fee2e2; color: var(--live); }
.badge.LIVE::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--live); animation: pulse 1.2s infinite; }
.badge.UPCOMING { background: #fef3c7; color: var(--soon); }
.badge.ENDED { background: #e2e8f0; color: var(--done); }
@keyframes pulse { 50% { opacity: 0.3; } }

.countdown {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 15px;
  background: #0b1f19; color: #fde047; border-radius: 8px; padding: 6px 10px; text-align: center;
}
.reg-note { font-size: 13px; color: var(--bd-green-dark); background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: 8px; padding: 6px 10px; }

/* Modal */
.overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.overlay[hidden] { display: none; }
.modal { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 460px; max-height: 92vh; overflow-y: auto; }
.modal.wide { max-width: 920px; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; border-bottom: 1px solid var(--line); padding-bottom: 10px; margin-bottom: 14px; }
.modal-head h2 { font-size: 18px; }
.modal-head .sub { font-size: 13px; color: var(--muted); }
.x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13.5px; font-weight: 600; }
.field input, .field select, .field textarea {
  padding: 9px 11px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: inherit; font-size: 15px; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field small { font-weight: 400; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.error { color: #b91c1c; font-size: 13.5px; margin-bottom: 10px; }
.error:empty { display: none; }

/* Result + merit */
.my-result { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.stat { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; }
.stat .v { font-size: 21px; font-weight: 700; color: var(--bd-green); }
.stat .k { font-size: 12.5px; color: var(--muted); }
.stat.rank .v { color: var(--bd-red); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table.merit { width: 100%; border-collapse: collapse; font-size: 14px; }
table.merit th, table.merit td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.merit th { background: #f1f5f9; font-size: 13px; }
table.merit td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.merit tr.me td { background: #ecfdf5; font-weight: 700; }
table.merit tr.top1 td:first-child { color: #b45309; font-weight: 700; }
.merit-tools { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13.5px; color: var(--muted); }
.merit-tools input { padding: 7px 10px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: inherit; min-width: 220px; }
.rule-note { font-size: 12.5px; color: var(--muted); margin-top: 10px; }

/* Admin */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; }
.panel h2 { font-size: 17px; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.admin-table th { background: #f8fafc; font-size: 13px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; font-size: 14px; }
.toast[hidden] { display: none; }

@media (max-width: 640px) {
  .my-result { grid-template-columns: repeat(2, 1fr); }
  .row2 { grid-template-columns: 1fr; }
  .exam-grid { grid-template-columns: 1fr; }
}

@media print {
  .toolbar, .hero, .no-print { display: none !important; }
  .overlay { position: static; background: none; padding: 0; }
  .modal { max-height: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
}
