/* =====================================================================
   app.css — Layout y componentes.
   ===================================================================== */

/* ---------- LOGIN ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-brand {
  position: relative;
  overflow: hidden;
  background: radial-gradient(120% 100% at 0% 0%, var(--sidebar-bg-2), var(--sidebar-bg) 60%);
  color: var(--sidebar-text-strong);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 54px;
}
.login-brand::before {
  content: "";
  position: absolute;
  inset: -30% -10% auto auto;
  width: 520px;
  height: 520px;
  background: var(--gradient);
  filter: blur(120px);
  opacity: 0.45;
  border-radius: 50%;
}
.login-brand .brand-mark {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
}
.login-brand .brand-mark .dot {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--gradient);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
}
.login-brand .pitch {
  position: relative;
  max-width: 460px;
}
.login-brand .pitch h1 {
  font-size: clamp(30px, 3.4vw, 46px);
  line-height: 1.05;
  margin-bottom: 18px;
}
.login-brand .pitch p {
  color: var(--sidebar-text);
  font-size: 17px;
  line-height: 1.6;
}
.login-brand .foot {
  position: relative;
  color: var(--sidebar-text);
  font-size: 13px;
  opacity: 0.8;
}

.login-form-side {
  display: grid;
  place-items: center;
  padding: 40px;
}
.login-card {
  width: 100%;
  max-width: 380px;
}
.login-card h2 {
  font-size: 28px;
  margin-bottom: 6px;
}
.login-card .sub {
  color: var(--text-muted);
  margin-bottom: 30px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 7px;
  color: var(--text);
}
.field input {
  width: 100%;
  padding: 13px 15px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 14%, transparent);
}
.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--gradient);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--primary) 70%, transparent);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.link {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
}
.alert-msg {
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}
.alert-msg.err { background: color-mix(in srgb, var(--danger) 12%, white); color: var(--danger); display: block; }
.alert-msg.ok { background: color-mix(in srgb, var(--success) 14%, white); color: var(--success); display: block; }

/* ---------- APP SHELL ---------- */
.shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}
.sidebar {
  position: relative;
  background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg));
  color: var(--sidebar-text);
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute;
  inset: -20% auto auto -20%;
  width: 320px;
  height: 320px;
  background: var(--gradient);
  filter: blur(110px);
  opacity: 0.3;
}
.sidebar .brand {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}
.sidebar .brand .mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--gradient);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sidebar .brand .name {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 19px;
}
.sidebar .brand img[data-app-logo] { display: none; height: 30px; }

.nav {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14.5px;
  position: relative;
  transition: background 0.15s, color 0.15s;
}
.nav a svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav a.active {
  background: rgba(255, 255, 255, 0.09);
  color: #fff;
}
.nav a.active::before {
  content: "";
  position: absolute;
  left: -18px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--gradient);
}
.nav a .soon {
  margin-left: auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.55;
}
.sidebar .side-foot {
  position: relative;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
}
.side-user .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  display: grid; place-items: center;
  color: #fff; font-weight: 700;
  flex-shrink: 0;
}
.side-user .u-name { color: #fff; font-weight: 600; font-size: 14px; }
.side-user .u-bank { font-size: 12px; opacity: 0.7; }
.logout {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--sidebar-text);
  padding: 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 13px;
  transition: background 0.15s;
}
.logout:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }

/* ---------- MAIN ---------- */
.main { padding: 26px 34px 60px; max-width: 1320px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar .greet h1 { font-size: 26px; }
.topbar .greet p { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.topbar .tools { display: flex; align-items: center; gap: 12px; }
.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 100px;
  letter-spacing: 0.02em;
}
.badge.pro { background: var(--gradient); color: #fff; }
.badge.lite { background: var(--surface); color: var(--text-muted); border: 1.5px solid var(--border); }
.bell {
  position: relative;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--surface);
  border: 1.5px solid var(--border);
  display: grid; place-items: center;
  cursor: pointer;
}
.bell .count {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 19px; height: 19px;
  padding: 0 5px;
  border-radius: 100px;
  background: var(--danger);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: grid; place-items: center;
}

/* ---------- GRID ---------- */
.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: 1.6fr 1fr; }
.cols-stats { grid-template-columns: repeat(4, 1fr); }
.cols-half { grid-template-columns: 1fr 1fr; }
.mt { margin-top: 18px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  animation: rise 0.5s both;
}
.card .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card .card-head h3 { font-size: 16px; }
.card .card-head .hint { font-size: 12.5px; color: var(--text-muted); }

/* Hero saldo consolidado */
.hero {
  position: relative;
  overflow: hidden;
  background: var(--gradient);
  color: #fff;
  border: none;
}
.hero::after {
  content: "";
  position: absolute;
  inset: auto -10% -60% auto;
  width: 380px; height: 380px;
  background: rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  filter: blur(10px);
}
.hero .label { position: relative; opacity: 0.85; font-size: 13.5px; font-weight: 600; }
.hero .amount { position: relative; font-family: var(--font-display); font-size: clamp(34px, 4vw, 46px); margin: 8px 0 4px; }
.hero .sub { position: relative; opacity: 0.85; font-size: 13.5px; }
.hero .mini-stats { position: relative; display: flex; gap: 26px; margin-top: 22px; }
.hero .mini-stats div span { display: block; opacity: 0.8; font-size: 12px; }
.hero .mini-stats div b { font-size: 17px; font-weight: 700; }

/* Stat cards */
.stat .ico { width: 40px; height: 40px; border-radius: 12px; background: var(--gradient-soft); display: grid; place-items: center; margin-bottom: 14px; color: var(--primary); }
.stat .stat-label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.stat .stat-val { font-family: var(--font-display); font-size: 23px; margin-top: 4px; }
.stat .stat-val.danger { color: var(--danger); }
.stat .stat-val.success { color: var(--success); }

/* Listas (cuentas, tarjetas, pagos, etc.) */
.list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .r-ico {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-2); color: var(--text-muted);
  font-size: 13px; font-weight: 700;
}
.row .r-main { flex: 1; min-width: 0; }
.row .r-title { font-weight: 600; font-size: 14.5px; }
.row .r-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }
.row .r-amount { font-weight: 700; font-size: 15px; text-align: right; white-space: nowrap; }
.row .r-amount.neg { color: var(--danger); }
.row .r-amount.pos { color: var(--success); }

/* Barras de progreso (presupuesto, metas) */
.progress { height: 8px; border-radius: 100px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.progress > span { display: block; height: 100%; border-radius: 100px; background: var(--gradient); }
.progress > span.over { background: var(--danger); }

/* Score gauge */
.score-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.gauge { position: relative; width: 168px; height: 168px; }
.gauge .val { position: absolute; inset: 0; display: grid; place-items: center; }
.gauge .val .n { font-family: var(--font-display); font-size: 44px; line-height: 1; }
.gauge .val .b { font-size: 12px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.score-bars { width: 100%; margin-top: 4px; display: flex; flex-direction: column; gap: 11px; }
.score-bars .sb-row { font-size: 12.5px; }
.score-bars .sb-row .sb-top { display: flex; justify-content: space-between; margin-bottom: 5px; color: var(--text-muted); font-weight: 600; }

/* Alertas */
.alert-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.alert-item:last-child { border-bottom: none; }
.alert-item .dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.alert-item .dot.critical { background: var(--danger); }
.alert-item .dot.warning { background: var(--warning); }
.alert-item .dot.info { background: var(--primary); }
.alert-item .a-title { font-weight: 600; font-size: 14px; }
.alert-item .a-msg { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* Overlay Pro (gating Lite/Pro) */
.locked { position: relative; }
.locked .lock-overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(3px);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 20px;
}
.lock-overlay .lk-badge { background: var(--gradient); color: #fff; font-size: 11px; font-weight: 700; padding: 5px 12px; border-radius: 100px; letter-spacing: 0.03em; }
.lock-overlay p { color: var(--text-muted); font-size: 13.5px; max-width: 240px; }

.empty { color: var(--text-muted); font-size: 14px; padding: 8px 0; }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 980px) {
  .cols-2, .cols-half { grid-template-columns: 1fr; }
  .cols-stats { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 14px 18px;
    gap: 14px;
  }
  .sidebar .nav, .sidebar .side-foot { display: none; }
  .main { padding: 20px 18px 50px; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

/* =====================================================================
   FASE 3 — formularios, filtros, editor de presupuesto, transacciones, admin
   ===================================================================== */
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 26px; }
.page-head p { color: var(--text-muted); font-size: 14px; margin-top: 3px; }

.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .spacer { flex: 1; }
.btn-sm { width: auto; padding: 11px 18px; font-size: 14px; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); transform: none; }

.month-nav { display: flex; align-items: center; gap: 10px; }
.month-nav button { width: 38px; height: 38px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-size: 16px; color: var(--text); }
.month-nav button:hover { background: var(--surface-2); }
.month-nav .label { font-weight: 700; font-family: var(--font-display); min-width: 160px; text-align: center; text-transform: capitalize; }

.input, select.input { padding: 11px 13px; border: 1.5px solid var(--border); border-radius: var(--radius-xs); font-family: inherit; font-size: 14px; background: var(--surface); color: var(--text); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }

/* Editor de presupuesto */
.bud-row { display: grid; grid-template-columns: 1.1fr 150px 1.3fr; gap: 18px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.bud-row:last-child { border-bottom: none; }
.bud-row .b-cat { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 14.5px; }
.bud-row .swatch { width: 13px; height: 13px; border-radius: 4px; flex-shrink: 0; }
.bud-row .b-amt input { width: 100%; text-align: right; }
.bud-row .b-prog .sub { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--text-muted); margin-bottom: 5px; }
.totals { display: flex; gap: 36px; margin-top: 20px; padding-top: 18px; border-top: 2px solid var(--border); flex-wrap: wrap; }
.totals div span { display: block; font-size: 13px; color: var(--text-muted); }
.totals div b { font-family: var(--font-display); font-size: 21px; }

/* Transacciones */
.tx-row { display: grid; grid-template-columns: 74px 1fr 190px 130px; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--border); }
.tx-row:last-child { border-bottom: none; }
.tx-date { font-size: 12.5px; color: var(--text-muted); font-weight: 700; }
.tx-desc .t { font-weight: 600; font-size: 14.5px; }
.tx-desc .s { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-muted); }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.tag-auto { font-size: 10px; background: var(--gradient); color: #fff; padding: 2px 7px; border-radius: 100px; margin-left: 6px; font-weight: 700; }
.cat-select { width: 100%; font-size: 13px; }
.tx-amt { text-align: right; font-weight: 700; font-size: 15px; white-space: nowrap; }
.tx-amt.neg { color: var(--danger); }
.tx-amt.pos { color: var(--success); }

/* Admin / configuración */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-grid .full { grid-column: 1 / -1; }
.color-row { display: flex; align-items: center; gap: 10px; }
.color-row input[type="color"] { width: 48px; height: 44px; border: 1.5px solid var(--border); border-radius: 10px; background: none; cursor: pointer; padding: 3px; }
.color-row input[type="text"] { flex: 1; }
.preview-brand { display: flex; align-items: center; gap: 12px; padding: 18px; border-radius: var(--radius-sm); background: linear-gradient(180deg, var(--sidebar-bg-2), var(--sidebar-bg)); color: #fff; }
.preview-brand .pm { width: 42px; height: 42px; border-radius: 12px; background: var(--gradient); display: grid; place-items: center; flex-shrink: 0; }
.preview-brand .pm svg { width: 22px; height: 22px; }
.preview-brand .pn { font-family: var(--font-display); font-weight: 700; font-size: 19px; }
.note { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px 15px; font-size: 13.5px; color: var(--text-muted); line-height: 1.5; }

@media (max-width: 820px) {
  .bud-row { grid-template-columns: 1fr; gap: 8px; }
  .tx-row { grid-template-columns: 1fr 110px; }
  .tx-row .cat-cell { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: 1fr; }
}

/* Logo en la tarjeta de vista previa del panel de marca */
.preview-brand img.prev-logo { height: 44px; width: auto; max-width: 130px; object-fit: contain; border-radius: 11px; display: none; background: #fff; padding: 4px; }
/* Logo en la barra lateral (cuando el banco define uno) */
.sidebar .brand img[data-app-logo] { width: auto; max-width: 150px; }

/* Logo del banco arriba del saludo en el dashboard */
.greet .bank-logo { height: 48px; width: auto; max-width: 200px; object-fit: contain; display: none; margin-bottom: 12px; border-radius: 10px; }
