/* ============================================================
   TaveexAdm — styles.css  (tema oscuro fintech, responsive)
   ============================================================ */

:root {
  --bg:        #0a0e17;
  --bg-2:      #0e1320;
  --surface:   #141a29;
  --surface-2: #1b2336;
  --elevated:  #202a41;
  --border:    rgba(255,255,255,0.07);
  --border-2:  rgba(255,255,255,0.12);

  --text:      #e8edf5;
  --muted:     #8a95ab;
  --faint:     #5b6478;

  --primary:   #6366f1;
  --primary-2: #818cf8;
  --pos:       #34d399;
  --neg:       #f87171;
  --warn:      #f59e0b;

  --radius:    16px;
  --radius-sm: 11px;
  --shadow:    0 10px 30px rgba(0,0,0,0.35);
  --sidebar-w: 248px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(99,102,241,0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(52,211,153,0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }
a { color: inherit; }

.hidden { display: none !important; }

/* ---------------- Scrollbar ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--surface-2); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--elevated); background-clip: content-box; }

/* ============================================================
   LOGIN
   ============================================================ */
#login {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(1000px 700px at 50% -20%, rgba(99,102,241,0.18), transparent 60%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border);
  border-radius: 22px; padding: 34px 28px;
  box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-logo {
  width: 46px; height: 46px; border-radius: 13px;
  display: grid; place-items: center; font-size: 24px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  box-shadow: 0 8px 22px rgba(99,102,241,0.45);
}
.brand-name { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.brand-sub  { font-size: 12.5px; color: var(--muted); }

.login-card h2 { font-size: 18px; font-weight: 650; margin-bottom: 4px; letter-spacing: -0.01em; }
.login-card .lead { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 500; }
.field input, .field select {
  width: 100%; padding: 12px 13px; font-size: 14.5px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }

.money-field { position: relative; }
.money-field .money-prefix {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14.5px; font-weight: 600; pointer-events: none;
}
.money-field input { padding-left: 44px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 16px; font-size: 14px; font-weight: 600;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); transition: .15s;
}
.btn:hover { background: var(--elevated); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #7c73f0); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-block { width: 100%; }
.btn-danger { color: var(--neg); border-color: rgba(248,113,113,0.35); background: rgba(248,113,113,0.08); }
.btn-danger:hover { background: rgba(248,113,113,0.16); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 9px; }

.login-hint {
  margin-top: 18px; font-size: 12px; color: var(--faint);
  text-align: center; padding: 10px; background: var(--bg-2);
  border-radius: 10px; border: 1px dashed var(--border-2);
}
.login-error { color: var(--neg); font-size: 12.5px; margin-top: 10px; min-height: 16px; text-align: center; }

/* ============================================================
   APP SHELL
   ============================================================ */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-right: 1px solid var(--border);
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.sidebar .brand { margin-bottom: 30px; padding: 0 6px; }
.sidebar .brand-logo { width: 40px; height: 40px; font-size: 21px; border-radius: 11px; }
.sidebar .brand-name { font-size: 17px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px; border-radius: 11px; border: none; background: transparent;
  color: var(--muted); font-size: 14.5px; font-weight: 500; text-align: left; width: 100%;
  transition: .14s;
}
.nav-item .ni-icon { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: var(--surface); color: var(--text); }
.nav-item.active { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-2); }
.nav-item.active .ni-icon { filter: drop-shadow(0 0 8px rgba(99,102,241,0.5)); }

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.user-chip {
  display: flex; align-items: center; gap: 11px; padding: 10px 11px;
  background: var(--surface); border-radius: 12px; border: 1px solid var(--border);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
}
.user-chip .u-name { font-size: 13px; font-weight: 600; }
.user-chip .u-role { font-size: 11px; color: var(--muted); }

/* ---------------- Main ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: 16px 26px;
  background: rgba(10,14,23,0.72); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.topbar .spacer { flex: 1; }

.month-nav { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 4px; }
.month-nav button { width: 32px; height: 32px; border-radius: 8px; border: none; background: transparent; color: var(--muted); font-size: 16px; }
.month-nav button:hover { background: var(--surface-2); color: var(--text); }
.month-nav .month-label { min-width: 118px; text-align: center; font-size: 13.5px; font-weight: 600; }

.content { padding: 24px 26px 100px; max-width: 1180px; width: 100%; }

/* ---------------- Bottom nav (mobile) ---------------- */
.bottom-nav { display: none; }

/* ============================================================
   COMPONENTES
   ============================================================ */
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 4px 2px 12px; }

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }

.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px;
}
.card-pad-lg { padding: 22px; }

/* Stat cards (resumen) */
.stat {
  position: relative; overflow: hidden;
}
.stat .stat-head { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 12px; }
.stat .stat-dot { width: 9px; height: 9px; border-radius: 50%; }
.stat .stat-main { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.stat .stat-second { font-size: 14px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat .stat-delta { display: inline-flex; align-items: center; gap: 5px; margin-top: 12px; font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 20px; }
.delta-up   { color: var(--pos); background: rgba(52,211,153,0.12); }
.delta-down { color: var(--neg); background: rgba(248,113,113,0.12); }
.delta-flat { color: var(--muted); background: var(--surface-2); }

.stat.accent-in::before,
.stat.accent-out::before,
.stat.accent-save::before {
  content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%;
}
.stat.accent-in::before   { background: linear-gradient(var(--pos), #10b981); }
.stat.accent-out::before  { background: linear-gradient(var(--neg), #ef4444); }
.stat.accent-save::before { background: linear-gradient(var(--primary), var(--primary-2)); }

/* Toggle cotización */
.fx-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 18px;
}
.fx-label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.switch { display: inline-block; position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border-2); border-radius: 20px; transition: .18s; }
.slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .18s; }
.switch input:checked + .slider { background: var(--primary); border-color: transparent; }
.switch input:checked + .slider::before { transform: translateX(18px); background: #fff; }
.fx-input { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.fx-input input { width: 90px; padding: 7px 10px; background: var(--bg-2); border: 1px solid var(--border-2); border-radius: 9px; color: var(--text); font-size: 13.5px; }
.fx-bar .fx-total { margin-left: auto; font-size: 13px; color: var(--muted); }
.fx-bar .fx-total b { color: var(--text); font-size: 15px; }

/* Chart cards */
.chart-card { min-height: 300px; }
.chart-card h3 { font-size: 15px; font-weight: 650; margin-bottom: 4px; }
.chart-card .chart-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 14px; }
.chart-wrap { position: relative; height: 260px; }

/* Lists / rows */
.row-list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 13px 4px;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-ico {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-size: 14.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-amt { text-align: right; font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.row-amt small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); }
.row-actions { display: flex; gap: 4px; }
.icon-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; display: grid; place-items: center; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* Badges / chips */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge-fijo     { color: #93c5fd; background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.25); }
.badge-variable { color: #fcd34d; background: rgba(245,158,11,0.12); border-color: rgba(245,158,11,0.25); }
.badge-cuota    { color: var(--primary-2); background: rgba(99,102,241,0.14); border-color: rgba(99,102,241,0.3); }
.badge-usd      { color: var(--pos); background: rgba(52,211,153,0.12); border-color: rgba(52,211,153,0.25); }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters select, .filters input {
  padding: 9px 12px; font-size: 13px; background: var(--surface); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 10px; outline: none;
}
.filters select:focus, .filters input:focus { border-color: var(--primary); }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .ph-desc { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Card (tarjeta) tiles */
.credit-card {
  border-radius: var(--radius); padding: 20px; color: #fff; position: relative; overflow: hidden;
  min-height: 168px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow); cursor: pointer; border: 1px solid rgba(255,255,255,0.12);
}
.credit-card.grad-visa   { background: linear-gradient(135deg, #4338ca, #6d28d9 55%, #9333ea); }
.credit-card.grad-master { background: linear-gradient(135deg, #b45309, #dc2626 55%, #db2777); }
.credit-card.grad-3      { background: linear-gradient(135deg, #0f766e, #0891b2 55%, #2563eb); }
.credit-card::after { content: ''; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; background: rgba(255,255,255,0.08); }
.cc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.cc-name { font-size: 15px; font-weight: 700; }
.cc-auto { font-size: 10.5px; font-weight: 600; padding: 3px 8px; border-radius: 20px; background: rgba(255,255,255,0.2); }
.cc-total-label { font-size: 11.5px; opacity: .85; }
.cc-total { font-size: 24px; font-weight: 750; letter-spacing: -0.02em; }
.cc-total small { font-size: 13px; font-weight: 600; opacity: .85; margin-left: 6px; }
.cc-foot { display: flex; gap: 18px; font-size: 11.5px; opacity: .9; }
.cc-foot b { display: block; font-size: 13px; opacity: 1; }

/* Detail blocks */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.detail-item { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; }
.detail-item .di-label { font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }
.detail-item .di-value { font-size: 15px; font-weight: 650; }

/* progress cuotas */
.cuota-prog { display: flex; gap: 4px; margin-top: 8px; }
.cuota-pip { flex: 1; height: 6px; border-radius: 4px; background: var(--surface-2); }
.cuota-pip.done { background: var(--primary); }
.cuota-pip.current { background: var(--primary-2); box-shadow: 0 0 8px rgba(129,140,248,0.6); }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .emoji { font-size: 34px; display: block; margin-bottom: 10px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(5,8,14,0.7); backdrop-filter: blur(4px); padding: 20px;
}
.modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border-2); border-radius: 20px; box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 14px; }
.modal-head h3 { font-size: 17px; font-weight: 700; }
.modal-body { padding: 4px 22px 8px; }
.modal-foot { display: flex; gap: 10px; padding: 16px 22px 22px; }
.modal-foot .btn { flex: 1; }
.form-row { display: flex; gap: 12px; }
.form-row .field { flex: 1; }
.field-hint { font-size: 11.5px; color: var(--faint); margin-top: 5px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 900px) {
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .sidebar { display: none; }
  .content { padding: 18px 15px 96px; }
  .topbar { padding: 14px 16px; }
  .topbar h1 { font-size: 17px; }
  .month-nav .month-label { min-width: 92px; font-size: 12.5px; }

  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
    background: rgba(14,19,32,0.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--border); padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    justify-content: space-around;
  }
  .bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; color: var(--muted); font-size: 10.5px; font-weight: 600;
    padding: 4px 8px; border-radius: 10px; min-width: 58px;
  }
  .bn-item .bn-icon { font-size: 20px; }
  .bn-item.active { color: var(--primary-2); }
  .bn-item.active .bn-icon { filter: drop-shadow(0 0 8px rgba(129,140,248,0.6)); }

  .stat .stat-main { font-size: 23px; }
  .fx-bar .fx-total { width: 100%; margin-left: 0; }
  .modal { max-width: 100%; }
}

@media (max-width: 420px) {
  .form-row { flex-direction: column; gap: 0; }
}
