:root{
  --bg: #f4f6fb;
  --card: #ffffff;
  --primary: #2f6fed;
  --primary-soft: #e8efff;
  --border: #d9e1f2;
  --text: #1f2937;
  --muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
}

*{
  box-sizing:border-box;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial;
}

body{
  margin:0;
  background:var(--bg);
  color:var(--text);
}

a{ text-decoration:none; color:inherit; }

.wrap{
  max-width:1100px;
  margin:0 auto;
  padding:20px;
}

/* ================= TOP BAR ================= */
.topbar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:14px 20px;
  background:var(--card);
  border-bottom:1px solid var(--border);
  position:sticky;
  top:0;
  z-index:10;
}

.right{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}

/* ================= BOTONES ================= */
.btn{
  padding:8px 14px;
  border-radius:10px;
  border:1px solid var(--border);
  background:var(--primary-soft);
  color:var(--primary);
  font-weight:500;
  cursor:pointer;
}

.btn:hover{
  background:var(--primary);
  color:#fff;
}

.btn.danger{
  background:#fee2e2;
  color:var(--danger);
  border-color:#fecaca;
}

.btn.danger:hover{
  background:var(--danger);
  color:#fff;
}

/* ================= TARJETAS ================= */
.card{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:18px;
}

/* ================= FORMULARIOS ================= */
form.card{
  display:grid;
  gap:12px;
  max-width:520px;
}

label{
  font-size:14px;
  color:var(--muted);
}

input,
textarea,
button{
  width:100%;
  padding:10px 12px;
  border-radius:10px;
  border:1px solid var(--border);
  background:#fff;
  color:var(--text);
  font-size:14px;
}

input:focus,
textarea:focus{
  outline:none;
  border-color:var(--primary);
  box-shadow:0 0 0 2px rgba(47,111,237,.15);
}

textarea{
  resize:vertical;
}

button{
  background:var(--primary);
  color:#fff;
  border:none;
  font-weight:600;
}

button:hover{
  filter:brightness(1.05);
}

/* ================= MENÚ PRINCIPAL ================= */
.grid{
  display:grid;
  grid-template-columns:repeat(3, minmax(0,1fr));
  gap:16px;
}

.tile{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:16px;
  padding:26px;
  text-align:center;
  font-size:18px;
  font-weight:600;
  transition:.15s ease;
}

.tile:hover{
  border-color:var(--primary);
  color:var(--primary);
}

.tile.disabled{
  opacity:.45;
  cursor:not-allowed;
}

/* ================= TABLAS (GASTOS) ================= */
.table{
  display:grid;
  gap:10px;
}

.thead,
.tr{
  display:grid;
  grid-template-columns:
    110px
    110px
    120px
    120px
    150px
    1fr
    220px;
  gap:10px;
  align-items:center;
}

.thead{
  font-weight:600;
  color:var(--muted);
  padding:0 10px;
}

.tr{
  background:var(--card);
  border:1px solid var(--border);
  border-radius:14px;
  padding:12px 10px;
}

.actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

/* ================= FILTROS ================= */
.row{
  display:flex;
  gap:12px;
  align-items:flex-end;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.row label{
  display:flex;
  flex-direction:column;
  gap:6px;
}

/* ================= MENSAJES ================= */
.error{
  background:#fee2e2;
  color:#991b1b;
  border:1px solid #fecaca;
  padding:12px;
  border-radius:12px;
}

.ok{
  background:#dcfce7;
  color:#065f46;
  border:1px solid #bbf7d0;
  padding:12px;
  border-radius:12px;
}

.muted{
  color:var(--muted);
}

/* ================= LOGIN ================= */
.center{
  min-height:100vh;
  display:grid;
  place-items:center;
}

/* ================= RESPONSIVE ================= */
@media (max-width: 900px){
  .grid{
    grid-template-columns:1fr;
  }

  .thead{
    display:none;
  }

  .tr{
    grid-template-columns:1fr;
    gap:6px;
  }

  .actions{
    justify-content:flex-start;
  }
}