/* Piezas reutilizables: ventanas, botones, inputs, filas, modales, nav y swipe. */
/* ---- card / "window" ---- */
.win{
  background:var(--cream); border:var(--win-border) solid var(--lav-light);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
}
/* barra de título estilo navegador:
   ○○○  <>  [ barra de direcciones ]  Título ◇▫
   Se arma con pseudo-elementos para que TODAS las ventanas existentes
   la hereden sin tocar su HTML. El orden visual lo da flex `order`. */
.win-bar{
  display:flex; align-items:center; gap:8px;
  padding:9px 13px; background:var(--pink-soft);
  border-bottom:var(--win-border) solid var(--lav-light);
  font-family:var(--font-display); font-weight:800; font-size:14.5px; color:var(--purple);
}
.win-bar::before{  /* semáforo + glifo de código */
  content:"<>"; order:-3; flex:0 0 auto;
  padding-left:47px; font-family:var(--font); font-size:12px; font-weight:800; color:var(--purple);
  background-image:var(--wb-dot),var(--wb-dot),var(--wb-dot);
  background-repeat:no-repeat;
  background-position:1px 50%, 14px 50%, 27px 50%;
  background-size:11px 11px;
}
.win-bar::after{  /* barra de direcciones (decorativa) */
  content:""; order:-1; flex:1 1 auto; min-width:24px; height:23px;
  border-radius:999px; border:2px solid var(--lav-light); background:var(--cream2);
}
:root{ --wb-dot:radial-gradient(circle at center, transparent 0 3px, var(--lav) 3.1px 4.4px, transparent 4.5px); }
/* los "dots" que ya existen en el HTML quedan ocultos: los dibuja ::before */
.win-bar .dots{ display:none; }
.win-bar>span{ order:0; margin-left:auto; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.win-bar>span::after{ content:" ◇▫"; font-size:11px; opacity:.65; }
.win-bar .btn{ order:1; flex:0 0 auto; padding:5px 11px; font-size:12px; }
.win-bar .script{ font-family:var(--font-display); }
.win-body{ padding:14px 16px 16px; }
@media (max-width:400px){ .win-bar::after{ display:none; } .win-bar>span{ margin-left:4px; } }

/* ---- buttons ---- */
.btn{
  font-family:var(--font); font-weight:800; font-size:14px;
  border:2px solid var(--lav-light);
  border-radius:999px; padding:10px 18px; background:var(--cream2); color:var(--ink);
  cursor:pointer; transition:transform .1s ease, box-shadow .1s ease;
  box-shadow:var(--shadow-hard);
}
.btn:active{ transform:translateY(1px); }
.btn-l{ background:var(--purple-dark); color:#fff; border-color:var(--purple-dark); }
.btn-pink{ background:var(--pink); border-color:var(--pink-dark); color:var(--pink-dark); }
.btn-mint{ background:var(--lav); border-color:var(--lav); color:#fff; }
.btn-sm{ padding:7px 14px; font-size:13px; }
.btn:disabled{ opacity:.45; cursor:not-allowed; }

/* ---- inputs ---- */
.inp,select.inp,textarea.inp{
  font-family:var(--font); font-weight:600; width:100%; padding:14px 16px;
  border:2.5px solid var(--lav-light);
  border-radius:16px; background:var(--cream2); font-size:15.5px; color:var(--ink);
}
.inp::placeholder{ color:var(--muted); }
.inp:focus{ outline:none; border-color:var(--lav); }
label.lbl{ font-size:12px; font-weight:800; color:var(--muted); display:block;
  margin:12px 0 5px; letter-spacing:.04em; text-transform:uppercase; }

/* ---- app header ---- */
.app-header{ display:flex; align-items:center; gap:9px; margin:6px 2px 16px; }
.app-header .brand-logo{ flex:0 0 auto; }
.app-header h1{ font-size:21px; margin:0; }
.app-header .header-actions{ margin-left:auto; display:flex; gap:8px; }
.icon-round{ width:40px; height:40px; border-radius:50%; background:var(--cream2);
  border:2.5px solid var(--lav-light); display:flex; align-items:center; justify-content:center;
  font-size:16px; cursor:pointer; color:var(--ink); }
.page-title{ display:flex; align-items:center; gap:9px; margin:6px 2px 16px; }
.page-title h1{ font-size:23px; margin:0; }
.page-title .header-actions{ margin-left:auto; display:flex; gap:8px; }

/* ---- month tabs (pills) ---- */
.tabs{ display:flex; gap:8px; overflow-x:auto; padding:2px 2px 8px; margin-bottom:12px;
  -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.tabs::-webkit-scrollbar{ display:none; }
.tab{ flex:0 0 auto; padding:9px 18px; border-radius:999px; border:2px solid var(--lav-light);
  background:var(--cream2); font-weight:800; font-size:14px; cursor:pointer; white-space:nowrap; color:var(--ink); }
.tab.active{ background:var(--lav); color:#fff; border-color:var(--lav); }
.tab.add{ background:var(--blue-soft); border-color:var(--lav-light); color:var(--purple-dark); }
.subtabs{ display:flex; gap:8px; overflow-x:auto; padding:0 2px 10px; scrollbar-width:none; }
.subtabs::-webkit-scrollbar{ display:none; }

.card{ margin-bottom:16px; }
.card .win-body{ display:flex; flex-direction:column; gap:12px; }

/* ---- progress ---- */
.progress-track{ background:var(--lav-soft); border-radius:99px; height:13px; overflow:hidden; display:flex; }
.progress-track>div{ transition:width .4s ease; }
.progress-fill-pagado{ background:var(--grad); height:100%; }
.progress-fill-pendiente{ background:var(--peach); height:100%; }

/* ---- filter pills ---- */
.filter-row{ display:flex; gap:8px; margin-bottom:6px; flex-wrap:wrap; }
.filter-btn{ font-size:12.5px; padding:6px 15px; border-radius:999px; border:2px solid var(--lav-light);
  background:transparent; cursor:pointer; font-weight:800; color:var(--purple); }
.filter-btn.active{ background:var(--lav); border-color:var(--lav); color:#fff; }

/* ---- list rows ---- */
.item-row{ display:flex; align-items:center; justify-content:space-between; gap:10px;
  background:var(--lav-soft); border-radius:15px; padding:12px 14px; margin-bottom:9px; }
.item-row:last-child{ margin-bottom:0; }
.item-main{ flex:1; min-width:0; }
.item-desc{ font-weight:800; font-size:14.5px; }
.item-desc.pagado{ text-decoration:line-through; opacity:.5; }
.item-meta{ font-size:11px; color:var(--muted); font-weight:700; display:flex; gap:6px; flex-wrap:wrap; margin-top:3px; align-items:center; }
.item-amt{ font-family:var(--font-display); font-weight:800; font-size:15px; white-space:nowrap; }
.item-actions{ display:flex; gap:2px; }
.icon-btn{ border:none; background:none; cursor:pointer; font-size:16px; padding:3px 6px; color:var(--purple); opacity:.75; }
.icon-btn:hover{ opacity:1; }

.pill-cat{ padding:2px 10px; border-radius:999px; font-size:10.5px; font-weight:800; color:#3a3550; }
.pill-usd{ background:var(--yellow); color:#8a6a1a; padding:2px 8px; border-radius:999px; font-size:10px; font-weight:800; }

/* ---- modal / sheet ---- */
.modal-overlay{ position:fixed; inset:0; background:rgba(61,46,102,.42); display:flex;
  align-items:flex-end; justify-content:center; z-index:100; padding:0; }
@media (min-width:560px){ .modal-overlay{ align-items:center; padding:16px; } }
.modal-box{ width:100%; max-width:460px; max-height:92vh; overflow-y:auto;
  border-radius:28px 28px 0 0; box-shadow:0 -16px 48px rgba(61,46,102,.3); }
@media (min-width:560px){ .modal-box{ border-radius:28px; } }
.modal-actions{ display:flex; gap:10px; justify-content:flex-end; margin-top:16px; }
.modal-actions .btn{ flex:1; }
.toggle-row{ display:flex; align-items:center; gap:9px; margin:10px 0; }
.toggle-row label{ font-size:14px; font-weight:700; }
/* Switch estético para los toggles de los modales (reemplaza el checkbox
   nativo sin tocar el HTML/JS: sigue siendo un input[type=checkbox]) */
.switch, .toggle-row input[type=checkbox]{
  appearance:none; -webkit-appearance:none; -moz-appearance:none;
  position:relative; flex:0 0 auto; cursor:pointer; vertical-align:middle;
  width:44px; height:24px; border-radius:999px;
  background:var(--lav-soft); border:2px solid var(--lav-light);
  transition:background .2s ease, border-color .2s ease;
}
.switch::after, .toggle-row input[type=checkbox]::after{
  content:''; position:absolute; top:1px; left:1px;
  width:18px; height:18px; border-radius:50%;
  background:#fff; box-shadow:0 1px 2px rgba(61,46,102,.3);
  transition:left .2s ease;
}
.switch:checked, .toggle-row input[type=checkbox]:checked{ background:var(--lav); border-color:var(--lav); }
.switch:checked::after, .toggle-row input[type=checkbox]:checked::after{ left:21px; }

.empty-state{ text-align:center; padding:26px 12px; color:var(--muted); font-size:13.5px; font-weight:700; }

/* ---- bottom nav ---- */
.bottom-nav{ position:fixed; left:0; right:0; bottom:0; z-index:60;
  background:var(--nav-bg); border-top:var(--win-border) solid var(--nav-border);
  display:flex; justify-content:space-between; align-items:center;
  padding:12px 26px calc(14px + env(safe-area-inset-bottom,0)); max-width:460px; margin:0 auto; }
.bottom-nav .nav-item{ display:flex; flex-direction:column; align-items:center; gap:3px;
  cursor:pointer; opacity:.45; color:var(--ink); border:none; background:none; font-family:var(--font); }
.bottom-nav .nav-item.active{ opacity:1; color:var(--purple-dark); }
.bottom-nav .nav-item .ni-ic{ font-size:20px; line-height:1; }
.bottom-nav .nav-item .ni-lbl{ font-size:10.5px; font-weight:800; }
.bottom-nav .nav-fab{ width:58px; height:58px; border-radius:50%; background:var(--fab); color:var(--fab-ink);
  display:flex; align-items:center; justify-content:center; font-size:30px; font-weight:800;
  margin-top:-38px; border:4px solid var(--nav-bg); box-shadow:0 8px 20px rgba(61,46,102,.3); cursor:pointer; }

/* ---- login / splash ---- */
#loginScreen{ min-height:100vh; display:flex; align-items:center; justify-content:center; padding:22px; }
.login-box{ width:100%; max-width:360px; }
.login-art{ text-align:center; margin-bottom:16px; }
.brand-lockup{ display:flex; align-items:center; justify-content:center; gap:10px; margin-bottom:6px; }
.brand-name{ font-family:var(--font-display); font-weight:800; font-size:30px; color:var(--ink); }

#loadingScreen{ min-height:100vh; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:14px; }
.spark-spin{ animation:sparkspin 2.4s ease-in-out infinite; }
@keyframes sparkspin{ 0%,100%{ transform:rotate(0) scale(1); } 50%{ transform:rotate(180deg) scale(1.15); } }

/* ---- swipe (mobile actions) ---- */
.swipe-wrap{ position:relative; overflow:hidden; border-radius:15px; margin-bottom:9px; }
.swipe-wrap:last-child{ margin-bottom:0; }
.swipe-tray{ position:absolute; top:0; right:0; height:100%; display:flex;
  /* el lado derecho acompaña el redondeo del wrap y lo recorta: si el botón
     de Borrar llega a la esquina, se asoma por el antialias del redondeo */
  border-top-right-radius:inherit; border-bottom-right-radius:inherit; overflow:hidden; }
.swipe-tray button{ border:none; color:#fff; font-weight:800; font-size:10px; width:60px;
  display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; cursor:pointer; }
.swipe-tray .sw-mover{ background:var(--lav); }
.swipe-tray .sw-dup{ background:var(--blue-soft); color:var(--purple-dark); }
.swipe-tray .sw-edit{ background:var(--mint-dark); }
.swipe-tray .sw-del{ background:var(--red-dark); }
.swipe-tray .ic{ font-size:17px; }
/* cerrado redondea igual que el wrap (si no, por las esquinas se asoma la
   bandeja); abierto o arrastrando endereza el lado derecho para quedar
   pegado a la bandeja, sin muesca redondeada en el medio */
.swipe-fg{ position:relative; background:var(--lav-soft); border-radius:inherit; z-index:1;
  transition:transform .18s ease; will-change:transform; }
.swipe-fg[data-open="1"]{ border-top-right-radius:0; border-bottom-right-radius:0; }
.swipe-inner{ display:flex; align-items:center; gap:10px; padding:12px 14px; }
.swipe-inner.pagado-op{ opacity:.55; }
.swipe-inner input[type=checkbox]{ width:20px; height:20px; accent-color:var(--mint-dark); flex:0 0 auto; }
/* En desktop la bandeja la abre bindSwipe() con el mouse, y sólo desde la
   mitad derecha de la fila: así se puede llegar al checkbox sin que se corra. */

table{ width:100%; border-collapse:collapse; }
th,td{ padding:6px 4px; }
thead th{ color:var(--muted); font-weight:800; font-size:11px; }
