:root {
  --blue: #0b3d6b;
  --blue-dark: #07294a;
  --bg: #f1f5f9;
  --card: #ffffff;
  --border: #cbd5e1;
  --text: #0f172a;
  --muted: #475569;
  --green: #15803d;
  --green-bg: #dcfce7;
  --red: #b91c1c;
  --red-bg: #fee2e2;
  --amber: #b45309;
  --amber-bg: #fef3c7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.admin-header {
  background: var(--blue-dark);
  color: #ffffff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 4px solid #d4a017;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.admin-badge {
  background: #d4a017;
  color: #111827;
  font-weight: 900;
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
}

.admin-brand h1 {
  margin: 0;
  font-size: 18px;
}

.admin-brand p {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: #cbd5e1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-outline {
  color: #ffffff;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
}

.btn-danger-outline {
  background: transparent;
  color: #fca5a5;
  border: 1px solid #f87171;
  padding: 8px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: var(--blue);
  color: #ffffff;
  border: none;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--blue-dark);
}

.btn-secondary {
  background: #e2e8f0;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}

.btn-warning {
  background: #d97706;
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
}

.btn-warning:hover {
  background: #b45309;
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--blue);
}

.btn-sm:hover {
  background: #e7f0f8;
}

.btn-sm-del {
  color: var(--red);
  margin-left: 4px;
}

/* LOGIN */
.login-wrapper {
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 28px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.login-card h2 {
  margin: 0 0 8px 0;
}

.login-card p {
  margin: 0 0 18px 0;
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.login-card input {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  border: 2px solid var(--border);
  border-radius: 4px;
  margin-bottom: 14px;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.alert-success {
  background: var(--green-bg);
  color: var(--green);
  padding: 10px 12px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
}

/* DASHBOARD */
.dashboard-container {
  max-width: 1240px;
  margin: 24px auto;
  padding: 0 16px 40px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 5px solid var(--blue);
  border-radius: 6px;
  padding: 16px 18px;
}

.kpi-green { border-left-color: var(--green); }
.kpi-red { border-left-color: var(--red); }
.kpi-dark-red { border-left-color: #7f1d1d; }

.kpi-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.kpi-value {
  display: block;
  font-size: 28px;
  margin-top: 4px;
}

.panel-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.muted-text {
  margin: 4px 0 0 0;
  font-size: 13px;
  color: var(--muted);
}

.filters-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filters-bar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: #ffffff;
}

.table-responsive {
  overflow-x: auto;
}

.attempts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.attempts-table th, .attempts-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.attempts-table th {
  background: #f8fafc;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}

.empty-cell {
  text-align: center !important;
  color: var(--muted);
  padding: 24px !important;
}

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 800;
}

.pill-passed { background: var(--green-bg); color: var(--green); }
.pill-failed { background: var(--red-bg); color: var(--red); }
.pill-invalidated { background: #7f1d1d; color: #ffffff; }
.pill-progress { background: var(--amber-bg); color: var(--amber); }

/* MODAL DETAIL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal-large {
  width: 100%;
  max-width: 980px;
  max-height: 90vh;
  background: #ffffff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.modal-header {
  background: var(--blue-dark);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-header .muted-text {
  color: #cbd5e1;
}

.btn-close {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  font-size: 16px;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.detail-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.meta-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  font-size: 12.5px;
}

.meta-box span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.meta-box strong {
  font-size: 14px;
}

.detail-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 14px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  font-weight: 700;
  font-size: 13.5px;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: -2px;
}

.tab-btn.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ANSWER REVIEW CARDS */
.review-item {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  border: 1px solid var(--border);
  border-left: 5px solid var(--red);
  border-radius: 5px;
  padding: 12px;
  margin-bottom: 10px;
  background: #ffffff;
}

.review-item.review-ok {
  border-left-color: var(--green);
}

.review-img-box {
  width: 110px;
  height: 90px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.review-img-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.review-topic {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.review-text {
  margin: 4px 0 8px 0;
  font-size: 14.5px;
  font-weight: 600;
}

.review-answers {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 12.5px;
}

.ans-tag {
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 700;
}

.ans-wrong { background: var(--red-bg); color: var(--red); }
.ans-correct { background: var(--green-bg); color: var(--green); }
.ans-neutral { background: #e2e8f0; color: #334155; }

/* ANTI-CHEAT LOG TABLE */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-row {
  display: grid;
  grid-template-columns: 155px 195px 1fr;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  background: #f8fafc;
}

.log-row.log-danger {
  background: #fef2f2;
  border-color: #fca5a5;
}

.log-row.log-warn {
  background: #fffbeb;
  border-color: #fcd34d;
}

.log-time {
  font-family: monospace;
  font-size: 12px;
  color: var(--muted);
}

.log-type {
  font-weight: 800;
  font-size: 12px;
}

@media (max-width: 768px) {
  .kpi-grid, .detail-meta-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .review-item {
    grid-template-columns: 1fr;
  }
  .log-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}
