*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d0d0f;
  --surface:   #141416;
  --surface-2: #1c1c1f;
  --border:    #2a2a30;
  --text:      #e0e0e8;
  --muted:     #606068;
  --accent:    #00cfff;
  --gasto:     #ff4040;
  --ingreso:   #00e87a;
  --nav-h:     64px;
  --safe-b:    env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── Layout ── */
#view {
  position: fixed;
  inset: 0 0 calc(var(--nav-h) + var(--safe-b)) 0;
  overflow-y: auto;
  padding: 1.5rem 1rem 1rem;
}

#nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s;
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-icon { font-size: 20px; line-height: 1; }
.nav-label { font-size: 9px; }

.nav-btn.active,
.nav-btn:active { color: var(--accent); }

.nav-btn--cta .nav-icon {
  font-size: 28px;
  color: var(--accent);
  text-shadow: 0 0 12px var(--accent);
  transition: text-shadow 0.15s;
}
.nav-btn--cta.active .nav-icon { text-shadow: 0 0 22px var(--accent); }

/* ── Tipografía ── */
h1 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

h2 {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 1rem;
  margin-bottom: 1rem;
}

/* ── Balance ── */
.balance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.balance-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem;
  text-align: center;
}

.balance-card--neto { grid-column: span 2; }

.balance-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.balance-amount {
  font-size: 1.3rem;
  font-weight: 700;
}

.balance-amount--gasto   { color: var(--gasto); }
.balance-amount--ingreso { color: var(--ingreso); }
.balance-amount--neto    { font-size: 1.7rem; }
.balance-amount--pos     { color: var(--ingreso); }
.balance-amount--neg     { color: var(--gasto); }

/* ── Lista movimientos ── */
.mov-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.mov-item:last-child { border-bottom: none; }

.mov-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.mov-icon--gasto   { background: rgba(255,64,64,.12);  border: 1px solid rgba(255,64,64,.25); }
.mov-icon--ingreso { background: rgba(0,232,122,.08);  border: 1px solid rgba(0,232,122,.2);  }

.mov-info  { flex: 1; min-width: 0; }
.mov-desc  { font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mov-meta  { font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.mov-amount { font-weight: 600; font-size: 0.9rem; flex-shrink: 0; }
.mov-amount--gasto   { color: var(--gasto); }
.mov-amount--ingreso { color: var(--ingreso); }

.btn-edit-mov {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.25rem 0.3rem;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s;
}
.btn-edit-mov:active { opacity: 1; color: var(--accent); }

/* ── Formulario ── */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.form-input,
.form-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  padding: 0.6rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus { border-color: var(--accent); }

.form-input--amount {
  font-size: 2.4rem;
  font-weight: 700;
  text-align: center;
  padding: 1rem;
  letter-spacing: 0.02em;
  background: var(--surface);
  border-color: var(--border);
}

.form-input--amount:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ── Toggle tipo ── */
.tipo-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tipo-btn {
  padding: 0.7rem;
  border-radius: 6px;
  border: 2px solid var(--border);
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.tipo-btn[data-tipo="gasto"].active   { border-color: var(--gasto);   color: var(--gasto);   background: rgba(255,64,64,.1); }
.tipo-btn[data-tipo="ingreso"].active { border-color: var(--ingreso); color: var(--ingreso); background: rgba(0,232,122,.07); }

/* ── Botones ── */
.btn {
  display: block;
  width: 100%;
  padding: 0.85rem;
  border-radius: 6px;
  border: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.15s;
}

.btn--primary {
  background: var(--accent);
  color: #000;
  box-shadow: 0 0 14px rgba(0,207,255,.25);
}
.btn--primary:active { box-shadow: 0 0 24px rgba(0,207,255,.45); }

.btn--ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn--danger {
  background: none;
  border: 1px solid var(--gasto);
  color: var(--gasto);
}

.btn--sm {
  width: auto;
  padding: 0.35rem 0.65rem;
  font-size: 0.65rem;
}

.mt { margin-top: 1rem; }

/* ── Categorías ── */
.cat-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
}

.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-name { flex: 1; }
.cat-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.07em; text-transform: uppercase; margin-top: 1px; }

/* ── Filtros ── */
.filters { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; }

.filter-btn {
  padding: 0.3rem 0.65rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s;
}
.filter-btn.active { border-color: var(--accent); color: var(--accent); }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: flex-end;
  z-index: 100;
  animation: fade-in 0.15s ease;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px 12px 0 0;
  padding: 1.5rem 1rem calc(1.5rem + var(--safe-b));
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  animation: slide-up 0.2s ease;
}

.modal-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.25rem;
}

/* ── States ── */
.empty {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 1rem;
  font-size: 0.8rem;
  line-height: 2;
}

.error-msg {
  color: var(--gasto);
  font-size: 0.75rem;
  margin-top: 0.4rem;
  min-height: 1.1rem;
}

.glow { text-shadow: 0 0 8px currentColor; }

/* ── Voz ── */
.mic-pantalla {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 180px);
  gap: 1.5rem;
}

.mic-btn-grande {
  width: 140px; height: 140px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: rgba(0,207,255,.08);
  font-size: 64px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(0,207,255,.15);
  line-height: 1;
}
.mic-btn-grande:active { transform: scale(0.93); }
.mic-btn-grande.recording {
  border-color: var(--gasto);
  background: rgba(255,64,64,.12);
  box-shadow: 0 0 30px rgba(255,64,64,.2);
  animation: pulse 1.2s ease-in-out infinite;
}
.mic-btn-grande:disabled {
  opacity: 0.6;
  cursor: default;
}

.link-manual {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  padding: 0.5rem;
}

.mic-hint {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-align: center;
}

.timer {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gasto);
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
}

.transcripcion-box {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}
.transcripcion-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.4rem;
}

/* ── Análisis ── */
.stat-item { margin-bottom: 0.9rem; }
.stat-item:last-child { margin-bottom: 0; }

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}

.stat-nombre { font-size: 0.82rem; }
.stat-amount { font-size: 0.82rem; font-weight: 600; }
.stat-amount--gasto   { color: var(--gasto); }
.stat-amount--ingreso { color: var(--ingreso); }

.stat-bar-bg {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin-bottom: 0.2rem;
}

.stat-bar {
  height: 4px;
  border-radius: 2px;
  transition: width 0.4s ease;
}
.stat-bar--gasto   { background: var(--gasto); }
.stat-bar--ingreso { background: var(--ingreso); }

.stat-pct {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: right;
}

/* ── Animations ── */
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,64,64,.4); }
  50%       { box-shadow: 0 0 0 14px rgba(255,64,64,0); }
}
