@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/vendor/fonts/plus-jakarta-sans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('/vendor/fonts/plus-jakarta-sans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #F4F6F8;
  --card: #FFFFFF;
  --ink: #101828;
  --ink-2: #344054;
  --muted: #5B6474;
  --faint: #98A2B3;
  --line: #E6E9EE;
  --line-2: #F1F3F6;
  --field: #F4F6F8;
  --dark: #0D3D30;
  --dark-2: #1F5A48;
  --mint: #7EE2B8;
  --mint-2: #A7E8C9;
  --mint-3: #CFE9DD;
  --green: #0B7F59;
  --green-bg: #E7F6EF;
  --amber: #F59E0B;
  --amber-ink: #B45309;
  --amber-bg: #FEF3E2;
  --red: #E5484D;
  --red-ink: #B91C1C;
  --red-bg: #FDECEC;
  --indigo-bg: #EEF2FF;
  --indigo-ink: #312E81;
  --shadow: 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 20px;
  --radius-lg: 28px;
  --tabbar-h: 84px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
/* Siempre al 100 % del ancho: sin zoom (pellizco ni doble toque) ni desplazamiento lateral. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; touch-action: pan-x pan-y; overflow-x: hidden; width: 100%; }
body { overflow-x: hidden; width: 100%; max-width: 100vw; }
a, button, input, select, textarea, label { touch-action: manipulation; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid #2F6FDB; outline-offset: 2px; border-radius: 8px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--card); padding: 8px 12px; border-radius: 10px; z-index: 100; }
.skip:focus { left: 8px; }
.boot, .loading-center { min-height: 60vh; display: flex; align-items: center; justify-content: center; }
/* Indicador de carga: el tramo del anillo del logotipo gira sobre el centro del círculo. */
.spinner { display: inline-flex; }
.spinner-arc { transform-box: view-box; transform-origin: 16px 16px; animation: spin .9s cubic-bezier(.45, .05, .55, .95) infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner-arc { animation: pulse 1.6s ease-in-out infinite !important; }
}
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- Estructura ---------- */
.shell { min-height: 100vh; min-height: 100dvh; }
.view { outline: none; padding-bottom: calc(var(--tabbar-h) + var(--safe-b)); }
body.no-chrome .view { padding-bottom: 0; }
.sidebar { display: none; }
.page { max-width: 560px; margin: 0 auto; padding: calc(20px + var(--safe-t)) 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.page.wide { max-width: 1180px; }
.page-full { min-height: 100vh; min-height: 100dvh; padding-bottom: calc(24px + var(--safe-b)); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-around;
  padding: 8px 10px calc(10px + var(--safe-b));
  background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
body.no-chrome .tabbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 62px; min-height: 52px; padding: 4px 8px; border-radius: 16px; justify-content: center; font-size: 11px; font-weight: 600; color: var(--muted); transition: background .15s; }
/* Opción seleccionada: sombreado verde pastel. */
.tab.active { color: var(--dark); font-weight: 700; background: var(--green-bg); }
.tab-add {
  display: flex; align-items: center; justify-content: center;
  width: 62px; height: 62px; margin-top: -22px; border-radius: 50%;
  background: var(--dark); box-shadow: 0 6px 16px rgba(13, 61, 48, .35);
  transition: transform .15s;
}
.tab-add:active { transform: scale(.94); }

/* ---------- Cabeceras ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.hello { font-size: 13px; color: var(--muted); }
.title { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.title-sm { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.subtitle { font-size: 13px; color: var(--muted); }
.h2 { margin: 6px 0 0 4px; font-size: 15px; font-weight: 700; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
.icon-btn.dark { background: var(--dark); color: #fff; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.icon-btn.bell { position: relative; }
.icon-btn .badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px var(--bg, #F4F6F8); }
/* El enlace mide exactamente lo que la foto: sin el hueco que deja una línea de texto por debajo. */
.avatar-link { display: inline-flex; flex: none; line-height: 0; border-radius: 50%; }
.avatar-link .avatar { box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(16, 24, 40, .18); }

/* ---------- Tarjetas ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-lg { border-radius: var(--radius-lg); }
.card.flush { padding: 4px 16px; }
.hero { background: var(--dark); color: #fff; border-radius: var(--radius-lg); padding: 18px 20px; }
.hero .label { font-size: 13px; color: var(--mint-2); font-weight: 600; }
.hero .sub { font-size: 13px; color: var(--mint-3); }
.big { font-size: 52px; font-weight: 800; letter-spacing: -.04em; line-height: 1; }
.mid { font-size: 36px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-link { display: flex; align-items: center; gap: 12px; min-height: 60px; border-bottom: 1px solid var(--line-2); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; padding: 0; text-align: left; }
.row-link:last-child { border-bottom: 0; }
.grow { flex: 1; min-width: 0; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.amount { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--green); }
.neg { color: var(--red-ink); }
.warn { color: var(--amber-ink); }
.chip-icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
}
.date-chip { flex: none; width: 44px; text-align: center; border-radius: 12px; background: var(--indigo-bg); padding: 4px 0; color: var(--indigo-ink); }
.date-chip b { display: block; font-size: 17px; line-height: 1.1; }
.date-chip span { display: block; font-size: 10px; font-weight: 700; }

/* Barras y anillos */
.bar { position: relative; height: 8px; border-radius: 4px; background: var(--line-2); }
.bar > i { display: block; height: 100%; border-radius: inherit; }
.bar .marker { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--ink); }
.hero .bar { background: var(--dark-2); height: 12px; border-radius: 6px; }
.hero .bar .marker { background: #fff; width: 3px; top: -5px; bottom: -5px; }
/* Cuando falta dinero: recuadro en rojo claro y textos en rojo oscuro. */
.hero.danger { background: var(--red-bg); color: #7F1D1D; box-shadow: inset 0 0 0 1px #F5C2C2; }
.hero.danger .label { color: var(--red-ink); }
.hero.danger .sub { color: #8F2A2A; }
.hero.danger .bar { background: #F6CFCF; }
.hero.danger .bar .marker { background: #7F1D1D; }
.ring-wrap { position: relative; display: inline-block; vertical-align: middle; flex: none; }
.ring-wrap > svg { display: block; }
.ring-wrap > .ring-center { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; }

/* Gráfico de barras de 14 días */
.daybars { position: relative; display: flex; align-items: flex-end; gap: 5px; height: 52px; margin-top: 14px; }
.daybars i { flex: 1; border-radius: 4px 4px 2px 2px; background: var(--mint); min-height: 3px; }
.daybars i.over { background: #FF9F8A; }
.daybars i.zero { background: rgba(126, 226, 184, .25); }
.daybars .limit { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--mint-2); opacity: .6; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11px; color: var(--ink-2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 52px; padding: 0 20px; border: 0; border-radius: 18px;
  font-size: 16px; font-weight: 800; background: var(--card); color: var(--ink);
}
.btn.primary { background: var(--dark); color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); font-weight: 600; }
.btn.soft { background: var(--field); font-weight: 700; }
.btn.danger { background: var(--red); color: #fff; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 14px; font-size: 14px; border-radius: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--green); font-weight: 700; font-size: 14px; min-height: 44px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 99px; border: 1px solid #E4E7EC; background: var(--card); font-size: 14px; font-weight: 600;
}
.pill[aria-pressed="true"], .pill.on { border: 2px solid var(--green); background: var(--green-bg); }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px #fff; }
/* Cuenta en riesgo de números rojos: rayas diagonales en rojo pastel; elegida, rojo entero. */
.pill.risk { border-color: #F3B4B4; background: repeating-linear-gradient(135deg, #FDECEC 0 7px, #F9D3D3 7px 14px); color: #7F1D1D; }
.pill.risk.on, .pill.risk[aria-pressed="true"] { border: 2px solid #B42318; background: #C8302A; color: #fff; }
.seg { display: flex; background: #E9ECF0; border-radius: 99px; padding: 3px; }
.seg button { flex: 1; min-height: 38px; padding: 0 14px; white-space: nowrap; border: 0; border-radius: 99px; background: transparent; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 2px rgba(16, 24, 40, .1); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .pill { flex: none; }

/* ---------- Formularios ---------- */
.field { display: block; background: var(--card); border-radius: 16px; padding: 10px 16px; box-shadow: var(--shadow); }
.field.plain { background: var(--field); box-shadow: none; }
.field > span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  width: 100%; border: 0; background: transparent; padding: 2px 0 0; font-size: 16px; outline: none; min-height: 28px;
}
.field select { appearance: none; -webkit-appearance: none; }
.form-error { background: var(--red-bg); color: var(--red-ink); border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }
.amount-input { text-align: center; padding: 10px 0 2px; }
.amount-input .value { font-size: 60px; font-weight: 800; letter-spacing: -.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.amount-input .value .cur { color: var(--faint); }
.amount-input .meta { font-size: 14px; color: var(--muted); margin-top: 8px; }
.keypad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.keypad button { min-height: 54px; border: 0; border-radius: 16px; background: var(--card); font-size: 24px; font-weight: 700; box-shadow: 0 1px 2px rgba(16, 24, 40, .06); }
.keypad button:active { background: var(--line-2); }
.picker-btn {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 12px; width: 100%;
  border: 0; border-radius: 16px; background: var(--card); text-align: left; box-shadow: var(--shadow);
}
.picker-btn .lbl { display: block; font-size: 11px; color: var(--muted); }
.picker-btn .val { display: block; font-size: 14px; font-weight: 700; }

/* Lista de opciones a pantalla completa (elegir categoría, cuenta...) */
.sheet-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(16, 24, 40, .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 85vh; overflow-y: auto; background: var(--card);
  border-radius: 28px 28px 0 0; padding: 10px 20px calc(24px + var(--safe-b));
}
.sheet .handle { width: 40px; height: 5px; border-radius: 3px; background: #D0D5DD; margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 8px; font-size: 20px; font-weight: 800; }
.option { display: flex; align-items: center; gap: 12px; min-height: 56px; width: 100%; padding: 6px 8px; border: 0; border-radius: 14px; background: transparent; text-align: left; font-size: 15px; font-weight: 600; }
.option[aria-selected="true"] { background: var(--green-bg); }
.option:hover { background: var(--line-2); }

/* Menú de añadir */
.add-option { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 20px; }
.add-option.featured { background: var(--dark); color: #fff; }
.add-option .t { display: block; font-size: 16px; font-weight: 700; }
.add-option .s { display: block; font-size: 13px; color: var(--muted); }
.add-option.featured .s { color: var(--mint-3); }
.chip-icon.logo { background: #fff; box-shadow: inset 0 0 0 1px var(--line-2); padding: 4px; overflow: hidden; }
.chip-icon.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.add-option .chip-icon { width: 48px; height: 48px; border-radius: 14px; }

/* Avisos */
.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); z-index: 60;
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 14px;
  max-width: calc(100% - 32px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red-ink); }
.update-banner {
  position: fixed; left: 12px; right: 12px; top: calc(12px + var(--safe-t)); z-index: 80; max-width: 536px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 10px 10px 16px; border-radius: 16px;
  background: var(--dark); color: #fff; font-size: 14px; font-weight: 600; box-shadow: 0 8px 24px rgba(16, 24, 40, .25);
}
.update-banner .btn { background: var(--mint); color: var(--dark); min-height: 36px; }
.dialog-backdrop { position: fixed; inset: 0; z-index: 70; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; padding: 20px; }
.dialog { background: var(--card); border-radius: 24px; padding: 22px; max-width: 400px; width: 100%; }
.dialog h2 { margin: 0 0 6px; font-size: 19px; }
.dialog p { margin: 0 0 18px; color: var(--muted); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.notice { display: flex; gap: 12px; align-items: center; border-radius: 20px; padding: 14px 16px; font-size: 14px; line-height: 1.4; }
.notice.amber { background: var(--amber-bg); color: #78350F; }
.notice.green { background: var(--green-bg); color: #065F46; }
.notice.indigo { background: var(--indigo-bg); color: var(--indigo-ink); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); display: flex; flex-direction: column; gap: 14px; align-items: center; }
.skeleton { background: linear-gradient(90deg, #eceff3 0%, #f6f7f9 50%, #eceff3 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 20px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Inicio de sesión */
.login { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; background: var(--dark); color: #fff; }
.login-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 16px; padding: calc(40px + var(--safe-t)) 28px 20px; text-align: center; }
.login-hero h1 { margin: 0; font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.login-hero p { margin: 0; color: var(--mint-3); font-size: 16px; }
.login-form { background: var(--card); color: var(--ink); border-radius: 32px 32px 0 0; padding: 28px 24px calc(30px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 560px; margin: 0 auto; }
.otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.otp input { width: 100%; height: 60px; text-align: center; border-radius: 16px; border: 1px solid #E4E7EC; background: var(--card); font-size: 26px; font-weight: 800; }
.otp input:focus { border: 2px solid var(--green); outline: none; }

/* Ticket */
.receipt-thumb { flex: none; width: 74px; height: 98px; border-radius: 10px; background: #F8F9FB; border: 1px solid #E4E7EC; object-fit: cover; }
.progress { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--green); transition: width .2s; }

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

/* Móvil en horizontal: aviso para girarlo. El iPad (más alto) y el ordenador no se ven afectados. */
.rotate-notice { display: none; }
@media (orientation: landscape) and (max-height: 520px) and (pointer: coarse) {
  .rotate-notice {
    display: flex; position: fixed; inset: 0; z-index: 1000; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; padding: 24px; text-align: center; background: var(--dark); color: #fff;
  }
  .rotate-notice strong { font-size: 22px; font-weight: 800; }
  .rotate-notice span { color: var(--mint-3); font-size: 15px; }
  body:has(.rotate-notice) { overflow: hidden; }
}

/* ---------- Escritorio e iPad ---------- */
@media (min-width: 900px) {
  body:not(.public) .shell { display: flex; }
  body:not(.public) .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    width: 250px; flex: none; padding: 28px 16px; background: var(--card); border-right: 1px solid var(--line);
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 10px 22px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
  .side-add { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 16px; margin-bottom: 14px; border-radius: 16px; background: var(--dark); color: #fff; font-weight: 800; }
  .side-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: 12px; color: var(--ink-2); font-size: 14px; font-weight: 600; }
  .side-link.active { background: var(--green-bg); color: var(--dark); font-weight: 700; }
  .side-link:not(.active):hover { background: var(--line-2); }
  .view { flex: 1; min-width: 0; padding-bottom: 0 !important; }
  .tabbar { display: none; }
  .page { padding-top: 32px; }
  .home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 28px; max-height: 80vh; }
  .hide-desktop { display: none !important; }
}
@media (max-width: 899px) {
  .hide-mobile { display: none !important; }
}
summary[data-why]::-webkit-details-marker { display: none; }
