/* Gastos WR — WR Smart Systems Solutions */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --surface-3: #eef0f8;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e5e7f0;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef0ff;
  --primary-text: #4338ca;
  --pos: #059669;
  --pos-soft: #e7f8f1;
  --neg: #e11d48;
  --neg-soft: #fdecf0;
  --warn: #d97706;
  --warn-soft: #fff5e1;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 24px -8px rgba(15, 23, 42, .10);
  --shadow-lg: 0 24px 60px -20px rgba(30, 27, 75, .35);
  --radius: 18px;
  --radius-sm: 12px;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0a0c16;
  --surface: #131627;
  --surface-2: #181c30;
  --surface-3: #20253d;
  --text: #e8eaf6;
  --text-2: #c3c7dc;
  --muted: #8a90ad;
  --border: #252a44;
  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-soft: #1f2245;
  --primary-text: #a5b4fc;
  --pos: #34d399;
  --pos-soft: #0f2a24;
  --neg: #fb7185;
  --neg-soft: #2e1420;
  --warn: #fbbf24;
  --warn-soft: #2d2412;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -12px rgba(0, 0, 0, .6);
  --shadow-lg: 0 30px 70px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-feature-settings: "cv11", "ss01";
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-text); text-decoration: none; }
.num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.bold { font-weight: 650; }
.hidden { display: none !important; }

/* ---------- Boot ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 14px; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 22px; letter-spacing: -.04em;
  box-shadow: 0 8px 24px -8px rgba(79, 70, 229, .6);
}
.boot .logo-mark { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.92); opacity: .7; } }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(124, 58, 237, .18), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, rgba(79, 70, 229, .18), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px;
  padding: 32px 28px; box-shadow: var(--shadow-lg); border: 1px solid var(--border);
}
.login-card h1 { font-size: 24px; margin: 18px 0 4px; letter-spacing: -.02em; }
.login-card form { margin-top: 22px; display: grid; gap: 14px; }
.login-foot { text-align: center; margin-top: 18px; font-size: 12px; color: var(--muted); }

/* ---------- Shell ---------- */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { padding: calc(12px + var(--safe-t)) 16px calc(96px + var(--safe-b)); max-width: 1180px; margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.topbar h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; letter-spacing: -.02em; font-size: 17px; }
.brand .logo-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px);
  border-top: 1px solid var(--border); padding: 6px 6px calc(6px + var(--safe-b));
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0;
  color: var(--muted); font-size: 11px; font-weight: 550; border-radius: 12px;
}
.bottom-nav a svg { width: 23px; height: 23px; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active .nav-ico { background: var(--primary-soft); }
.nav-ico { padding: 3px 14px; border-radius: 999px; display: grid; place-items: center; transition: background .2s; }

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--safe-b)); z-index: 41;
  width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--grad); color: #fff;
  box-shadow: 0 14px 30px -10px rgba(79, 70, 229, .75); display: grid; place-items: center; cursor: pointer;
  transition: transform .15s ease;
}
.fab:active { transform: scale(.94); }
.fab svg { width: 28px; height: 28px; }

@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 252px 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh;
    padding: 22px 14px; border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidebar .brand { padding: 0 10px 18px; }
  .sidebar a.nav {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--text-2); font-weight: 550;
  }
  .sidebar a.nav svg { width: 20px; height: 20px; color: var(--muted); }
  .sidebar a.nav:hover { background: var(--surface-2); }
  .sidebar a.nav.active { background: var(--primary-soft); color: var(--primary-text); }
  .sidebar a.nav.active svg { color: var(--primary); }
  .sidebar .side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
  .sidebar .nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 12px 6px; font-weight: 650; }
  .bottom-nav { display: none; }
  .main { padding: 28px 36px 48px; }
  .fab { bottom: 32px; right: 36px; }
  .topbar .brand { display: none; }
}

/* ---------- Month switcher ---------- */
.month-switch {
  display: inline-flex; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; box-shadow: var(--shadow-sm); padding: 3px;
}
.month-switch button { border: 0; background: none; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.month-switch button:hover { background: var(--surface-3); color: var(--text); }
.month-switch span { font-weight: 600; font-size: 14px; min-width: 112px; text-align: center; text-transform: capitalize; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1100px) { .dash-grid { grid-template-columns: 1.55fr 1fr; align-items: start; } }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px;
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-h h3 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.card.flush { padding: 6px 0; }
.card.flush .card-h { padding: 12px 18px 4px; }

.hero {
  background: var(--grad); color: #fff; border: 0; position: relative; overflow: hidden;
  box-shadow: 0 24px 50px -24px rgba(79, 70, 229, .8);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -80px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .22), transparent 70%);
}
.hero .label { opacity: .82; font-size: 13px; font-weight: 550; }
.hero .big { font-size: 34px; font-weight: 750; letter-spacing: -.03em; margin: 4px 0 2px; }
.hero .chip { background: rgba(255, 255, 255, .18); color: #fff; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; position: relative; z-index: 1; }
.hero-stats > div { background: rgba(255, 255, 255, .12); border-radius: 14px; padding: 10px 12px; }
.hero-stats .k { font-size: 11.5px; opacity: .8; }
.hero-stats .v { font-weight: 700; font-size: 15px; margin-top: 2px; }

.stat { display: flex; flex-direction: column; gap: 4px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.stat .v { font-size: 21px; font-weight: 720; letter-spacing: -.02em; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px; cursor: pointer; position: relative;
  transition: background .12s;
}
.row:hover { background: var(--surface-2); }
.row + .row::before { content: ""; position: absolute; top: 0; left: 70px; right: 18px; border-top: 1px solid var(--border); }
.row .ico {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 19px; flex: none;
}
.row .body { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 680; text-align: right; white-space: nowrap; }
.row .amt .s { text-align: right; font-weight: 500; }
.day-h { padding: 14px 18px 4px; font-size: 12px; font-weight: 650; color: var(--muted); display: flex; justify-content: space-between; }

.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .e-ico { font-size: 36px; margin-bottom: 6px; }
.empty p { margin: 4px 0 14px; }

/* ---------- Chips / badges ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.chip.pos { background: var(--pos-soft); color: var(--pos); }
.chip.neg { background: var(--neg-soft); color: var(--neg); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pri { background: var(--primary-soft); color: var(--primary-text); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  font-weight: 700; font-size: 13px; flex: none; letter-spacing: -.02em;
}
.avatar.sm { width: 26px; height: 26px; font-size: 11px; }
.avatar.lg { width: 44px; height: 44px; font-size: 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent;
  padding: 10px 16px; border-radius: 12px; font-weight: 620; cursor: pointer; background: var(--surface-3);
  color: var(--text); transition: transform .1s, background .15s, box-shadow .15s; white-space: nowrap; font-size: 14.5px;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px -10px rgba(79, 70, 229, .8); }
.btn.ghost { background: transparent; border-color: var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--neg-soft); color: var(--neg); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; pointer-events: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  display: grid; place-items: center; cursor: pointer; color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 19px; height: 19px; }
.link-btn { background: none; border: 0; color: var(--primary-text); font-weight: 600; cursor: pointer; padding: 4px; font-size: 13.5px; }

/* ---------- Segmented tabs ---------- */
.seg {
  display: flex; background: var(--surface-3); border-radius: 14px; padding: 4px; gap: 2px; margin-bottom: 14px;
  overflow-x: auto; scrollbar-width: none;
}
.seg::-webkit-scrollbar { display: none; }
.seg button {
  flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: 10px; font-weight: 600;
  color: var(--muted); cursor: pointer; white-space: nowrap; font-size: 14px;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 1px 3px rgba(0, 0, 0, .08); }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field > label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); outline: none; transition: border .15s, box-shadow .15s; font-size: 15px;
  appearance: none; -webkit-appearance: none;
}
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 18%, transparent); background: var(--surface); }
.form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount-input { position: relative; }
.amount-input span { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); font-weight: 700; color: var(--muted); font-size: 22px; }
.amount-input input { font-size: 30px; font-weight: 750; padding: 14px 16px 14px 44px; letter-spacing: -.02em; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 550; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.hint { font-size: 12.5px; color: var(--muted); }
.err { color: var(--neg); font-size: 13px; font-weight: 550; min-height: 0; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; max-height: 230px; overflow-y: auto; padding: 2px; }
.cat-pick {
  border: 1.5px solid var(--border); background: var(--surface-2); border-radius: 14px; padding: 9px 4px 7px;
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-size: 11.5px; font-weight: 600;
  color: var(--text-2); text-align: center; line-height: 1.15; transition: all .12s;
}
.cat-pick .e { font-size: 21px; }
.cat-pick.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }

.people-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.person-chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px 5px 5px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface-2); cursor: pointer; font-weight: 600; font-size: 13.5px;
}
.person-chip.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }

.file-drop {
  border: 1.5px dashed var(--border); border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px;
  cursor: pointer; background: var(--surface-2); color: var(--muted); font-size: 13.5px;
}
.file-drop img { width: 46px; height: 46px; object-fit: cover; border-radius: 10px; }
.file-drop .fd-ico { width: 46px; height: 46px; border-radius: 10px; background: var(--surface-3); display: grid; place-items: center; font-size: 20px; }

/* ---------- Progress ---------- */
.bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: var(--primary); transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.bar.over > i { background: var(--neg); }
.bar.near > i { background: var(--warn); }
.budget-row { padding: 10px 18px; display: grid; gap: 7px; }
.budget-row .top { display: flex; align-items: center; gap: 10px; }

/* ---------- Reminders ---------- */
.reminder {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--warn-soft); margin-bottom: 8px;
}
.reminder.vencido { background: var(--neg-soft); }
.reminder .t { font-weight: 650; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.sm { height: 200px; }
.donut-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; }
.donut-wrap .chart-box { height: 150px; }
.legend { display: grid; gap: 7px; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 420px) { .donut-wrap { grid-template-columns: 1fr; } .donut-wrap .chart-box { height: 170px; } }

/* ---------- Modal ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(10, 12, 25, .45); z-index: 100; display: flex; align-items: flex-end;
  justify-content: center; animation: fade .18s ease; backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 24px 24px 0 0; padding: 8px 20px calc(20px + var(--safe-b)); box-shadow: var(--shadow-lg);
  animation: up .26s cubic-bezier(.2, .8, .2, 1);
}
.modal .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 10px; }
.modal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }
.modal-h h3 { margin: 0; font-size: 19px; letter-spacing: -.02em; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { border-radius: 24px; padding: 20px 24px 24px; }
  .modal .grab { display: none; }
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; top: calc(14px + var(--safe-t)); transform: translateX(-50%); z-index: 200; display: grid; gap: 8px; }
.toast {
  background: #111827; color: #fff; padding: 11px 16px; border-radius: 14px; font-weight: 550; font-size: 14px;
  box-shadow: var(--shadow-lg); animation: up .25s ease; max-width: 90vw;
}
.toast.err { background: var(--neg); }

/* ---------- Misc ---------- */
.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 2px 10px; }
.section-title h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-s { gap: 6px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.group-card { cursor: pointer; transition: transform .15s, box-shadow .15s; }
.group-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.g-ico { width: 48px; height: 48px; border-radius: 15px; background: var(--primary-soft); display: grid; place-items: center; font-size: 24px; flex: none; }
.invite-box { display: flex; gap: 8px; align-items: center; background: var(--surface-2); border: 1px dashed var(--border); padding: 8px 8px 8px 12px; border-radius: 12px; }
.invite-box code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--muted); }
.menu-list .row .ico { background: var(--surface-3); }
.debt { display: flex; align-items: center; gap: 10px; padding: 12px 18px; }
.debt .arrow { color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.skeleton { background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; }
@keyframes sk { to { background-position: -200% 0; } }
.view-enter { animation: viewin .28s cubic-bezier(.2, .8, .2, 1); }
@keyframes viewin { from { opacity: 0; transform: translateY(6px); } }
.preview-img { max-width: 100%; border-radius: 14px; display: block; margin: 0 auto; }
.table-like .row { cursor: default; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Ajustes de ancho en móvil ---------- */
.grid > *, .grid-2 > *, .kpis > *, .hero-stats > div { min-width: 0; }
.hero-stats .v { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { overflow-x: clip; }
@media (max-width: 480px) {
  .hero .big { font-size: 30px; }
  .hero-stats { gap: 6px; }
  .hero-stats > div { padding: 8px 9px; }
  .hero-stats .v { font-size: 14px; }
  .month-switch span { min-width: 92px; font-size: 13px; }
  .month-switch button { width: 28px; height: 28px; }
  .topbar h2 { font-size: 19px; }
  .card { padding: 16px; }
}

.topbar .brand { display: none; }
.debt-who { flex: 1; min-width: 0; display: grid; gap: 4px; }
