:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #071b55;
  --muted: #5f6f8f;
  --line: #dce3ef;
  --primary: #ffdc00;
  --primary-dark: #e8c800;
  --navy: #002b7f;
  --navy-2: #071b55;
  --success: #13a052;
  --danger: #d92d20;
  --warning: #b7791f;
  --shadow: 0 20px 55px rgba(7, 27, 85, 0.10);
  --soft-shadow: 0 10px 26px rgba(7, 27, 85, 0.08);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: Lucida, 'Courier New', monospace;
  background: linear-gradient(135deg, #ffffff 0%, #f3f5f9 45%, #eef2f8 100%);
  color: var(--text);
  min-height: 100vh;
}
button, input, select, textarea { font: inherit; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  background: var(--surface);
  color: var(--text);
  padding: 30px 22px;
  display: flex;
  flex-direction: column;
  gap: 30px;
  z-index: 10;
  border-right: 1px solid var(--line);
  box-shadow: 12px 0 35px rgba(7, 27, 85, .06);
}
.brand { display: flex; gap: 14px; align-items: center; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 8px;
  background: var(--primary);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 10px 22px rgba(255, 220, 0, .35);
}
.brand-mark span { width: 12px; height: 12px; background: var(--navy); display:block; border-radius: 2px; transform: translate(4px,-4px); }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.08; color: var(--navy-2); letter-spacing: .2px; }
.brand p { margin: 5px 0 0; color: var(--muted); font-size: 13px; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; }
.nav { display: grid; gap: 9px; }
.nav-link {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 13px 14px;
  text-align: left;
  color: var(--navy-2);
  background: transparent;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
  font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace;
  font-weight: 700;
}
.nav-link:hover { background: #f7f9fd; transform: translateX(4px); border-color: var(--line); }
.nav-link.active { background: var(--primary); color: var(--navy-2); box-shadow: 0 10px 22px rgba(255,220,0,.28); }

.app { margin-left: 292px; padding: 28px; }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px 20px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(10px);
  animation: slideDown .35s ease both;
}
.eyebrow { margin: 0 0 6px; color: var(--muted); font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.topbar h2 { margin: 0; font-size: 31px; color: var(--navy-2); }
.top-actions, .form-actions, .row-actions, .actions-grid { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  background: var(--surface);
  color: var(--navy-2);
  cursor: pointer;
  font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 22px rgba(7, 27, 85, .12); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--navy-2); }
.btn.ghost { background: #f8fafc; }
.btn.danger { background: #fff5f5; color: var(--danger); border-color: #fecaca; }
.btn.small { padding: 8px 11px; font-size: 13px; }
.icon-btn { border: 1px solid var(--line); background: #fff; color: var(--navy); border-radius: 10px; padding: 8px 10px; cursor: pointer; transition: .18s ease; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; font-weight: 700; }
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--soft-shadow); }
.icon-btn.delete { color: var(--danger); }

.section { display: none; animation: fadeUp .28s ease both; }
.section.active { display: block; }
.summary-grid { display: grid; grid-template-columns: repeat(6, minmax(145px, 1fr)); gap: 16px; }
.card, .panel, .chart-card, .form-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover, .panel:hover, .chart-card:hover, .form-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: #c9d4e6; }
.card { padding: 20px; min-height: 120px; position: relative; overflow:hidden; }
.card::after { content:""; position:absolute; right:-30px; top:-30px; width:82px; height:82px; background: rgba(255,220,0,.34); border-radius:999px; }
.card span { color: var(--muted); font-size: 13px; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; font-weight: 700; }
.card strong { display: block; margin-top: 12px; font-size: 25px; color: var(--navy-2); }
.card small { color: var(--muted); font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; }
.card.highlight { background: linear-gradient(135deg, var(--navy-2), var(--navy)); color: #fff; }
.card.highlight span, .card.highlight small, .card.highlight strong { color: #fff; }
.card.highlight::after { background: var(--primary); opacity:.9; }

.period-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 18px 0; }
.panel { padding: 20px; }
.panel h3, .chart-card h3 { margin: 0 0 14px; color: var(--navy-2); font-size: 20px; }
.panel p { margin: 0; font-size: 26px; font-weight: 800; color: var(--navy); }
.panel-head { display:flex; justify-content:space-between; align-items:center; gap:12px; margin-bottom: 12px; }
.charts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.chart-card { padding: 20px; height: 340px; }
.chart-card canvas { max-height: 270px; }

.form-card { padding: 22px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
label { display: grid; gap: 8px; color: var(--navy-2); font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; font-weight: 800; font-size: 14px; }
label.wide { grid-column: span 3; }
input, select, textarea {
  border: 1px solid #cfd8e6;
  border-radius: 10px;
  padding: 12px 13px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary-dark); box-shadow: 0 0 0 4px rgba(255,220,0,.24); }
.form-actions { margin-top: 18px; }
.filters { display: grid; grid-template-columns: repeat(5, minmax(130px, 1fr)); gap: 12px; margin-bottom: 16px; }
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; min-width: 760px; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: #f8fafc; }
tbody tr { animation: fadeUp .22s ease both; transition: background .18s ease; }
tbody tr:hover { background: #fffbea; }
.badge { padding: 6px 10px; border-radius: 999px; font-weight: 800; font-size: 12px; text-transform: capitalize; }
.badge.ingreso { background:#eaf8ef; color:var(--success); }
.badge.gasto { background:#fff1f1; color:var(--danger); }
.badge.prestamo { background:#eef4ff; color:var(--navy); }
.badge.deuda { background:#fff8db; color:var(--warning); }
.actions-grid { margin-bottom: 18px; }
.report-box { display:grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.report-item { background:#f8fafc; border:1px solid var(--line); border-radius:14px; padding:16px; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; }
.report-item span { color:var(--muted); display:block; margin-bottom:8px; }
.config-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.toast { position: fixed; right: 24px; bottom: 24px; background: var(--navy-2); color:#fff; padding:14px 16px; border-radius:14px; box-shadow: var(--shadow); opacity:0; transform: translateY(12px) scale(.98); pointer-events:none; transition:.25s ease; z-index:100; font-family: 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif, 'Courier New', monospace; }
.toast.show { opacity:1; transform: translateY(0) scale(1); }
.toast.error { background: var(--danger); }

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 27, 85, .38);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  padding: 18px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
  z-index: 200;
}
.confirm-overlay.show { opacity: 1; pointer-events: auto; }
.confirm-box {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 28px 80px rgba(7, 27, 85, .22);
  padding: 24px;
  transform: translateY(18px) scale(.96);
  transition: transform .22s ease;
}
.confirm-overlay.show .confirm-box { transform: translateY(0) scale(1); }
.confirm-box h3 { margin: 0 0 8px; color: var(--navy-2); font-size: 22px; }
.confirm-box p { margin: 0 0 18px; color: var(--muted); line-height: 1.45; }
.confirm-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; }
.confirm-actions .btn { min-width: 120px; }

@keyframes fadeUp { from { opacity:0; transform: translateY(12px); } to { opacity:1; transform: translateY(0); } }
@keyframes slideDown { from { opacity:0; transform: translateY(-12px); } to { opacity:1; transform: translateY(0); } }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  label.wide { grid-column: span 2; }
  .filters { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: sticky; top: 0; width: 100%; height: auto; padding: 14px; gap: 12px; }
  .brand h1 { font-size: 16px; }
  .nav { display:flex; overflow-x:auto; padding-bottom: 4px; }
  .nav-link { white-space: nowrap; padding: 10px 12px; }
  .app { margin-left:0; padding: 14px; }
  .topbar { align-items:flex-start; flex-direction: column; border-radius: 18px; }
  .topbar h2 { font-size: 25px; }
  .top-actions, .top-actions .btn { width: 100%; }
  .top-actions .btn { justify-content:center; text-align:center; }
  .summary-grid, .period-grid, .charts-grid, .report-box, .config-grid { grid-template-columns: 1fr; }
  .chart-card { height: 310px; }
  .form-grid, .filters { grid-template-columns: 1fr; }
  label.wide { grid-column: span 1; }
  .btn { width: 100%; }
  .row-actions .icon-btn { width:auto; }
  .toast { left: 14px; right: 14px; bottom: 14px; }
}
