/* Cuentas Claras — Diseño financiero moderno con familiaridad Splitwise:
   barra superior verde, acción principal naranja, verde "te deben", naranja "debes". */

:root {
  /* Marca y acciones (contraste AA >= 4.5:1 con texto blanco) */
  --brand: #118268;
  --brand-hover: #0d6e58;
  --brand-bar-top: #139073;
  --brand-bar-bot: #0f7a61;
  --brand-soft: #e6f5f0;
  --brand-soft-strong: #cdece2;

  --cta: #d14719;
  --cta-hover: #b83b12;
  --cta-soft: #fff0ea;

  /* Semánticos de saldo (AA >= 4.5:1 sobre --surface y --surface-2) */
  --pos: #0d7a5f;
  --pos-soft: #e6f5f0;
  --neg: #c43f14;
  --neg-soft: #fff0ea;

  /* Superficies y texto */
  --bg: #f2f6f4;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --surface-3: #eaf1ee;
  --text: #16221f;
  --text-soft: #43544f;
  --text-muted: #5d6e69;
  --border: #e4ece9;
  --border-strong: #cdd9d5;

  /* Aliases de compatibilidad */
  --teal: var(--brand);
  --teal-dark: var(--brand-hover);
  --orange: var(--cta);
  --orange-dark: var(--cta-hover);
  --accent: var(--brand);
  --muted: var(--text-muted);
  --soft: var(--text-soft);
  --line: var(--border);
  --line-strong: var(--border-strong);

  /* Tipografía */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Escala de espaciado */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;

  /* Radios */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(15, 32, 27, .05);
  --shadow-sm: 0 2px 8px rgba(15, 32, 27, .06);
  --shadow-md: 0 8px 24px rgba(15, 32, 27, .12);
  --shadow-lg: 0 20px 52px rgba(10, 24, 20, .24);

  /* Foco y transiciones */
  --ring: 0 0 0 3px rgba(17, 130, 104, .28);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --dur: 160ms;

  --top-h: 54px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #179477;
    --brand-hover: #1cad8b;
    --brand-bar-top: #126b56;
    --brand-bar-bot: #0e5847;
    --brand-soft: rgba(74, 222, 178, .13);
    --brand-soft-strong: rgba(74, 222, 178, .22);

    --cta: #cf4618;
    --cta-hover: #e25626;
    --cta-soft: rgba(255, 140, 100, .14);

    --pos: #4adeb2;
    --pos-soft: rgba(74, 222, 178, .13);
    --neg: #ff8c64;
    --neg-soft: rgba(255, 140, 100, .14);

    --bg: #0c1211;
    --surface: #141d1b;
    --surface-2: #1b2724;
    --surface-3: #24332f;
    --text: #edf4f1;
    --text-soft: #b6c5c0;
    --text-muted: #8a9d97;
    --border: #23312d;
    --border-strong: #32443f;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, .24);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, .28);
    --shadow-md: 0 10px 28px rgba(0, 0, 0, .42);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .58);
    --ring: 0 0 0 3px rgba(74, 222, 178, .32);

    color-scheme: dark;
  }
}

/* ---------- reset y tipografía base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; overflow-x: clip; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; font-weight: 700; line-height: 1.22; letter-spacing: -.015em; }
h2 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); font-weight: 700; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
code {
  background: var(--surface-3);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.muted { color: var(--text-muted); }
.soft { color: var(--text-soft); }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { font-variant-numeric: tabular-nums; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- barra superior ---------- */
#top {
  background: linear-gradient(180deg, var(--brand-bar-top) 0%, var(--brand-bar-bot) 100%);
  color: #fff;
  box-shadow: 0 1px 0 rgba(0, 0, 0, .08), 0 2px 10px rgba(10, 40, 32, .14);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-in {
  max-width: 1200px;
  margin: 0 auto;
  height: var(--top-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--s-4);
  gap: var(--s-3);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -.015em;
  border-radius: var(--r-sm);
  padding: 4px 6px 4px 2px;
}
.brand:focus-visible, .user:focus-visible { outline-color: #fff; }
.logo {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #fff;
  color: var(--brand);
  font-weight: 900;
  font-size: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .14);
  flex: none;
}
.logo.big {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  font-size: 32px;
  background: linear-gradient(145deg, var(--brand-bar-top), var(--brand-bar-bot));
  color: #fff;
  box-shadow: 0 8px 20px rgba(17, 130, 104, .28);
}
.user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 10px 4px 5px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .14);
  transition: background var(--dur) var(--ease);
  min-width: 0;
}
.user:hover { background: rgba(255, 255, 255, .24); }
.user span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px; }

/* ---------- estructura de 3 columnas (escritorio) ---------- */
#cols {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr) 268px;
  gap: var(--s-5);
  padding: var(--s-5) var(--s-4) var(--s-8);
  align-items: start;
  min-height: calc(100dvh - var(--top-h));
}

#side {
  position: sticky;
  top: calc(var(--top-h) + var(--s-5));
  max-height: calc(100dvh - var(--top-h) - 40px);
  overflow-y: auto;
  padding: 2px 2px var(--s-5);
  font-size: 14px;
}
#side a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--text-soft);
  border-radius: var(--r-sm);
  min-width: 0;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
#side a span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
#side a:hover { background: var(--surface-3); color: var(--text); }
#side a.active {
  background: var(--brand-soft);
  color: var(--pos);
  font-weight: 700;
}
#side a.main { font-size: 14.5px; font-weight: 600; color: var(--text); padding: 9px 10px; margin-bottom: 2px; }
#side a.main.active { color: var(--pos); }
#side svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}
#side .hd {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 10px 4px;
  margin: var(--s-4) 0 2px;
}
#side .hd button {
  border: 0;
  background: none;
  color: var(--pos);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background var(--dur) var(--ease);
}
#side .hd button:hover { background: var(--brand-soft); }
#side .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
#side .s-emoji { width: 18px; text-align: center; flex: none; font-size: 14px; }

#view {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  padding: 0 0 var(--s-6);
  min-width: 0;
}

#right {
  position: sticky;
  top: calc(var(--top-h) + var(--s-5));
  font-size: 14px;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}
#right .box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  box-shadow: var(--shadow-xs);
}
#right h2 { margin-bottom: var(--s-3); }
#right .rrow {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 7px 6px;
  margin: 0 -6px;
  border-radius: var(--r-sm);
  transition: background var(--dur) var(--ease);
}
#right a.rrow:hover { background: var(--surface-2); }
#right .rrow b { display: block; font-size: 14px; font-weight: 600; line-height: 1.25; }
#right .rrow small { font-size: 12.5px; display: block; }
#right .r-total { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }
#right .tip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.5;
}
#right .tip a { color: var(--pos); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

#tabs, #fab { display: none; }

@media (max-width: 1040px) {
  #cols { grid-template-columns: 216px minmax(0, 1fr); }
  #right { display: none; }
}

@media (max-width: 760px) {
  :root { --top-h: 52px; }
  #cols { display: block; padding: 0; min-height: calc(100dvh - var(--top-h)); }
  #side { display: none; }
  #view {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: var(--surface);
    min-height: calc(100dvh - var(--top-h));
    padding-bottom: calc(148px + env(safe-area-inset-bottom));
  }
  .top-in { padding: 0 var(--s-3); }
  #tabs {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 15;
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(15, 32, 27, .06);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  #tabs a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    padding: 4px 2px;
    min-height: 46px;
    border-radius: var(--r-sm);
    transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
  }
  #tabs a.active { color: var(--pos); font-weight: 700; }
  #tabs a.active svg { stroke-width: 2.2; }
  #tabs svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  #fab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    position: fixed;
    right: 16px;
    bottom: calc(74px + env(safe-area-inset-bottom));
    z-index: 16;
    border: 0;
    background: var(--cta);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 13px 20px;
    min-height: 48px;
    border-radius: var(--r-pill);
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(209, 71, 25, .36), 0 2px 6px rgba(0, 0, 0, .14);
    transition: transform var(--dur) var(--ease), background var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  }
  #fab:hover { background: var(--cta-hover); }
  #fab:active { transform: scale(.96); }
  #fab .plus { font-size: 21px; line-height: 1; font-weight: 700; }
  .head .actions .btn.primary[data-act="new-expense"] { display: none; }
}

/* ---------- encabezados, secciones y tarjetas ---------- */
.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--s-4) var(--s-5);
  min-height: 68px;
}
.head > div:first-child { min-width: 0; flex: 1 1 200px; }
.head .sub { color: var(--text-muted); font-size: 13.5px; margin-top: 3px; }
.head .ttl { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.back {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 10px var(--s-4) 0;
  color: var(--pos);
  font-size: 13.5px;
  font-weight: 700;
}
@media (max-width: 760px) {
  .head { padding: var(--s-4); min-height: 60px; }
  .back { display: inline-flex; }
}

.actions { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.section { margin-top: 0; }
.section > .section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  padding: 10px var(--s-5);
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 760px) {
  .section > .section-head { padding: 10px var(--s-4); }
}
.section-head a { color: var(--pos); font-size: 13px; font-weight: 700; }
.section-head a:hover { text-decoration: underline; }
.card { background: var(--surface); }
.pad { padding: var(--s-4) var(--s-5); }
.block { padding: var(--s-5); border-bottom: 1px solid var(--border); }
.block h2 { margin-bottom: var(--s-3); }
@media (max-width: 760px) {
  .pad { padding: var(--s-4); }
  .block { padding: var(--s-4); }
}

/* ---------- botones ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 9px 14px;
  min-height: 38px;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--cta);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(209, 71, 25, .24);
}
.btn.primary:hover { background: var(--cta-hover); }
.btn.mint {
  background: var(--brand);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(17, 130, 104, .22);
}
.btn.mint:hover { background: var(--brand-hover); }
.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-soft);
}
.btn.ghost:hover { background: var(--surface-3); color: var(--text); }
.btn.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 32%, var(--border-strong)); }
.btn.danger:hover { background: var(--neg-soft); border-color: var(--neg); }
.btn.small { padding: 6px 11px; min-height: 32px; font-size: 12.5px; border-radius: 7px; }
.btn.wide { width: 100%; padding: 13px 16px; min-height: 46px; font-size: 15.5px; font-weight: 700; }

@media (max-width: 760px) {
  .btn { min-height: 42px; padding: 10px 14px; }
  .btn.small { min-height: 36px; padding: 7px 12px; }
}

/* ---------- franja de saldos del panel (.strip) ---------- */
.strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.strip > div {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 13px 10px 11px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 0;
  box-shadow: var(--shadow-xs);
}
.strip > div::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-strong);
}
.strip > div.kpi-neg::before { background: var(--neg); }
.strip > div.kpi-pos::before { background: var(--pos); }
.strip > div.kpi-total::before { background: var(--border-strong); }
.strip b {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  letter-spacing: -.015em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.strip b.pos { color: var(--pos); }
.strip b.neg { color: var(--neg); }
@media (max-width: 760px) {
  .strip { padding: var(--s-3) var(--s-3); gap: 8px; }
  .strip > div { padding: 10px 6px; font-size: 11.5px; }
  .strip b { font-size: 16px; }
}

.two { display: grid; grid-template-columns: 1fr 1fr; }
.two > div { min-width: 0; }
.two > div + div { border-left: 1px solid var(--border); }
.two h2 {
  padding: 14px var(--s-5) 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.two h2.r { justify-content: flex-end; text-align: right; }
@media (max-width: 560px) {
  .two { grid-template-columns: 1fr; }
  .two > div + div { border-left: 0; border-top: 1px solid var(--border); }
  .two h2 { padding: 14px var(--s-4) 6px; }
  .two h2.r { justify-content: flex-start; text-align: left; }
}

/* ---------- tarjetas resumen hero ---------- */
.hero { border-bottom: 1px solid var(--border); background: var(--surface-2); padding: var(--s-3) var(--s-5); }
.hero .card {
  padding: 14px var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.hero .label {
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .06em;
}
.hero .big { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -.015em; }
.hero .line { display: block; }
.hero .line small { font-size: 13.5px; font-weight: 600; margin-right: 6px; }
.hero .detail { font-size: 13px; color: var(--text-muted); }
.hero.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
@media (max-width: 760px) {
  .hero { padding: var(--s-3) var(--s-4); }
}
@media (max-width: 480px) {
  .hero.grid { grid-template-columns: 1fr; }
}

/* ---------- listas y filas ---------- */
.list { overflow: hidden; }
.row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px var(--s-5);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  min-width: 0;
  transition: background var(--dur) var(--ease);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.static { cursor: default; }
.row.static:hover { background: transparent; }
.row .main { flex: 1; min-width: 0; }
.row .title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .sub.pos { color: var(--pos); font-weight: 600; font-size: 13.5px; }
.row .sub.neg { color: var(--neg); font-weight: 600; font-size: 13.5px; }
.row .right {
  text-align: right;
  flex: none;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}
.row .right small { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-muted); }
.row .right.pos small, .row .right .pos small { color: var(--pos); }
.row .right.neg small, .row .right .neg small { color: var(--neg); }
.row .right .line { display: block; }

/* columnas de gasto estilo Splitwise */
.row .who {
  width: 122px;
  text-align: right;
  flex: none;
  font-size: 14.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--border);
  padding-right: 12px;
  color: var(--text-soft);
}
.row .who small {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row .lent { width: 124px; text-align: left; }

@media (max-width: 760px) {
  .row { padding: 11px var(--s-4); gap: 10px; }
}
@media (max-width: 560px) {
  .row .who { display: none; }
  .row .lent { width: auto; text-align: right; }
}

.month {
  padding: 7px var(--s-5);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
@media (max-width: 760px) {
  .month { padding: 7px var(--s-4); }
}

.date {
  width: 34px;
  text-align: center;
  flex: none;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.1;
  letter-spacing: .03em;
}
.date b {
  display: block;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-soft);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex: none;
}
.icon.pay {
  background: var(--pos-soft);
  border-color: color-mix(in srgb, var(--pos) 22%, var(--border));
}

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

.tag {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-soft);
  vertical-align: middle;
}
.tag.ok { background: var(--pos-soft); color: var(--pos); }
.tag.wait { background: var(--neg-soft); color: var(--neg); }

/* estados vacíos y carga */
.empty {
  color: var(--text-muted);
  padding: var(--s-6) var(--s-4);
  text-align: center;
  font-size: 14px;
  line-height: 1.5;
}
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .empty-ico { font-size: 28px; display: block; margin-bottom: 6px; opacity: .85; }
.empty .btn { margin-top: var(--s-3); }

.skel-list { padding: var(--s-2) 0; }
.skel-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px var(--s-5);
  border-bottom: 1px solid var(--border);
}
.skel-row:last-child { border-bottom: 0; }
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}
.skel-box { width: 38px; height: 38px; border-radius: 10px; flex: none; }
.skel-lines { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.skel-l1 { height: 14px; width: 58%; }
.skel-l2 { height: 11px; width: 36%; }
.skel-amt { width: 64px; height: 16px; flex: none; }
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (max-width: 760px) { .skel-row { padding: 12px var(--s-4); } }

.more { padding: var(--s-4); text-align: center; }

/* ---------- pestañas internas (Gastos / Saldos) ---------- */
.tabs {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 var(--s-4);
  gap: var(--s-2);
}
.tabs button {
  flex: 1;
  background: none;
  border: 0;
  padding: 12px 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--pos); border-bottom-color: var(--brand); }

/* ---------- filtros y formularios ---------- */
.filters {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-5);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.filters input[type=search] { flex: 1 1 200px; min-width: 0; }
.filters select { width: auto; flex: 0 1 auto; max-width: 100%; }
@media (max-width: 760px) {
  .filters { padding: var(--s-3) var(--s-4); }
  .filters input[type=search] { flex: 1 1 100%; }
  .filters #fgroup { flex: 1 1 100%; }
  .filters select { flex: 1 1 calc(50% - 4px); min-width: 120px; font-size: 14px; }
}

input[type=text], input[type=search], input[type=password], input[type=email], input[type=date], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  min-height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  min-width: 0;
  font-size: 15px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: .8; }
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
textarea { min-height: 68px; resize: vertical; }
input[type=file] {
  width: 100%;
  font-size: 14px;
  color: var(--text-soft);
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  margin: var(--s-3) 0 5px;
}
label.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  padding: 9px 0;
  cursor: pointer;
}
label.check input {
  width: 19px;
  height: 19px;
  accent-color: var(--brand);
  flex: none;
  cursor: pointer;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.grid3 { display: grid; grid-template-columns: minmax(0, 1fr) 108px; gap: var(--s-2); }
@media (max-width: 400px) {
  .grid2 { gap: var(--s-2); }
}

.error {
  color: var(--neg);
  background: var(--neg-soft);
  border: 1px solid color-mix(in srgb, var(--neg) 25%, transparent);
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 600;
  margin-top: var(--s-3);
}
.hint { color: var(--text-muted); font-size: 13px; line-height: 1.45; margin-top: 6px; }

/* bloque rápido de descripción + importe en #eform y #sform */
.amount-hero {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4) var(--s-4);
  margin-top: var(--s-3);
}
.amount-hero label:first-child { margin-top: 0; }
.amount-hero #edesc {
  font-size: 17px;
  font-weight: 600;
  min-height: 46px;
}
.amount-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: var(--s-2);
  align-items: stretch;
}
.amount-input {
  font-size: 26px !important;
  font-weight: 700 !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
  min-height: 54px !important;
  padding: 8px 12px !important;
}
.amount-input-wrap select {
  font-weight: 700;
  min-height: 54px;
  text-align: center;
}

/* bloque de reparto */
.split-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4) var(--s-4);
  margin-top: var(--s-4);
}
.split-box > label:first-child { margin-top: 0; }
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 3px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-sm);
}
.seg button {
  border: 0;
  background: transparent;
  padding: 8px 4px;
  min-height: 36px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-soft);
  cursor: pointer;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.seg button:hover { color: var(--text); }
.seg button.active {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: var(--shadow-xs);
}
.split-help {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 8px;
}
.people-pick {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 2px 10px;
  margin-top: 8px;
}
.people-pick .pp {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.people-pick .pp:last-child { border-bottom: 0; }
.people-pick .pp label { flex: 1; min-width: 0; overflow: hidden; }
.people-pick .pp .pp-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.people-pick .pp input[type=text] {
  width: 84px;
  min-height: 36px;
  padding: 6px 8px;
  text-align: right;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.people-pick .pp .calc {
  width: 74px;
  text-align: right;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex: none;
}
#splitmsg { margin-top: 8px; font-weight: 600; }
#splitmsg.warn { color: var(--neg); }
#splitmsg.ok { color: var(--pos); }

/* ---------- diálogos ---------- */
dialog {
  border: 1px solid var(--border);
  padding: 0;
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  width: min(490px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dlgIn 180ms var(--ease);
}
@keyframes dlgIn {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
dialog::backdrop {
  background: rgba(10, 22, 19, .58);
  backdrop-filter: blur(2px);
}
.dlg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px var(--s-4);
  background: linear-gradient(180deg, var(--brand-bar-top) 0%, var(--brand-bar-bot) 100%);
  color: #fff;
  flex: none;
}
.dlg-head h3 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.dlg-head button {
  border: 0;
  background: rgba(255, 255, 255, .16);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 21px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  transition: background var(--dur) var(--ease);
}
.dlg-head button:hover { background: rgba(255, 255, 255, .28); }
.dlg-head button:focus-visible { outline-color: #fff; }
.dlg-body {
  padding: var(--s-1) var(--s-4) var(--s-4);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.dlg-foot {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin: var(--s-5) calc(var(--s-4) * -1) calc(var(--s-4) * -1);
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: calc(var(--s-4) * -1);
  flex-wrap: wrap;
}
@media (max-width: 560px) {
  dialog { width: calc(100vw - 14px); }
  .dlg-foot .btn { flex: 1 1 auto; }
}

.detail-banner {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-4);
  margin-top: var(--s-3);
}
.detail-meta { color: var(--text-muted); font-size: 13px; }
.detail-title { font-size: 19px; font-weight: 700; margin-top: 6px; line-height: 1.25; }
.detail-cost { font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; color: var(--text); }
.kv-list {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  padding: 0 12px;
}
.kv {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
}
.kv:first-child { border-top: 0; }
.comment {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  margin-top: 8px;
  font-size: 14px;
}
.comment small { color: var(--text-muted); font-size: 12px; display: block; margin-bottom: 2px; }

/* ---------- onboarding ---------- */
.ob { text-align: center; padding: var(--s-5) var(--s-2) var(--s-2); }
.ob .art {
  width: 76px;
  height: 76px;
  margin: 0 auto;
  border-radius: 22px;
  background: var(--brand-soft);
  display: grid;
  place-items: center;
  font-size: 40px;
  line-height: 1;
}
.ob h3 { font-size: 21px; font-weight: 700; margin: var(--s-4) 0 8px; letter-spacing: -.015em; }
.ob p { color: var(--text-soft); max-width: 340px; margin: 0 auto; line-height: 1.5; }
.ob video { width: 100%; max-height: 46dvh; border-radius: var(--r-sm); background: #000; margin-top: 12px; }
.ob-dots { display: flex; gap: 6px; justify-content: center; margin: var(--s-5) 0 0; }
.ob-dots i {
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  transition: width var(--dur) var(--ease), background var(--dur) var(--ease);
}
.ob-dots i.on { width: 22px; background: var(--brand); }
.ob-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s-2);
  margin-top: var(--s-5);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
}

/* ---------- guías en video ---------- */
.guide {
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
  display: grid;
  grid-template-columns: 196px minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}
.guide:last-child { border-bottom: 0; }
.guide video {
  width: 100%;
  border-radius: var(--r-md);
  background: #0b1110;
  aspect-ratio: 9 / 16;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.guide h3 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.guide ol { margin: var(--s-3) 0 0; padding-left: 20px; color: var(--text-soft); line-height: 1.55; }
.guide li { margin: 6px 0; }
@media (max-width: 560px) {
  .guide { grid-template-columns: 1fr; padding: var(--s-4); gap: var(--s-3); }
  .guide video { max-height: 64dvh; }
}

/* ---------- gráficos de resumen ---------- */
.bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 6px;
  align-items: end;
  height: 184px;
  padding-top: 12px;
}
.bars .bar {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 4px;
  min-width: 0;
}
.bars .fill {
  width: 100%;
  max-width: 34px;
  background: linear-gradient(180deg, var(--brand-bar-top), var(--brand-bar-bot));
  border-radius: 5px 5px 2px 2px;
  min-height: 3px;
  transition: height 240ms var(--ease);
}
.bars .bar.zero .fill { background: var(--border); min-height: 2px; }
.bars .lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); }
.bars .val {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  max-width: 100%;
}
@media (max-width: 480px) {
  .bars { gap: 3px; height: 164px; }
  .bars .lbl { font-size: 10px; }
  .bars .val { font-size: 9px; }
}

.catrow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 12px var(--s-5);
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.catrow:last-child { border-bottom: 0; }
.catrow .cat-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.catrow .track {
  grid-column: 1 / -1;
  height: 7px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.catrow .track i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand-bar-top), var(--brand));
  border-radius: var(--r-pill);
}
@media (max-width: 760px) {
  .catrow { padding: 11px var(--s-4); }
}

/* ---------- ajuste: bloque de importación ---------- */
.danger-zone {
  background: var(--neg-soft);
  border: 1px solid color-mix(in srgb, var(--neg) 22%, var(--border));
  border-radius: var(--r-md);
  padding: var(--s-4);
}
.danger-zone h2 { color: var(--neg); }

/* ---------- flujo de pago (#sform) ---------- */
.pay-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: end;
}
.pay-arrow {
  padding-bottom: 10px;
  color: var(--pos);
  font-weight: 800;
  font-size: 18px;
  text-align: center;
}

/* ---------- entrada, registro y toast ---------- */
#gate {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 0%, var(--brand-soft) 0%, transparent 45%),
    radial-gradient(circle at 85% 100%, var(--cta-soft) 0%, transparent 42%),
    var(--bg);
  padding: max(4dvh, 24px) var(--s-4) var(--s-8);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.gate-card {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: var(--s-6) var(--s-5);
  text-align: center;
}
.gate-card h1 { margin-top: var(--s-3); font-size: 24px; }
.gate-card p.lead { color: var(--text-soft); margin-top: 6px; font-size: 14.5px; line-height: 1.5; }
.gate-card label { text-align: left; }
.gate-card .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.gate-card #lform input, #lform.gate-card input { margin-top: var(--s-4); padding: 14px 16px; font-size: 16px; }
.gate-card #lpass { margin-top: 10px; }
.gate-card .btn { margin-top: var(--s-4); }
.gate-card .btn + .btn { margin-top: 10px; }
.gate-card input.code {
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 8px;
  font-variant-numeric: tabular-nums;
  min-height: 54px;
}
.gate-card video {
  width: 100%;
  max-height: 48dvh;
  border-radius: var(--r-md);
  background: #000;
  margin-top: var(--s-4);
  border: 1px solid var(--border);
}
.gate-foot {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  margin: var(--s-4) auto 0;
  max-width: 380px;
  line-height: 1.45;
}
.gate-foot a { color: var(--pos); font-weight: 700; text-decoration: underline; text-underline-offset: 2px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 40;
  background: #172320;
  color: #f4faf8;
  border: 1px solid rgba(255, 255, 255, .12);
  padding: 11px 18px;
  border-radius: var(--r-pill);
  font-weight: 600;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 32px);
  text-align: center;
}
@media (prefers-color-scheme: dark) {
  #toast {
    background: #edf4f1;
    color: #13201d;
    border-color: transparent;
  }
}

/* compartir por WhatsApp, instalar y notificaciones */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text-soft); border-radius: 999px; padding: 7px 14px; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.chip.on { background: var(--brand-soft); border-color: var(--pos); color: var(--text); }
.btn.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn.wa:hover { background: #178f47; }
ol.steps { margin: var(--s-3) 0 0; padding-left: 22px; color: var(--text-soft); line-height: 1.6; text-align: left; }
ol.steps li + li { margin-top: 4px; }
#instabs { margin-top: var(--s-3); }
