@import url("https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #fffcf5;
  --surface: #ffffff;
  --surface-alt: #fbf6e8;
  --border: #ecdfb4;
  --text: #2b2620;
  --text-muted: #7a6f55;
  --gold-1: #b8892b;
  --gold-2: #d4af37;
  --gold-3: #f0cd6b;
  --gold-4: #ffe9ae;
  --accent-deep: #8a6a1c;
  --success: #3f7d4a;
  --success-bg: #eaf4ea;
  --danger: #b3452e;
  --danger-bg: #fbebe6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-soft: 0 1px 2px rgba(43, 38, 32, 0.04), 0 8px 24px -12px rgba(184, 137, 43, 0.25);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 500;
  margin: 0;
  color: var(--text);
}

a {
  color: var(--accent-deep);
}

.gold-text {
  background: linear-gradient(100deg, var(--gold-1), var(--gold-2) 45%, var(--gold-3));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Layout shell ---------- */

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px clamp(20px, 5vw, 56px);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fffdf7 0%, var(--bg) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: "Fraunces", serif;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-4));
  box-shadow: inset 0 0 0 1px rgba(184, 137, 43, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  color: var(--accent-deep);
}

.topbar nav a {
  text-decoration: none;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-left: 22px;
  transition: color 0.15s ease;
}

.topbar nav a:hover {
  color: var(--accent-deep);
}

main {
  flex: 1;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: clamp(28px, 6vw, 64px) clamp(20px, 5vw, 24px);
}

footer {
  text-align: center;
  padding: 22px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ---------- Hero / search ---------- */

.hero {
  text-align: center;
  padding-bottom: 34px;
}

.hero h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem);
  line-height: 1.15;
}

.hero p {
  color: var(--text-muted);
  margin-top: 10px;
  font-size: 1.02rem;
}

.search-shell {
  margin-top: 30px;
  display: flex;
  gap: 10px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
}

.search-shell input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  padding: 12px 18px;
  font-family: inherit;
  color: var(--text);
}

.search-shell input::placeholder {
  color: #b3a687;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: 999px;
  padding: 12px 24px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.15s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(100deg, var(--gold-1), var(--gold-2) 55%, var(--gold-3));
  color: #33260a;
  box-shadow: 0 6px 16px -6px rgba(184, 137, 43, 0.55);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px -6px rgba(184, 137, 43, 0.65);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
}

.btn-ghost:hover {
  border-color: var(--gold-2);
  color: var(--accent-deep);
}

.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius-sm);
}

.btn-danger:hover {
  background: #f6dbd0;
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

/* ---------- Result / certificate cards ---------- */

.results {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cert-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  box-shadow: var(--shadow-soft);
}

.cert-card .info h3 {
  font-size: 1.08rem;
  font-weight: 600;
}

.cert-card .info .meta {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.cert-card .info .meta span + span::before {
  content: "•";
  margin: 0 8px;
  color: var(--border);
}

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  margin-top: 24px;
}

.empty-state .icon {
  font-size: 1.8rem;
  margin-bottom: 10px;
}

.status-line {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 1.2em;
}

.status-line.error {
  color: var(--danger);
}

/* ---------- Admin ---------- */

.login-shell {
  max-width: 380px;
  margin: 6vh auto 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-soft);
}

.login-shell h2 {
  font-size: 1.4rem;
}

.login-shell p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 6px;
}

.field {
  margin-top: 18px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.field input,
.field select {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus,
.field select:focus {
  border-color: var(--gold-2);
}

.login-shell .btn {
  width: 100%;
  margin-top: 22px;
}

.dash-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 26px;
}

.stat-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.stat-pill strong {
  color: var(--text);
  font-family: "Fraunces", serif;
  font-size: 1rem;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 10px 4px;
  margin-right: 22px;
  font-family: "Inter", sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transform: translateY(1px);
}

.tab-btn.active {
  color: var(--accent-deep);
  border-bottom-color: var(--gold-2);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-soft);
}

.card + .card {
  margin-top: 18px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.dropzone {
  border: 1.5px dashed var(--gold-2);
  border-radius: var(--radius-md);
  background: var(--surface-alt);
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease;
}

.dropzone:hover,
.dropzone.drag {
  background: var(--gold-4);
}

.dropzone .icon {
  font-size: 1.6rem;
}

.dropzone p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.dropzone input {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody input,
tbody td input {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.87rem;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 10px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.hidden {
  display: none !important;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(43, 38, 32, 0.15);
  border-top-color: var(--accent-deep);
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
  margin-right: 6px;
}

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

.progress-bar {
  height: 6px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 14px;
  border: 1px solid var(--border);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-1), var(--gold-3));
  width: 0%;
  transition: width 0.2s ease;
}

.small-muted {
  font-size: 0.82rem;
  color: var(--text-muted);
}
