:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --text: #1b2420;
  --muted: #66716b;
  --border: #dde2dd;
  --accent: #1f6b4f;       /* verde aloe */
  --accent-ink: #ffffff;
  --gold: #c99a2e;
  --danger: #b3261e;
  --label-bg: linear-gradient(135deg, #14382b 0%, #1f6b4f 100%);
  --label-ink: #f6f2e6;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412;
    --surface: #171e1b;
    --text: #e7ece9;
    --muted: #97a39c;
    --border: #2a3430;
    --accent: #3fa27b;
    --accent-ink: #08120e;
    --gold: #e0b44c;
    --danger: #ef6b62;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; padding-block: 28px 56px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; margin: 0 0 .4em; letter-spacing: -.02em; }
h2 { font-size: 1.25rem; margin: 0; }
img { max-width: 100%; display: block; }
.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 16px; }
.mono { font-family: "JetBrains Mono", ui-monospace, monospace; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.inline { display: inline; }

/* barra superior */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; color: var(--text); font-size: 1.1rem; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
nav { display: flex; gap: 18px; align-items: center; font-weight: 500; }
nav a { color: var(--text); }
.footer { border-top: 1px solid var(--border); color: var(--muted); font-size: .85rem; padding-block: 20px; }

/* botones y formularios */
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 10px; padding: 10px 18px; display: inline-block;
}
.btn:hover { text-decoration: none; filter: brightness(1.08); }
button.link { background: none; color: var(--accent); padding: 0; font-weight: 500; }
button.link.danger { color: var(--danger); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.search { display: flex; gap: 8px; max-width: 520px; width: 100%; }
.search input { flex: 1; min-width: 0; }
.search-sm { max-width: 380px; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: color-mix(in srgb, var(--accent) 15%, transparent); }
.flash-error { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

/* portada */
.hero { text-align: center; padding: 48px 0 40px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.hero p { max-width: 560px; margin: 0 0 12px; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h1 { margin: 0; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* rejilla de cartas */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; color: var(--text); box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { text-decoration: none; transform: translateY(-3px); }
.tile-img { aspect-ratio: 5 / 7; background: var(--bg); display: grid; place-items: center; padding: 12px; }
.tile-img img { max-height: 100%; object-fit: contain; border-radius: 6px; }
.tile-body { padding: 12px 14px 14px; }
.tile-name { font-weight: 700; }
.tile-meta { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: .8rem; color: var(--muted); }
.pill { background: var(--gold); color: #1b1407; font-weight: 800; border-radius: 999px; padding: 1px 10px; }
.noimg { color: var(--muted); font-size: .85rem; }
.noimg.big { padding: 80px 0; text-align: center; width: 100%; }

/* ficha de certificado */
.cert-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.cert-top .search { max-width: 380px; }
.cert { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

.label {
  background: var(--label-bg); color: var(--label-ink);
  display: flex; justify-content: space-between; gap: 16px;
  padding: 18px 22px; border-bottom: 4px solid var(--gold);
}
.label-title { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; }
.label-name { font-size: clamp(1.3rem, 3.5vw, 1.8rem); font-weight: 800; letter-spacing: -.01em; line-height: 1.2; }
.label-sub { font-size: .9rem; opacity: .85; }
.label-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; flex-shrink: 0; }
.label-grade-txt { font-size: .75rem; font-weight: 700; letter-spacing: .14em; color: var(--gold); }
.label-grade { font-size: 2.6rem; font-weight: 800; line-height: 1; }
.label-cert { font-size: .85rem; opacity: .85; margin-top: 4px; }

.cert-body { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; padding: 24px; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start; }
.photos figure { margin: 0; }
.photos img { border-radius: 10px; box-shadow: var(--shadow); width: 100%; }
.photos figcaption { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 6px; }

.verified { display: inline-block; font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); border-radius: 999px; padding: 4px 12px; font-size: .85rem; margin-bottom: 14px; }
dl { display: grid; grid-template-columns: max-content 1fr; margin: 0; }
dt, dd { padding: 9px 0; border-bottom: 1px solid var(--border); margin: 0; }
dt { color: var(--muted); padding-right: 24px; font-size: .9rem; }
dd { font-weight: 600; }

.pop { display: flex; gap: 10px; margin: 18px 0; }
.pop div { flex: 1; background: var(--bg); border-radius: 10px; padding: 10px; text-align: center; }
.pop strong { display: block; font-size: 1.4rem; }
.pop span { font-size: .75rem; color: var(--muted); }
.desc { white-space: pre-line; color: var(--text); margin-bottom: 18px; }
.qr { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--border); padding-top: 16px; word-break: break-all; }
.qr-code { color: var(--text); flex-shrink: 0; width: 96px; }
.qr-code svg { width: 96px; height: 96px; }

/* admin */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px; }
.panel.narrow { max-width: 380px; margin: 40px auto; }
.panel label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: .9rem; }
.panel label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 500; }
.panel label.check input { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.form-actions { display: flex; gap: 16px; align-items: center; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 14px; }
.thumb { width: 40px; height: 56px; object-fit: cover; border-radius: 4px; }
.thumb.big { width: 120px; height: auto; }

@media (max-width: 760px) {
  .cert-body { grid-template-columns: 1fr; padding: 16px; }
  .label { padding: 14px 16px; }
  .label-grade { font-size: 2rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .hero { padding-top: 28px; }
}
