:root {
  --bg: #f7f3ef; --card: #ffffff; --ink: #2d2226; --muted: #7c6c70; --line: #eadfd8;
  --brand: #6e3b48; --brand-2: #4d2531; --soft: #f3e6e8; --ok: #1f8a5b; --warn: #c27b12; --bad: #c43b45;
  --r: 14px; --sh: 0 1px 2px rgba(45,34,38,.06), 0 6px 20px rgba(45,34,38,.06);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }

.top { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1rem; padding: .7rem 1rem; padding-top: calc(.7rem + env(safe-area-inset-top));
  background: var(--brand-2); color: #fff; flex-wrap: wrap; }
.top__brand { font-weight: 700; font-size: 1.05rem; }
.top__nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.top__nav button { background: none; border: 0; color: rgba(255,255,255,.75); font: inherit; font-weight: 500; padding: .45rem .8rem; border-radius: 99px; cursor: pointer; white-space: nowrap; }
.top__nav button.is-on { background: rgba(255,255,255,.16); color: #fff; }
.top__user { display: flex; align-items: center; gap: .6rem; }
.top .link { color: #fff; }
.chip { background: #f2dcae; color: var(--brand-2); font-weight: 700; padding: .25rem .7rem; border-radius: 99px; font-size: .85rem; white-space: nowrap; }
@media (max-width: 640px) { .top__nav { order: 3; flex-basis: 100%; } }

.main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 5rem; }
.bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.bar .grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; background: var(--brand); color: #fff; font: inherit; font-weight: 600;
  padding: .6rem 1rem; border-radius: 10px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-2); }
.btn--ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn--ghost:hover { background: var(--soft); }
.btn--ok { background: var(--ok); } .btn--ok:hover { background: #18704a; }
.btn--bad { background: #fff; color: var(--bad); border-color: #f0c9cc; } .btn--bad:hover { background: #fdeeee; }
.btn--sm { padding: .35rem .65rem; font-size: .85rem; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: default; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; text-decoration: underline; }

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 1.1rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.stack > * + * { margin-top: 1rem; }

.ev { display: flex; flex-direction: column; gap: .55rem; }
.ev__head { display: flex; justify-content: space-between; gap: .5rem; align-items: flex-start; }
.ev__name { font-weight: 700; font-size: 1.05rem; }
.ev__url { font-size: .82rem; word-break: break-all; }
.ev__meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .85rem; color: var(--muted); }
.ev__actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: auto; }
.badge { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: .2rem .55rem; border-radius: 99px; white-space: nowrap; }
.badge--borrador { background: #fff3dc; color: var(--warn); }
.badge--publicado { background: #e3f5ec; color: var(--ok); }
.badge--archivado { background: #eee; color: #777; }

.tpl { overflow: hidden; padding: 0; display: flex; flex-direction: column; cursor: pointer; border: 2px solid transparent; transition: border-color .2s, transform .2s; }
.tpl:hover { transform: translateY(-2px); }
.tpl.is-on { border-color: var(--brand); }
.tpl img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; display: block; background: var(--soft); }
.tpl__body { padding: .8rem 1rem 1rem; display: flex; flex-direction: column; gap: .3rem; }
.tpl__name { font-weight: 700; }

.field { display: flex; flex-direction: column; gap: .3rem; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--muted); }
.fields { display: grid; gap: .85rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fields--1 { grid-template-columns: 1fr; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=datetime-local], select, textarea {
  font: inherit; color: inherit; width: 100%; padding: .6rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
textarea { min-height: 5.5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #d9b6bd; border-color: var(--brand); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; cursor: pointer; }
.check input { width: 1.1rem; height: 1.1rem; accent-color: var(--brand); }
.hint { font-size: .8rem; color: var(--muted); }
.ok { color: var(--ok); } .bad { color: var(--bad); }

.sec { border-top: 1px solid var(--line); padding-top: 1.1rem; margin-top: 1.1rem; }
.sec:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.sec__title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .8rem; }

.rows { display: flex; flex-direction: column; gap: .6rem; }
.row { display: grid; gap: .5rem; align-items: center; padding: .6rem; border: 1px solid var(--line); border-radius: 10px; background: #fffdfb; }
.row.is-off { opacity: .5; }
.row--it { grid-template-columns: auto 6.5rem 1fr 7.5rem 4rem auto; }
.row--lugar { grid-template-columns: auto 1fr 1fr auto; }
.row--lugar .full { grid-column: 2 / -2; }
@media (max-width: 700px) {
  .row--it { grid-template-columns: auto 1fr auto; }
  .row--it .it-hora { grid-column: 2; } .row--it .it-ev { grid-column: 1 / -1; } .row--it .it-ico, .row--it .it-emo { grid-column: span 1; }
  .row--lugar { grid-template-columns: auto 1fr auto; } .row--lugar .full, .row--lugar .half { grid-column: 1 / -1; }
}
.x { background: none; border: 0; color: var(--bad); font-size: 1.2rem; cursor: pointer; padding: .2rem .4rem; }

.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 1rem 0; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; font: inherit; font-weight: 600; color: var(--muted); padding: .6rem .9rem; cursor: pointer; white-space: nowrap; }
.tabs button.is-on { color: var(--brand); border-color: var(--brand); }

.photos { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.photo { position: relative; border-radius: 12px; overflow: hidden; background: var(--soft); aspect-ratio: 3 / 4; display: grid; place-items: center; border: 2px dashed var(--line); }
.photo--wide { aspect-ratio: 16 / 9; }
.photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo label { position: relative; z-index: 1; cursor: pointer; text-align: center; font-size: .85rem; font-weight: 600; color: var(--brand); padding: .5rem; }
.photo.has-img label { position: absolute; bottom: .4rem; left: .4rem; right: .4rem; background: rgba(255,255,255,.92); border-radius: 8px; }
.photo .x { position: absolute; top: .3rem; right: .3rem; z-index: 2; background: rgba(255,255,255,.92); border-radius: 50%; width: 1.8rem; height: 1.8rem; padding: 0; }
.photo input { display: none; }
.photo__tag { position: absolute; top: .4rem; left: .4rem; z-index: 2; background: rgba(0,0,0,.55); color: #fff; font-size: .7rem; padding: .1rem .45rem; border-radius: 6px; }

.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .5rem; border-bottom: 1px solid var(--line); }
.table td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table input { padding: .4rem .5rem; }
.table-wrap { overflow-x: auto; }
.code { font-family: ui-monospace, monospace; font-weight: 600; letter-spacing: .05em; }

.stats { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.stat { background: var(--card); border-radius: 12px; box-shadow: var(--sh); padding: .9rem 1rem; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }

.auth { max-width: 400px; margin: 8vh auto 0; }
.auth h1 { text-align: center; margin-bottom: .3rem; }
.auth p.lead { text-align: center; color: var(--muted); margin: 0 0 1.4rem; }

.toast { position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: .7rem 1.1rem;
  border-radius: 12px; z-index: 200; box-shadow: var(--sh); font-weight: 500; max-width: calc(100% - 2rem); }
.toast.is-bad { background: var(--bad); }
.modal { position: fixed; inset: 0; background: rgba(30,20,24,.45); z-index: 150; display: grid; place-items: center; padding: 1rem; }
.modal__box { background: #fff; border-radius: 16px; padding: 1.3rem; width: min(440px, 100%); max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal__actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.1rem; }
.savebar { position: sticky; bottom: 0; z-index: 40; background: rgba(247,243,239,.95); backdrop-filter: blur(6px); padding: .7rem 0; padding-bottom: calc(.7rem + env(safe-area-inset-bottom));
  display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--line); margin-top: 1.2rem; }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.grid--tpl { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.table td:first-child input { min-width: 9.5rem; }
