:root {
  --paper: #F6F5FB;
  --card: #ffffff;
  --ink: #1B1740;
  --ink-2: #4A4668;
  --muted: #7C7899;
  --line: #E9E6F4;
  --violet: #5B4BDB;
  --violet-soft: #ECE9FC;
  --spark: #F5A524;
  --ok: #17845A;
  --ok-soft: #DFF5EA;
  --warn: #9A5F00;
  --warn-soft: #FDF0D3;
  --bad: #C0362C;
  --bad-soft: #FCE6E3;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(27, 23, 64, .04), 0 8px 24px rgba(27, 23, 64, .06);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.45 var(--body);
  padding-bottom: 92px;
  -webkit-font-smoothing: antialiased;
}

h1 { font: 800 1.6rem/1.15 var(--display); margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font: 700 1.1rem/1.2 var(--display); margin: 0 0 12px; }
h2 small { font: 500 .8rem var(--body); }
p { margin: 0 0 10px; }
small, .muted { color: var(--muted); }
a { color: var(--violet); font-weight: 600; text-decoration: none; }
.back { font-size: .9rem; }
.grande { font: 800 1.8rem var(--display); }

/* Encabezado */
.demo-banner {
  max-width: 760px; margin: 12px auto 0; padding: 12px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  background: var(--warn-soft); color: var(--ink); border-radius: 14px;
  font-size: .82rem;
}
.demo-banner strong { font-family: var(--display); }
.demo-banner span { flex: 1 1 240px; }
.demo-banner a { text-decoration: underline; text-underline-offset: 3px; }
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: rgba(246, 245, 251, .92); backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand > div { min-width: 0; }
.brand strong { display: block; font: 700 .98rem/1.2 var(--display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: .76rem; }
.logo { flex: none; width: 38px; height: 38px; }
.rol { flex: none; display: flex; flex-direction: column; font-size: .68rem; color: var(--muted); }
.rol select {
  border: 0; border-radius: 99px; padding: 6px 10px; margin-top: 2px; width: auto;
  background: var(--violet-soft); color: var(--violet); font: 700 .82rem var(--body);
}

/* Navegación */
#nav {
  position: fixed; bottom: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; padding: 6px;
  background: var(--ink); border-radius: 24px; box-shadow: 0 10px 30px rgba(27, 23, 64, .3);
}
#nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px; border-radius: 18px;
  color: #B9B4D8; font-size: .68rem; font-weight: 600;
}
#nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#nav a.on { background: var(--violet); color: #fff; }

main { max-width: 760px; margin: 0 auto; padding: 8px 16px 16px; }

/* Portada */
.hero {
  position: relative; overflow: hidden;
  padding: 20px; margin-bottom: 14px; border-radius: 26px; color: #fff;
  background: linear-gradient(135deg, #5B4BDB 0%, #3F31B0 60%, #2A2180 100%);
  box-shadow: 0 14px 34px rgba(91, 75, 219, .32);
}
.hero::after {
  content: ""; position: absolute; right: -50px; top: -60px; width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 165, 36, .5), rgba(245, 165, 36, 0) 70%);
}
.hero small { display: block; color: #CFC9FF; }
.hero small::first-letter { text-transform: uppercase; }
.hero-label { display: block; margin-top: 10px; font-size: .9rem; color: #E2DEFF; }
.hero-num { display: block; font: 800 2.5rem/1.1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.hero-row { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.hero-row div { background: rgba(255, 255, 255, .13); border-radius: 14px; padding: 9px 10px; }
.hero-row span { display: block; font-size: .7rem; color: #E2DEFF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hero-row b { font: 700 .98rem var(--display); font-variant-numeric: tabular-nums; }
.hero.slim .hero-label { margin-top: 0; }
.hero.slim .hero-num { font-size: 2.1rem; }

/* Accesos rápidos */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.quick button {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 4px; border: 0; border-radius: 18px; background: var(--card); box-shadow: var(--shadow);
  font-size: .78rem; font-weight: 600; color: var(--ink-2);
}
.quick button span { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--violet-soft); font-size: 1.25rem; }

/* Bloques */
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin: 6px 0 14px; }
.head > div:first-child { min-width: 0; flex: 1 1 220px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; align-items: baseline; }
.card-top a { font-size: .85rem; }

.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile { border-radius: 18px; padding: 13px 14px; background: var(--card); box-shadow: var(--shadow); }
.tile span { display: block; font-size: .8rem; color: var(--ink-2); }
.tile b { font: 800 1.3rem var(--display); font-variant-numeric: tabular-nums; }
.tile.in { background: var(--ok-soft); box-shadow: none; } .tile.in b { color: var(--ok); }
.tile.out { background: var(--bad-soft); box-shadow: none; } .tile.out b { color: var(--bad); }

.resumen { background: var(--card); border-radius: var(--radius); padding: 16px 16px 2px; margin-bottom: 14px; box-shadow: var(--shadow); }
.resumen-top { margin-bottom: 12px; }
.resumen-top span { display: block; font-size: .85rem; color: var(--ink-2); }
.resumen-top b { display: block; font: 800 2rem/1.15 var(--display); font-variant-numeric: tabular-nums; }

.pills { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.pills div { background: var(--card); border-radius: 18px; padding: 10px 4px; text-align: center; box-shadow: var(--shadow); }
.pills b { display: block; font: 800 1.4rem var(--display); color: var(--violet); }
.pills span { font-size: .74rem; color: var(--muted); }

.bar { height: 10px; border-radius: 99px; background: var(--line); overflow: hidden; margin: 8px 0 6px; }
.bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--violet), #8F83FF); }

.stack { display: flex; gap: 3px; height: 16px; margin-bottom: 12px; }
.stack i { border-radius: 6px; min-width: 6px; }
.legend { list-style: none; margin: 0; padding: 0; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 7px 0; }
.legend .main { flex: 1; font-weight: 600; }
.legend small { width: 42px; text-align: right; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }

/* Avisos */
.alert { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 18px; margin-bottom: 10px; font-size: .9rem; line-height: 1.35; }
.alert > span:nth-child(2) { flex: 1; }
.aico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: rgba(255, 255, 255, .7); font-size: 1.2rem; }
.alert.warn { background: var(--warn-soft); color: #5E3A00; }
.alert.bad { background: var(--bad-soft); color: #7A1F18; }
.alert.info { background: var(--violet-soft); color: #2F2687; }
.alert button, .alert .btn { flex: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.gris { background: #EEEDF4; color: var(--muted); }
.badge.info { background: var(--violet-soft); color: var(--violet); }

/* Listas */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.list li:last-child { padding-bottom: 2px; }
.list .main { min-width: 0; flex: 1; }
.list .main b { display: block; font-weight: 600; line-height: 1.3; }
.list .main small { display: block; font-size: .8rem; }
.list .main .btns { margin-top: 6px; }
.list .side { text-align: right; flex: none; }
.list li.mov { align-items: flex-start; }
.row-link { cursor: pointer; }
.vacio { justify-content: center; color: var(--muted); padding: 18px 0 !important; }
.vacio span { font-size: 1.4rem; }

.ico { flex: none; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 14px; font-size: 1.2rem; }
.ico.in { background: var(--ok-soft); }
.ico.out { background: var(--bad-soft); }
.ico.soft { background: var(--violet-soft); }
.avatar { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; color: #fff; font: 700 .9rem var(--display); }
.avatar.big { width: 72px; height: 72px; font-size: 1.5rem; margin: 0 auto 10px; }
.fecha { flex: none; width: 46px; padding: 6px 0; border-radius: 14px; background: var(--violet-soft); color: var(--violet); text-align: center; font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.fecha b { display: block; font: 800 1.15rem/1 var(--display); }

.amount { font: 700 1rem var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.amount.in { color: var(--ok); }
.amount.out { color: var(--bad); }
.tachado { text-decoration: line-through; color: var(--muted); }

.chips-in { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chip { padding: 2px 9px; border-radius: 99px; background: var(--paper); font-size: .74rem; font-weight: 600; color: var(--ink-2); }
.center { justify-content: center; }

/* Fichas */
.ficha { text-align: center; background: var(--card); border-radius: 26px; padding: 22px 16px 18px; margin-bottom: 14px; box-shadow: var(--shadow); }
.ficha .chips-in, .ficha .btns { margin-top: 12px; }
.ficha .muted { margin-top: 8px; }

.months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin: 4px 0 12px; }
.months div { text-align: center; font-size: .72rem; font-weight: 700; color: var(--muted); }
.months span { display: grid; place-items: center; height: 38px; margin-bottom: 4px; border-radius: 14px; background: #EEEDF4; font-size: 1rem; }
.months .paid span { background: var(--violet); color: #fff; }
.months .paid { color: var(--violet); }
.months .due span { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 2px var(--spark); }

/* Actividades */
.acts { display: grid; gap: 12px; margin-bottom: 14px; }
.act { display: flex; gap: 14px; background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.act-ico { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 18px; font-size: 1.7rem; background: var(--violet-soft); }
.act-ico.big { width: 76px; height: 76px; font-size: 2.3rem; margin: 0 auto 10px; border-radius: 24px; }
.t-rifa .act-ico { background: #FDF0D3; }
.t-kiosco .act-ico { background: var(--ok-soft); }
.t-evento .act-ico { background: #FCE3EE; }
.act-body { flex: 1; min-width: 0; }
.act-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.act-top h2 { margin: 0; }
.act-num { display: flex; align-items: baseline; gap: 6px; margin: 8px 0 2px; }
.act-num b { font: 800 1.5rem var(--display); font-variant-numeric: tabular-nums; }
.act-num span { font-size: .82rem; color: var(--muted); }

/* Controles */
.btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
button, .btn {
  font: 600 .9rem var(--body);
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 99px; padding: 10px 16px; cursor: pointer; display: inline-block;
}
button.primary, .btn.primary { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: 0 6px 16px rgba(91, 75, 219, .28); }
button.small, .btn.small { padding: 6px 12px; font-size: .8rem; box-shadow: none; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 2px 0; margin-right: 6px; color: var(--violet); font-size: .8rem; }
button.link.danger { color: var(--bad); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.chips button { padding: 6px 13px; font-size: .8rem; background: var(--paper); border-color: transparent; color: var(--ink-2); }
.chips button.on { background: var(--ink); color: #fff; }

input, select, textarea {
  font: inherit; width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--violet); box-shadow: 0 0 0 3px var(--violet-soft); }
input[type=search] { background: var(--paper); border-color: transparent; border-radius: 99px; }
.pill-select { width: auto; border-radius: 99px; border: 0; background: var(--card); box-shadow: var(--shadow); font-weight: 600; text-transform: capitalize; }
label.f { display: block; font-size: .82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 12px; }
label.f > input, label.f > select, label.f > textarea { margin-top: 5px; font-weight: 400; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: .86rem; margin-bottom: 12px; }
label.check input { width: auto; }
.muestra { margin: 8px 0 0; padding-left: 18px; }
.hint { font-size: .86rem; padding: 11px 14px; border-radius: 14px; background: var(--violet-soft); color: #2F2687; margin-bottom: 12px; }
.error { font-size: .88rem; padding: 11px 14px; border-radius: 14px; background: var(--bad-soft); color: #7A1F18; margin-bottom: 12px; }
.error:empty { display: none; }

dialog { border: 0; border-radius: 26px; padding: 22px; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; color: var(--ink); box-shadow: 0 24px 60px rgba(27, 23, 64, .35); }
dialog::backdrop { background: rgba(27, 23, 64, .55); backdrop-filter: blur(3px); }
dialog h2 { font-size: 1.3rem; margin-bottom: 14px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
dialog img { max-width: 100%; border-radius: 14px; }

#toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 99px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.on { opacity: 1; }

body.ro [data-w] { display: none !important; }
body:not(.asesora) [data-asesora] { display: none !important; }

/* Recibo y talones */
.recibo { border: 2px dashed var(--line); border-radius: 18px; padding: 16px; font-size: .92rem; background: var(--paper); }
.recibo h3 { margin: 0 0 2px; font: 700 1rem var(--display); }
.recibo table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.recibo td { padding: 6px 0; border-top: 1px solid var(--line); }
.recibo td.n { text-align: right; font-variant-numeric: tabular-nums; }
.recibo .tot { font: 800 1.3rem var(--display); margin: 8px 0 4px; color: var(--violet); }
#print { display: none; }

/* Informes */
.informe { font-size: .9rem; overflow-x: auto; margin-bottom: 12px; }
.informe h3 { margin: 0 0 2px; font: 700 1rem var(--display); }
.informe .sub { color: var(--ink-2); font-weight: 600; margin-bottom: 8px; }
.informe table { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.informe th, .informe td { padding: 6px 4px; border-top: 1px solid var(--line); text-align: left; font-weight: 400; vertical-align: top; }
.informe td:last-child { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.informe tr.sub th { padding-top: 14px; border-top: 0; font-weight: 700; color: var(--violet); }
.informe tr.tot th, .informe tr.tot td { font-weight: 700; }
.informe tr.fin th, .informe tr.fin td { border-top: 2px solid var(--ink); }
.informe thead th { font-weight: 700; font-size: .78rem; color: var(--ink-2); border-top: 0; }
.informe td small { white-space: nowrap; }
.informe .pie { font-size: .78rem; color: var(--muted); }
.orden { margin: 0 0 12px; padding-left: 22px; }
.orden li { padding: 3px 0; }

@media (min-width: 900px) {
  body { padding: 0 0 0 232px; }
  #nav { top: 16px; bottom: 16px; left: 16px; right: auto; width: 200px; flex-direction: column; gap: 4px; padding: 10px; }
  #nav a { flex: none; flex-direction: row; gap: 12px; padding: 12px 14px; font-size: .92rem; }
  .top { background: none; backdrop-filter: none; padding: 20px 16px 8px; max-width: 760px; margin: 0 auto; position: static; }
  #toast { bottom: 28px; }
  .acts { grid-template-columns: 1fr 1fr; }
}

@media print {
  body { padding: 0; background: #fff; }
  body > *:not(#print) { display: none !important; }
  #print { display: block; font-family: var(--body); }
  .talon { border: 1px dashed #000; padding: 10px 12px; margin: 0 0 8px; font-size: 11pt; break-inside: avoid; }
  .talon h3 { margin: 0 0 4px; font-size: 11pt; }
  .talon p { margin: 0 0 4px; white-space: pre-line; }
  .recibo { border: 1px solid #000; background: #fff; }
  .informe, .hoja { font-size: 11pt; color: #000; overflow: visible; }
  .informe tr { break-inside: avoid; }
  .informe th, .informe td { border-top: 1px solid #999; }
  .informe tr.sub th, .informe .sub, .informe .pie, .informe thead th { color: #000; }
  .hoja h3 { margin: 0 0 2pt; font-size: 13pt; }
  .hoja .sub { font-weight: 700; margin-bottom: 18pt; }
  .hoja p, .hoja ol { margin: 0 0 10pt; line-height: 1.5; }
  .hoja .pie { font-size: 9pt; margin-top: 24pt; }
  .firmas { display: flex; justify-content: space-around; margin-top: 70pt; }
  .firmas span { width: 38%; padding-top: 4pt; border-top: 1px solid #000; text-align: center; }
}
