/* ===========================================================
   Zoe Tiendita — tema otoñal
   =========================================================== */
:root {
  --ink: #3b2416;
  --ink-soft: #7a5a44;
  --muted: #a4846b;
  --paper: rgba(255, 249, 238, .66);
  --paper-solid: #fffaf1;
  --line: rgba(122, 74, 40, .16);

  --pumpkin: #e8772e;
  --pumpkin-dark: #c95e1b;
  --rust: #b8461f;
  --cranberry: #a8323e;
  --mustard: #e3a92f;
  --olive: #5f7d32;

  --in: #4f7d2e;
  --in-bg: #e6efd3;
  --out: #b33a2f;
  --out-bg: #f9ddd5;
  --warn: #c07c0c;
  --warn-bg: #fdefcd;

  --radius: 22px;
  --shadow: 0 14px 34px -16px rgba(110, 52, 18, .45), 0 2px 6px rgba(110, 52, 18, .07);
  --font-head: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --spring: cubic-bezier(.3, 1.5, .5, 1);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #f7c48c linear-gradient(180deg, #fff1d8 0%, #fdd9a8 38%, #f5b273 72%, #ec9a5b 100%) fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { font-family: var(--font-head); font-weight: 600; margin: 0; }
button { font-family: inherit; color: inherit; }
::selection { background: #f5c07a; }

/* ---------- fondo ---------- */
.scene {
  position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden;
  background: #f3b06e;
}
.scene::before {
  content: ''; position: absolute; inset: -3%;
  background: url('img/fondo.jpg') center / cover no-repeat;
  background-image: image-set(url('img/fondo.webp') type('image/webp'), url('img/fondo.jpg') type('image/jpeg'));
  animation: paneo 45s ease-in-out infinite alternate;
}
/* velo cálido para que el texto se lea sobre la ilustración */
.scene::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255, 244, 226, .55) 0%, rgba(255, 240, 220, .22) 40%, rgba(255, 236, 214, .12) 100%);
}
@keyframes paneo { from { transform: scale(1) translate(0, 0); } to { transform: scale(1.06) translate(-1%, -1%); } }

/* ---------- hojas que caen ---------- */
.leaves { position: fixed; inset: 0; z-index: 1; pointer-events: none; overflow: hidden; }
.leaf { position: absolute; top: -8vh; animation: caer linear infinite; will-change: transform; }
.leaf > span { display: inline-block; animation: vaiven ease-in-out infinite alternate; }
@keyframes caer { to { transform: translateY(118vh); } }
@keyframes vaiven {
  from { transform: translateX(-34px) rotate(-30deg); }
  to   { transform: translateX(34px) rotate(40deg); }
}

/* ---------- layout ---------- */
.app {
  position: relative; z-index: 2;
  display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 26px;
  max-width: 1420px; margin: 0 auto; padding: 20px;
}
main { min-width: 0; padding-bottom: 40px; }

.glass, .sidebar, .card {
  background: var(--paper);
  -webkit-backdrop-filter: blur(5px) saturate(1.3);
  backdrop-filter: blur(5px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .7);
  box-shadow: var(--shadow);
}

/* ---------- sidebar ---------- */
.sidebar {
  position: sticky; top: 20px; height: calc(100vh - 40px);
  display: flex; flex-direction: column; gap: 18px;
  padding: 22px 14px; border-radius: 30px;
}
.brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 0 8px 16px; border-bottom: 2px dashed var(--line); }
.brand-logo { width: 160px; height: 160px; flex: none; border-radius: 50%; filter: drop-shadow(0 4px 8px rgba(150, 70, 20, .3)); transition: transform .5s var(--spring); }
.brand:hover .brand-logo { transform: rotate(-6deg) scale(1.05); }
.brand h1 { font-size: 1.5rem; line-height: 1; color: var(--rust); letter-spacing: -.01em; }
.brand small { color: var(--ink-soft); font-weight: 800; font-size: .74rem; letter-spacing: .08em; text-transform: uppercase; }

nav { display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: 0; border-radius: 16px; background: transparent;
  font: 800 1rem var(--font); color: var(--ink-soft); cursor: pointer; text-align: left;
  transition: background .25s, color .25s, box-shadow .25s, transform .2s;
}
.nav-btn .ico { font-size: 1.25rem; transition: transform .35s var(--spring); }
.nav-btn:hover { background: rgba(232, 119, 46, .12); color: var(--ink); }
.nav-btn:hover .ico { transform: rotate(-12deg) scale(1.25); }
.nav-btn:active { transform: scale(.97); }
.nav-btn.active {
  background: linear-gradient(135deg, #f08a3c, var(--rust));
  color: #fff; box-shadow: 0 10px 20px -10px rgba(184, 70, 31, .9);
}
.nav-badge {
  margin-left: auto; min-width: 22px; text-align: center;
  background: var(--cranberry); color: #fff; font-size: .72rem; font-weight: 900;
  border-radius: 999px; padding: 2px 7px; animation: latido 2s ease-in-out infinite;
}
.nav-btn.active .nav-badge { background: #fff; color: var(--rust); }
@keyframes latido { 50% { transform: scale(1.15); } }

.sidebar-foot {
  margin-top: auto; padding: 14px; border-radius: 18px;
  background: repeating-linear-gradient(-45deg, rgba(232, 119, 46, .07) 0 10px, rgba(232, 119, 46, .02) 10px 20px);
  border: 2px dashed rgba(232, 119, 46, .3);
  font-size: .84rem; color: var(--ink-soft); line-height: 1.45;
}
.sidebar-foot p { margin: 4px 0 0; }
.paw { font-size: 1.3rem; display: inline-block; animation: latido 3s ease-in-out infinite; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin: 6px 0 22px;
}
.title-wrap { display: flex; align-items: center; gap: 14px; }
.view-icon {
  width: 58px; height: 58px; display: grid; place-items: center; font-size: 1.8rem;
  border-radius: 20px; background: var(--paper); box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, .7);
  animation: rebote .7s var(--spring);
}
.topbar h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); color: var(--ink); line-height: 1.05; text-shadow: 0 1px 0 #fff8ec, 0 0 14px rgba(255, 246, 230, .95), 0 0 4px rgba(255, 246, 230, .9); }
.topbar p { margin: 3px 0 0; color: #5e3f2a; font-weight: 800; text-shadow: 0 0 10px rgba(255, 246, 230, .95), 0 0 3px rgba(255, 246, 230, .9); }
.top-actions { display: flex; gap: 10px; flex-wrap: wrap; }
/* logo grande arriba, solo en teléfono */
.mobile-logo { display: none; justify-content: center; margin: 2px 0 10px; }
.mobile-logo img { width: min(190px, 52vw); height: auto; border-radius: 50%; filter: drop-shadow(0 10px 18px rgba(120, 50, 15, .35)); animation: flotarLogo 4s ease-in-out infinite alternate; }
@keyframes flotarLogo { to { transform: translateY(-6px) rotate(-2deg); } }
@keyframes mecer { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
.enter > .stack > .hero { animation: subir .65s var(--ease) both; }
@keyframes rebote { from { transform: scale(.4) rotate(-20deg); opacity: 0; } }

/* ---------- tarjetas ---------- */
.card { border-radius: var(--radius); padding: 20px; position: relative; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h3 { font-size: 1.15rem; display: flex; align-items: center; gap: 8px; }
.card-head .link { font-weight: 800; font-size: .88rem; color: var(--rust); background: none; border: 0; cursor: pointer; padding: 4px 6px; border-radius: 8px; }
.card-head .link:hover { background: rgba(232, 119, 46, .12); }

.enter .card, .enter .stat, .enter .debt-card { animation: subir .65s var(--ease) both; animation-delay: calc(var(--i, 0) * 65ms); }
@keyframes subir { from { opacity: 0; transform: translateY(18px) scale(.98); } }

.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.stat {
  display: flex; align-items: center; gap: 14px; padding: 18px; border-radius: var(--radius);
  overflow: hidden; transition: transform .35s var(--spring), box-shadow .3s;
}
.stat:hover { transform: translateY(-5px) rotate(-.6deg); box-shadow: 0 22px 40px -18px rgba(110, 52, 18, .55); }
.stat::after {
  content: '🍁'; position: absolute; right: -10px; bottom: -16px; font-size: 64px; opacity: .08;
  transform: rotate(-20deg); transition: transform .6s var(--spring), opacity .3s;
}
.stat:hover::after { transform: rotate(10deg) scale(1.15); opacity: .16; }
.stat-ico {
  width: 52px; height: 52px; flex: none; display: grid; place-items: center; font-size: 1.55rem;
  border-radius: 16px; background: #fde6c6;
}
.stat.in .stat-ico { background: var(--in-bg); }
.stat.out .stat-ico { background: var(--out-bg); }
.stat.warn .stat-ico { background: var(--warn-bg); }
.stat-label { display: block; font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat-value { display: block; font-family: var(--font-head); font-weight: 600; font-size: 1.65rem; line-height: 1.15; margin-top: 2px; white-space: nowrap; }
.stat.in .stat-value { color: var(--in); }
.stat.out .stat-value { color: var(--out); }
.stat-hint { color: var(--muted); font-weight: 700; font-size: .8rem; }
.stats.mini .stat { padding: 14px; }
.stats.mini .stat-value { font-size: 1.35rem; }
.stats.mini .stat-ico { width: 44px; height: 44px; font-size: 1.3rem; border-radius: 14px; }

/* ---------- hero del panel ---------- */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  padding: 26px 28px; border-radius: 28px; color: #fff; overflow: hidden;
  background:
    radial-gradient(circle at 92% -20%, rgba(255, 220, 150, .55), transparent 45%),
    linear-gradient(120deg, #ee8237 0%, #c94d26 55%, #a8323e 100%);
  border: 1px solid rgba(255, 255, 255, .35);
}
.hero h3 { font-size: clamp(1.5rem, 3vw, 2rem); }
.hero p { margin: 6px 0 0; font-weight: 700; opacity: .92; }
.hero .fecha { text-transform: uppercase; font-weight: 900; font-size: .82rem; letter-spacing: .08em; opacity: .85; display: block; margin-bottom: 4px; }
.hero-deco { position: absolute; inset: 0; pointer-events: none; }
.hero-deco span { position: absolute; font-size: 28px; opacity: .3; animation: flotar 6s ease-in-out infinite alternate; }
@keyframes flotar { to { transform: translateY(-12px) rotate(25deg); } }
.hero .quick { display: flex; gap: 8px; flex-wrap: wrap; position: relative; }
.hero .btn.glassy {
  background: rgba(255, 255, 255, .18); color: #fff; border: 1px solid rgba(255, 255, 255, .45);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.hero .btn.glassy:hover { background: rgba(255, 255, 255, .3); }
.hero .btn.white { background: #fff; color: var(--rust); }

.empty-hero { text-align: center; padding: 34px 20px; }
.empty-hero .big { font-size: 3.4rem; display: inline-block; animation: flotar 3s ease-in-out infinite alternate; }
.empty-hero h3 { font-size: 1.5rem; margin: 8px 0 6px; }
.empty-hero p { color: var(--ink-soft); font-weight: 700; margin: 0 auto 16px; max-width: 460px; }
.empty-hero .row { justify-content: center; }

.tip {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--warn-bg); border: 2px dashed #e9bf6a; border-radius: 18px; padding: 12px 16px; font-weight: 700;
}
.tip p { margin: 0; flex: 1; min-width: 200px; }

.grid-panel { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.span2 { grid-column: span 2; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

/* ---------- gráfico ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gl { stroke: rgba(122, 74, 40, .14); stroke-dasharray: 4 6; }
.chart .lbl { font: 800 12px var(--font); fill: var(--ink-soft); text-transform: capitalize; }
.chart .val { font: 800 10px var(--font); fill: var(--muted); }
.chart .bar { transform-box: fill-box; transform-origin: 50% 100%; transition: opacity .2s, filter .2s; cursor: default; }
.enter .chart .bar { animation: crecer .9s var(--ease) both; animation-delay: calc(var(--i) * 70ms + 200ms); }
.chart .bar:hover { filter: brightness(1.12) drop-shadow(0 4px 6px rgba(0, 0, 0, .15)); }
@keyframes crecer { from { transform: scaleY(0); } }
.legend { display: flex; gap: 14px; font-size: .82rem; font-weight: 800; color: var(--ink-soft); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }

/* ---------- listas simples ---------- */
.list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.list li {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, .45); transition: transform .25s var(--spring), background .2s;
}
.list li:hover { transform: translateX(4px); background: rgba(255, 255, 255, .85); }
.list .grow { flex: 1; min-width: 0; }
.list b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list small { color: var(--muted); font-weight: 700; }
.list .em { font-size: 1.4rem; }
.bar-mini { height: 7px; border-radius: 99px; background: rgba(122, 74, 40, .1); margin-top: 6px; overflow: hidden; }
.bar-mini span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mustard), var(--pumpkin)); }
.enter .bar-mini span { animation: llenar 1s var(--ease) both .3s; transform-origin: left; }
@keyframes llenar { from { transform: scaleX(0); } }

.nada { text-align: center; color: var(--muted); font-weight: 700; padding: 22px 10px; }
.nada .big { font-size: 2.2rem; display: block; margin-bottom: 6px; }

/* ---------- movimientos ---------- */
.mov-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.mov {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 16px; background: rgba(255, 255, 255, .5);
  border-left: 5px solid transparent; transition: transform .25s var(--spring), background .2s, box-shadow .2s;
}
.mov:hover { transform: translateY(-2px); background: rgba(255, 255, 255, .92); box-shadow: 0 8px 18px -12px rgba(110, 52, 18, .5); }
.mov.ingreso { border-left-color: var(--in); }
.mov.egreso { border-left-color: var(--out); }
.mov-ico {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px;
  font-weight: 900; font-size: 1.1rem;
}
.mov.ingreso .mov-ico { background: var(--in-bg); color: var(--in); }
.mov.egreso .mov-ico { background: var(--out-bg); color: var(--out); }
.mov-main b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mov-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; align-items: center; }
.mov-nota { color: var(--muted); font-size: .8rem; font-weight: 700; font-style: italic; }
.mov-monto { font-family: var(--font-head); font-weight: 600; font-size: 1.1rem; white-space: nowrap; }
.mov.ingreso .mov-monto { color: var(--in); }
.mov.egreso .mov-monto { color: var(--out); }
.mov-act { display: flex; gap: 4px; opacity: .55; transition: opacity .2s; }
.mov:hover .mov-act { opacity: 1; }
.mov-fecha { color: var(--muted); font-weight: 800; font-size: .78rem; white-space: nowrap; }

.day + .day { margin-top: 18px; }
.day-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 0 4px 8px; font-weight: 900; color: var(--ink-soft); font-size: .86rem;
}
.day-head small { font-weight: 800; color: var(--muted); }

.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  background: rgba(232, 119, 46, .12); color: var(--rust); font-size: .74rem; font-weight: 800; white-space: nowrap;
}
.chip.green { background: var(--in-bg); color: var(--in); }
.chip.red { background: var(--out-bg); color: var(--out); }
.chip.gray { background: rgba(122, 74, 40, .08); color: var(--ink-soft); }

/* ---------- barra de herramientas ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 240px; }
.search::before { content: '🔎'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: .95rem; pointer-events: none; }
.search input { padding-left: 38px; }
.toolbar select { width: auto; flex: 0 1 220px; }
.seg { display: inline-flex; background: rgba(122, 74, 40, .08); border-radius: 14px; padding: 4px; gap: 2px; }
.seg button {
  border: 0; background: transparent; padding: 7px 13px; border-radius: 10px; font-weight: 800; font-size: .88rem;
  color: var(--ink-soft); cursor: pointer; transition: background .2s, color .2s, box-shadow .2s;
}
.seg button.on { background: #fff; color: var(--rust); box-shadow: 0 3px 8px -4px rgba(110, 52, 18, .5); }
.month-nav { display: inline-flex; align-items: center; gap: 6px; background: rgba(255, 255, 255, .7); border-radius: 14px; padding: 4px; }
.month-nav b { min-width: 150px; text-align: center; text-transform: capitalize; font-family: var(--font-head); font-weight: 600; }

/* ---------- tabla ---------- */
.tbl-wrap { overflow-x: auto; margin: 0 -6px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0 6px; }
.tbl th {
  text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--ink-soft); font-weight: 900; padding: 4px 12px;
}
.tbl td { padding: 10px 12px; background: rgba(255, 255, 255, .5); transition: background .2s; }
.tbl tr td:first-child { border-radius: 14px 0 0 14px; }
.tbl tr td:last-child { border-radius: 0 14px 14px 0; }
.tbl tbody tr { transition: transform .25s var(--spring); }
.tbl tbody tr:hover { transform: translateY(-2px); }
.tbl tbody tr:hover td { background: rgba(255, 255, 255, .95); }
.tbl .num { text-align: right; white-space: nowrap; font-weight: 800; }
.tbl tr.low td { background: rgba(253, 239, 205, .8); }
.prod { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.prod-emoji {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center; font-size: 1.5rem;
  border-radius: 14px; background: linear-gradient(135deg, #fff1dc, #fbd9ad);
  transition: transform .4s var(--spring);
}
tr:hover .prod-emoji { transform: rotate(-12deg) scale(1.12); }
.prod small { display: block; color: var(--muted); font-weight: 700; font-size: .8rem; }
.stock-pill {
  display: inline-block; min-width: 46px; text-align: center; padding: 4px 10px; border-radius: 999px;
  font-weight: 900; background: var(--in-bg); color: var(--in);
}
.stock-pill.low { background: var(--warn-bg); color: var(--warn); }
.stock-pill.zero { background: var(--out-bg); color: var(--out); }
.actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; white-space: nowrap; }

/* ---------- botones ---------- */
.btn {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px; padding: 10px 16px; cursor: pointer;
  font: 800 .95rem var(--font); background: rgba(122, 74, 40, .09); color: var(--ink);
  transition: transform .2s var(--spring), box-shadow .25s, background .2s, filter .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(0) scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(135deg, #f39144, var(--pumpkin-dark)); color: #fff; box-shadow: 0 8px 16px -8px rgba(201, 94, 27, .9); }
.btn.green { background: linear-gradient(135deg, #79a046, var(--in)); color: #fff; box-shadow: 0 8px 16px -8px rgba(79, 125, 46, .9); }
.btn.red { background: linear-gradient(135deg, #d0574a, var(--cranberry)); color: #fff; box-shadow: 0 8px 16px -8px rgba(168, 50, 62, .9); }
.btn.danger { background: linear-gradient(135deg, #d0574a, #8f2430); color: #fff; }
.btn.ghost { background: rgba(122, 74, 40, .08); }
.btn.ghost:hover { background: rgba(122, 74, 40, .14); }
.btn.sm { padding: 6px 12px; font-size: .84rem; border-radius: 11px; }
.btn:hover.primary, .btn:hover.green, .btn:hover.red { filter: brightness(1.06); }
.ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .55); transform: scale(0); animation: onda .6s ease-out; pointer-events: none; }
@keyframes onda { to { transform: scale(2.4); opacity: 0; } }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.icon-btn {
  width: 36px; height: 36px; flex: none; display: inline-grid; place-items: center;
  border: 0; border-radius: 12px; background: rgba(122, 74, 40, .07); cursor: pointer; font-size: .95rem;
  transition: transform .25s var(--spring), background .2s;
}
.icon-btn:hover { background: rgba(232, 119, 46, .2); transform: scale(1.12) rotate(-6deg); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

/* ---------- formularios ---------- */
input, select, textarea {
  width: 100%; font: 700 .95rem var(--font); color: var(--ink);
  background: #fffdf8; border: 2px solid #f0dcc2; border-radius: 13px; padding: 10px 12px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--pumpkin); box-shadow: 0 0 0 4px rgba(232, 119, 46, .18); background: #fff; }
input[readonly] { background: #f7efe3; color: var(--ink-soft); }
input::placeholder, textarea::placeholder { color: #c4a78c; font-weight: 600; }
textarea { resize: vertical; min-height: 70px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: .74rem; font-weight: 900; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 > .span2, .grid2 > .full { grid-column: 1 / -1; }
.hint { font-size: .84rem; color: var(--ink-soft); font-weight: 700; margin: 12px 0 0; }

.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 800; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-ui {
  width: 46px; height: 26px; flex: none; border-radius: 99px; background: #e8d6bf; position: relative; transition: background .25s;
}
.switch-ui::after {
  content: ''; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, .2); transition: transform .3s var(--spring);
}
.switch input:checked + .switch-ui { background: var(--pumpkin); }
.switch input:checked + .switch-ui::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-ui { box-shadow: 0 0 0 4px rgba(232, 119, 46, .25); }

.emoji-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.emoji-pick button {
  width: 38px; height: 38px; border-radius: 12px; border: 2px solid transparent; background: rgba(122, 74, 40, .06);
  font-size: 1.2rem; cursor: pointer; transition: transform .25s var(--spring), border-color .2s, background .2s;
}
.emoji-pick button:hover { transform: scale(1.15) rotate(-8deg); }
.emoji-pick button.on { border-color: var(--pumpkin); background: #fff; }

.total-live {
  margin-top: 16px; display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-radius: 16px; background: linear-gradient(135deg, #fff1dc, #fde0b9);
  font-weight: 900; color: var(--ink-soft);
}
.total-live b { font-family: var(--font-head); font-size: 1.6rem; color: var(--rust); display: inline-block; }
.bump { animation: bump .35s var(--spring); }
@keyframes bump { 40% { transform: scale(1.15); } }
.quick-amt { display: flex; gap: 6px; margin-top: 6px; }

.resumen-deuda {
  display: flex; gap: 14px; align-items: center; padding: 12px 14px; border-radius: 16px;
  background: rgba(232, 119, 46, .08); margin-bottom: 16px;
}
.resumen-deuda .avatar { width: 44px; height: 44px; font-size: 1.1rem; }
.resumen-deuda b { display: block; }
.resumen-deuda small { color: var(--ink-soft); font-weight: 700; }
.resumen-deuda .saldo { margin-left: auto; text-align: right; }
.resumen-deuda .saldo b { font-family: var(--font-head); font-size: 1.3rem; color: var(--cranberry); }

/* ---------- modal ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  width: min(580px, calc(100vw - 24px)); max-height: calc(100vh - 32px); overflow: visible;
}
dialog::backdrop { background: rgba(59, 36, 22, .42); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); animation: fade .25s; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  background: var(--paper-solid); border-radius: 28px; overflow: hidden;
  box-shadow: 0 30px 70px -20px rgba(70, 30, 10, .6);
  animation: pop .42s var(--spring);
  max-height: calc(100vh - 32px); display: flex; flex-direction: column;
}
dialog.closing .modal-card { animation: popout .2s ease-in forwards; }
dialog.closing::backdrop { opacity: 0; transition: opacity .2s; }
@keyframes pop { from { opacity: 0; transform: translateY(24px) scale(.92); } }
@keyframes popout { to { opacity: 0; transform: translateY(12px) scale(.95); } }
.plaid {
  height: 12px; flex: none;
  background:
    repeating-linear-gradient(90deg, rgba(120, 30, 30, .45) 0 7px, transparent 7px 20px),
    repeating-linear-gradient(0deg, rgba(120, 30, 30, .45) 0 7px, transparent 7px 20px),
    #e8772e;
}
.plaid.in { background-color: #6f9a3e; }
.plaid.out { background-color: #c0473c; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px 6px; }
.modal-head h2 { font-size: 1.4rem; flex: 1; }
.modal-icon { font-size: 1.7rem; display: inline-block; animation: rebote .6s var(--spring); }
.modal-body { padding: 14px 22px 6px; overflow-y: auto; }
.modal-body p.lead { margin: 0; font-weight: 700; color: var(--ink-soft); line-height: 1.5; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px 20px; }

/* ---------- deudores ---------- */
.debt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 18px; }
.debt-card {
  border-radius: var(--radius); padding: 18px; display: flex; flex-direction: column; gap: 12px;
  background: var(--paper); -webkit-backdrop-filter: blur(5px) saturate(1.3); backdrop-filter: blur(5px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .7); box-shadow: var(--shadow);
  border-top: 6px solid var(--mustard);
  transition: transform .35s var(--spring), box-shadow .3s;
}
.debt-card:hover { transform: translateY(-5px) rotate(.4deg); box-shadow: 0 24px 44px -20px rgba(110, 52, 18, .6); }
.debt-card.vencida { border-top-color: var(--cranberry); }
.debt-card.pronto { border-top-color: var(--pumpkin); }
.debt-card.pagada { border-top-color: var(--in); opacity: .85; }
.debt-top { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 48px; height: 48px; flex: none; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 1.25rem; color: #fff;
  background: linear-gradient(135deg, var(--mustard), var(--pumpkin));
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.debt-top h3 { font-size: 1.15rem; line-height: 1.1; }
.debt-top small { color: var(--muted); font-weight: 700; }
.debt-top a { color: var(--in); font-weight: 800; text-decoration: none; }
.debt-top .badge { margin-left: auto; }
.badge { padding: 4px 10px; border-radius: 999px; font-size: .74rem; font-weight: 900; white-space: nowrap; background: var(--warn-bg); color: var(--warn); }
.badge.vencida { background: var(--out-bg); color: var(--out); animation: latido 2.2s ease-in-out infinite; }
.badge.pronto { background: #fde1c9; color: var(--pumpkin-dark); }
.badge.pagada { background: var(--in-bg); color: var(--in); }
.debt-concept { margin: 0; font-weight: 700; color: var(--ink-soft); }
.debt-amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.debt-amounts div { background: rgba(255, 255, 255, .5); border-radius: 14px; padding: 8px 4px; }
.debt-amounts small { display: block; font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.debt-amounts b { font-family: var(--font-head); font-weight: 600; font-size: 1.05rem; }
.debt-amounts .saldo b { color: var(--cranberry); font-size: 1.2rem; }
.pagada .debt-amounts .saldo b { color: var(--in); }
.progress { height: 10px; border-radius: 99px; background: rgba(122, 74, 40, .1); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mustard), var(--in)); transform-origin: left; }
.enter .progress span { animation: llenar 1.1s var(--ease) both .35s; }
.debt-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: .82rem; font-weight: 800; color: var(--ink-soft); }
.debt-card details { background: rgba(255, 255, 255, .45); border-radius: 14px; padding: 8px 12px; }
.debt-card summary { cursor: pointer; font-weight: 800; font-size: .86rem; color: var(--ink-soft); }
.abonos { list-style: none; padding: 0; margin: 8px 0 2px; display: grid; gap: 6px; }
.abonos li { display: flex; align-items: center; gap: 8px; font-size: .88rem; font-weight: 700; }
.abonos li span { flex: 1; color: var(--ink-soft); }
.abonos li b { color: var(--in); }
.abonos .icon-btn { width: 28px; height: 28px; font-size: .78rem; border-radius: 9px; }
.debt-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: auto; }
.debt-actions .btn { flex: 1; }
.notas { font-size: .84rem; color: var(--ink-soft); font-style: italic; margin: 0; }

.clientes { display: flex; flex-wrap: wrap; gap: 8px; }
.cliente-chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: rgba(255, 255, 255, .7); font-weight: 800; font-size: .88rem; cursor: pointer; border: 0;
  transition: transform .25s var(--spring), background .2s;
}
.cliente-chip:hover { transform: translateY(-2px); background: #fff; }
.cliente-chip .avatar { width: 28px; height: 28px; font-size: .8rem; }
.cliente-chip b { color: var(--cranberry); }

/* ---------- ajustes ---------- */
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { margin: 2px 0 0; color: var(--ink-soft); font-size: .86rem; font-weight: 600; }
.card p.desc { margin: 0 0 14px; color: var(--ink-soft); font-weight: 600; line-height: 1.5; }
.danger-zone { border: 2px dashed rgba(168, 50, 62, .35); }

/* ---------- nube: indicador y pantalla de acceso ---------- */
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.sync-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--paper); border: 1px solid rgba(255, 255, 255, .7); box-shadow: var(--shadow);
  font-size: .8rem; color: var(--ink-soft); white-space: nowrap;
}
.sync-pill.ok b { color: var(--in); }
.sync-pill.saving span { display: inline-block; animation: latido 1s ease-in-out infinite; }
.sync-pill.err { background: var(--out-bg); }
.sync-pill.err b { color: var(--out); }

body.bloqueado { overflow: hidden; }
body.bloqueado .app { visibility: hidden; }
.auth {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 30% 20%, rgba(255, 244, 214, .7), transparent 60%);
}
.auth-card {
  width: min(400px, 100%); display: grid; gap: 14px; text-align: center;
  padding: 30px 26px; border-radius: 30px; background: var(--paper);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border: 1px solid rgba(255, 255, 255, .75); box-shadow: 0 30px 70px -24px rgba(110, 52, 18, .6);
  animation: pop .5s var(--spring);
}
.auth-card .field { text-align: left; }
.auth-card h1 { font-size: 2rem; color: var(--rust); line-height: 1; }
.auth-logo .brand-logo { width: min(200px, 55vw); height: auto; margin: -4px auto 0; display: block; }
.auth-logo.girando .brand-logo { animation: mecer 1s ease-in-out infinite alternate; }
.auth-sub { margin: 0; color: var(--ink-soft); font-weight: 700; }
.auth-msg { margin: 0; padding: 10px 14px; border-radius: 14px; background: var(--out-bg); color: var(--out); font-weight: 800; font-size: .9rem; }
.auth-card .btn { width: 100%; padding: 13px; font-size: 1.05rem; }
.auth-card .row .btn { width: auto; }

/* ---------- alerta: no se pudo guardar en el equipo ---------- */
.alerta-guardado {
  position: fixed; z-index: 70; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(640px, calc(100vw - 24px)); display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px; border-radius: 18px; background: #8f2430; color: #fff3e0;
  box-shadow: 0 18px 40px -14px rgba(60, 10, 10, .7); animation: toastIn .4s var(--spring);
}
.alerta-guardado > span { font-size: 1.4rem; }
.alerta-guardado p { margin: 0; flex: 1; min-width: 200px; font-weight: 700; }
.alerta-guardado .btn { background: #fff3e0; color: #8f2430; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: 360px;
  padding: 12px 18px 12px 14px; border-radius: 18px; background: #3b2416; color: #fff3e0;
  box-shadow: 0 16px 30px -12px rgba(40, 20, 8, .6); font-weight: 800;
  animation: toastIn .45s var(--spring);
}
.toast span { font-size: 1.3rem; display: inline-block; animation: girar 1s var(--ease); }
.toast p { margin: 0; }
.toast.warn { background: #8a5a12; }
.toast.error { background: #8f2430; }
.toast.out { animation: toastOut .3s ease-in forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px) scale(.9); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(40px); } }
@keyframes girar { from { transform: rotate(-180deg) scale(.3); } }

.burst {
  position: fixed; left: 50%; top: 45%; z-index: 100; font-size: 28px; pointer-events: none;
  animation: estallido 1.5s cubic-bezier(.2, .7, .3, 1) forwards;
}
@keyframes estallido {
  0% { transform: translate(-50%, -50%) scale(.2); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(1); opacity: 0; }
}

.foot { text-align: center; margin: 30px auto 0; width: fit-content; padding: 6px 14px; border-radius: 999px; background: rgba(255, 249, 238, .75); font-weight: 800; font-size: .84rem; color: var(--ink-soft); }

/* ---------- portafolio (admin del ERP y página pública) ---------- */
a.btn { text-decoration: none; }
.lbl-corto { display: none; }
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 18px; }
.pf-card {
  display: flex; flex-direction: column; border-radius: var(--radius); overflow: hidden; min-width: 0;
  background: var(--paper); -webkit-backdrop-filter: blur(5px) saturate(1.3); backdrop-filter: blur(5px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .7); box-shadow: var(--shadow);
  transition: transform .35s var(--spring), box-shadow .3s, opacity .3s;
}
.pf-card:hover { transform: translateY(-5px) rotate(-.4deg); box-shadow: 0 24px 44px -20px rgba(110, 52, 18, .6); }
.enter .pf-card { animation: subir .65s var(--ease) both; animation-delay: calc(min(var(--i, 0), 14) * 55ms); }
.pf-card.oculto { opacity: .6; }
.pf-foto {
  position: relative; display: block; width: 100%; aspect-ratio: 1; padding: 0; border: 0; cursor: pointer; overflow: hidden;
  background: linear-gradient(135deg, #fff1dc, #fbd9ad);
}
.pf-foto img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .6s var(--ease), filter .3s; }
.pf-card:hover .pf-foto img { transform: scale(1.05); }
.pf-card.agotado .pf-foto img { filter: grayscale(.7) brightness(.97); }
.pf-sinfoto { display: grid; place-items: center; height: 100%; font-size: 3rem; opacity: .45; }
.pf-marcas { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; gap: 5px; flex-wrap: wrap; }
.pf-marcas .chip { background: rgba(255, 250, 241, .93); box-shadow: 0 2px 6px rgba(70, 30, 10, .15); }
.pf-estado {
  position: absolute; right: 10px; bottom: 10px; padding: 5px 11px; border-radius: 999px;
  font-size: .76rem; font-weight: 900; color: #fff; background: var(--in); box-shadow: 0 4px 10px -4px rgba(40, 20, 8, .5);
}
.pf-estado.pocos { background: var(--pumpkin-dark); }
.pf-estado.agotado { background: var(--cranberry); }
.pf-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.pf-body h3 { font-size: 1.1rem; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pf-body small { color: var(--muted); font-weight: 800; }
.pf-seg { display: flex; margin-top: 8px; }
.pf-seg button { flex: 1; padding: 7px 4px; font-size: .8rem; white-space: nowrap; }
.pf-acciones { display: flex; gap: 6px; justify-content: flex-end; margin-top: auto; padding-top: 10px; }

.pf-link { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.pf-link-txt { min-width: 0; flex: 1 1 280px; }
.pf-link h3 { font-size: 1.15rem; }
.pf-link p { margin: 4px 0 8px; color: var(--ink-soft); font-weight: 600; }
.pf-link code {
  display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top;
  padding: 5px 10px; border-radius: 10px; background: rgba(255, 255, 255, .7); font: 800 .86rem var(--font); color: var(--rust);
}
.pf-girando { display: inline-block; animation: mecer 1s ease-in-out infinite alternate; }

/* selector de fotos (formulario) */
.pf-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; transition: opacity .2s; }
.pf-fotos.procesando { opacity: .55; pointer-events: none; }
.pf-thumb {
  position: relative; aspect-ratio: 1; border-radius: 14px; overflow: hidden; background: #fbe6c8;
  box-shadow: 0 4px 10px -6px rgba(110, 52, 18, .5); animation: pop .35s var(--spring);
}
.pf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pf-thumb .chip { position: absolute; left: 6px; bottom: 6px; background: rgba(255, 250, 241, .95); }
.pf-thumb .icon-btn { position: absolute; width: 28px; height: 28px; font-size: .78rem; border-radius: 9px; background: rgba(255, 250, 241, .92); }
.pf-quitar { top: 6px; right: 6px; }
.pf-portada { left: 6px; bottom: 6px; }
.pf-add {
  aspect-ratio: 1; border-radius: 14px; border: 2px dashed rgba(232, 119, 46, .45); background: rgba(232, 119, 46, .06);
  cursor: pointer; display: grid; place-content: center; justify-items: center; gap: 2px; font-size: 1.6rem; color: var(--rust);
  transition: background .2s, transform .25s var(--spring);
}
.pf-add span { font: 800 .74rem var(--font); }
.pf-add:hover { background: rgba(232, 119, 46, .14); transform: scale(1.03); }
.pf-radio { display: flex; gap: 8px; flex-wrap: wrap; }
.pf-radio label { flex: 1 1 120px; cursor: pointer; position: relative; }
.pf-radio input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pf-radio span {
  display: block; text-align: center; padding: 10px 8px; border-radius: 13px; border: 2px solid #f0dcc2; background: #fffdf8;
  font-weight: 800; font-size: .9rem; transition: border-color .2s, box-shadow .2s, background .2s;
}
.pf-radio input:checked + span { border-color: var(--pumpkin); background: #fff; box-shadow: 0 0 0 4px rgba(232, 119, 46, .15); }
.pf-radio input:focus-visible + span { box-shadow: 0 0 0 4px rgba(232, 119, 46, .3); }

/* ---------- estado de cuenta en PDF ---------- */
.pdf-btn {
  position: relative; flex: none; border: 0; cursor: pointer; padding: 4px 8px; border-radius: 8px; font: 900 .66rem var(--font); letter-spacing: .06em;
  color: #fff; background: linear-gradient(135deg, #f08a3c, var(--rust)); box-shadow: 0 4px 10px -5px rgba(184, 70, 31, .9);
  transition: transform .25s var(--spring), filter .2s; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
/* zona de toque más grande que el botón (en el teléfono es fácil errarle a algo tan chico) */
.pdf-btn::after { content: ''; position: absolute; inset: -10px -8px; }
.pdf-btn:active { transform: scale(.92); }
/* en pantallas táctiles el hover se queda pegado tras el primer toque: solo con mouse */
@media (hover: hover) { .pdf-btn:hover { transform: scale(1.12) rotate(-4deg); filter: brightness(1.08); } }
.cliente-item { display: inline-flex; align-items: center; gap: 4px; }
.debt-top { flex-wrap: wrap; }
.debt-quien { flex: 1 1 150px; min-width: 0; }
.debt-nombre { display: flex; align-items: center; gap: 7px; }
.debt-nombre h3 { min-width: 0; }
.pdf-modal { min-height: 170px; display: grid; place-items: center; gap: 12px; }
.pdf-modal .hint { margin: 0; text-align: center; }
.pdf-cargando { text-align: center; font-weight: 700; color: var(--ink-soft); }
.pdf-cargando .pf-girando { font-size: 2.6rem; }
.pdf-cargando p { margin: 8px 0 0; }
.pdf-vista img {
  display: block; max-width: 100%; max-height: 50vh; border-radius: 10px; border: 1px solid var(--line);
  box-shadow: 0 16px 34px -14px rgba(110, 52, 18, .55); animation: pop .4s var(--spring);
}

/* Páginas A4 (794 × 1123 px) que se dibujan fuera de la vista y se pasan a PDF.
   Quedan detrás del fondo (z-index -1): nunca se ven en pantalla. */
#pdfStage { position: fixed; left: 0; top: 0; z-index: -1; width: 794px; pointer-events: none; }
.pdf-page {
  width: 794px; height: 1123px; overflow: hidden; display: flex; flex-direction: column; position: relative;
  color: #3b2416; font-family: var(--font); background: linear-gradient(180deg, #fffaf1 0%, #fff3e1 100%);
}
.pdf-plaid { flex: none; height: 14px; display: flex; gap: 13px; padding-left: 6px; position: relative; overflow: hidden; background: #e8772e; }
.pdf-plaid i { flex: none; width: 7px; background: rgba(120, 30, 30, .45); }
.pdf-plaid b { position: absolute; left: 0; right: 0; top: 4px; height: 6px; background: rgba(120, 30, 30, .45); }
.pdf-hero {
  flex: none; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 20px;
  padding: 26px 40px; color: #fff; background: linear-gradient(120deg, #ee8237 0%, #c94d26 55%, #a8323e 100%);
}
.pdf-hoja { position: absolute; font-size: 30px; opacity: .28; }
.pdf-marca { display: flex; align-items: center; gap: 18px; position: relative; }
.pdf-logo { width: 98px; height: 98px; flex: none; border-radius: 50%; background: #fff; padding: 4px; box-shadow: 0 10px 22px -10px rgba(60, 20, 5, .65); }
.pdf-logo img { width: 100%; height: 100%; border-radius: 50%; display: block; }
.pdf-marca h1 { font-size: 38px; line-height: 1; }
.pdf-marca p { margin: 8px 0 0; font-weight: 900; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; opacity: .92; }
.pdf-fecha { position: relative; text-align: right; background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .45); border-radius: 16px; padding: 10px 16px; }
.pdf-fecha small { display: block; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; opacity: .85; }
.pdf-fecha b { font-size: 15px; font-weight: 800; }
.pdf-mini { flex: none; display: flex; align-items: center; gap: 12px; padding: 12px 40px; color: #fff; background: linear-gradient(120deg, #ee8237, #c94d26 60%, #a8323e); }
.pdf-mini img { width: 42px; height: 42px; border-radius: 50%; background: #fff; padding: 2px; }
.pdf-mini b { font-family: var(--font-head); font-weight: 600; font-size: 21px; }
.pdf-mini span { margin-left: auto; font-weight: 800; font-size: 13px; opacity: .92; }

.pdf-cuerpo { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 14px; padding: 24px 40px 12px; }
.pdf-cuerpo > * { flex: none; }
.pdf-grupo { display: flex; flex-direction: column; gap: 12px; }
.pdf-pie {
  flex: none; display: flex; justify-content: space-between; align-items: center; margin: 0 40px; padding: 12px 0 18px;
  border-top: 2px dashed rgba(122, 74, 40, .22); font-size: 12px; font-weight: 800; color: #7a5a44;
}
.pdf-etq { display: block; font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: #a4846b; }

.pdf-cliente {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 20px; background: #fff;
  border: 1px solid rgba(122, 74, 40, .12); box-shadow: 0 10px 24px -16px rgba(110, 52, 18, .45);
}
.pdf-avatar {
  width: 60px; height: 60px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-family: var(--font-head); font-weight: 600; font-size: 27px; color: #fff; background: linear-gradient(135deg, #e3a92f, #e8772e);
}
.pdf-cliente-txt { flex: 1; min-width: 0; }
.pdf-cliente h2 { font-size: 27px; line-height: 1.1; margin: 2px 0 4px; overflow-wrap: anywhere; }
.pdf-cliente p { margin: 0; font-size: 13px; font-weight: 700; color: #7a5a44; }
.pdf-saldo { flex: none; text-align: right; padding: 10px 16px; border-radius: 16px; background: #f9ddd5; }
.pdf-saldo b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 27px; color: #a8323e; line-height: 1.1; margin-top: 2px; }
.pdf-saldo.ok { background: #e6efd3; }
.pdf-saldo.ok b { color: #4f7d2e; }

.pdf-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pdf-stat { position: relative; overflow: hidden; padding: 12px 14px; border-radius: 16px; background: #fff; border: 1px solid rgba(122, 74, 40, .12); }
.pdf-stat::after { content: '🍁'; position: absolute; right: -8px; bottom: -14px; font-size: 46px; opacity: .08; transform: rotate(-20deg); }
.pdf-stat i { font-style: normal; display: flex; width: 34px; height: 34px; align-items: center; justify-content: center; border-radius: 11px; background: #fde6c6; font-size: 17px; margin-bottom: 7px; }
.pdf-stat b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 19px; margin-top: 2px; white-space: nowrap; }
.pdf-stat small { display: block; font-size: 11px; font-weight: 800; color: #a4846b; margin-top: 1px; }
.pdf-stat.in i { background: #e6efd3; }
.pdf-stat.in b { color: #4f7d2e; }
.pdf-stat.out i { background: #f9ddd5; }
.pdf-stat.out b { color: #a8323e; }
.pdf-avance { padding: 12px 16px; border-radius: 16px; background: linear-gradient(135deg, #fff1dc, #fde0b9); }
.pdf-avance-top { display: flex; justify-content: space-between; font-size: 13px; font-weight: 900; color: #7a5a44; margin-bottom: 8px; }
.pdf-avance-top b { color: #b8461f; }
.pdf-barra { height: 9px; border-radius: 99px; background: rgba(122, 74, 40, .12); overflow: hidden; }
.pdf-barra span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #e3a92f, #4f7d2e); }
.pdf-barra.grande { height: 12px; background: rgba(255, 255, 255, .7); }

.pdf-seccion { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 20px; color: #b8461f; }
.pdf-seccion small { font-family: var(--font); font-weight: 800; font-size: 13px; color: #a4846b; }
.pdf-seccion::after { content: ''; flex: 1; border-top: 2px dashed rgba(122, 74, 40, .22); }
.pdf-deuda {
  display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 16px; background: #fff;
  border: 1px solid rgba(122, 74, 40, .12); border-left: 6px solid #e3a92f;
}
.pdf-deuda.vencida { border-left-color: #a8323e; }
.pdf-deuda.pronto { border-left-color: #e8772e; }
.pdf-deuda.pagada { border-left-color: #4f7d2e; }
.pdf-deuda-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pdf-deuda-top b { display: block; font-size: 15px; font-weight: 900; overflow-wrap: anywhere; }
.pdf-deuda-top small { font-size: 12px; font-weight: 700; color: #7a5a44; }
.pdf-badge { flex: none; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 900; white-space: nowrap; background: #fdefcd; color: #c07c0c; }
.pdf-badge.vencida { background: #f9ddd5; color: #b33a2f; }
.pdf-badge.pronto { background: #fde1c9; color: #c95e1b; }
.pdf-badge.pagada { background: #e6efd3; color: #4f7d2e; }
.pdf-montos { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; text-align: center; }
.pdf-montos div { background: #fdf6ea; border-radius: 12px; padding: 6px 4px; }
.pdf-montos small { display: block; font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; color: #a4846b; }
.pdf-montos b { font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.pdf-montos .saldo b { color: #a8323e; }
.pdf-deuda.pagada .pdf-montos .saldo b { color: #4f7d2e; }
.pdf-abonos { border-radius: 12px; background: #fdf6ea; padding: 8px 12px; }
.pdf-abonos-titulo { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; color: #a4846b; margin-bottom: 2px; }
.pdf-abono { display: grid; grid-template-columns: 70px 104px 1fr auto; gap: 8px; padding: 4px 0; font-size: 12.5px; font-weight: 700; color: #7a5a44; border-top: 1px dashed rgba(122, 74, 40, .16); }
.pdf-abonos-titulo + .pdf-abono, .pdf-abonos > .pdf-abono:first-child { border-top: 0; }
.pdf-abono b { color: #4f7d2e; font-weight: 900; text-align: right; }
.pdf-notas { margin: 0; font-size: 12px; font-style: italic; color: #7a5a44; }
.pdf-gracias { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-radius: 18px; background: #fdefcd; border: 2px dashed #e9bf6a; }
.pdf-gracias > span { font-size: 30px; }
.pdf-gracias b { display: block; font-family: var(--font-head); font-weight: 600; font-size: 18px; }
.pdf-gracias p { margin: 2px 0 0; font-size: 13px; font-weight: 700; color: #7a5a44; }
.pdf-gracias.ok { background: #e6efd3; border-color: #a9c77c; }

/* ---------- responsive ---------- */
@media (max-width: 1150px) {
  .grid-panel { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app {
    grid-template-columns: minmax(0, 1fr); gap: 0;
    padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) calc(110px + env(safe-area-inset-bottom)) calc(16px + env(safe-area-inset-left));
  }
  .sidebar {
    position: fixed; z-index: 30; top: auto; height: auto;
    left: calc(10px + env(safe-area-inset-left)); right: calc(10px + env(safe-area-inset-right)); bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; border-radius: 24px; background: rgba(255, 249, 238, .84);
  }
  .brand, .sidebar-foot { display: none; }
  nav { flex-direction: row; justify-content: space-around; }
  .nav-btn { flex: 1; flex-direction: column; gap: 2px; padding: 8px 4px; font-size: .7rem; text-align: center; position: relative; border-radius: 18px; }
  .nav-btn .ico { font-size: 1.3rem; }
  .nav-badge { position: absolute; top: 2px; right: calc(50% - 26px); margin: 0; font-size: .62rem; padding: 1px 5px; min-width: 18px; }
  #toasts { bottom: calc(96px + env(safe-area-inset-bottom)); right: 16px; left: 16px; justify-items: center; }
  .mobile-logo { display: flex; }
  .view-icon { width: 48px; height: 48px; font-size: 1.5rem; border-radius: 16px; }
  .lbl-largo { display: none; }
  .lbl-corto { display: inline; }
}
@media (max-width: 700px) {
  .grid-panel, .grid-2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .hero { padding: 22px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; }
  .stat-value { font-size: 1.3rem; }
  .grid2 { grid-template-columns: 1fr; }
  .top-actions, .top-right { width: 100%; }
  .sync-pill { margin-right: auto; }
  .top-actions .btn { flex: 1 1 auto; padding: 10px 12px; }
  .mov { grid-template-columns: auto minmax(0, 1fr) auto; }
  .mov-act { grid-column: 2 / -1; justify-content: flex-end; opacity: 1; }
  .month-nav { width: 100%; justify-content: space-between; }
  .toolbar select { flex: 1 1 100%; }

  /* tabla → tarjetas */
  .tbl thead { display: none; }
  .tbl, .tbl tbody, .tbl tr, .tbl td { display: block; width: 100%; }
  .tbl tr { background: rgba(255, 255, 255, .5); border-radius: 16px; padding: 8px; margin-bottom: 10px; }
  .tbl tr.low { background: rgba(253, 239, 205, .85); }
  .tbl td { background: none !important; border-radius: 0 !important; padding: 5px 6px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .tbl td[data-label]::before { content: attr(data-label); font-size: .72rem; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
  .tbl td.first { display: block; }
  .tbl td.first::before { display: none; }
  .actions { justify-content: flex-end; padding-top: 8px !important; }
  .modal-foot .btn { flex: 1; }

  .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pf-body { padding: 10px 10px 12px; }
  .pf-body h3 { font-size: .98rem; }
  .pf-seg button span { display: none; }
  .pf-acciones { justify-content: space-between; gap: 2px; }
  .pf-acciones .icon-btn { width: 32px; height: 32px; }
  .pf-estado { right: 6px; bottom: 6px; font-size: .68rem; padding: 4px 8px; }
  .pf-marcas { top: 6px; left: 6px; }
}
@media (max-width: 420px) {
  .nav-btn { font-size: .62rem; padding: 8px 2px; }
  .nav-btn .ico { font-size: 1.15rem; }
}
@media (max-width: 380px) {
  .stats { grid-template-columns: 1fr; }
}

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