* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: #f5f5f2;
  color: #22292f;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  background: #1f4d2c;
  color: white;
}
.topbar .brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: white;
  text-decoration: none;
}
.topbar nav { display: flex; gap: 1rem; flex: 1; }
.topbar nav a, .topbar .logout { color: #d9ead3; text-decoration: none; }
.topbar nav a:hover, .topbar .logout:hover { color: white; }
.topbar .usuario { color: #b7c9be; font-size: 0.9rem; }

.container { max-width: 900px; margin: 0 auto; padding: 1.5rem; flex: 1; display: flex; flex-direction: column; width: 100%; }

.flashes { list-style: none; padding: 0; margin: 0 0 1rem; }
.flash { padding: 0.6rem 1rem; border-radius: 4px; margin-bottom: 0.5rem; }
.flash-success { background: #d9ead3; color: #1f4d2c; }
.flash-error { background: #f4cccc; color: #7a1f1f; }

table { width: 100%; border-collapse: collapse; margin: 1rem 0; }
th, td { text-align: left; padding: 0.5rem; border-bottom: 1px solid #ddd; }
th { background: #eee; }

form.stacked p { margin: 0.75rem 0; }
form.stacked label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input, select, textarea {
  width: 100%; max-width: 400px; padding: 0.4rem; border: 1px solid #ccc; border-radius: 4px;
}
button, .btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  background: #1f4d2c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.95rem;
}
button:hover, .btn:hover { background: #163a20; }
.btn-danger { background: #a83232; }
.btn-danger:hover { background: #7a1f1f; }
.errors { color: #a83232; font-size: 0.85rem; margin: 0.2rem 0 0; padding: 0; }

.progreso-bar {
  background: #ddd; border-radius: 6px; height: 22px; overflow: hidden; margin: 0.5rem 0;
}
.progreso-fill { background: #1f4d2c; height: 100%; color: white; text-align: right;
  padding-right: 6px; font-size: 0.8rem; line-height: 22px; white-space: nowrap; }

.estado { padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.estado-pagado { background: #d9ead3; color: #1f4d2c; }
.estado-debe { background: #f4cccc; color: #7a1f1f; }

.badge { display: inline-block; padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }
.badge-mas { background: #fff2cc; color: #7f6000; }

.search-form { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.search-form input { max-width: 300px; }

.actions { display: flex; gap: 0.5rem; margin: 1rem 0; flex-wrap: wrap; }

.inline-form { display: inline; }

.cuota-form { display: flex; gap: 0.3rem; }
.cuota-input { max-width: 110px; }

.fila-debe { background: #fdecea; }
.fila-pagado { background: #eaf6ec; }

.seccion-titulo { margin-top: 2rem; }
.seccion-titulo.debe { color: #7a1f1f; }
.seccion-titulo.pagado { color: #1f4d2c; }

.metricas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.metric-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font-family: inherit;
}
.metric-card:hover { border-color: #1f4d2c; }
.metric-card.active { border-color: #1f4d2c; background: #eaf6ec; }
.metric-valor { font-size: 1.4rem; font-weight: 700; color: #1f4d2c; }
.metric-label { font-size: 0.85rem; color: #556; }

.login-page {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.5rem;
}
.login-logo { width: 150px; height: 150px; object-fit: contain; margin-bottom: 0.5rem; }
.login-page form.stacked { width: 100%; max-width: 320px; text-align: left; margin-top: 0.5rem; }
