:root {
  --bg: #f5f2ec;
  --surface: #fdfbf7;
  --text: #23201b;
  --muted: #7a7468;
  --line: #e2ddd2;
  --brand: #2f4a3c;
  --brand-ink: #fdfbf7;
  --brand-soft: #e9eee9;
  --gold: #a8812f;
  --gold-soft: #f3ead2;
  --ok: #2f6b48;
  --danger: #9b3a2f;
  --bar: #d9dfd5;
  --radius: 4px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --sans: 'Helvetica Neue', 'Segoe UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1c1f22;
    --text: #ece8de;
    --muted: #9a9588;
    --line: #2d3033;
    --brand: #9fc0ab;
    --brand-ink: #15171a;
    --brand-soft: #232a26;
    --gold: #d2ac5a;
    --gold-soft: #2e2918;
    --ok: #8cc9a2;
    --danger: #e08c80;
    --bar: #2a3530;
  }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.6 var(--sans); -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-underline-offset: 3px; }
h1, h2, h3, .brand { font-family: var(--serif); font-weight: 500; letter-spacing: -.01em; }

.topbar {
  display: flex; align-items: center; gap: 32px; flex-wrap: wrap;
  padding: 18px 40px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.brand { font-size: 1.4rem; text-decoration: none; color: var(--text); font-style: italic; }
.topbar nav { display: flex; gap: 26px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 4px 0; text-decoration: none; color: var(--muted); font-size: .8rem;
  text-transform: uppercase; letter-spacing: .12em; border-bottom: 1px solid transparent;
}
.topbar nav a:hover { color: var(--text); }
.topbar nav a.active { color: var(--text); border-bottom-color: var(--gold); }
.userbox { display: flex; align-items: center; gap: 12px; font-size: .85rem; color: var(--muted); }

main { max-width: 760px; margin: 0 auto; padding: 56px 24px 96px; }
main.wide { max-width: 1040px; }
h1 { font-size: 2.1rem; margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 1.35rem; margin: 0 0 14px; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 52ch; margin: 0 0 32px; }
.muted { color: var(--muted); }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .16em; color: var(--gold); margin-bottom: 10px; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px 34px; margin-bottom: 28px;
}
.badge {
  display: inline-block; font-size: .68rem; font-weight: 600; padding: 2px 9px; border-radius: 2px;
  text-transform: uppercase; letter-spacing: .12em;
  background: var(--brand-soft); color: var(--brand);
}
.badge.closed { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.badge.admin { background: var(--gold-soft); color: var(--gold); }

.btn {
  display: inline-block; border: 1px solid var(--brand); cursor: pointer; text-decoration: none; font: inherit;
  font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .12em;
  padding: 11px 24px; border-radius: var(--radius); background: var(--brand); color: var(--brand-ink);
  transition: opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--text); opacity: 1; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.small { padding: 6px 14px; font-size: .7rem; }

label { display: block; font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 18px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
.auth { max-width: 440px; margin: 24px auto; }
.error { color: var(--danger); font-size: .9rem; min-height: 1.3em; margin-top: 10px; }
.ok { color: var(--ok); }

/* Buscador */
.search { position: relative; margin: 0 0 28px; }
.search input { padding-left: 14px; font-size: 1rem; background: var(--surface); }
.search-count { font-size: .8rem; color: var(--muted); margin-top: 8px; }
.empty { text-align: center; padding: 48px 0; color: var(--muted); font-family: var(--serif); font-style: italic; }

/* Resultados */
.options { display: grid; gap: 8px; margin: 22px 0; }
.opt {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.opt .fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); z-index: 0; transition: width .6s; }
.opt > span { position: relative; z-index: 1; }
.opt.mine { border-color: var(--brand); }
.opt .pct { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.opt.winner { border-color: var(--gold); background: var(--gold-soft); }
.opt.winner .fill { background: var(--gold); opacity: .28; }
.opt.winner .name { font-weight: 700; }
.opt.winner .pct { color: var(--text); font-weight: 700; }
.tag-win {
  display: inline-block; margin-left: 10px; font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--brand-ink); background: var(--gold); padding: 2px 7px; border-radius: 2px; vertical-align: middle;
}
.vote-opt { display: flex; gap: 10px; align-items: center; margin: 0; cursor: pointer; text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 400; color: var(--text); }
.vote-opt input { width: auto; accent-color: var(--brand); }
.meta { font-size: .82rem; color: var(--muted); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.poll-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.poll h2.poll-title, .poll h1 { font-size: 1.7rem; }
.section-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); margin: 8px 0 20px; font-family: var(--sans); font-weight: 600; }

/* Admin */
.tabs { display: flex; gap: 28px; margin-bottom: 32px; border-bottom: 1px solid var(--line); }
.tabs button {
  background: none; border: 0; font: inherit; font-size: .78rem; text-transform: uppercase; letter-spacing: .12em;
  font-weight: 600; color: var(--muted); padding: 10px 0; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--gold); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin-bottom: 28px; border: 1px solid var(--line); background: var(--surface); }
.stat { padding: 20px 22px; border-right: 1px solid var(--line); }
.stat:last-child { border-right: 0; }
.stat b { display: block; font-family: var(--serif); font-weight: 500; font-size: 2.2rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 12px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; }
.table-wrap { overflow-x: auto; }
.row { display: flex; gap: 8px; margin-bottom: 8px; }
.row input { flex: 1; }
.poll-admin { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.poll-admin:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.detail { background: var(--bg); border-radius: var(--radius); padding: 18px; margin-top: 12px; }
.meter { height: 4px; background: var(--line); overflow: hidden; margin: 6px 0 16px; }
.meter > div { height: 100%; background: var(--brand); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 560px) {
  .two { grid-template-columns: 1fr; }
  .topbar { padding: 14px 18px; gap: 14px; }
  .card { padding: 22px 20px; }
  main { padding-top: 36px; }
  .stat { border-right: 0; border-bottom: 1px solid var(--line); }
}
