/* ===== VARIABLES Y SYSTEM DESIGN ===== */
:root {
  --bg-app: #0F172A;
  --bg-card: #1E293B;
  --bg-card-hover: #334155;
  --bg-input: #0F172A;
  
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-sub: #64748B;

  --accent: #6366F1;
  --accent-light: rgba(99, 102, 241, 0.15);
  --success: #10B981;
  --danger: #EF4444;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 24px;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #020617;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  height: 100vh;
  overflow: hidden;
}

#app {
  max-width: 440px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== CABECERA & BALANCE ===== */
.app-header {
  padding: 20px 20px 16px;
  background: linear-gradient(180deg, #1E293B 0%, #0F172A 100%);
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  font-size: 20px;
  color: var(--accent);
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.month-selector {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 20px;
  padding: 4px 8px;
}

.month-arrow {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  padding: 0 8px;
  cursor: pointer;
}

.month-display {
  position: relative;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.month-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  cursor: pointer;
}

/* Tarjeta de Balance */
.balance-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-l);
  padding: 20px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
}

.balance-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.balance-amount-wrap {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin: 6px 0 16px;
}

.balance-amount {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.balance-amount-wrap .currency {
  font-size: 22px;
  font-weight: 600;
  color: var(--accent);
}

.balance-grid {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: var(--radius-m);
  padding: 12px;
}

.balance-subitem {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.balance-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.1);
}

.subitem-label {
  font-size: 11px;
  color: var(--text-muted);
}

.subitem-value {
  font-size: 14px;
  font-weight: 600;
}

.subitem-value.pos { color: var(--success); }
.subitem-value.neg { color: var(--text-muted); }

/* ===== ÁREA DE CONTENIDO ===== */
.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px calc(90px + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.view--hidden { display: none; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 12px;
}

.section-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
}

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* Tarjetas de Categorías */
.category-cards-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cat-card {
  background: var(--bg-card);
  border-radius: var(--radius-m);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.cat-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
}

.cat-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.cat-balance {
  font-size: 13px;
  color: var(--text-muted);
}

.cat-balance strong {
  color: var(--text-main);
}

.progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Movimientos */
.movements-group-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.movement-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-radius: var(--radius-m);
}

.movement-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.movement-title { font-weight: 600; font-size: 14px; }
.movement-sub { font-size: 12px; color: var(--text-muted); }
.movement-price { font-weight: 700; font-size: 15px; color: var(--text-main); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 32px;
  margin-bottom: 8px;
}

/* Ajustes e Ingresos */
.card-setting {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius-m);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.setting-info h3 { font-size: 14px; margin-bottom: 2px; }
.setting-info p { font-size: 12px; color: var(--text-muted); }

.input-inline {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-input);
  padding: 8px 12px;
  border-radius: var(--radius-s);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.input-inline input {
  width: 70px;
  background: transparent;
  border: none;
  color: #FFF;
  font-weight: 700;
  text-align: right;
  outline: none;
}

.fixed-list, .manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.backup-card {
  display: flex;
  gap: 12px;
}

/* Palette Swatches */
.color-palette {
  display: flex;
  gap: 10px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.swatch.is-selected {
  border-color: #FFF;
}

/* ===== TABBAR & FAB ===== */
.tabbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: calc(65px + var(--safe-bottom));
  background: #1E293B;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-around;
  padding-bottom: var(--safe-bottom);
}

.tab-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-sub);
  cursor: pointer;
  width: 25%;
}

.tab-icon { font-size: 18px; }
.tab-text { font-size: 10px; font-weight: 600; }
.tab-item.is-active { color: var(--accent); }

.fab-btn {
  position: absolute;
  right: 20px;
  bottom: calc(80px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 28px;
  background: var(--accent);
  color: #FFF;
  border: none;
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.fab-icon { font-size: 30px; font-weight: 300; line-height: 1; }

/* ===== MODALES ===== */
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}

.modal-sheet {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius-l) var(--radius-l) 0 0;
  padding: 12px 24px calc(24px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--text-sub);
  border-radius: 2px;
  align-self: center;
  margin-bottom: 8px;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
}

.field-amount {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 10px 0;
}

.field-amount input {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-main);
  background: none;
  border: none;
  width: 150px;
  text-align: right;
  outline: none;
}

.field-amount .currency {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.custom-input, .custom-select {
  width: 100%;
  height: 48px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-m);
  padding: 0 16px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
}

.alert-box {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-s);
  font-size: 12px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-primary, .btn-cancel, .btn-danger, .btn-secondary {
  flex: 1;
  height: 48px;
  border-radius: var(--radius-m);
  font-weight: 600;
  font-size: 15px;
  border: none;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: #FFF; }
.btn-cancel { background: transparent; color: var(--text-muted); }
.btn-danger { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.btn-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text-main); }

/* Toast Notification */
.toast-notification {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #FFF;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 20px rgba(0,0,0,0.3);
  z-index: 200;
}