:root {
  --bg: #f8f7f4;
  --bg2: #ffffff;
  --text: #1a1a18;
  --text2: #6b6b67;
  --text3: #a0a09a;
  --border: rgba(0,0,0,0.1);
  --border2: rgba(0,0,0,0.18);
  --green: #1D9E75;
  --red: #E24B4A;
  --blue: #185FA5;
  --amber: #BA7517;
  --radius: 10px;
  --radius-sm: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141412;
    --bg2: #1e1e1b;
    --text: #e8e6de;
    --text2: #9c9a92;
    --text3: #6b6b67;
    --border: rgba(255,255,255,0.08);
    --border2: rgba(255,255,255,0.15);
  }
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); font-size: 15px; }

header { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; border-bottom: 0.5px solid var(--border); background: var(--bg2); position: sticky; top: 0; z-index: 10; }
.header-left { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 18px; color: var(--text2); }
.header-mes { font-size: 16px; font-weight: 500; }
.currency-toggle { display: flex; gap: 3px; }
.cur-btn { padding: 5px 12px; font-size: 12px; border: 0.5px solid var(--border2); border-radius: 20px; cursor: pointer; background: none; color: var(--text2); transition: all .15s; }
.cur-btn.active { background: var(--text); color: var(--bg); border-color: var(--text); }

nav { display: flex; gap: 2px; padding: 0 20px; border-bottom: 0.5px solid var(--border); background: var(--bg2); overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
.nav-btn { padding: 12px 14px; font-size: 13px; border: none; background: none; cursor: pointer; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; transition: all .15s; }
.nav-btn.active { color: var(--text); border-bottom-color: var(--text); font-weight: 500; }

main { max-width: 900px; margin: 0 auto; padding: 20px; }
.tab { display: none; }
.tab.active { display: block; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.metric-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.metric-value { font-size: 20px; font-weight: 500; }
.metric-sub { font-size: 11px; color: var(--text3); margin-top: 3px; }
.pos { color: var(--green); }
.neg { color: var(--red); }
.info { color: var(--blue); }

.card { background: var(--bg2); border: 0.5px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin-bottom: 14px; }
.card-title { font-size: 11px; font-weight: 500; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 620px) { .grid-2 { grid-template-columns: 1fr; } }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
@media (max-width: 480px) { .form-row { grid-template-columns: 1fr; } }
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg label { font-size: 12px; color: var(--text2); }
input, select, textarea { width: 100%; padding: 8px 10px; font-size: 14px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); outline: none; transition: border-color .15s; font-family: inherit; }
input:focus, select:focus { border-color: var(--text); }
.hint { font-size: 13px; color: var(--text3); margin-bottom: 14px; }

.btn-primary { padding: 10px 18px; background: var(--text); color: var(--bg); border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; transition: opacity .15s; font-family: inherit; }
.btn-primary:hover { opacity: .85; }
.btn-primary.full { width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; border: 0.5px solid var(--border2); border-radius: var(--radius-sm); background: none; color: var(--text2); cursor: pointer; font-family: inherit; }
.btn-danger { border-color: var(--red); color: var(--red); }

.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.list-item:last-child { border-bottom: none; padding-bottom: 0; }
.item-icon { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; font-weight: 600; }
.item-body { flex: 1; min-width: 0; }
.item-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-sub { font-size: 12px; color: var(--text2); margin-top: 1px; }
.item-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.item-amount { font-size: 14px; font-weight: 500; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 500; }
.badge-ingreso { background: #E1F5EE; color: #0F6E56; }
.badge-gasto { background: #FCEBEB; color: #A32D2D; }
.badge-alta { background: #EAF3DE; color: #3B6D11; }
.badge-media { background: #E6F1FB; color: #185FA5; }
.badge-baja { background: #FAEEDA; color: #854F0B; }

.cat-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.cat-name { flex: 1; font-size: 13px; }
.cat-bar-wrap { flex: 2; background: var(--bg); border-radius: 3px; height: 5px; overflow: hidden; }
.cat-bar { height: 5px; border-radius: 3px; }
.cat-amount { font-size: 12px; font-weight: 500; min-width: 70px; text-align: right; }
.cat-pct { font-size: 11px; color: var(--text3); min-width: 32px; text-align: right; }

.progress-wrap { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin-top: 6px; }
.progress-fill { height: 6px; border-radius: 3px; transition: width .3s; }
.goal-block { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 0.5px solid var(--border); }
.goal-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.goal-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.goal-name { font-size: 14px; font-weight: 500; }
.goal-sub { font-size: 12px; color: var(--text2); }
.goal-actions { display: flex; gap: 6px; margin-top: 10px; }
.goal-actions input { font-size: 13px; flex: 1; }

.chart-wrap { position: relative; width: 100%; height: 220px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text2); }
.leg-dot { width: 10px; height: 10px; border-radius: 2px; }

.sim-result { background: var(--bg); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; }
.sim-big { font-size: 26px; font-weight: 500; }
.sim-label { font-size: 13px; color: var(--text2); margin-top: 3px; }
.empty { text-align: center; padding: 24px; color: var(--text3); font-size: 14px; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 10px; }
.alert-warn { background: #FAEEDA; color: #854F0B; }
.alert-ok { background: #EAF3DE; color: #3B6D11; }
