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

:root {
  --bg: #f8f9fa;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --accent: #2d6a4f;
  --accent-light: #40916c;
  --accent-bg: #edf7f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }

/* ── Header ── */
header { padding: 64px 0 48px; text-align: center; }
header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
header h1 span { color: var(--accent); }
header p {
  color: var(--text-secondary);
  font-size: 1.1rem;
  max-width: 480px;
  margin: 0 auto 24px;
}

.contract-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color 0.2s;
}
.contract-badge:hover { border-color: var(--accent-light); }
.contract-badge .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}
.contract-badge code {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.75rem;
}

/* ── Stats ── */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 48px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.stat-card .number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
}
.stat-card .label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Section ── */
section { margin-bottom: 48px; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-header h2 { font-size: 1.25rem; font-weight: 600; }
.section-header .count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--accent-bg);
  padding: 4px 12px;
  border-radius: 100px;
}

/* ── Cat wall ── */
.cat-wall {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.cat-card {
  display: block;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s, transform 0.2s;
}
.cat-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent-light);
  transform: translateY(-2px);
}
.cat-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  color: var(--accent-light);
}
.cat-info { padding: 14px 16px; }
.cat-info .cat-name {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.cat-info .cat-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

/* ── Cat detail ── */
.cat-profile {
  display: flex;
  gap: 24px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 40px;
}
.cat-profile .cat-photo-lg {
  width: 160px;
  height: 160px;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--accent-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
  color: var(--accent-light);
  flex-shrink: 0;
}
.cat-profile .cat-detail h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.cat-profile .cat-detail .loc {
  font-size: 0.85rem;
  color: var(--accent);
  margin-bottom: 12px;
}
.cat-profile .cat-detail .desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--accent); }

/* ── Table ── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead { background: #f9fafb; }
th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
tr:hover { background: #fafbfc; }

td .hash {
  font-family: "SF Mono", "Fira Code", monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
td .message {
  display: inline-block;
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--text-secondary);
}
.cat-tag {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--accent-bg);
  padding: 2px 10px;
  border-radius: 100px;
  text-decoration: none;
}
.cat-tag:hover { background: #d9f0e3; }
.timestamp {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}
.proof-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}
.proof-link:hover { text-decoration: underline; color: var(--accent-light); }

/* ── Buttons ── */
.scan-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
}
.scan-btn:hover { border-color: var(--accent-light); color: var(--accent); }
.scan-btn .icon { display: inline-flex; transition: transform 0.2s; }
.scan-btn:hover .icon { transform: translateX(2px); }

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

/* ── Empty / Loading ── */
.empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-secondary);
}
.empty p { margin-top: 8px; font-size: 0.9rem; }
.spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error-state { text-align: center; padding: 48px 16px; }
.error-state .icon { font-size: 2rem; margin-bottom: 8px; display: block; }
.error-state p { color: #dc2626; font-size: 0.9rem; }
.error-state .hint { color: var(--text-secondary); font-size: 0.8rem; margin-top: 4px; }

/* ── Footer ── */
footer {
  text-align: center;
  padding: 32px 0 48px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  margin-top: 16px;
}
footer a { color: var(--accent); text-decoration: none; }

/* ── Responsive ── */
@media (max-width: 640px) {
  header { padding: 40px 0 32px; }
  header h1 { font-size: 1.75rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat-card:last-child { grid-column: span 2; }
  .cat-wall { grid-template-columns: repeat(2, 1fr); }
  .cat-profile { flex-direction: column; align-items: center; text-align: center; }
}
