:root {
  --font-main: "Google Sans Flex", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --surface-3: #ebe9e2;
  --text: #171717;
  --text-dim: #67645e;
  --border: #e1dfd8;
  --accent: #171717;
  --accent-contrast: #ffffff;
  --danger: #9c1c1c;
  --ok: #0c6b43;
  --warning: #8a5b00;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 18px 50px rgba(0,0,0,.07);
  --gap: 16px;
  --bottom-nav-height: 88px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  min-height: 100dvh;
  margin: 0;
  font: 16px/1.5 var(--font-main);
  background: var(--bg);
  color: var(--text);
}
button, input, textarea, select { font: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }
#app { min-height: 100dvh; }
.app-shell {
  min-height: 100dvh;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: rgba(246,245,242,.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { min-width: 0; }
.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--text-dim);
  font-size: .72rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 750;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: .84rem;
  white-space: nowrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
}
.status-dot.ok { background: var(--ok); }
.main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.hero {
  min-height: 158px;
  display: flex;
  align-items: end;
}
.hero h2, .card-title {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 5vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.card h2:not(.card-title) {
  margin: 0 0 12px;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .075em;
  color: var(--text-dim);
}
p { color: var(--text-dim); }
.grid { display: grid; gap: 14px; }
.metric-card {
  display: grid;
  gap: 6px;
}
.metric-card strong {
  display: block;
  font-size: 1.65rem;
  line-height: 1;
}
.metric-card span { color: var(--text-dim); }
.material-icons { font-size: 21px; line-height: 1; }
.bottom-nav {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border-radius: 22px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}
.bottom-nav a,
.bottom-nav button {
  min-width: 0;
  border: 0;
  text-decoration: none;
  background: transparent;
  display: grid;
  gap: 2px;
  justify-items: center;
  align-content: center;
  color: var(--text);
  padding: 8px 4px;
  border-radius: 14px;
  cursor: pointer;
}
.bottom-nav small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .67rem;
  color: var(--text-dim);
}
.bottom-nav a[aria-current="page"],
.bottom-nav button.active {
  background: var(--surface-2);
}
.bottom-nav a[aria-current="page"] small { color: var(--text); }
.sk,
.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg,#ece9e1,#f9f8f5,#ece9e1);
  border-radius: 18px;
  animation: pulse 1.2s infinite;
}
.sk-line { height: 14px; margin-bottom: 10px; border-radius: 999px; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
.sk-line.w80 { width: 80%; }
.sk-block { height: 72px; }
@keyframes pulse { 0% { opacity: .68; } 50% { opacity: 1; } 100% { opacity: .68; } }
@media (prefers-reduced-motion: reduce) {
  .sk, .skeleton { animation: none; }
}
#update-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(var(--bottom-nav-height) + 18px + env(safe-area-inset-bottom, 0px));
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--accent-contrast);
  box-shadow: var(--shadow);
}
#update-banner span { color: inherit; }
#update-banner button {
  border: 0;
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.app-fallback {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.app-fallback a { color: var(--text); font-weight: 700; }
@media (min-width: 760px) {
  .app-shell { padding-bottom: 0; }
  .main { padding: 24px; }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bottom-nav {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: min(620px, calc(100% - 24px));
  }
}

/* v0.2 — núcleo global alfa */
code {
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .86em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.admin-token-card {
  display: grid;
  gap: 14px;
}
.inline-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
.entity-form {
  display: grid;
  gap: 12px;
}
.field {
  display: grid;
  gap: 6px;
}
.field label,
.check-row {
  color: var(--text-dim);
  font-size: .84rem;
  font-weight: 650;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 16px;
  padding: 12px 13px;
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(23,23,23,.08);
}
button {
  border: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 760;
  cursor: pointer;
}
button.ghost {
  background: var(--surface-2);
  color: var(--text);
}
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.form-note {
  font-size: .88rem;
}
.form-note.ok { color: var(--ok); }
.form-note.error { color: var(--danger); }
.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}
.check-row input {
  width: auto;
}
.item-list {
  list-style: none;
  display: grid;
  gap: 8px;
}
.item-row {
  display: grid;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-2);
}
.item-row strong {
  font-size: 1rem;
}
.item-meta {
  color: var(--text-dim);
  font-size: .86rem;
}
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 9px;
  background: var(--surface-2);
  font-size: .82rem;
  color: var(--text-dim);
}
.stats-grid .metric-card strong { font-size: 2rem; }
@media (min-width: 760px) {
  .inline-form {
    grid-template-columns: minmax(260px, 1fr) auto auto;
    align-items: end;
  }
  .entity-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
  .entity-form button,
  .entity-form .check-row {
    grid-column: span 2;
  }
}

/* v0.3 — Papeleo FormRenderer alfa */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
  margin-bottom: 14px;
}
.papeleo-form-host {
  margin-top: 14px;
}
.form-actions {
  display: flex;
  gap: 8px;
}
.field-error {
  min-height: 1.1em;
  color: var(--danger);
  font-size: .78rem;
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(156,28,28,.08);
}
.repeater-field {
  align-items: stretch;
}
.repeater-list {
  display: grid;
  gap: 8px;
}
.repeater-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.repeater-row button,
.repeater-add {
  white-space: nowrap;
}
@media (min-width: 760px) {
  .form-actions,
  .repeater-field,
  .field:has(textarea) {
    grid-column: span 2;
  }
}

/* v0.4 — repeaters con filas compuestas para eventos, variantes y asociaciones */
.repeater-row-object {
  grid-template-columns: 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--surface-2);
}
.mini-field {
  display: grid;
  gap: 4px;
  font-size: .82rem;
  color: var(--text-dim);
}
.mini-field input {
  width: 100%;
}
@media (min-width: 760px) {
  .repeater-row-object {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    align-items: end;
  }
  .repeater-row-object button {
    align-self: end;
  }
}
