/* atrelo split — tokens del sistema Atrelo Efficiency (modo producto claro; oscuro con el navy de marca) */
:root {
  --atrelo-blue: #2d5bff;
  --grad: linear-gradient(95deg, #3f6dff 0%, #6a52f0 42%, #a14ee6 72%, #d65bff 100%);
  --grad-text: linear-gradient(95deg, #4f7cff 10%, #8a64f2 55%, #c45ce8 100%);
  --surface-page: #f5f6fa;
  --surface-card: #ffffff;
  --surface-sunken: #edeff6;
  --surface-sheet: #ffffff;
  --text-strong: #0e1330;
  --text-body: #383f5e;
  --text-muted: #686f91;
  --text-faint: #a7aecb;
  --text-link: #2d5bff;
  --border-subtle: #e2e5f0;
  --border-default: #cdd2e4;
  --blue-soft: #e9eeff;
  --purple-soft: #f0eeff;
  --purple-ink: #7a3fd6;
  --success-text: #0f7a50;
  --success-soft: #e3f6ee;
  --danger-text: #c42f35;
  --danger-soft: #fce9ea;
  --warning-text: #9a5b00;
  --warning-soft: #fcf1dd;
  --focus-ring: rgba(45,91,255,0.4);
  --shadow-card: 0 4px 20px rgba(45,91,255,0.07);
  --shadow-lg: 0 18px 48px rgba(14,19,48,0.16);
  --glow-brand: 0 12px 32px rgba(95,70,235,0.4);
  --backdrop: rgba(14,19,48,0.45);
  --radius-md: 14px; --radius-lg: 20px; --radius-pill: 999px;
  --font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.22,.8,.34,1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-page: #050410; --surface-card: #0f0c24; --surface-sunken: #08071a; --surface-sheet: #110d28;
    --text-strong: #f6f7ff; --text-body: #b8bee0; --text-muted: #9aa1cc; --text-faint: #6b7099; --text-link: #8a9dff;
    --border-subtle: rgba(255,255,255,0.08); --border-default: rgba(255,255,255,0.16);
    --blue-soft: rgba(63,109,255,0.18); --purple-soft: rgba(161,78,230,0.18); --purple-ink: #c9a2ff;
    --success-text: #45d49a; --success-soft: rgba(69,212,154,0.14);
    --danger-text: #ff8fa8; --danger-soft: rgba(255,111,145,0.14);
    --warning-text: #ffbd66; --warning-soft: rgba(255,189,102,0.14);
    --focus-ring: rgba(123,143,255,0.55);
    --shadow-card: 0 4px 24px rgba(0,0,0,0.35); --shadow-lg: 0 22px 70px rgba(0,0,0,0.55);
    --backdrop: rgba(0,0,0,0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--surface-page); color: var(--text-body); font-family: var(--font);
  font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { color: var(--text-strong); letter-spacing: -0.02em; line-height: 1.2; }
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.ic { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Estructura */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.pantalla {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(160px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.topbar h1 { font-size: 1.3rem; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .centro { text-align: center; }
.marca-mini { width: 30px; height: 30px; flex: none; }
.btn-icono {
  width: 42px; height: 42px; border-radius: 13px; border: 1px solid var(--border-subtle); background: var(--surface-card);
  display: grid; place-items: center; color: var(--text-strong); flex: none;
}
.btn-icono:hover { border-color: var(--border-default); }

.card { background: var(--surface-card); border: 1px solid var(--border-subtle); border-radius: 18px; box-shadow: var(--shadow-card); padding: 16px; }
.card.lista { padding: 4px 16px; }
.etiqueta { font-size: .7rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted); }
.fila-etiqueta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 4px; }
.enlace { background: none; border: 0; padding: 4px 0; color: var(--text-link); font-weight: 600; font-size: .84rem; }
.nota { font-size: .82rem; color: var(--text-muted); }
.vacio { text-align: center; padding: 28px 12px; color: var(--text-muted); font-size: .9rem; display: grid; gap: 6px; justify-items: center; }
.vacio .ic { width: 32px; height: 32px; color: var(--text-faint); }
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; font-size: .84rem; }
.aviso.info { background: var(--blue-soft); color: var(--text-body); }
.aviso.alerta { background: var(--warning-soft); color: var(--warning-text); }
.aviso.cerrado { background: var(--surface-sunken); color: var(--text-muted); }
.aviso .ic { width: 18px; height: 18px; margin-top: 1px; }
.aviso b { color: var(--text-strong); }

/* Botones */
.btn {
  min-height: 48px; border-radius: var(--radius-md); border: 1px solid transparent; padding: 0 18px;
  font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .2s var(--ease-out), opacity .2s, background .2s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn-primario { background: var(--grad); color: #fff; box-shadow: var(--glow-brand); }
.btn-primario:hover:not(:disabled) { opacity: .92; }
.btn-secundario { background: var(--surface-card); border-color: var(--border-default); color: var(--text-strong); }
.btn-peligro { background: var(--danger-soft); color: var(--danger-text); }
.btn-ancho { width: 100%; }
.btn-chico { min-height: 36px; padding: 0 12px; font-size: .8rem; border-radius: 11px; }
.fab {
  position: fixed; z-index: 20; bottom: calc(84px + env(safe-area-inset-bottom, 0px)); right: max(16px, calc(50% - 264px));
  height: 52px; padding: 0 20px; border: 0; border-radius: 17px; color: #fff; font-weight: 600; font-size: .92rem;
  background: var(--grad); box-shadow: var(--glow-brand); display: flex; align-items: center; gap: 8px;
}
.fab.solo { bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }

/* Barra de pestañas */
.tabbar {
  position: fixed; z-index: 15; bottom: 0; left: 0; right: 0; background: var(--surface-card); border-top: 1px solid var(--border-subtle);
  padding: 8px max(8px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px));
}
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.tab { background: none; border: 0; display: grid; justify-items: center; gap: 3px; font-size: .72rem; font-weight: 600; color: var(--text-muted); padding: 6px 0; border-radius: 12px; }
.tab[aria-current="page"] { color: var(--atrelo-blue); }

/* Campos */
.campo { display: grid; gap: 6px; }
.campo > label:not(.recibo), .campo > .etiqueta { font-size: .7rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--text-muted); }
.inp, select.inp {
  width: 100%; min-height: 46px; border-radius: 13px; border: 1px solid var(--border-default); background: var(--surface-card);
  color: var(--text-strong); padding: 0 14px; font-size: 1rem; font-weight: 500;
}
.inp::placeholder { color: var(--text-faint); }
.inp:focus { outline: none; border-color: var(--atrelo-blue); box-shadow: 0 0 0 4px var(--focus-ring); }
.inp[aria-invalid="true"] { border-color: var(--danger-text); box-shadow: 0 0 0 4px var(--danger-soft); }
.inp-codigo { text-align: center; letter-spacing: .5em; font-size: 1.4rem; font-weight: 700; }

/* Avatares */
.av {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: .74rem; font-weight: 700; color: #fff; flex: none;
}
.avs { display: flex; }
.avs .av { width: 30px; height: 30px; font-size: .66rem; border: 2px solid var(--surface-card); margin-left: -9px; }
.avs .av:first-child { margin-left: 0; }

/* Saldo principal */
.saldo { border-radius: 22px; padding: 18px; color: #fff; background: var(--grad); box-shadow: var(--glow-brand); display: grid; gap: 2px; }
.saldo small { font-size: .72rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .88; }
.saldo .grande { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; line-height: 1.15; }
.saldo .sub { font-size: .84rem; opacity: .92; }

/* Píldoras de saldo */
.pill { font-size: .76rem; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.positivo { background: var(--success-soft); color: var(--success-text); }
.pill.negativo { background: var(--danger-soft); color: var(--danger-text); }
.pill.cero { background: var(--surface-sunken); color: var(--text-muted); }

/* Tarjeta de grupo */
.grupo { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; gap: 12px; align-items: center; width: 100%; text-align: left; font: inherit; color: inherit; }
.grupo:hover { border-color: var(--border-default); }
.grupo-ic { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--blue-soft); color: var(--atrelo-blue); }
.grupo-ic.alt { background: var(--purple-soft); color: var(--purple-ink); }
.grupo h3 { font-size: 1rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grupo p { font-size: .8rem; color: var(--text-muted); }

/* Resumen del grupo */
.resumen { display: grid; gap: 10px; }
.resumen .total { font-size: 1.7rem; font-weight: 800; color: var(--text-strong); letter-spacing: -0.02em; }

/* Filas de gasto / pago / historial */
.fila { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border-subtle); width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.fila:first-child { border-top: 0; }
button.fila:hover h4 { color: var(--text-link); }
.fila h4 { font-size: .94rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila p { font-size: .76rem; color: var(--text-muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fila .monto { font-weight: 700; color: var(--text-strong); text-align: right; font-size: .95rem; }
.fila .monto small { display: block; font-size: .7rem; font-weight: 500; color: var(--text-muted); }
.icono-fila { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--success-soft); color: var(--success-text); }
.tag { display: inline-flex; align-items: center; gap: 3px; font-size: .68rem; font-weight: 600; color: var(--text-link); background: var(--blue-soft); padding: 1px 8px; border-radius: var(--radius-pill); }
.tag .ic { width: 12px; height: 12px; }

/* Saldos y pagos sugeridos */
.saldo-fila { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; }
.saldo-fila .av { width: 34px; height: 34px; }
.saldo-fila span { font-weight: 600; color: var(--text-strong); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saldo-fila small { display: block; font-size: .72rem; color: var(--text-muted); font-weight: 500; }
.positivo-txt { color: var(--success-text); font-weight: 700; }
.negativo-txt { color: var(--danger-text); font-weight: 700; }
.cero-txt { color: var(--text-muted); font-weight: 600; font-size: .84rem; }
.sugerido { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 12px 0; border-top: 1px solid var(--border-subtle); }
.sugerido:first-child { border-top: 0; }
.flujo { display: flex; align-items: center; gap: 4px; }
.flujo .av { width: 32px; height: 32px; font-size: .68rem; }
.flujo .ic { width: 15px; height: 15px; color: var(--text-muted); }
.sugerido p { font-size: .84rem; line-height: 1.35; }
.sugerido b { color: var(--text-strong); }

/* Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 12px 4px 4px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-default); background: var(--surface-card); font-weight: 600; font-size: .84rem; color: var(--text-body);
}
.chip .av { width: 26px; height: 26px; font-size: .62rem; }
.chip[aria-pressed="true"] { border-color: var(--atrelo-blue); background: var(--blue-soft); color: var(--text-strong); }
.chip[aria-pressed="false"]:not(.chip-listo) .av { opacity: .35; }
.chip.listo { border-color: var(--success-text); background: var(--success-soft); color: var(--success-text); }
.chip-sin-av { padding: 6px 14px; }

/* Compras de un gasto */
.compras { display: grid; gap: 8px; }
.compra { display: grid; grid-template-columns: minmax(0, 1fr) 104px 34px; gap: 6px; align-items: center; }
.compra .inp { min-height: 44px; font-size: .95rem; }
.compra .inp-monto { text-align: right; font-variant-numeric: tabular-nums; }
.btn-quitar { width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--text-muted); display: grid; place-items: center; }
.btn-quitar:hover { background: var(--danger-soft); color: var(--danger-text); }
.btn-quitar .ic { width: 16px; height: 16px; }
.btn-punteado {
  min-height: 44px; border-radius: 13px; border: 1.5px dashed var(--border-default); background: transparent; color: var(--text-link);
  font-weight: 600; font-size: .86rem; display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%;
}
.btn-punteado:hover { border-color: var(--atrelo-blue); background: var(--blue-soft); }
.total-gasto { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.total-gasto span { font-size: .82rem; color: var(--text-muted); }
.total-gasto strong { font-size: 1.45rem; font-weight: 800; color: var(--text-strong); letter-spacing: -0.02em; }

/* Recibo */
.recibo {
  border: 1.5px dashed var(--border-default); border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px;
  cursor: pointer; width: 100%; background: transparent; text-align: left;
}
.recibo:hover { border-color: var(--atrelo-blue); }
.recibo-ic { width: 46px; height: 46px; border-radius: 12px; background: var(--purple-soft); color: var(--purple-ink); display: grid; place-items: center; flex: none; overflow: hidden; }
.recibo-ic img { width: 100%; height: 100%; object-fit: cover; }
.recibo b { display: block; font-size: .9rem; color: var(--text-strong); font-weight: 600; }
.recibo small { font-size: .76rem; color: var(--text-muted); }
.recibo-grande { width: 100%; border-radius: 14px; border: 1px solid var(--border-subtle); display: block; max-height: 60vh; object-fit: contain; background: var(--surface-sunken); }

/* Hojas (modales desde abajo) */
.fondo-hoja { position: fixed; inset: 0; z-index: 40; background: var(--backdrop); display: flex; align-items: flex-end; justify-content: center; animation: aparecer .2s ease; }
.hoja {
  width: 100%; max-width: 560px; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--surface-sheet);
  border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg); display: grid; gap: 16px; align-content: start;
  padding: 10px max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px));
  animation: subir .28s var(--ease-out);
}
.hoja::before { content: ""; width: 40px; height: 4px; border-radius: 4px; background: var(--border-default); justify-self: center; }
.hoja-titulo { display: flex; align-items: center; gap: 10px; }
.hoja-titulo h2 { font-size: 1.2rem; font-weight: 700; flex: 1; }
.hoja .acciones { display: grid; gap: 10px; }
@media (min-width: 600px) {
  .fondo-hoja { align-items: center; padding: 24px; }
  .hoja { border-radius: 26px; }
  .hoja::before { display: none; }
}
@keyframes subir { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes aparecer { from { opacity: 0; } to { opacity: 1; } }

/* Iconos de grupo a elegir */
.iconos { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.icono-op { aspect-ratio: 1; border-radius: 14px; border: 1px solid var(--border-default); background: var(--surface-card); display: grid; place-items: center; color: var(--text-muted); }
.icono-op[aria-pressed="true"] { border-color: var(--atrelo-blue); background: var(--blue-soft); color: var(--atrelo-blue); }

/* Lista de nombres a invitar */
.lista-nombres { display: grid; gap: 8px; }
.nombre-fila { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.nombre-fila span { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nombre-fila small { display: block; font-size: .74rem; color: var(--text-muted); font-weight: 500; }
.agregar-nombre { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.enlace-copiar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.enlace-copiar code { font-size: .78rem; padding: 12px; border-radius: 12px; background: var(--surface-sunken); color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; user-select: all; }

/* Login */
.login { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 22px; max-width: 400px; width: 100%; margin: 0 auto; padding-bottom: 40px; }
.login-marca { display: grid; justify-items: center; gap: 12px; text-align: center; }
.login-marca svg { width: 76px; height: 76px; filter: drop-shadow(0 0 16px rgba(123,63,240,.4)); }
.wordmark { font-size: 1.9rem; font-weight: 700; letter-spacing: -0.03em; color: var(--text-strong); }
.wordmark b { font-weight: 800; }
.lema { font-size: .95rem; color: var(--text-muted); max-width: 30ch; }
.separador { display: flex; align-items: center; gap: 12px; font-size: .78rem; color: var(--text-muted); }
.separador::before, .separador::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.btn-google { background: var(--surface-card); border: 1px solid var(--border-default); color: var(--text-strong); }

/* Brillo de marca en pantallas de entrada (estilo Atrelo) */
.con-brillo {
  background:
    radial-gradient(520px 320px at 85% -5%, rgba(123, 63, 240, .16), transparent 70%),
    radial-gradient(480px 300px at 0% 10%, rgba(63, 109, 255, .12), transparent 70%);
}

/* Cuánto ha puesto cada quien */
.barras { display: grid; gap: 14px; }
.barra-fila { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; align-items: center; }
.barra-fila .av { width: 34px; height: 34px; }
.barra-info { display: grid; gap: 6px; min-width: 0; }
.barra-cab { display: flex; justify-content: space-between; gap: 8px; font-size: .86rem; }
.barra-cab span { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barra-cab b { color: var(--text-strong); }
.barra { height: 8px; border-radius: var(--radius-pill); background: var(--surface-sunken); overflow: hidden; }
.barra span { display: block; height: 100%; border-radius: inherit; transition: width .5s var(--ease-out); }

.acciones-fila { display: flex; gap: 2px; }

/* Toast */
.toast {
  position: fixed; z-index: 60; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 20px);
  background: var(--text-strong); color: var(--surface-page); padding: 12px 18px; border-radius: 14px; font-size: .88rem; font-weight: 500;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .25s var(--ease-out);
  width: max-content; max-width: min(440px, calc(100% - 32px)); text-align: center;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.cargando { flex: 1; display: grid; place-items: center; }
.cargando svg { width: 64px; height: 64px; animation: latir 1.6s ease-in-out infinite; }
@keyframes latir { 50% { transform: scale(1.08); filter: drop-shadow(0 0 18px rgba(123,63,240,.5)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
