/* ============================================
   BASE.CSS — Variables, reset, layout general
   ============================================ */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-hover: #2d3a50;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --border: #334155;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
  --header-height: 56px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen { min-height: 100vh; }
#app-screen { padding-bottom: var(--nav-height); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ---------- Épocas ---------- */
.gasto { color: var(--danger); }
.ingreso { color: var(--success); }

/* ---------- Tarjetas ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 16px;
}

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 0.2s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
  background: none; border: none; color: var(--text);
  font-size: 18px; cursor: pointer; padding: 8px; border-radius: var(--radius-sm);
}
.btn-icon:hover { background: var(--bg-hover); }
.btn-close {
  background: none; border: none; color: var(--text-muted);
  font-size: 20px; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
}
.btn-close:hover { color: var(--text); background: var(--bg-hover); }

/* ---------- Inputs ---------- */
input, select, textarea {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: var(--font);
  width: 100%; transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
label { display: block; margin-bottom: 12px; }
label > span {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase;
}
select { appearance: none; cursor: pointer; }

/* ---------- Error ---------- */
.error-msg {
  background: rgba(239,68,68,0.15); color: var(--danger);
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 13px; margin-bottom: 12px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: 11px; font-weight: 600;
}
.badge-success { background: rgba(34,197,94,0.15); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.15); color: var(--accent); }

/* ---------- Navegación inferior ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--bg-card); border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: center;
  z-index: 100;
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--text-dim);
  font-size: 10px; cursor: pointer; padding: 8px 12px;
  transition: color 0.2s;
}
.nav-btn .nav-icon { font-size: 20px; }
.nav-btn.active { color: var(--accent); }

/* ---------- Encabezado app ---------- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-height);
  background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
}
.app-header h1 { font-size: 16px; font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.user-badge {
  background: var(--bg-card); padding: 4px 10px; border-radius: 16px;
  font-size: 12px; color: var(--text-muted);
}

/* ---------- Login ---------- */
.login-container {
  max-width: 360px; margin: 0 auto; padding: 60px 20px;
  text-align: center;
}
.login-header { margin-bottom: 32px; }
.login-header h1 { font-size: 32px; margin-bottom: 4px; }
.login-header p { color: var(--text-muted); }
.login-form { text-align: left; }
.login-form button { width: 100%; margin-top: 8px; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 200; display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: var(--bg-card); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto;
  padding: 20px;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; }

/* ---------- Dashboard ---------- */
.dash-cards { display: grid; gap: 12px; padding: 12px 16px 24px; }
.dash-card { background: var(--bg-card); border-radius: var(--radius); padding: 16px; }
.dash-balance { text-align: center; padding: 24px 16px; }
.dash-balance .amount { font-size: 36px; font-weight: 700; }
.dash-balance .label { font-size: 13px; color: var(--text-muted); }
.dash-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.dash-mini { text-align: center; padding: 16px; }
.dash-mini .amount { font-size: 22px; font-weight: 600; }

.section-title {
  font-size: 14px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; padding: 16px 16px 4px;
}

/* ---------- Lista de items ---------- */
.item-list { padding: 0 16px; }
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; background: var(--bg-card);
  border-radius: var(--radius-sm); margin-bottom: 8px;
}
.item-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-info .title { font-size: 14px; font-weight: 500; }
.item-info .subtitle { font-size: 12px; color: var(--text-muted); }
.item-amount { font-size: 15px; font-weight: 600; text-align: right; }
.item-actions { display: flex; gap: 4px; }

/* ---------- Pestañas ---------- */
.tabs {
  display: flex; gap: 4px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab-btn {
  background: none; border: none; color: var(--text-muted);
  padding: 8px 16px; border-radius: 20px; font-size: 13px;
  cursor: pointer; white-space: nowrap;
}
.tab-btn.active { background: var(--accent); color: #fff; }

/* ---------- Charts ---------- */
.chart-container { padding: 16px; }
.chart-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.chart-label { width: 100px; font-size: 12px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.chart-bar-wrap { flex: 1; height: 20px; background: var(--bg-input); border-radius: 10px; overflow: hidden; }
.chart-bar { height: 100%; border-radius: 10px; transition: width 0.4s; }
.chart-value { width: 70px; font-size: 12px; font-weight: 600; text-align: right; }

/* ---------- Filtros ---------- */
.filters {
  display: flex; gap: 8px; padding: 12px 16px; flex-wrap: wrap;
}
.filters input, .filters select { width: auto; }
.filters input[type="date"] { width: 140px; }

/* ---------- Utils ---------- */
.fab {
  position: fixed; bottom: calc(var(--nav-height) + 16px); right: 16px;
  width: 48px; height: 48px; border-radius: 50%; background: var(--accent);
  color: #fff; border: none; font-size: 24px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4); z-index: 60;
  transition: background 0.2s;
}
.fab:hover { background: var(--accent-hover); }

.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }
.currency { font-family: 'SF Mono', 'Cascadia Code', monospace; }

/* ---------- Responsive: escritorio ---------- */
@media (min-width: 768px) {
  #app-screen { max-width: 800px; margin: 0 auto; }
  .dash-cards { grid-template-columns: 1fr 1fr; }
  .dash-balance { grid-column: 1 / -1; }
  .bottom-nav { left: calc(50% - 400px); right: calc(50% - 400px); }
  .modal { border-radius: var(--radius); margin: 40px auto; }
}
