:root {
  --azul: #1B5BB5;
  --verde: #3DAA35;
  --gris: #f4f5f7;
  --texto-sec: #6b7280;
  --borde: #e2e5ea;
}
* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--gris);
  color: #1f2430;
}
.topbar {
  background: var(--azul);
  color: white;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.topbar .brand { font-weight: 600; font-size: 16px; }
.topbar .user { font-size: 12px; opacity: .9; }
.topbar button {
  background: transparent;
  border: 1px solid rgba(255,255,255,.5);
  color: white;
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
.container { max-width: 960px; margin: 0 auto; padding: 16px 12px; }
.card {
  background: white;
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
h1, h2, h3 { margin-top: 0; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
label { font-size: 13px; color: var(--texto-sec); display: block; margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borde);
  border-radius: 8px;
  font-size: 15px;
  margin-bottom: 12px;
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); }

/* Tablas responsivas: scroll horizontal en móvil */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 400px; }
th, td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--borde); }
th { color: var(--texto-sec); white-space: nowrap; }

button.primary {
  background: var(--azul);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 15px;
  cursor: pointer;
  width: 100%;
}
button.success {
  background: var(--verde);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
button.danger {
  background: white;
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
button.secondary {
  background: white;
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}
.totales { display: flex; justify-content: flex-end; }
.totales table { width: 100%; min-width: unset; max-width: 280px; }
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.badge-warning { background: #fff4d6; color: #92660b; }
.badge-success { background: #e3f6df; color: #1f7a23; }
.badge-danger { background: #fbe4e2; color: #b3261e; }
.badge-info { background: #e6f1fb; color: #0c447c; }
.alert {
  background: var(--gris);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--texto-sec);
  margin-bottom: 12px;
}
.error { color: #b3261e; font-size: 13px; margin-bottom: 8px; }

/* Botones de accion en tablas: se apilan en movil */
.btn-group { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* En pantallas pequeñas, grids de 2/3 col pasan a 1 col */
@media (max-width: 600px) {
  .container { padding: 10px 8px; }
  .card { padding: 14px 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .topbar .brand { font-size: 14px; }
  button.primary { font-size: 15px; padding: 12px; }
  .totales { justify-content: stretch; }
  .totales table { max-width: 100%; }
  h2 { font-size: 16px; }
}
