/* ============================================================
   Presupuesto Personal — estilos
   Paleta Atento 2025 + estética de "libro de caja": las cifras
   monetarias siempre en monoespaciada, como un registro contable.
   ============================================================ */

:root {
  --lapis: #00558C;
  --purple: #3B2447;
  --azure: #88D2F8;
  --overcast: #E3EDED;
  --tangerine: #EFA27F;
  --green: #00A79D;
  --gray: #595959;
  --silver: #A3A3A3;
  --text: #333333;
  --white: #FFFFFF;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(59, 36, 71, 0.08), 0 1px 2px rgba(59, 36, 71, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--overcast);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.num {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-feature-settings: "tnum";
}

button {
  font-family: inherit;
  cursor: pointer;
}

a { color: var(--lapis); }

/* ============== LOGIN ============== */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--purple) 0%, #2a1a35 55%, #1c1124 100%);
  padding: 24px;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px 36px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
}

.login-ledger {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  border-radius: 12px;
  background: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--azure);
  font-family: 'JetBrains Mono', monospace;
  font-size: 22px;
  font-weight: 700;
}

.login-card h1 {
  font-size: 19px;
  margin: 0 0 4px;
  color: var(--purple);
}

.login-card p.subtitle {
  color: var(--gray);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-card input[type="password"],
.login-card input[type="text"] {
  width: 100%;
  padding: 14px 16px;
  font-size: 22px;
  letter-spacing: 6px;
  text-align: center;
  border: 1.5px solid var(--silver);
  border-radius: var(--radius);
  font-family: 'JetBrains Mono', monospace;
  margin-bottom: 14px;
}
.login-card input:focus { outline: 2px solid var(--lapis); border-color: var(--lapis); }

.login-card button {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius);
  background: var(--lapis);
  color: var(--white);
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s;
}
.login-card button:hover { background: #00436e; }

.login-error {
  color: #b3441c;
  background: #fdeee7;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 14px;
  display: none;
}
.login-error.visible { display: block; }

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

.sidebar {
  width: 230px;
  background: var(--purple);
  color: var(--white);
  flex-shrink: 0;
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 32px;
}
.sidebar .brand .mark {
  width: 34px; height: 34px;
  background: var(--azure);
  color: var(--purple);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 15px;
}
.sidebar .brand .name { font-weight: 600; font-size: 15px; line-height: 1.3; }
.sidebar .brand .name small { display: block; color: var(--azure); font-size: 11px; font-weight: 400; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 8px;
  color: #d9c9e5;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-item.active { background: var(--lapis); color: var(--white); }

.sidebar-foot { margin-top: auto; }
.sidebar-foot .logout {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.25);
  background: transparent;
  color: #d9c9e5;
  font-size: 13px;
}
.sidebar-foot .logout:hover { color: var(--white); border-color: var(--white); }

.main {
  flex: 1;
  min-width: 0;
  padding: 28px 36px 60px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar h2 { margin: 0; font-size: 21px; color: var(--purple); }
.topbar .controls { display: flex; align-items: center; gap: 10px; }

input[type="month"], select, input[type="text"], input[type="number"], input[type="date"], textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 11px;
  border: 1.5px solid var(--silver);
  border-radius: 8px;
  color: var(--text);
  background: var(--white);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--lapis); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--lapis); color: var(--white); }
.btn-primary:hover { background: #00436e; }
.btn-ghost { background: var(--white); color: var(--lapis); border: 1.5px solid var(--lapis); }
.btn-ghost:hover { background: #eef7fd; }
.btn-danger { background: transparent; color: #b3441c; padding: 4px 8px; font-size: 13px; }
.btn-small { padding: 6px 10px; font-size: 13px; }

/* ============== CARDS / GRID ============== */
.cards-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 980px) { .cards-row { grid-template-columns: repeat(2, 1fr); } }

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  border-left: 4px solid var(--lapis);
}
.card.accent-ingreso { border-left-color: var(--green); }
.card.accent-gasto { border-left-color: var(--tangerine); }
.card.accent-balance { border-left-color: var(--purple); }
.card.accent-ahorro { border-left-color: var(--azure); }

.card .label { font-size: 12.5px; color: var(--gray); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
.card .value { font-size: 25px; font-weight: 700; color: var(--purple); }
.card .value.num { font-family: 'JetBrains Mono', monospace; }
.card .delta { font-size: 12.5px; margin-top: 6px; }
.delta.up { color: var(--green); }
.delta.down { color: #b3441c; }

.panel {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.charts-row { display: grid; grid-template-columns: 1.1fr 1.4fr; gap: 16px; margin-bottom: 22px; }
@media (max-width: 980px) { .charts-row { grid-template-columns: 1fr; } }

.rxh-bar-track {
  background: var(--overcast);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin: 10px 0 8px;
}
.rxh-bar-fill { height: 100%; background: var(--green); border-radius: 999px; transition: width 0.3s; }
.rxh-bar-fill.alerta { background: var(--tangerine); }
.rxh-meta { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--gray); }
.rxh-note { font-size: 12px; color: var(--gray); margin-top: 10px; font-style: italic; line-height: 1.5; }

/* ============== TABLA ============== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--gray);
  border-bottom: 1.5px solid var(--overcast);
  padding: 8px 10px;
}
tbody td { padding: 10px 10px; border-bottom: 1px solid var(--overcast); vertical-align: middle; }
tbody tr:hover { background: #fafcfc; }
.tag-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 6px; }
.amount-ingreso { color: var(--green); font-weight: 600; }
.amount-gasto { color: #b3441c; font-weight: 600; }
.empty-state { text-align: center; padding: 36px 10px; color: var(--gray); font-size: 14px; }

/* ============== FILTROS / FORM ROWS ============== */
.filter-row { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field label { display: block; font-size: 12.5px; color: var(--gray); margin-bottom: 5px; font-weight: 500; }
.form-field input, .form-field select, .form-field textarea { width: 100%; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.checkbox-row input { width: auto; }

/* ============== MODAL ============== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(27,16,32,0.55);
  display: none; align-items: center; justify-content: center; padding: 20px; z-index: 50;
}
.modal-overlay.visible { display: flex; }
.modal-box {
  background: var(--white); border-radius: 14px; padding: 26px 26px 22px;
  max-width: 540px; width: 100%; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 30px 70px rgba(0,0,0,0.3);
}
.modal-box h3 { margin: 0 0 18px; color: var(--purple); font-size: 17px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--gray); float: right; line-height: 1; }

.type-toggle { display: flex; border-radius: 8px; overflow: hidden; border: 1.5px solid var(--silver); margin-bottom: 4px; }
.type-toggle button { flex: 1; padding: 9px; border: none; background: var(--white); font-weight: 600; font-size: 13.5px; color: var(--gray); }
.type-toggle button.active.tipo-ingreso { background: var(--green); color: var(--white); }
.type-toggle button.active.tipo-gasto { background: var(--tangerine); color: var(--white); }

/* ============== CATEGORÍAS / PRESUPUESTO ============== */
.cat-budget-row { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--overcast); gap: 10px; }
.cat-budget-row .cat-name { display: flex; align-items: center; font-size: 14px; }
.cat-budget-row input[type="number"] { width: 130px; text-align: right; }
.section { display: none; }
.section.active { display: block; }

.toast {
  position: fixed; bottom: 26px; right: 26px; background: var(--purple); color: var(--white);
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  opacity: 0; transform: translateY(8px); transition: all 0.25s; z-index: 100;
}
.toast.visible { opacity: 1; transform: translateY(0); }

blockquote { font-style: italic; color: var(--gray); border-left: 3px solid var(--silver); padding-left: 12px; margin: 10px 0; }

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: column; padding: 14px 16px; gap: 10px; }
  .sidebar .brand { margin-bottom: 4px; }
  .sidebar nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
  .sidebar nav .nav-item { flex: 0 0 auto; white-space: nowrap; }
  .sidebar-foot { margin-top: 0; }
  .sidebar-foot .logout { width: auto; }
  .main { padding: 18px; }
  .cards-row { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
