/* ── styles.css ─────────────────────────────────────────────────────── */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
:root {
  --bg:#0f172a; --surface:#1e293b; --surface2:#273347;
  --accent:#3b82f6; --green:#22c55e; --red:#ef4444; --orange:#f97316;
  --text:#f1f5f9; --muted:#94a3b8; --border:#334155; --radius:16px;
}
.light {
  --bg:#f1f5f9; --surface:#ffffff; --surface2:#e2e8f0;
  --text:#0f172a; --muted:#64748b; --border:#cbd5e1;
}
body {
  background:var(--bg); color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  min-height:100vh; transition:background .3s,color .3s;
}

/* ── Layout responsive ── */
.app-container { width:100%; }
.content-area { padding-bottom:80px; padding-top:12px; }

@media (min-width:768px) {
  .nav { position:fixed; left:0; top:0; bottom:0; width:220px; flex-direction:column; border-top:none; border-right:1px solid var(--border); padding:20px 0; justify-content:flex-start; gap:4px; z-index:10; background:var(--surface); overflow-y:auto; }
  .nav button { flex-direction:row; justify-content:flex-start; padding:12px 20px; gap:12px; font-size:14px; border-radius:12px; margin:0 8px; width:calc(100% - 16px); }
  .nav button svg { width:20px; height:20px; flex-shrink:0; }
  .main-content { margin-left:220px; min-height:100vh; }
  .header { padding:24px 32px 20px; }
  .content-area { padding:16px 32px 40px; }
  .fab { bottom:32px; right:32px; }
  .tablet-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
  .tablet-grid .card { margin-bottom:0; }
  .page { padding:0; }
  .modal { max-width:500px; margin:0 auto; border-radius:24px; margin-bottom:40px; }
  .modal-overlay { align-items:center; }
  .toast { bottom:40px; }
  .undo-toast { bottom:40px; }
}

@media (min-width:1280px) {
  .nav { width:260px; }
  .main-content { margin-left:260px; }
  .tablet-grid { grid-template-columns:1fr 1fr; gap:24px; }
  .content-area { padding:24px 48px 40px; }
  .summary-grid { gap:16px; }
  .summary-item { padding:20px; }
  .summary-item .value { font-size:22px; }
}

/* ── Header ── */
.header { background:var(--surface); padding:20px 16px 16px; position:sticky; top:0; z-index:9; border-bottom:1px solid var(--border); }
.header h1 { font-size:20px; font-weight:700; }
.month-nav { display:flex; align-items:center; gap:12px; margin-top:10px; }
.month-nav button { background:var(--surface2); border:none; color:var(--text); width:32px; height:32px; border-radius:8px; font-size:16px; cursor:pointer; }

/* ── Nav ── */
.nav { position:fixed; bottom:0; left:0; right:0; background:var(--surface); border-top:1px solid var(--border); display:flex; z-index:10; overflow-x:auto; }
.nav button { flex:1; min-width:56px; padding:10px 0; background:none; border:none; color:var(--muted); font-size:9px; cursor:pointer; display:flex; flex-direction:column; align-items:center; gap:3px; transition:color .2s; }
.nav button.active { color:var(--accent); }
.nav button svg { width:20px; height:20px; }

/* ── Pages ── */
.page { display:none; padding:0px 16px 16px 16px; }
.page.active { display:block; animation: fadeIn 0.40s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
} 

/* ── Cards ── */
.card { background:var(--surface); border-radius:var(--radius); padding:16px; margin-bottom:12px; }
.card-title { font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; margin-bottom:10px; }

/* ── Summary ── */
.summary-grid { display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; margin-bottom:12px; }
.summary-item { background:var(--surface); border-radius:var(--radius); padding:14px 10px; text-align:center; }
.summary-item .label { font-size:11px; color:var(--muted); margin-bottom:4px; }
.summary-item .value { font-size:17px; font-weight:700; }
.value.green { color:var(--green); }
.value.red { color:var(--red); }
.value.blue { color:var(--accent); }

/* ── Donut ── */
.donut-wrap { display:flex; flex-direction:column; align-items:center; padding:10px 0; }
.donut-container { position:relative; display:flex; align-items:center; justify-content:center; width:180px; height:180px; }
.donut-container svg { width:180px; height:180px; }
.donut-center { position:absolute; display:flex; flex-direction:column; align-items:center; }
.donut-pct { font-size:22px; font-weight:700; }
.donut-label { font-size:11px; color:var(--muted); margin-top:2px; }
.legend { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; justify-content:center; }
.legend-item { display:flex; align-items:center; gap:5px; font-size:12px; }
.legend-dot { width:10px; height:10px; border-radius:50%; }

/* ── Donut animado ── */
@keyframes donutDraw {
  from { stroke-dashoffset: var(--circ); }
  to   { stroke-dashoffset: var(--final-offset); }
}
.donut-arc {
  animation: donutDraw 1s ease forwards;
  stroke-dashoffset: var(--circ);
}

/* ── Bars ── */
.rule-bar { margin-bottom:14px; }
.rule-bar .rule-header { display:flex; justify-content:space-between; font-size:13px; margin-bottom:6px; }
.rule-bar .rule-header .pct { color:var(--muted); font-size:12px; }
.bar-bg { background:var(--surface2); border-radius:99px; height:10px; overflow:hidden; }
.bar-fill { height:100%; border-radius:99px; transition:width .4s; }
.rule-bar .amounts { display:flex; justify-content:space-between; font-size:11px; color:var(--muted); margin-top:4px; }

/* ── Items ── */
.item { display:flex; align-items:center; justify-content:space-between; padding:12px 0; border-bottom:1px solid var(--border); }
.item:last-child { border-bottom:none; }
.item-left { display:flex; align-items:center; gap:10px; flex:1; min-width:0; }
.item-icon { width:36px; height:36px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.item-name { font-size:14px; font-weight:500; }
.item-sub { font-size:12px; color:var(--muted); }
.item-amount { font-size:15px; font-weight:600; white-space:nowrap; }
.item-actions { display:flex; gap:6px; align-items:center; flex-shrink:0; }
.btn-del  { background:none; border:none; color:var(--red);    font-size:18px; cursor:pointer; padding:4px; }
.btn-edit { background:none; border:none; color:var(--accent); font-size:15px; cursor:pointer; padding:4px; opacity:.8; transition:opacity .15s; }
.btn-edit:hover { opacity:1; }

/* ★ Tags / Etiquetas */
.item-tags { display:flex; flex-wrap:wrap; gap:4px; margin-top:4px; }
.tag { background:rgba(59,130,246,.15); color:var(--accent); border-radius:99px; padding:2px 8px; font-size:11px; }

/* ── FAB ── */
.fab { position:fixed; bottom:90px; right:20px; width:56px; height:56px; background:var(--accent); border:none; border-radius:50%; color:#fff; font-size:28px; cursor:pointer; box-shadow:0 4px 20px rgba(59,130,246,.4); z-index:9; display:flex; align-items:center; justify-content:center; }

/* ── Modal ── */
.modal-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,.6); z-index:20; align-items:flex-end; }
.modal-overlay.open { display:flex; }
.modal { background:var(--surface); border-radius:24px 24px 0 0; padding:24px 16px 40px; width:100%; max-height:90vh; overflow-y:auto; }
.modal h3 { font-size:17px; font-weight:700; margin-bottom:16px; }
.form-group { margin-bottom:14px; }
.form-group label { font-size:12px; color:var(--muted); display:block; margin-bottom:6px; }
.form-group input, .form-group select { width:100%; background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:12px; color:var(--text); font-size:16px; outline:none; }
.form-group input:focus, .form-group select:focus { border-color:var(--accent); }
.btn-primary { width:100%; background:var(--accent); border:none; color:#fff; padding:14px; border-radius:12px; font-size:16px; font-weight:600; cursor:pointer; margin-top:4px; }
.btn-secondary { width:100%; background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:12px; border-radius:12px; font-size:14px; cursor:pointer; }
.btn-danger { width:100%; background:rgba(239,68,68,.15); border:1px solid rgba(239,68,68,.3); color:var(--red); padding:12px; border-radius:12px; font-size:14px; cursor:pointer; margin-top:8px; }

/* ── Goal ── */
.goal-progress { background:var(--surface2); border-radius:99px; height:12px; overflow:hidden; margin-bottom:8px; }
.goal-fill { height:100%; background:var(--accent); border-radius:99px; transition:width .5s; }
.goal-text { display:flex; justify-content:space-between; font-size:12px; color:var(--muted); }

/* ── Settings ── */
.setting-row { display:flex; justify-content:space-between; align-items:center; padding:12px 0; border-bottom:1px solid var(--border); }
.setting-row:last-child { border-bottom:none; }
.setting-info { flex:1; }
.setting-label { font-size:14px; font-weight:500; }
.setting-desc { font-size:12px; color:var(--muted); margin-top:2px; }
.setting-control select, .setting-control input { background:var(--surface2); border:1px solid var(--border); border-radius:8px; padding:8px 10px; color:var(--text); font-size:13px; outline:none; width:100px; }
.rule-warn { font-size:12px; color:var(--red); margin-top:8px; display:none; }
.rule-warn.show { display:block; }

/* ── Badge ── */
.badge { font-size:10px; padding:2px 6px; border-radius:99px; font-weight:600; }
.badge.over { background:rgba(239,68,68,.15); color:var(--red); }
.badge.warn { background:rgba(249,115,22,.15); color:var(--orange); }
.badge.ok   { background:rgba(34,197,94,.12);  color:var(--green); }

/* ── Empty ── */
.empty { text-align:center; color:var(--muted); padding:32px 16px; font-size:14px; }

/* ── Toast ── */
.toast { position:fixed; bottom:100px; left:50%; transform:translateX(-50%); background:#1e293b; color:#f1f5f9; padding:12px 20px; border-radius:12px; font-size:14px; z-index:99; opacity:0; transition:opacity .3s; pointer-events:none; border:1px solid var(--border); white-space:nowrap; }
.toast.show { opacity:1; }

/* ── ★ Vista Anual ── */
.anual-row { display:grid; grid-template-columns:36px 1fr 140px; align-items:center; gap:8px; padding:8px 0; border-bottom:1px solid var(--border); }
.anual-row:last-child { border-bottom:none; }
.anual-row.anual-empty { opacity:.35; }
.anual-month { font-size:13px; font-weight:600; color:var(--muted); }
.anual-bars { display:flex; flex-direction:column; gap:4px; }
.anual-bar-wrap { background:var(--surface2); border-radius:99px; height:7px; overflow:hidden; }
.anual-bar { height:100%; border-radius:99px; transition:width .4s; min-width:2px; }
.anual-bar.ing { background:var(--green); }
.anual-bar.gas { background:var(--red); }
.anual-values { display:flex; flex-direction:column; align-items:flex-end; gap:2px; }
.anual-totals { display:grid; grid-template-columns:1fr 1fr 1fr; gap:8px; margin-top:16px; padding-top:14px; border-top:2px solid var(--border); }
.anual-total-item { text-align:center; }
.anual-total-label { font-size:11px; color:var(--muted); margin-bottom:4px; }
.anual-total-val { font-size:15px; font-weight:700; }
.month-nav-btn { background:var(--surface2); border:none; color:var(--text); width:32px; height:32px; border-radius:8px; font-size:16px; cursor:pointer; }

/* ── ★ Deudas ── */
.debt-paid { opacity:.6; }
.btn-toggle { background:none; border:2px solid var(--border); color:var(--muted); width:28px; height:28px; border-radius:50%; font-size:13px; cursor:pointer; display:flex; align-items:center; justify-content:center; transition:all .2s; }
.btn-toggle.active { border-color:var(--green); color:var(--green); background:rgba(34,197,94,.1); }

/* ── ★ Botón añadir pequeño ── */
.btn-add-small { background:var(--accent); border:none; color:#fff; width:28px; height:28px; border-radius:8px; font-size:18px; cursor:pointer; display:flex; align-items:center; justify-content:center; line-height:1; }

/* ── ★ Input con botón calculadora ── */
.input-with-btn { display:flex; gap:6px; align-items:center; }
.input-with-btn input { flex:1; }
.btn-calc { background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:10px; border-radius:10px; font-size:16px; cursor:pointer; flex-shrink:0; white-space:nowrap; }

/* ── ★ Calculadora ── */
.calc-modal { max-width:320px !important; }
.calc-display { background:var(--surface2); border-radius:12px; padding:16px; font-size:28px; font-weight:700; text-align:right; margin-bottom:16px; min-height:60px; word-break:break-all; }
.calc-keys { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:12px; }
.calc-btn { background:var(--surface2); border:none; color:var(--text); padding:16px 8px; border-radius:12px; font-size:18px; cursor:pointer; transition:background .15s; }
.calc-btn:active { background:var(--border); }
.calc-op   { background:rgba(249,115,22,.15); color:var(--orange); }
.calc-eq   { background:rgba(59,130,246,.2); color:var(--accent); }
.calc-confirm { background:rgba(34,197,94,.2); color:var(--green); font-size:20px; }
.calc-clear { background:rgba(239,68,68,.15); color:var(--red); }

/* ── ★ Recurrentes toggle ── */
.btn-toggle { background:none; border:2px solid var(--border); color:var(--muted); width:28px; height:28px; border-radius:50%; font-size:12px; cursor:pointer; transition:all .2s; }
.btn-toggle.active { border-color:var(--accent); color:var(--accent); background:rgba(59,130,246,.1); }

/* ── ★ Onboarding ── */
.ob-overlay { display:none; position:fixed; inset:0; background:var(--bg); z-index:100; align-items:center; justify-content:center; }
.ob-overlay.open { display:flex; }
.ob-container { display:flex; flex-direction:column; width:100%; max-width:480px; height:100%; max-height:100vh; padding:0 0 32px; overflow:hidden; }
.ob-progress-bar { height:3px; background:var(--surface2); width:100%; flex-shrink:0; }
.ob-progress { height:100%; background:var(--accent); border-radius:99px; transition:width .4s ease; }
.ob-top { display:flex; justify-content:flex-end; padding:14px 20px 0; flex-shrink:0; }
.ob-skip { background:none; border:none; color:var(--muted); font-size:14px; cursor:pointer; padding:4px 8px; }
.ob-body { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:16px 28px; overflow-y:auto; text-align:center; }
.ob-emoji { font-size:72px; margin-bottom:24px; line-height:1; }
.ob-title { font-size:24px; font-weight:700; line-height:1.3; margin-bottom:14px; }
.ob-desc  { font-size:15px; color:var(--muted); line-height:1.6; max-width:320px; margin-bottom:28px; }
.ob-options { display:flex; flex-direction:column; gap:10px; width:100%; max-width:320px; }
.ob-options-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.ob-option { background:var(--surface); border:2px solid var(--border); color:var(--text); border-radius:12px; padding:12px 16px; font-size:15px; cursor:pointer; transition:all .2s; text-align:left; }
.ob-option.selected { border-color:var(--accent); background:rgba(59,130,246,.12); color:var(--accent); font-weight:600; }
.ob-option:hover:not(.selected) { border-color:var(--muted); }
.ob-features { display:grid; grid-template-columns:1fr 1fr; gap:12px; width:100%; max-width:360px; text-align:left; }
.ob-feature-item { background:var(--surface); border-radius:12px; padding:12px; display:flex; align-items:center; gap:10px; }
.ob-feature-icon { font-size:22px; flex-shrink:0; }
.ob-feature-label { font-size:13px; line-height:1.3; }
.ob-bottom { display:flex; align-items:center; justify-content:space-between; padding:0 24px; flex-shrink:0; }
.ob-dots { display:flex; gap:6px; }
.ob-dot { width:8px; height:8px; border-radius:50%; background:var(--border); transition:all .3s; }
.ob-dot.active { background:var(--accent); width:22px; border-radius:99px; }
.ob-next { background:var(--accent); border:none; color:#fff; padding:14px 28px; border-radius:14px; font-size:16px; font-weight:600; cursor:pointer; transition:opacity .2s; }
.ob-next:active { opacity:.8; }
.ob-slide-out-left { animation:slideOutLeft .2s ease forwards; }
.ob-slide-in       { animation:slideIn .25s ease forwards; }
@keyframes slideOutLeft { from { opacity:1; transform:translateX(0); } to { opacity:0; transform:translateX(-40px); } }
@keyframes slideIn      { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }
@media (min-width:768px) {
  .ob-container { height:auto; min-height:600px; border-radius:24px; box-shadow:0 24px 80px rgba(0,0,0,.4); margin:auto; }
  .ob-overlay { background:rgba(0,0,0,.6); }
}

/* ── ★ Filtros y búsqueda ── */
.filter-bar { display:flex; flex-direction:column; gap:8px; margin-bottom:12px; }
.filter-search { width:100%; background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:10px 12px; color:var(--text); font-size:14px; outline:none; transition:border-color .2s; }
.filter-search:focus { border-color:var(--accent); }
.filter-row { display:flex; gap:8px; flex-wrap:wrap; }
.filter-row select { flex:1; min-width:110px; background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:8px 10px; color:var(--text); font-size:13px; outline:none; transition:border-color .2s; }
.filter-row select:focus { border-color:var(--accent); }
.filter-btn-dir { background:var(--surface2); border:1px solid var(--border); border-radius:10px; padding:8px 14px; color:var(--text); font-size:14px; cursor:pointer; white-space:nowrap; flex-shrink:0; transition:background .15s; }
.filter-btn-dir:active { background:var(--border); }
.filter-count { font-size:11px; color:var(--muted); margin-bottom:2px; min-height:14px; }

/* ── ★ Tendencias de categoría ── */
.trend {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
}
.trend-up   { background: rgba(239,68,68,.14);  color: var(--red);    }
.trend-down { background: rgba(34,197,94,.14);  color: var(--green);  }
.trend-flat { background: rgba(148,163,184,.14); color: var(--muted); }

/* ── ★ Gráfico comparativo ── */
.comp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.comp-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--text);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}
.comp-legend {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 10px;
}
.comp-legend span { display:flex; align-items:center; gap:5px; }
.comp-dot { width:10px; height:10px; border-radius:2px; flex-shrink:0; }
.comp-chart-wrap {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 4px;
}
#comp-chart svg text { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }

/* ── ★ Card subtítulo de sección ── */
.section-card {
  display: none;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin: 8px 16px 0px 16px;
  border-left: 4px solid var(--accent);
}
.section-card.visible { display: block; }
.section-card-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
@media (min-width: 768px) {
  .section-card { margin: 8px 0 0 0; }
}

/* ── ★ Top 3 categorías ── */
.top3-row { display:flex; align-items:center; gap:10px; margin-bottom:14px; }
.top3-row:last-child { margin-bottom:0; }
.top3-medal { font-size:22px; flex-shrink:0; }
.top3-info { flex:1; }
.top3-header { display:flex; justify-content:space-between; margin-bottom:5px; }
.top3-cat { font-size:13px; font-weight:600; }
.top3-amt { font-size:13px; color:var(--muted); }
.top3-bar-bg { background:var(--surface2); border-radius:99px; height:8px; overflow:hidden; }
.top3-bar-fill { height:100%; border-radius:99px; width:0%; transition:width 0.6s ease; }

/* ── ★ Gráfico línea ahorro ── */
#ahorro-line-chart { width:100%; padding:4px 0 8px; }
#ahorro-line-chart svg text { font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif; }
/* ── ★ Separación cards Análisis ── */
#page-analisis .card + .card { margin-top: 12px; }

/* ── ★ Landscape en móvil y tablet ── */
@media (orientation: landscape) and (max-height: 500px) {
  /* Nav lateral compacta en lugar de barra inferior */
  .nav {
    position: fixed;
    left: 0; top: 0; bottom: 0; right: auto;
    width: 64px;
    flex-direction: column;
    border-top: none;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    justify-content: flex-start;
    padding: 8px 0;
    gap: 2px;
  }
  .nav button {
    flex: none;
    width: 64px;
    min-width: unset;
    padding: 10px 0;
    font-size: 8px;
    gap: 2px;
  }
  .main-content { margin-left: 64px; }
  .content-area { padding-bottom: 16px; padding-top: 8px; }
  .fab { bottom: 16px; right: 16px; width: 48px; height: 48px; font-size: 22px; }

  /* Header más compacto */
  .header { padding: 8px 16px; }
  .header h1 { font-size: 16px; }
  .month-nav { margin-top: 6px; }

  /* Modal ocupa toda la pantalla en landscape */
  .modal-overlay { align-items: center; }
  .modal {
    border-radius: 16px;
    max-height: 95vh;
    padding: 16px 16px 20px;
    margin: 8px;
    width: calc(100% - 16px);
  }
  .modal h3 { font-size: 15px; margin-bottom: 10px; }
  .form-group { margin-bottom: 8px; }
  .form-group input, .form-group select { padding: 8px 10px; font-size: 14px; }
  .btn-primary { padding: 10px; }

  /* Toast más arriba para no solaparse con el FAB */
  .toast { bottom: 16px; }
  .undo-toast { bottom: 16px; }

  /* Onboarding adaptado a landscape */
  .ob-container { flex-direction: row; max-width: 100%; height: 100%; }
  .ob-body { padding: 8px 20px; }
  .ob-emoji { font-size: 48px; margin-bottom: 12px; }
  .ob-title { font-size: 18px; margin-bottom: 8px; }
  .ob-desc { font-size: 13px; margin-bottom: 12px; }
  .ob-progress-bar { height: 2px; }
  .ob-bottom { padding: 0 16px; }
}

/* ── ★ Landscape en tablet (768px+ ancho, altura media) ── */
@media (orientation: landscape) and (min-width: 768px) and (max-height: 768px) {
  .content-area { padding-top: 8px; padding-bottom: 24px; }
  .header { padding: 12px 32px; }
  .modal { max-height: 92vh; padding: 16px 20px 24px; }
  .form-group { margin-bottom: 10px; }
  .ob-body { padding: 12px 28px; }
  .ob-emoji { font-size: 52px; margin-bottom: 14px; }
}

/* ══════════════════════════════════════════════════════════════════
   Categorías personalizadas — Ajustes + Modal
   ══════════════════════════════════════════════════════════════════ */

/* ── Card ajustes ── */
.cat-settings-section { margin-bottom: 16px; }

.cat-default-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1.5px solid;
  background: var(--surface2);
  color: var(--text);
}

.cat-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-custom-list  { display: flex; flex-direction: column; gap: 6px; }

.cat-custom-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cat-chip-custom { flex: 1; }

/* ── Emoji grid ── */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  gap: 4px;
  max-height: 150px;
  overflow-y: auto;
  padding: 4px;
  background: var(--surface2);
  border-radius: var(--radius);
}

.emoji-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
  font-size: 20px;
  padding: 3px;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  line-height: 1;
  text-align: center;
}

.emoji-btn:hover    { background: var(--surface); }
.emoji-btn.selected { border-color: var(--accent); background: var(--surface); }

/* ── Color grid ── */
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px;
}

.color-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid transparent;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  outline: none;
}

.color-btn:hover    { transform: scale(1.15); }
.color-btn.selected { border-color: var(--text); transform: scale(1.15); }
.cat-section-label { font-size:11px; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; margin-bottom:8px; }
.cat-custom-list { margin-top:8px; }
.cat-add-button { margin-top:10px; width:100%; }
.cat-separator { border:none; border-top:1px solid var(--border); margin:12px 0; }

/* ── Solicitud de reseña ── */
.review-modal { text-align:center; }
.review-icon { font-size:42px; margin-bottom:8px; }
.review-text { color:var(--muted); font-size:14px; line-height:1.5; margin:0 0 18px; }
.review-dismiss {
  border:0; background:none; color:var(--muted); cursor:pointer;
  font-size:12px; margin-top:12px; padding:8px;
}

/* ── Objetivos y previsión ── */
.card-header-inline { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.card-header-inline .card-title { margin:0; }
.forecast-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.card-subtitle { color:var(--muted); font-size:11px; line-height:1.4; margin:-5px 0 10px; }
.forecast-grid > div { background:var(--surface2); border-radius:10px; padding:10px; }
.forecast-grid span { display:block; color:var(--muted); font-size:11px; margin-bottom:4px; }
.forecast-grid strong { display:block; font-size:15px; }
.forecast-grid .green { color:var(--green); }
.forecast-grid .red { color:var(--red); }
.forecast-warning { margin-top:10px; padding:9px 10px; border-radius:9px; background:rgba(239,68,68,.12); color:var(--red); font-size:12px; }
.goal-item { padding:12px 0; border-bottom:1px solid var(--border); }
.goal-item:first-child { padding-top:0; }
.goal-item:last-child { border-bottom:0; padding-bottom:0; }
.goal-item-header, .goal-values { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.goal-item-header { margin-bottom:9px; }
.goal-emoji { margin-right:6px; }
.goal-actions { display:flex; align-items:center; gap:5px; }
.goal-contribute { border:0; border-radius:8px; background:rgba(59,130,246,.14); color:var(--accent); padding:5px 7px; cursor:pointer; font-size:11px; }
.goal-values { margin-top:6px; color:var(--muted); font-size:12px; }
.goal-values strong { color:var(--text); }
.goal-hint { color:var(--muted); font-size:11px; line-height:1.4; margin-top:6px; }
.form-help { color:var(--muted); font-size:11px; margin-top:5px; }

.forecast-opening { display:flex; align-items:center; justify-content:space-between; gap:8px; font-size:13px; color:var(--muted); margin-bottom:10px; }
.forecast-opening strong { color:var(--text); }
.btn-link { background:none; border:none; color:var(--accent); font-size:13px; padding:0; cursor:pointer; text-align:left; text-decoration:underline; }
.backup-banner { border:1px solid var(--accent); font-size:13px; line-height:1.4; }
.backup-banner-actions { display:flex; gap:8px; margin-top:10px; }
.backup-banner-actions button { margin-top:0; padding:10px; font-size:14px; flex:1; }
input[type=date] { color-scheme:dark; }
body.light input[type=date] { color-scheme:light; }

.dialog-overlay { z-index:40; align-items:center; padding:16px; }
.dialog { border-radius:20px; max-width:420px; margin:0 auto; padding:20px 16px; }
.dialog p { font-size:15px; line-height:1.45; margin-bottom:14px; }
.dialog input { width:100%; background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:12px; border-radius:10px; font-size:16px; margin-bottom:14px; outline:none; }
.dialog input:focus { border-color:var(--accent); }
.dialog-actions { display:flex; gap:8px; }
.dialog-actions button { flex:1; margin-top:0; padding:12px; font-size:15px; }
.undo-toast { position:fixed; bottom:160px; left:50%; transform:translateX(-50%); display:flex; align-items:center; gap:14px; background:#1e293b; color:#f1f5f9; padding:10px 12px 10px 16px; border-radius:12px; font-size:14px; z-index:98; border:1px solid var(--border); max-width:calc(100vw - 32px); opacity:0; pointer-events:none; transition:opacity .3s; }
.undo-toast.show { opacity:1; pointer-events:auto; }
.undo-toast span { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.undo-toast button { background:none; border:none; color:#60a5fa; font-weight:700; font-size:14px; cursor:pointer; padding:4px; white-space:nowrap; }

.forecast-daily { display:flex; align-items:baseline; flex-wrap:wrap; gap:6px; background:rgba(59,130,246,.12); border-radius:10px; padding:10px 12px; margin-bottom:10px; font-size:13px; color:var(--muted); }
.forecast-daily strong { font-size:20px; color:var(--accent); }
.forecast-daily.no-margin { background:rgba(239,68,68,.12); color:var(--red); }
/* Cabecera: ‹ mes › en una sola fila */
.header { display:flex; align-items:center; gap:12px; }
.header > div { flex:1; min-width:0; text-align:center; }
.month-label { font-size:17px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.header .month-nav-btn { flex-shrink:0; width:38px; height:38px; font-size:20px; }
.header .section-card { display:none; margin:6px auto 0; padding:3px 12px; border-left-width:3px; border-radius:8px; background:var(--surface2); }
.header .section-card.visible { display:inline-block; }
.header .section-card-text { font-size:13px; }

.field-help { color:var(--muted); font-size:11px; line-height:1.4; margin-top:6px; }

.shared-box { background:var(--surface2); border-radius:12px; padding:10px 12px; }
.check-row { display:flex !important; align-items:center; gap:8px; font-size:14px; color:var(--text) !important; cursor:pointer; margin:0 !important; }
.check-row input { width:18px; height:18px; accent-color:var(--accent); }
#f-shared-fields { margin-top:10px; }

/* Importación de extractos */
.import-modal { max-height:94vh; }
.import-steps-help { color:var(--muted); font-size:13px; line-height:1.5; margin:0 0 14px 18px; }
.import-preview, .import-list { background:var(--surface2); border-radius:12px; padding:4px 10px; }
.import-row { display:flex; gap:8px; align-items:center; padding:8px 0; border-bottom:1px solid var(--border); font-size:13px; }
.import-row:last-child, .import-item:last-child { border-bottom:none; }
.import-date { color:var(--muted); flex-shrink:0; font-size:12px; }
.import-name { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-weight:600; }
.import-amount { flex-shrink:0; font-weight:700; }
.import-amount.red, .import-summary .red { color:var(--red); }
.import-amount.green, .import-summary .green { color:var(--green); }
.import-summary { display:flex; justify-content:space-between; align-items:center; background:var(--surface2); border-radius:12px; padding:12px; margin-bottom:8px; font-size:14px; }
.import-summary strong { font-size:18px; }
.import-toggle-all { display:flex; gap:16px; margin:8px 0; }
.import-item { display:flex; gap:10px; align-items:flex-start; padding:10px 0; border-bottom:1px solid var(--border); }
.import-item input[type=checkbox] { width:20px; height:20px; margin-top:2px; accent-color:var(--accent); flex-shrink:0; }
.import-item-main { flex:1; min-width:0; }
.import-item-top { display:flex; gap:8px; align-items:center; font-size:14px; }
.import-item-sub { color:var(--muted); font-size:12px; margin:2px 0 6px; }
.import-item.is-duplicate { opacity:.55; }
.import-cat { width:100%; background:var(--surface); border:1px solid var(--border); color:var(--text); border-radius:8px; padding:6px 8px; font-size:13px; }
.btn-primary:disabled { opacity:.5; cursor:default; }

/* Calendario de gasto (escala secuencial de un solo tono) */
:root { --heat-1:#1e3a5f; --heat-2:#1e4fa8; --heat-3:#2f6fe0; --heat-4:#7fb0ff; --heat-ink-4:#0b1530; }
body.light { --heat-1:#dbeafe; --heat-2:#93c5fd; --heat-3:#3b82f6; --heat-4:#1d4ed8; --heat-ink-4:#ffffff; }
.cal-grid { display:grid; grid-template-columns:repeat(7, 1fr); gap:4px; }
.cal-head { text-align:center; font-size:11px; color:var(--muted); padding-bottom:2px; text-transform:uppercase; }
.cal-cell { aspect-ratio:1; min-height:38px; border:none; border-radius:8px; background:var(--surface2); color:var(--text); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:1px; padding:0; cursor:pointer; font-family:inherit; }
.cal-empty { background:transparent; cursor:default; }
.cal-day { font-size:12px; font-weight:600; line-height:1; }
.cal-amt { font-size:9px; line-height:1; opacity:.9; min-height:9px; }
.cal-cell.heat-1, .cal-legend .heat-1 { background:var(--heat-1); }
.cal-cell.heat-2, .cal-legend .heat-2 { background:var(--heat-2); }
.cal-cell.heat-3, .cal-legend .heat-3 { background:var(--heat-3); color:#fff; }
.cal-cell.heat-4, .cal-legend .heat-4 { background:var(--heat-4); color:var(--heat-ink-4); }
.cal-cell.cal-today { outline:2px solid var(--text); outline-offset:-2px; }
.cal-cell.selected { box-shadow:0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }
.cal-legend { display:flex; align-items:center; justify-content:flex-end; gap:4px; font-size:10px; color:var(--muted); margin:8px 0 2px; }
.cal-legend i { width:12px; height:12px; border-radius:3px; display:inline-block; }
.cal-detail:not(:empty) { margin-top:10px; background:var(--surface2); border-radius:10px; padding:10px 12px; font-size:13px; }
.cal-detail-head { display:flex; justify-content:space-between; margin-bottom:6px; }
.cal-detail-row { display:flex; justify-content:space-between; gap:10px; padding:3px 0; color:var(--muted); }
.cal-detail-row span:first-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Ritmo de gasto */
.pace-headline { font-size:13px; line-height:1.45; margin-bottom:8px; color:var(--text); }
.pace-headline.pace-up { color:var(--red); }
.pace-headline.pace-down { color:var(--green); }
.pace-legend { display:flex; gap:14px; font-size:11px; color:var(--muted); margin-bottom:4px; }
.pace-legend span { display:flex; align-items:center; gap:5px; }
.pace-key { display:inline-block; width:14px; height:3px; border-radius:2px; margin-right:4px; vertical-align:middle; }
.pace-key-cur { background:var(--accent); }
.pace-key-prev { background:var(--muted); }
.pace-wrap { position:relative; }
.pace-wrap svg { width:100%; height:auto; display:block; touch-action:pan-y; }
.pace-cur { fill:none; stroke:var(--accent); stroke-width:2.2; stroke-linejoin:round; stroke-linecap:round; }
.pace-prev { fill:none; stroke:var(--muted); stroke-width:2; stroke-dasharray:4 3; stroke-linejoin:round; opacity:.8; }
.pace-dot { fill:var(--accent); stroke:var(--surface); stroke-width:2; }
.pace-grid { stroke:var(--border); stroke-width:1; }
.pace-axis { fill:var(--muted); font-size:9px; }
.pace-cross { stroke:var(--muted); stroke-width:1; }
.pace-tip { position:absolute; top:0; background:var(--surface2); border:1px solid var(--border); border-radius:8px; padding:6px 8px; font-size:11px; pointer-events:none; white-space:nowrap; }
.pace-tip div { display:flex; align-items:center; }
.pace-table { margin-top:8px; font-size:12px; color:var(--muted); }
.pace-table summary { cursor:pointer; }
.pace-table table { width:100%; border-collapse:collapse; margin-top:6px; }
.pace-table th, .pace-table td { text-align:right; padding:3px 4px; border-bottom:1px solid var(--border); }
.pace-table th:first-child, .pace-table td:first-child { text-align:left; }

/* Informe anual: oculto en pantalla, único contenido al imprimir */
.print-report { display:none; }
@media print {
  @page { size:A4; margin:16mm 14mm; }
  body { background:#fff !important; }
  body > *:not(#print-report) { display:none !important; }
  .print-report { display:block !important; color:#111827; font-family:-apple-system, 'Segoe UI', Roboto, Arial, sans-serif; font-size:11pt; }
  .rep-header { display:flex; justify-content:space-between; align-items:flex-end; border-bottom:2px solid #1d4ed8; padding-bottom:8px; margin-bottom:14px; }
  .rep-header h1 { font-size:20pt; margin:0; }
  .rep-header p, .rep-brand { color:#4b5563; font-size:9.5pt; margin:2px 0 0; }
  .rep-kpis { display:grid; grid-template-columns:repeat(4, 1fr); gap:8px; margin-bottom:8px; }
  .rep-kpis div { border:1px solid #e5e7eb; border-radius:6px; padding:8px; }
  .rep-kpis span { display:block; font-size:8.5pt; color:#4b5563; }
  .rep-kpis strong { font-size:13pt; }
  .rep-note { font-size:9pt; color:#4b5563; margin:4px 0 10px; }
  .print-report h2 { font-size:12.5pt; margin:16px 0 6px; color:#1d4ed8; break-after:avoid; }
  .rep-table { width:100%; border-collapse:collapse; font-size:9.5pt; break-inside:auto; }
  .rep-table th { text-align:left; font-weight:600; color:#4b5563; border-bottom:1.5px solid #9ca3af; padding:4px 6px; }
  .rep-table td { border-bottom:1px solid #e5e7eb; padding:3px 6px; }
  .rep-table tr { break-inside:avoid; }
  .rep-table .num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
  .rep-table .neg { color:#b91c1c; }
  .rep-table .bar-col { width:28%; }
  .rep-bar { height:8px; background:#3b82f6; border-radius:2px; -webkit-print-color-adjust:exact; print-color-adjust:exact; }
  .rep-total td { font-weight:700; border-top:1.5px solid #9ca3af; }
  .rep-empty { color:#9ca3af; }
  .rep-footer { margin-top:18px; font-size:8.5pt; color:#9ca3af; border-top:1px solid #e5e7eb; padding-top:6px; }
}

/* Patrimonio */
.wealth-net { font-size:30px; font-weight:800; letter-spacing:-.5px; margin:2px 0 10px; }
.wealth-breakdown { display:grid; grid-template-columns:repeat(3, 1fr); gap:8px; margin-bottom:10px; }
.wealth-breakdown div { background:var(--surface2); border-radius:10px; padding:8px; }
.wealth-breakdown span { display:block; color:var(--muted); font-size:10.5px; margin-bottom:3px; }
.wealth-breakdown strong { font-size:13px; }
.wealth-breakdown .green { color:var(--green); }
.wealth-breakdown .red { color:var(--red); }

/* Reparto de ingresos */
.allocation-card { border:1px solid var(--green); }
.alloc-row { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:6px 0; font-size:14px; border-bottom:1px solid var(--border); }
.alloc-row span { flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.alloc-row input { width:96px; background:var(--surface2); border:1px solid var(--border); color:var(--text); border-radius:8px; padding:7px 8px; font-size:15px; text-align:right; }

/* Monedas y viajes */
.fx-row { margin-top:8px; background:var(--surface2); border-radius:10px; padding:8px 10px; }
.fx-row label { font-size:12px; color:var(--muted); display:block; margin-bottom:4px; }
.fx-row input { width:100%; }
.fx-preview { color:var(--text); font-weight:600; }
.fx-row a { color:var(--accent); }
.trip-card { border:1px solid var(--accent); background:linear-gradient(135deg, rgba(59,130,246,.12), transparent 60%), var(--surface); }
.trip-card .card-title { margin:0; text-transform:none; font-size:15px; color:var(--text); }
.trip-info { font-size:13px; color:var(--muted); line-height:1.5; }
