/* =========================================================================
   Referidos BNI — estilos (sistema visual basado en la plantilla Finza)
   ========================================================================= */
@font-face { font-family: "Inter"; src: url("../fonts/inter-regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-semibold.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Inter"; src: url("../fonts/inter-bold.woff2") format("woff2"); font-weight: 700 800; font-display: swap; }

:root {
  --bg: #030D01;
  --primary: #66FE4C;
  --primary-shadow: #1CC300;
  --primary-soft: rgba(102, 254, 76, 0.4);
  --glow: #21960D;
  --card: linear-gradient(290deg, #081B05 38%, #104108 97%);
  --row: #071605;
  --avatar: #082D0E;
  --tile: #183E11;
  --chip: #263D21;
  --nav: rgba(6, 42, 1, 0.92);
  --input-border: #19212C;
  --line: rgba(255, 255, 255, 0.08);
  --text: #FFFFFF;
  --text-2: #D6D3D1;
  --text-3: #9AA4B2;
  --orange: #FF9900;
  --red: #EF5C5C;
  --radius: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: 66px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: #B8FFAB; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
button { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- estructura ---------- */
.glow {
  position: fixed; top: 40px; left: 50%; width: 341px; height: 219px; border-radius: 50%;
  background: var(--glow); filter: blur(90px); opacity: .55; transform: translateX(10%) rotate(-37deg);
  pointer-events: none; z-index: 0;
}
.app {
  position: relative; z-index: 1; max-width: 480px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--safe-top) + 14px) 20px calc(var(--safe-bottom) + 24px);
}
.app.with-nav { padding-bottom: calc(var(--safe-bottom) + var(--nav-h) + 36px); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.center { text-align: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.green { color: var(--primary); }
.orange { color: var(--orange); }
.red { color: var(--red); }
.mt-auto { margin-top: auto; }

/* ---------- barra superior ---------- */
.topbar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.logo {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--primary); box-shadow: inset 3px 3px 6px 0 var(--primary-shadow);
  color: #000; font-weight: 800; font-size: 13px; letter-spacing: -.5px;
  display: flex; align-items: center; justify-content: center;
}
.logo.lg { width: 84px; height: 84px; border-radius: 24px; font-size: 28px; letter-spacing: -1px;
  box-shadow: inset 6px 5px 12px 0 var(--primary-shadow), 0 0 40px rgba(102, 254, 76, .25); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 15px; font-weight: 700; letter-spacing: .5px; }
.brand-text span { font-size: 11px; color: var(--text-3); }
.icon-btn {
  width: 44px; height: 44px; border-radius: 22px; border: 0; flex-shrink: 0;
  background: rgba(255, 255, 255, .1); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: rgba(255, 255, 255, .16); color: var(--text); }
.page-title { display: flex; align-items: center; gap: 12px; }

/* ---------- avatares ---------- */
.avatar {
  width: 46px; height: 46px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: var(--avatar); color: var(--primary); font-weight: 600; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 36px; height: 36px; font-size: 13px; }
.avatar.lg { width: 84px; height: 84px; font-size: 26px; }
.avatar.tile { background: var(--tile); border: 1px solid rgba(255, 255, 255, .1); }

/* ---------- tarjetas ---------- */
.card { background: var(--card); border: 1px solid rgba(255, 255, 255, .05); border-radius: var(--radius); padding: 14px; }
.panel { background: var(--row); border-radius: 10px; padding: 12px; }
.panel.outline { border: 1px solid var(--line); }
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px;
  background: var(--row); color: var(--text); border: 1px solid transparent; min-height: 66px;
}
a.item:hover { border-color: rgba(255, 255, 255, .1); color: var(--text); }
.item.me { background: var(--tile); border-color: var(--primary-soft); }
.item.dashed { border: 1px dashed rgba(255, 153, 0, .4); }
.item-title { font-size: 15px; font-weight: 500; }
.item-sub { font-size: 12px; color: var(--text-3); }
.item-end { font-weight: 600; white-space: nowrap; color: #E2E8F0; }

.balance { display: flex; align-items: center; gap: 8px; font-size: 32px; line-height: 1.1; font-weight: 600; }
.star { color: var(--orange); }
.tiles { display: flex; gap: 12px; }
.tile { flex: 1; min-width: 0; padding: 12px; border-radius: 8px; background: var(--tile); border: 1px solid rgba(255, 255, 255, .1); display: flex; flex-direction: column; }
.tile.primary { background: var(--primary); border-color: var(--primary); color: #000; }
.tile .k { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; opacity: .8; }
.tile .v { font-size: 17px; font-weight: 700; }

.alert { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px;
  background: rgba(102, 254, 76, .08); border: 1px solid var(--primary-soft); color: var(--text); }
.alert.warn { background: rgba(255, 153, 0, .08); border-color: rgba(255, 153, 0, .4); }
.alert.error { background: rgba(239, 92, 92, .1); border-color: rgba(239, 92, 92, .45); }
a.alert:hover { color: var(--text); filter: brightness(1.1); }

.empty { text-align: center; padding: 28px 16px; color: var(--text-3); border: 1px dashed var(--chip); border-radius: 12px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; font-weight: 600; }

/* ---------- chips ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 11px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .06); color: var(--text); white-space: nowrap; }
.chip.green { background: var(--primary); color: #000; border-color: var(--primary); font-weight: 600; }
.chip.orange { background: rgba(255, 153, 0, .15); color: var(--orange); border-color: transparent; font-weight: 600; }
.chip.red { background: rgba(239, 92, 92, .15); color: var(--red); border-color: transparent; font-weight: 600; }
.chip.dim { color: var(--text-3); }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 14px 16px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--primary); color: #000; font-weight: 500; font-size: 16px; letter-spacing: -.32px;
  transition: transform .15s ease, filter .15s ease; width: 100%; text-align: center;
}
.btn:hover { color: #000; filter: brightness(1.05); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.secondary { background: var(--tile); color: var(--text); border: 1px solid rgba(255, 255, 255, .1); }
.btn.secondary:hover { color: var(--text); }
.btn.ghost { background: transparent; color: var(--primary); min-height: 44px; padding: 10px; }
.btn.danger { background: transparent; color: var(--red); min-height: 44px; padding: 10px; }
.btn.sm { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; }
.pill-btn { padding: 9px 14px; border-radius: 999px; background: var(--primary); box-shadow: inset 5px 4px 8px 0 var(--primary-shadow);
  color: #000; font-weight: 500; font-size: 14px; border: 0; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; min-height: 40px; }
.pill-btn:hover { color: #000; }
.pill-btn.dark { background: var(--tile); color: var(--text); box-shadow: none; border: 1px solid rgba(255, 255, 255, .1); }
.pill-btn.dark:hover { color: var(--text); }
.spinner { width: 18px; height: 18px; border: 2px solid rgba(0, 0, 0, .25); border-top-color: #000; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.secondary .spinner { border-color: rgba(255, 255, 255, .25); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- segmentado / pestañas ---------- */
.segmented { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 6px; padding: 4px;
  background: var(--row); border: 1px solid rgba(255, 255, 255, .05); border-radius: 999px; }
.segmented button, .segmented a { min-height: 40px; border-radius: 999px; border: 0; background: transparent; color: var(--text-2);
  font-weight: 500; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.segmented .on { background: var(--primary); color: #000; }
.segmented .count { font-size: 11px; padding: 1px 6px; border-radius: 999px; background: rgba(0, 0, 0, .2); }
.segmented :not(.on) .count { background: var(--chip); color: var(--text); }

/* ---------- formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 14px; color: #D4D4D8; }
.input, .select, .textarea {
  width: 100%; min-height: 52px; border-radius: 12px; border: 1px solid var(--input-border); background: #000;
  color: var(--text); padding: 0 14px; font: inherit; font-size: 16px; outline: none;
}
.textarea { padding: 14px; min-height: 96px; resize: vertical; }
.select { appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239AA4B2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 42px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary-soft); }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input[readonly] { background: var(--row); color: var(--text-2); }
.input-group { display: flex; align-items: center; min-height: 52px; border-radius: 12px; border: 1px solid var(--input-border); background: #000; padding: 0 6px 0 14px; }
.input-group:focus-within { border-color: var(--primary-soft); }
.input-group .input { border: 0; background: transparent; padding: 0; min-height: 50px; }
.input-group .prefix { color: var(--text-3); font-weight: 600; font-size: 20px; margin-right: 6px; }
.input.big { font-size: 26px; font-weight: 600; }
.input.code { text-align: center; font-size: 28px; letter-spacing: 10px; font-weight: 600; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex-shrink: 0; accent-color: var(--primary); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--row); cursor: pointer; }
.rules { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-2); }
.rules span { display: flex; gap: 8px; align-items: center; }
.rules i { width: 8px; height: 8px; border-radius: 4px; background: var(--chip); }
.rules .ok i { background: var(--primary); }
.form-error { color: var(--red); font-size: 14px; }
.hint { font-size: 12px; color: var(--text-3); }

.steps { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 6px; }
.steps div { display: flex; flex-direction: column; gap: 6px; font-size: 11px; color: var(--text-3); }
.steps i { height: 4px; border-radius: 2px; background: var(--chip); }
.steps .on { color: var(--text-2); }
.steps .on i { background: var(--primary); }

.pipeline { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
.pipeline i { height: 6px; border-radius: 3px; background: var(--chip); }
.pipeline i.on { background: var(--primary); }
.pipeline-labels { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 11px; color: var(--text-3); }

.timeline { display: flex; flex-direction: column; gap: 10px; }
.timeline div { display: flex; gap: 10px; font-size: 13px; }
.timeline i { width: 8px; height: 8px; border-radius: 4px; background: var(--primary); margin-top: 6px; flex-shrink: 0; }

.qr { padding: 12px; background: #fff; border-radius: 12px; width: 220px; height: 220px; }
.code-text { font-family: ui-monospace, Menlo, monospace; font-size: 20px; font-weight: 600; letter-spacing: 2px; color: var(--primary); }

.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; }
.badge { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11px; text-align: center; color: var(--text-3); }
.badge .ring { width: 52px; height: 52px; border-radius: 26px; border: 1.5px dashed var(--chip); background: var(--row);
  display: flex; align-items: center; justify-content: center; color: var(--text-3); }
.badge.earned { color: var(--text); }
.badge.earned .ring { border: 0; background: var(--primary); color: #000; }
.badge.earned:nth-child(even) .ring { background: var(--orange); }
.pos { width: 36px; height: 36px; border-radius: 18px; background: var(--avatar); color: var(--text-2);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0; }
.pos.first { background: var(--primary); color: #000; }

/* ---------- navegación inferior ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 12px); z-index: 20;
  display: flex; justify-content: center; pointer-events: none; padding: 0 12px;
}
.nav-inner {
  display: flex; gap: 2px; padding: 8px 12px; border-radius: 37px; background: var(--nav); pointer-events: auto;
  border: 1px solid rgba(255, 255, 255, .1); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, .5);
}
.nav a { width: 62px; min-height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-3); font-size: 11.5px; border-radius: 20px; position: relative; }
.nav a.on { color: var(--primary); }
.nav a:hover { color: var(--text); }
.nav a.on:hover { color: var(--primary); }
.nav .dot { position: absolute; top: 2px; right: 14px; width: 8px; height: 8px; border-radius: 4px; background: var(--orange); }

/* ---------- avisos y diálogos ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; top: calc(var(--safe-top) + 10px); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { max-width: 440px; width: 100%; padding: 12px 14px; border-radius: 12px; background: #0d2a08; border: 1px solid var(--primary-soft);
  color: var(--text); font-size: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .5); animation: drop .25s ease; pointer-events: auto; }
.toast.error { background: #2a0d0d; border-color: rgba(239, 92, 92, .5); }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

dialog.sheet {
  border: 1px solid rgba(255, 255, 255, .08); border-radius: 18px; padding: 20px; background: #061404; color: var(--text);
  width: min(440px, calc(100% - 32px)); max-height: calc(100dvh - 48px);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, .7); backdrop-filter: blur(2px); }
.loading { display: flex; justify-content: center; padding: 48px 0; }
.loading .spinner { width: 28px; height: 28px; border-color: rgba(255, 255, 255, .15); border-top-color: var(--primary); }

.install { display: flex; align-items: center; gap: 12px; }
@media (min-width: 520px) {
  .app { padding-left: 24px; padding-right: 24px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
