/* ── Vera App — Brand Theme ─────────────────────────────────────────────────
   Paleta oficial Vera:
   #0F4D46 — Verde oscuro primario
   #22B497 — Teal principal (accent / CTA)
   #7ADBC1 — Teal claro (highlights)
   #0D1B2A — Fondo navy oscuro
   #F2F4F7 — Casi blanco (texto)
   ────────────────────────────────────────────────────────────────────────── */
:root {
  --bg:          #0D1B2A;
  --surface:     #112433;
  --surface2:    #1A3042;
  --border:      rgba(34,180,151,.18);
  --primary:     #22B497;
  --primary-dk:  #0F4D46;
  --primary-lt:  #7ADBC1;
  --gold:        #22B497;     /* compat — apunta al teal principal */
  --gold-soft:   rgba(34,180,151,.12);
  --green:       #22B497;
  --green-soft:  rgba(34,180,151,.12);
  --yellow:      #F59E0B;
  --yellow-soft: rgba(245,158,11,.12);
  --red:         #EF4444;
  --red-soft:    rgba(239,68,68,.12);
  --text:        #F2F4F7;
  --text-muted:  rgba(242,244,247,.50);
  --text-dim:    rgba(242,244,247,.28);
  --radius:      12px;
  --nav-h:       68px;
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

.screen {
  display: none;
  flex-direction: column;
  flex: 1;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

.scroll-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 0;
  -webkit-overflow-scrolling: touch;
}

/* ── Login Screen ───────────────────────────────────────────────────────── */
#screen-login {
  justify-content: center;
  align-items: center;
  padding: 32px 24px;
  background: radial-gradient(ellipse at top, #0F3D36 0%, var(--bg) 65%);
  padding-bottom: 32px !important;
}

.login-logo {
  text-align: center;
  margin-bottom: 40px;
}
.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary-dk), var(--primary));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 16px;
}
.login-logo h1 {
  font-size: 32px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: .02em;
}
.login-logo .tagline {
  font-size: 13px;
  color: var(--primary-lt);
  margin-top: 4px;
  font-weight: 500;
  letter-spacing: .04em;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 380px;
}

/* ── Form Elements ──────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 6px;
}

input, select, textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  padding: 12px 14px;
  outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(34,180,151,.12); }
input[type="date"] { color-scheme: dark; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2322B497' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
select option { background: #1A3042; color: #F2F4F7; }

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity .2s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary-dk), var(--primary));
  color: #fff;
}
.btn-gold {
  background: linear-gradient(135deg, var(--primary), var(--primary-lt));
  color: #0D1B2A;
}
.btn-danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(239,68,68,.3);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-link {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--text); }

.error-msg {
  color: var(--red);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* ── Top Bar ────────────────────────────────────────────────────────────── */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 16px 0;
  flex-shrink: 0;
}
.top-bar .brand { font-size: 18px; font-weight: 800; color: var(--primary); }
.top-bar .user-chip {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
}

/* ── Bottom Nav ─────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding-top: 10px;
  padding-bottom: env(safe-area-inset-bottom);
  padding-left: 4px;
  padding-right: 4px;
  z-index: 100;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 10px;
  font-family: inherit;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
  padding: 4px 0;
  border-radius: 10px;
  transition: color .2s;
  -webkit-tap-highlight-color: transparent;
  flex: 1 0 72px;
  min-width: 72px;
  max-width: 100px;
  scroll-snap-align: start;
}
.nav-btn .nav-icon { font-size: 22px; line-height: 1; }
.nav-btn.active { color: var(--primary); }

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

/* ── Semáforo card ──────────────────────────────────────────────────────── */
.semaforo-card {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.semaforo-card.verde    { background: var(--green-soft);   border: 1px solid rgba(34,180,151,.3); }
.semaforo-card.amarillo { background: var(--yellow-soft);  border: 1px solid rgba(245,158,11,.3); }
.semaforo-card.rojo     { background: var(--red-soft);     border: 1px solid rgba(239,68,68,.3); }

.semaforo-dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}
.verde   .semaforo-dot  { background: var(--green);  box-shadow: 0 0 8px var(--green); }
.amarillo .semaforo-dot { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }
.rojo    .semaforo-dot  { background: var(--red);    box-shadow: 0 0 8px var(--red); }

.semaforo-text .label { font-size: 11px; color: var(--text-muted); }
.semaforo-text .value { font-size: 15px; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ── KPI Row ────────────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.kpi-card .kpi-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.kpi-card .kpi-value { font-size: 18px; font-weight: 800; margin-top: 4px; }
.kpi-card .kpi-sub   { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.kpi-card.gold  .kpi-value { color: var(--primary); }
.kpi-card.green .kpi-value { color: var(--green); }
.kpi-card.red   .kpi-value { color: var(--red); }
.kpi-card.white .kpi-value { color: var(--text); }

/* ── Section header ─────────────────────────────────────────────────────── */
.section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin: 16px 0 10px;
}

/* ── Progress bars ──────────────────────────────────────────────────────── */
.cat-row { margin-bottom: 14px; }
.cat-row-top {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.cat-name    { font-size: 13px; font-weight: 600; color: var(--text); }
.cat-amounts { font-size: 12px; color: var(--text-muted); }

.progress-track {
  width: 100%;
  height: 7px;
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill { height: 100%; border-radius: 4px; transition: width .5s ease; }
.progress-fill.verde    { background: var(--green); }
.progress-fill.amarillo { background: var(--yellow); }
.progress-fill.rojo     { background: var(--red); }

/* ── Transaction list ───────────────────────────────────────────────────── */
.tx-list { display: flex; flex-direction: column; gap: 8px; }

.tx-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  position: relative;
}
.tx-left { flex: 1; min-width: 0; }
.tx-category { font-size: 13px; font-weight: 700; color: var(--text); }
.tx-meta     { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.tx-note     { font-size: 11px; color: var(--text-dim); margin-top: 2px; font-style: italic; }
.tx-right    { text-align: right; flex-shrink: 0; }
.tx-amount   { font-size: 16px; font-weight: 800; }
.tx-amount.income  { color: var(--green); }
.tx-amount.expense { color: var(--red); }
.tx-user-badge { font-size: 10px; color: var(--text-dim); margin-top: 2px; }

.tx-delete-btn {
  background: none; border: none;
  color: var(--text-dim); font-size: 16px;
  cursor: pointer; padding: 4px; border-radius: 6px; flex-shrink: 0;
  transition: color .2s;
}
.tx-delete-btn:hover { color: var(--red); }
.tx-edit-btn {
  background: none; border: none;
  color: var(--text-dim); font-size: 16px;
  cursor: pointer; padding: 4px; border-radius: 6px; flex-shrink: 0;
  transition: color .2s; margin-right: 2px;
}
.tx-edit-btn:hover { color: var(--primary); }

/* ── Filters ────────────────────────────────────────────────────────────── */
.filter-row {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px;
}
.filter-chip {
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px; font-family: inherit; font-weight: 600;
  padding: 6px 14px; cursor: pointer; white-space: nowrap;
  transition: background .2s, color .2s;
}
.filter-chip.active {
  background: var(--gold-soft);
  border-color: var(--primary);
  color: var(--primary);
}

/* ── Type toggle ────────────────────────────────────────────────────────── */
.type-toggle {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; margin-bottom: 18px;
}
.type-btn {
  padding: 12px; border: none; background: transparent;
  color: var(--text-muted); font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all .2s;
}
.type-btn.active.income  { background: var(--green-soft); color: var(--green); }
.type-btn.active.expense { background: var(--red-soft);   color: var(--red); }

/* ── Month nav ──────────────────────────────────────────────────────────── */
.month-nav {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px;
}
.month-nav-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px; color: var(--text-muted);
  font-size: 18px; padding: 6px 14px; cursor: pointer;
}
.month-nav-btn:disabled { opacity: .3; cursor: not-allowed; }
.month-label { font-size: 16px; font-weight: 700; color: var(--text); }

/* ── Empty state ────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 20px;
  font-size: 13px; font-weight: 600; color: var(--text);
  opacity: 0; transition: opacity .3s, transform .3s;
  z-index: 999; white-space: nowrap; pointer-events: none;
}
.toast.show    { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-color: rgba(34,180,151,.4); color: var(--primary); }
.toast.error   { border-color: rgba(239,68,68,.4);  color: var(--red); }

/* ── Loading spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(34,180,151,.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 32px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Alerts screen ──────────────────────────────────────────────────────── */
.alert-summary-bar {
  margin-top: 8px; padding: 10px 14px;
  border-radius: 10px; font-size: 13px; font-weight: 700;
}
.alert-summary-bar.urgent { background: rgba(239,68,68,.1);   border: 1px solid rgba(239,68,68,.3);   color: var(--red); }
.alert-summary-bar.ok     { background: rgba(34,180,151,.08); border: 1px solid rgba(34,180,151,.25); color: var(--green); }

.alert-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 8px;
}
.alert-item.vencido { border-color: rgba(239,68,68,.4);   background: rgba(239,68,68,.05); }
.alert-item.hoy     { border-color: rgba(239,68,68,.5);   background: rgba(239,68,68,.08); }
.alert-item.urgente { border-color: rgba(245,158,11,.4);  background: rgba(245,158,11,.05); }
.alert-item.proximo { border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.03); }
.alert-item.enviado { border-color: rgba(107,114,128,.3); background: rgba(107,114,128,.05); }
.alert-item.pagado  { border-color: rgba(34,180,151,.2);  background: rgba(34,180,151,.04); opacity:.65; }
.alert-item.cobrado { border-color: rgba(34,180,151,.2);  background: rgba(34,180,151,.04); opacity:.65; }

.alert-item-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.alert-icon   { font-size: 22px; flex-shrink: 0; }
.alert-nombre { font-size: 14px; font-weight: 700; color: var(--text); }
.alert-days   { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.alert-item-right { text-align: right; flex-shrink: 0; }
.alert-monto  { font-size: 15px; font-weight: 800; color: var(--text); }

.alert-badge {
  display: inline-block; margin-top: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
}
.badge-vencido { background: rgba(239,68,68,.2);   color: var(--red); }
.badge-hoy     { background: rgba(239,68,68,.25);  color: var(--red); }
.badge-urgente { background: rgba(245,158,11,.2);  color: var(--yellow); }
.badge-proximo { background: rgba(245,158,11,.12); color: var(--yellow); }
.badge-enviado { background: rgba(107,114,128,.15);color: #9ca3af; }
.badge-ok      { background: rgba(34,180,151,.12); color: var(--green); }
.badge-pagado  { background: rgba(34,180,151,.2);  color: var(--green); font-weight:900; }

/* ── Vera Analysis insights ─────────────────────────────────────────────── */
.vera-insight {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,.05);
  font-size: 13px; line-height: 1.5;
}
.vera-insight:last-child { border-bottom: none; }
.insight-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.insight-msg { color: rgba(242,244,247,.8); }
.vera-insight.positivo .insight-msg { color: rgba(242,244,247,.9); }
.vera-insight.alerta   .insight-msg { color: rgba(255,200,100,.9); }
.vera-insight.info     .insight-msg { color: rgba(242,244,247,.7); }

/* ── Nav badge dot ──────────────────────────────────────────────────────── */
.nav-btn { position: relative; }
.nav-btn[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge);
  position: absolute; top: 0; right: 10px;
  background: var(--red); color: #fff;
  font-size: 9px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

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