/* iSanPro Contabilidad — tema oscuro de marca */
/* Paleta de marca: #FF2D2D · #FF8A00 · #FFC107 · #0F172A · #374151 · #D1D5DB — tipografía Inter */
:root {
  --bg: #0a0d14;
  --bg-2: #0f1420;
  --card: #121826;
  --card-2: #1a2131;
  --line: #232b3b;
  --text: #f3f4f6;
  --muted: #9aa3b2;
  --light: #D1D5DB;
  --slate: #374151;
  --navy: #0F172A;
  --red: #FF2D2D;
  --orange: #FF8A00;
  --yellow: #FFC107;
  --orange-2: #FFA51F;
  --grad: linear-gradient(135deg, #FFA51F 0%, #FF6A14 55%, #FF2D2D 100%);
  --grad-brand: linear-gradient(135deg, #FFC107 0%, #FF8A00 45%, #FF2D2D 100%);
  --green: #22c55e;
  --blue: #3b82f6;
  --purple: #8b5cf6;
  --empresa: #3b82f6;
  --casa: #22c55e;
  --pos: #34d672;
  --danger: #ff5a5a;
  --radius: 18px;
  --nav-h: 74px;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text);
  background: radial-gradient(1100px 560px at 85% -12%, rgb(255 138 0 / .12), transparent 60%),
              radial-gradient(900px 500px at -10% 110%, rgb(255 45 45 / .07), transparent 60%), var(--bg);
  background-attachment: fixed;
  font: 400 15px/1.45 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
}
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 1.05rem; font-weight: 600; }
h3 { font-size: 1.15rem; font-weight: 600; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .8rem; }
.grow { flex: 1; min-width: 0; }
.error { color: var(--danger); min-height: 1.1em; margin: .6rem 0 0; font-size: .88rem; }
.neg { color: var(--red); }
.pos { color: var(--pos); }
.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: .7rem .85rem; border-radius: 12px; outline: none;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text);
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgb(255 138 0 / .2); }
input[type=color] { width: 2.6rem; height: 2.6rem; padding: 3px; flex: none; cursor: pointer; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--orange); }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; color: var(--muted); }
label > input, label > select, label > textarea { font-size: 1rem; }
.lbl { font-size: .82rem; color: var(--muted); margin-bottom: .45rem; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .65rem 1rem; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); cursor: pointer; text-decoration: none; white-space: nowrap; font-size: .92rem; font-weight: 550;
}
.btn:hover { background: #24242c; }
.btn.small { padding: .4rem .7rem; font-size: .82rem; }
.btn.primary { background: var(--grad); border: 0; color: #fff; box-shadow: 0 8px 24px rgb(255 60 20 / .3); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: .95rem 1.2rem; font-size: 1rem; border-radius: 14px; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--danger); }
.btn.danger-fill { background: #e5383b; border-color: #e5383b; color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn { border: 0; background: none; cursor: pointer; padding: .4rem; border-radius: 10px; color: var(--muted); display: inline-flex; }
.icon-btn:hover { background: var(--card-2); color: var(--text); }
.round-btn {
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; position: relative; flex: none;
}
.round-btn:hover { background: var(--card-2); }
.round-btn.on { border-color: var(--orange); color: var(--orange); }
.dot-badge { position: absolute; top: 7px; right: 8px; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 2px var(--card); }
.link { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: .85rem; display: inline-flex; align-items: center; gap: .2rem; padding: .2rem; }
.link.orange { color: var(--orange); font-weight: 600; }
.link.small { font-size: .78rem; }

/* Marca */
.brand { display: flex; align-items: center; gap: .55rem; }
.logo-sym { height: 44px; width: auto; flex: none; }
.logo-word { height: 34px; width: auto; flex: none; }
.ico.grad { stroke: url(#igrad); }
.gtile {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; flex: none;
  background: linear-gradient(160deg, #1c2436, #111726); border: 1px solid #2a3346;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / .04), 0 8px 18px rgb(0 0 0 / .35);
}
.gtile .ico { width: 24px; height: 24px; stroke-width: 2.2; }
.gtile.sm { width: 38px; height: 38px; border-radius: 11px; }
.gtile.sm .ico { width: 20px; height: 20px; }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgb(255 154 31 / .5); cursor: pointer;
  background: var(--grad-brand); color: #fff; font-weight: 700; font-size: 1.05rem; display: grid; place-items: center; flex: none;
}
.avatar.big { width: 64px; height: 64px; font-size: 1.5rem; cursor: default; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  text-align: center;
  width: 100%; max-width: 360px; background: var(--card); padding: 2rem 1.5rem; border-radius: 24px;
  border: 1px solid var(--line); display: flex; flex-direction: column; gap: .9rem;
  box-shadow: 0 30px 80px rgb(0 0 0 / .5);
}
.login-logo { width: 150px; margin: 0 auto -.4rem; }
.login-word { width: 250px; max-width: 100%; margin: 0 auto .6rem; }

/* Estructura: barra inferior en el móvil, lateral en pantallas grandes */
.content { padding: 0 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; }
.view { display: flex; flex-direction: column; gap: 1rem; padding-top: max(18px, env(safe-area-inset-top)); }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around; align-items: stretch;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgb(14 14 18 / .92); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.nav-brand { display: none; }
.nav button {
  flex: 1; border: 0; background: none; cursor: pointer; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .3rem; font-size: .72rem;
}
.nav button .ico { width: 24px; height: 24px; }
.nav button.on { color: var(--orange); font-weight: 600; }
.nav button.on .ico { stroke: url(#igrad); filter: drop-shadow(0 0 8px rgb(255 120 0 / .5)); }

@media (min-width: 900px) {
  .nav {
    top: 0; right: auto; width: 240px; height: auto; flex-direction: column; justify-content: flex-start; gap: .3rem;
    padding: 22px 14px; border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-brand { display: block; padding: 0 .2rem 1.6rem; }
  .nav-brand .logo-sym { height: 38px; }
  .nav-brand .logo-word { height: 30px; }
  .nav button { flex: none; flex-direction: row; justify-content: flex-start; gap: .8rem; padding: .8rem 1rem; border-radius: 14px; font-size: .95rem; }
  .nav button.on { background: rgb(255 138 0 / .12); }
  .content { margin-left: 240px; padding: 8px 36px 48px; }
  .home-head .brand { visibility: hidden; }
}

/* Cabeceras */
.view-head { display: flex; align-items: center; gap: .7rem; justify-content: space-between; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: .5rem; }
.home-head { display: flex; justify-content: space-between; align-items: center; }
.hello-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; }
.hello { font-size: 2rem; margin-bottom: .25rem; }
.chips { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  position: relative; flex-direction: row; align-items: center; gap: .4rem; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 0 .6rem; height: 40px; font-size: .88rem;
}
.chip select { border: 0; background: none; padding: 0 1.2rem 0 0; appearance: none; -webkit-appearance: none; font-size: .88rem; cursor: pointer; box-shadow: none; }
.chip .chev { position: absolute; right: .55rem; pointer-events: none; color: var(--muted); }
.chip > .ico:first-child { color: var(--muted); }
.sec-title { font-size: 1.15rem; }
.sec-row { display: flex; justify-content: space-between; align-items: center; }

/* Tarjetas */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-title { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .9rem; flex-wrap: wrap; }
.card-title h2 { display: flex; align-items: center; gap: .4rem; }

/* KPI ingresos / gastos */
.kpi2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.kpi-card {
  position: relative; overflow: hidden; border-radius: var(--radius); padding: 1rem 1rem .9rem; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: .15rem; min-height: 132px;
}
.kpi-card.in { background: linear-gradient(160deg, rgb(34 197 94 / .16), rgb(34 197 94 / .03) 70%), var(--card); border-color: rgb(34 197 94 / .22); }
.kpi-card.out { background: linear-gradient(160deg, rgb(255 69 69 / .18), rgb(255 69 69 / .03) 70%), var(--card); border-color: rgb(255 69 69 / .24); }
.kpi-card .k-head { display: flex; align-items: center; gap: .45rem; font-size: .92rem; color: #e6e6ea; }
.k-badge { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.in .k-badge { background: var(--green); }
.out .k-badge { background: var(--red); }
.k-badge .ico { width: 14px; height: 14px; stroke-width: 3; }
.kpi-card .k-value { font-size: 1.85rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: .25rem; }
.in .k-value { color: #4ade80; }
.out .k-value { color: #ff6b6b; }
.kpi-card .k-delta { font-size: .8rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; padding-right: 58px; }
.k-delta b { font-weight: 700; }
.k-delta .up, .k-delta .down { display: inline-flex; align-items: center; gap: .1rem; }
.kpi-card .spark { position: absolute; right: 12px; bottom: 12px; width: 58px; height: 40px; }
.kpi2.small .kpi-card { min-height: 108px; }
.kpi2.small .k-value { font-size: 1.5rem; }

/* Saldo actual */
.saldo-card {
  width: 100%; text-align: left; cursor: pointer; display: grid; grid-template-columns: auto 1fr auto; gap: .2rem .9rem; align-items: center;
  background: linear-gradient(160deg, rgb(255 154 31 / .10), transparent 60%), var(--card); color: var(--text);
}
.saldo-card .s-icon { width: 54px; height: 54px; border-radius: 15px; background: linear-gradient(135deg, #ffd34d, #ff9a1f); display: grid; place-items: center; color: #3a2400; grid-row: span 2; }
.saldo-card .s-icon .ico { width: 28px; height: 28px; }
.saldo-card .s-label { font-size: .9rem; color: #e6e6ea; }
.saldo-card .s-value { font-size: 1.9rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.saldo-card .s-delta { grid-row: span 2; align-self: center; }
.saldo-card .s-chart { grid-column: 1 / -1; margin-top: .6rem; height: 92px; }
.saldo-card .s-chart svg { width: 100%; height: 100%; display: block; }
.pct { font-size: .78rem; font-weight: 700; padding: .25rem .5rem; border-radius: 99px; display: inline-flex; align-items: center; gap: .15rem; white-space: nowrap; }
.pct.good { color: #4ade80; background: rgb(34 197 94 / .14); }
.pct.bad { color: #ff7a7a; background: rgb(255 69 69 / .14); }
.pct.flat { color: var(--muted); background: var(--card-2); }
.pct .ico { width: 12px; height: 12px; stroke-width: 3; }

/* Acciones rápidas */
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.quick button {
  border: 1px solid var(--line); background: var(--card); border-radius: 16px; padding: .85rem .3rem .75rem; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .5rem; font-size: .76rem; font-weight: 500; color: var(--light); text-align: center; line-height: 1.2;
}
.quick button:hover { background: var(--card-2); }
.qi { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: #fff; flex: none; }
.qi .ico { width: 21px; height: 21px; }

/* Beneficio neto, saldo y avisos */
.net-card { display: grid; grid-template-columns: 1fr auto; gap: .15rem .8rem; align-items: center;
  background: linear-gradient(160deg, rgb(255 138 0 / .12), transparent 60%), var(--card); }
.net-card .n-label { font-size: .92rem; color: var(--light); }
.net-card .n-value { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.net-card .n-chart { grid-column: 1 / -1; height: 96px; margin-top: .5rem; }
.net-card .n-chart svg { width: 100%; height: 100%; display: block; }
.saldo-strip, .alert-strip { width: 100%; display: flex; align-items: center; gap: .8rem; padding: .8rem 1rem; text-align: left; cursor: pointer; color: var(--text); }
.saldo-strip:hover, .alert-strip:hover { background: var(--card-2); }
.saldo-strip b, .alert-strip b { font-variant-numeric: tabular-nums; }
.alert-strip { border-color: rgb(255 138 0 / .35); background: rgb(255 138 0 / .07); }

/* Inicio en dos columnas en pantallas grandes */
.home-grid { display: grid; gap: 1rem; }
.home-main, .home-side { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
@media (min-width: 1100px) { .home-grid { grid-template-columns: 1.1fr 1fr; align-items: start; } }

/* Listas de movimientos */
.list { display: flex; flex-direction: column; }
.row {
  display: grid; grid-template-columns: auto 1fr auto; gap: .8rem; align-items: center;
  padding: .75rem 1rem; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--card-2); }
.tile {
  width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; color: #fff; flex: none;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 92%, #fff 8%), color-mix(in srgb, var(--c) 70%, #000 30%));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--c) 30%, transparent);
}
.tile .ico { width: 22px; height: 22px; }
.tile.big { width: 56px; height: 56px; border-radius: 16px; }
.tile.big .ico { width: 28px; height: 28px; }
.row .r-main { min-width: 0; }
.row .r-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-sub { font-size: .8rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; white-space: nowrap; overflow: hidden; }
.row .r-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row .r-amt small { display: block; font-weight: 400; font-size: .76rem; color: var(--muted); margin-top: .1rem; }
.month-head { font-weight: 650; font-size: 1.05rem; margin: .6rem .1rem .55rem; display: flex; justify-content: space-between; align-items: baseline; }
.month-head span { font-size: .8rem; color: var(--muted); font-weight: 500; }
#mov-list .list { margin-bottom: .6rem; }
.list-sum { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); padding: 0 .2rem; }
.empty { padding: 2rem 1rem; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.search { border-radius: 14px; padding: .8rem 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-end; }
.filters label { flex: 1; min-width: 140px; }
.filter-actions { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Segmentado */
.seg { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: none; padding: .55rem 1rem; border-radius: 10px; cursor: pointer; color: var(--muted); font-size: .92rem; font-weight: 550; }
.seg button.on { background: var(--grad); color: #fff; font-weight: 600; box-shadow: 0 6px 18px rgb(255 60 20 / .32); }
.seg.pill { display: flex; }
.seg.pill button { flex: 1; }
.seg.full { display: flex; margin-bottom: 1rem; }
.seg.full button { flex: 1; }

/* Facturas */
.inv-sum { display: flex; gap: .6rem; flex-wrap: wrap; }
.inv-sum .sum-chip { flex: 1; min-width: 140px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .7rem .9rem; }
.inv-sum .sum-chip span { display: block; font-size: .76rem; color: var(--muted); }
.inv-sum .sum-chip b { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.st { font-size: .74rem; font-weight: 600; }
.st.pagada { color: #4ade80; }
.st.pendiente { color: var(--orange); }
.st.borrador { color: var(--muted); }
.st.vencida { color: var(--red); }
.sticky-cta { position: sticky; bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom)); z-index: 5; }
@media (min-width: 900px) { .sticky-cta { bottom: 20px; } }
.inv-total { background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .9rem; font-size: .88rem; color: var(--muted); display: grid; grid-template-columns: 1fr auto; gap: .2rem .8rem; font-variant-numeric: tabular-nums; }
.inv-total b { color: var(--text); text-align: right; }
.inv-total .tot { font-size: 1.05rem; color: var(--text); font-weight: 700; }
.repeat-box { display: flex; align-items: center; gap: .8rem; }
.repeat-box select { width: auto; flex: 1; }

/* Categorías */
.cat-grid { display: grid; gap: .7rem; }
@media (min-width: 700px) { .cat-grid { grid-template-columns: 1fr 1fr; } }
.cat-card {
  display: grid; grid-template-columns: auto 1fr auto; gap: .25rem .9rem; align-items: center; text-align: left; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .95rem 1rem; color: var(--text); width: 100%;
}
.cat-card:hover { background: var(--card-2); }
.cat-card .tile { grid-row: span 2; }
.cat-card .c-name { font-weight: 600; display: flex; gap: .4rem; align-items: center; min-width: 0; }
.cat-card .c-name span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-card .c-amt { font-size: .95rem; font-variant-numeric: tabular-nums; color: #e6e6ea; }
.cat-card .c-pct { grid-row: span 2; color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.cat-card .c-bar { grid-column: 2 / -1; height: 7px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-top: .3rem; }
.cat-card .c-bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.cat-card.zero { opacity: .55; }
.cat-sep { font-size: .82rem; color: var(--muted); margin: .4rem .2rem 0; }
.amb-tag { font-size: .66rem; padding: .08rem .4rem; border-radius: 99px; background: var(--card-2); color: var(--muted); font-weight: 600; flex: none; }
.period-nav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .35rem; }
.period-nav span { font-weight: 650; }
.period-nav button { border: 0; background: none; cursor: pointer; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--text); }
.period-nav button:hover { background: var(--card-2); }

.cat-preview { display: flex; align-items: center; gap: .9rem; margin-bottom: 1rem; }
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.swatches button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; background: var(--c); }
.swatches button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }
.icon-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: .4rem; }
.icon-pick button { height: 42px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.icon-pick button.on { border-color: var(--orange); color: var(--orange); background: rgb(255 106 16 / .1); }

/* Gráficos */
.chart svg { width: 100%; height: auto; display: block; }
.chart text, .donut-wrap text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: #24242b; }
.legend { display: flex; gap: 1.1rem; font-size: .82rem; color: var(--muted); margin-bottom: .6rem; justify-content: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .35rem; vertical-align: -1px; }
.donut-wrap { display: grid; grid-template-columns: 168px 1fr; gap: 1rem; align-items: center; }
.donut-wrap svg { width: 168px; height: 168px; }
.donut-wrap text.d-total { font-size: 21px; font-weight: 750; fill: var(--text); }
.d-legend { display: flex; flex-direction: column; gap: .5rem; font-size: .86rem; min-width: 0; }
.d-legend div { display: grid; grid-template-columns: 10px 1fr auto auto; gap: .55rem; align-items: center; }
.d-legend i { width: 10px; height: 10px; border-radius: 50%; }
.d-legend span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-legend .pc { color: var(--muted); font-variant-numeric: tabular-nums; }
.d-legend .am { font-variant-numeric: tabular-nums; text-align: right; min-width: 4.5rem; }
@media (max-width: 420px) {
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .d-legend { width: 100%; }
}

/* Informes */
.inf-grid { display: grid; gap: 1rem; }
@media (min-width: 1000px) { .inf-grid { grid-template-columns: 1fr 1fr; } }
.compare { display: flex; flex-direction: column; }
.compare .cmp { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.compare .cmp:last-child { border-bottom: 0; }
.compare .cmp b { font-variant-numeric: tabular-nums; }
.compare .cmp small { display: block; color: var(--muted); font-size: .76rem; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.tbl th, .tbl td { padding: .5rem .3rem; text-align: right; border-bottom: 1px solid var(--line); }
.tbl th:first-child, .tbl td:first-child { text-align: left; }
.tbl th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.tbl tr:last-child td { border-bottom: 0; font-weight: 700; }

/* Más */
.profile { display: flex; gap: 1rem; align-items: center; }
.menu { display: flex; flex-direction: column; }
.menu > * {
  display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; border: 0; border-bottom: 1px solid var(--line);
  background: none; cursor: pointer; text-align: left; text-decoration: none; color: var(--text); font-size: .98rem; width: 100%;
}
.menu > *:last-child { border-bottom: 0; }
.menu > *:hover { background: var(--card-2); }
.menu small { display: block; font-size: .78rem; color: var(--muted); margin-top: .1rem; }
.menu > * > .ico { color: var(--muted); }

/* Cuentas */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.kpi .label { color: var(--muted); font-size: .8rem; }
.kpi .value { font-size: 1.4rem; font-weight: 750; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.kpi .value.neg { color: var(--red); }
.kpi .sub { color: var(--muted); font-size: .76rem; margin-top: .1rem; }
.acc-list { display: flex; flex-direction: column; }
.acc { display: grid; grid-template-columns: auto 1fr auto; gap: .9rem; align-items: center; padding: .75rem .2rem; border-top: 1px solid var(--line); cursor: pointer; border-radius: 10px; }
.acc:first-child { border-top: 0; }
.acc:hover { background: var(--card-2); }
.acc .acc-color { width: 6px; height: 2.4rem; border-radius: 3px; }
.acc .concept, .led .concept { font-weight: 600; }
.acc .meta, .led .meta { font-size: .8rem; color: var(--muted); }
.acc .amount, .led .amount { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc .amount { font-size: 1.1rem; }
.acc-color { display: inline-block; width: 6px; height: 1.1rem; border-radius: 3px; margin-right: .5rem; vertical-align: -2px; }
.pill { font-size: .68rem; padding: .12rem .5rem; border-radius: 99px; font-weight: 700; }
.pill.empresa { background: rgb(59 130 246 / .16); color: #60a5fa; }
.pill.casa { background: rgb(34 197 94 / .16); color: #4ade80; }
.pill.ahorro { background: rgb(255 194 26 / .16); color: var(--yellow); }

/* Extracto de cuenta */
.ledger-saldo { font-size: 1.7rem; font-weight: 750; margin-top: .2rem; font-variant-numeric: tabular-nums; }
.ledger-actions { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.ledger { max-height: 55vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.led { display: grid; grid-template-columns: 5.6rem 1fr auto 2rem; gap: .7rem; align-items: center; padding: .6rem .8rem; border-bottom: 1px solid var(--line); }
.led:last-child { border-bottom: 0; }
.led[data-kind=expense] { cursor: pointer; }
.led[data-kind=expense]:hover { background: var(--card-2); }
.led.start { background: var(--card-2); }
.led .date { font-size: .8rem; color: var(--muted); }
.led .amount small { display: block; font-weight: 400; font-size: .75rem; color: var(--muted); }

/* Diálogos: hoja inferior en el móvil, ventana centrada en escritorio */
dialog {
  border: 1px solid var(--line); border-radius: 22px; padding: 0; width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px); background: var(--card); color: var(--text); box-shadow: 0 30px 80px rgb(0 0 0 / .6);
}
dialog::backdrop { background: rgb(0 0 0 / .7); backdrop-filter: blur(3px); }
dialog.wide { width: min(760px, calc(100vw - 24px)); }
dialog.xl { width: min(1000px, calc(100vw - 24px)); }
dialog.confirm { width: min(420px, calc(100vw - 24px)); }
dialog.confirm p { line-height: 1.5; }
@media (max-width: 640px) {
  dialog:not(.confirm) {
    width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; border-bottom: 0;
    max-height: 92vh; padding-bottom: env(safe-area-inset-bottom);
  }
}
#exp-form, .dlg-body { padding: 1.2rem; }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; gap: .5rem; }
.dlg-head h3 { margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.span2 { grid-column: span 2; }
label.check { flex-direction: row; align-items: center; gap: .55rem; color: var(--text); font-size: .9rem; }
.ticket-box { display: flex; flex-direction: column; gap: .4rem; font-size: .85rem; color: var(--muted); }
.ticket-box a { color: var(--orange); }
#iva-preview { margin: -.3rem 0 0; }
.dlg-foot { display: flex; gap: .5rem; margin-top: 1rem; align-items: center; flex-wrap: wrap; }
#form-ambito button.on[data-ambito=empresa], #form-ambito button.on[data-ambito=casa] { color: #fff; }

/* Importar extracto */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .4rem; text-align: center;
  padding: 2.5rem 1rem; border: 2px dashed var(--line); border-radius: 16px; cursor: pointer; color: var(--text); }
.dropzone:hover, .dropzone.over { border-color: var(--orange); background: rgb(255 106 16 / .07); }
.dropzone input { display: none; }
.imp-mapping { border: 1px solid var(--line); border-radius: 14px; padding: .6rem .9rem; margin-bottom: .8rem; }
.imp-mapping summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .6rem; margin-top: .8rem; }
.imp-sample { margin-top: .7rem; font-size: .75rem; color: var(--muted); overflow-x: auto; white-space: nowrap; }
.imp-bar { display: flex; justify-content: space-between; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.imp-filter button { padding: .4rem .7rem; font-size: .82rem; }
.imp-list { max-height: 48vh; overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.imp-row { display: grid; grid-template-columns: 5.4rem minmax(0, 1fr) 6.5rem 8.5rem minmax(0, 11rem); gap: .6rem; align-items: center;
  padding: .5rem .7rem; border-bottom: 1px solid var(--line); font-size: .88rem; }
.imp-row:last-child { border-bottom: 0; }
.imp-row.off { opacity: .45; }
.imp-row .date { color: var(--muted); font-size: .8rem; }
.imp-row .conc { min-width: 0; }
.imp-row .conc input, .imp-row select { padding: .35rem .5rem; font-size: .85rem; border-radius: 9px; }
.imp-row .flags { display: flex; gap: .3rem; margin-top: .2rem; flex-wrap: wrap; }
.imp-row .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.flag { font-size: .68rem; padding: .05rem .4rem; border-radius: 99px; background: var(--card-2); color: var(--muted); }
.flag.dup { background: rgb(255 194 26 / .16); color: var(--yellow); }
.imp-saldo { margin-top: .8rem; display: flex; flex-direction: column; gap: .35rem; font-size: .88rem; }
.imp-saldo label { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); font-size: .88rem; }
.imp-totals { margin-top: .6rem; display: flex; gap: 1.2rem; flex-wrap: wrap; font-size: .88rem; color: var(--muted); }
.imp-totals b { color: var(--text); }

/* Botón flotante y aviso */
.fab {
  position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer; z-index: 15;
  background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 10px 28px rgb(255 60 20 / .45);
}
.fab .ico { width: 26px; height: 26px; stroke-width: 2.6; }
@media (min-width: 900px) { .fab { bottom: 28px; right: 32px; } }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%) translateY(20px);
  background: #fff; color: #111; padding: .65rem 1rem; border-radius: 12px; font-weight: 550;
  opacity: 0; pointer-events: none; transition: .2s; font-size: .9rem; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 560px) {
  h1 { font-size: 1.75rem; }
  .hello { font-size: 1.75rem; }
  .kpi-card .k-value { font-size: 1.5rem; }
  .kpi-card .spark { width: 40px; height: 28px; right: 10px; bottom: 10px; }
  .kpi-card .k-delta { padding-right: 42px; }
  .saldo-card .s-value { font-size: 1.6rem; }
  .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: span 1; }
  .quick { gap: .45rem; }
  .quick button { font-size: .72rem; padding: .75rem .2rem .65rem; }
  .led { grid-template-columns: 4.6rem 1fr auto 1.6rem; gap: .5rem; padding: .55rem .6rem; }
  .imp-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .imp-row .date { grid-column: 1 / -1; margin-bottom: -.4rem; }
  .imp-filter { max-width: 100%; overflow-x: auto; }
  .view-head .chip.scope { order: 5; }
}

.row.static { cursor: default; }
.row.static:hover { background: none; }
.row.off { opacity: .5; }
.r-main .c-bar { height: 6px; background: var(--card-2); border-radius: 99px; overflow: hidden; margin-top: .4rem; }
.r-main .c-bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.home-head .brand .logo-word { height: 32px; }
@media (max-width: 560px) {
  .logo-sym { height: 38px; }
  .home-head .brand .logo-word { height: 28px; }
  .net-card .n-value { font-size: 1.7rem; }
}

/* Usuarios */
.readonly [data-w] { display: none !important; }
body:not(.is-admin) .admin-only { display: none !important; }
.p-name { font-weight: 700; font-size: 1.1rem; }
.p-tags { display: flex; gap: .35rem; flex-wrap: wrap; margin-top: .35rem; }
.chk-row { display: flex; gap: 1.2rem; flex-wrap: wrap; }
.mini-av { width: 18px; height: 18px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .62rem; font-weight: 700; color: #fff; background: var(--slate); flex: none; }
#setup-form h2 { font-size: 1.2rem; }
#setup-form input, #login-form input { text-align: left; }

/* Asistente de IA */
.ia-banner { background: rgb(255 138 0 / .1); border: 1px solid rgb(255 138 0 / .35); border-radius: 12px; padding: .65rem .8rem; margin-bottom: .9rem; font-size: .86rem; color: var(--light); }
.ia-banner b { color: var(--orange); }
.ia-photo { position: relative; margin: .9rem 0 .6rem; }
.ia-shot { flex-direction: row; align-items: center; gap: .8rem; padding: .8rem; border: 2px dashed var(--line); border-radius: 14px; cursor: pointer; color: var(--text); font-size: .95rem; }
.ia-shot:hover { border-color: var(--orange); }
.ia-shot input { display: none; }
#ia-preview { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
#ia-photo-x { position: absolute; top: 6px; right: 6px; background: rgb(0 0 0 / .6); color: #fff; }
.ia-text { display: flex; gap: .5rem; align-items: flex-start; }
.ia-text textarea { flex: 1; }
#ia-mic.rec { border-color: var(--red); color: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(255 45 45 / .25); } }
.dlg-head h3 { display: flex; align-items: center; gap: .4rem; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--orange); border-radius: 50%; animation: sp .8s linear infinite; vertical-align: -2px; margin-right: .35rem; }
@keyframes sp { to { transform: rotate(360deg); } }

/* Inicio: elegir Casa, Empresa o Todo con botones grandes */
.scope-big { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .6rem; }
.scope-big button {
  display: flex; align-items: center; justify-content: center; gap: .6rem; min-height: 64px; padding: .7rem .6rem;
  border-radius: 18px; border: 1px solid var(--line); background: var(--card); color: var(--light);
  font-size: 1.02rem; font-weight: 600; cursor: pointer; transition: background .15s, transform .1s;
}
.scope-big button:active { transform: scale(.98); }
.scope-big button:hover { background: var(--card-2); }
.scope-big .sb-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--bg-2); border: 1px solid var(--line); flex: none; }
.scope-big .sb-ico .ico { width: 19px; height: 19px; stroke: url(#igrad); }
.scope-big button.on { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 26px rgb(255 60 20 / .35); }
.scope-big button.on .sb-ico { background: rgb(255 255 255 / .18); border-color: rgb(255 255 255 / .25); }
.scope-big button.on .sb-ico .ico { stroke: #fff; }
@media (max-width: 420px) {
  .scope-big button { flex-direction: column; gap: .35rem; min-height: 78px; font-size: .92rem; }
}
