* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f0f2f5;
  color: #333;
}

/* ─── LOGIN ─────────────────────────────────────────────────────────────────── */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-box {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  width: 100%;
  max-width: 400px;
}

.login-box h1 { text-align: center; color: #1a73e8; margin-bottom: 0.3rem; }
.login-box p  { text-align: center; color: #888; margin-bottom: 1.5rem; font-size: 0.9rem; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

/* Overlay para cerrar sidebar en mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

.sidebar {
  width: 220px;
  background: #1e2a3a;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  z-index: 100;
}

.sidebar .logo {
  text-align: center;
  padding: 1rem;
  font-size: 1.1rem;
  font-weight: bold;
  color: #7eb3ff;
  border-bottom: 1px solid #2e3f54;
  margin-bottom: 1rem;
}

.sidebar nav a {
  display: block;
  padding: 0.75rem 1.5rem;
  color: #b0c4de;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.2s;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  background: #2e3f54;
  color: white;
}

.sidebar .logout {
  margin-top: auto;
  padding: 1rem 1.5rem;
  color: #e57373;
  cursor: pointer;
  font-size: 0.9rem;
  border-top: 1px solid #2e3f54;
}

.sidebar .logout:hover { background: #2e3f54; }

/* Barra superior mobile */
.topbar {
  display: none;
  align-items: center;
  gap: 0.75rem;
  background: #1e2a3a;
  padding: 0.75rem 1rem;
  color: white;
  position: sticky;
  top: 0;
  z-index: 98;
}

.topbar .topbar-title {
  font-size: 1rem;
  font-weight: bold;
  color: #7eb3ff;
}

.hamburger {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 4px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s;
}

.main-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  min-width: 0;
}

/* ─── STATS ──────────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border-radius: 10px;
  padding: 1.2rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  text-align: center;
}

.stat-card .number { font-size: 1.8rem; font-weight: bold; color: #1a73e8; }
.stat-card .label  { color: #888; font-size: 0.85rem; margin-top: 0.3rem; }

/* ─── CARDS Y TABLAS ─────────────────────────────────────────────────────────── */

.card {
  background: white;
  border-radius: 10px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 1.5rem;
}

.card h2 { margin-bottom: 1rem; font-size: 1.1rem; color: #444; }

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 500px;
}

thead th {
  background: #f8f9fa;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e9ecef;
  white-space: nowrap;
}

tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
}

tbody tr:hover { background: #fafafa; }

/* ─── BADGES ─────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-activo    { background: #d4edda; color: #155724; }
.badge-inactivo  { background: #e2e3e5; color: #383d41; }
.badge-moroso    { background: #f8d7da; color: #721c24; }
.badge-vencida   { background: #fff3cd; color: #856404; }
.badge-cancelada { background: #e2e3e5; color: #383d41; }

/* ─── FORMULARIOS ────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; font-size: 0.9rem; color: #555; font-weight: 500; }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #1a73e8;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ─── BOTONES ─────────────────────────────────────────────────────────────────── */

.btn {
  padding: 0.55rem 1.1rem;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn-primary  { background: #1a73e8; color: white; }
.btn-success  { background: #28a745; color: white; }
.btn-danger   { background: #dc3545; color: white; }
.btn-warning  { background: #ffc107; color: #333; }
.btn-secondary{ background: #6c757d; color: white; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.82rem; }

/* ─── MODAL ──────────────────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }

.modal {
  background: white;
  border-radius: 10px;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal h3 { margin-bottom: 1.2rem; color: #333; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.2rem; flex-wrap: wrap; }

/* ─── ALERTAS ─────────────────────────────────────────────────────────────────── */

.alert {
  padding: 0.8rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.alert-error   { background: #f8d7da; color: #721c24; }
.alert-success { background: #d4edda; color: #155724; }

/* ─── BÚSQUEDA ───────────────────────────────────────────────────────────────── */

.search-input {
  padding: 0.55rem 0.8rem;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.9rem;
  width: 250px;
  max-width: 100%;
}

.page-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 1.5rem; color: #2c3e50; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 3rem;
  color: #aaa;
  font-size: 0.95rem;
}

/* ─── RESPONSIVE ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {

  /* Sidebar se oculta y se muestra con hamburger */
  .layout { flex-direction: column; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }

  /* Topbar visible en mobile */
  .topbar { display: flex; }

  .main-content {
    padding: 1rem;
    width: 100%;
  }

  .page-title { font-size: 1.1rem; margin-bottom: 1rem; }

  /* Stats en 2 columnas en mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
  }

  .stat-card { padding: 0.9rem 0.75rem; }
  .stat-card .number { font-size: 1.4rem; }

  /* Card con menos padding */
  .card { padding: 1rem; }

  /* Toolbar en columna */
  .table-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .table-toolbar > * { width: 100%; }

  .table-toolbar div[style*="display:flex"],
  .table-toolbar > div {
    flex-wrap: wrap;
    width: 100%;
  }

  .search-input { width: 100%; }

  .btn { width: 100%; text-align: center; }
  .btn-sm { width: auto; }

  /* Formularios en columna */
  .form-row { grid-template-columns: 1fr; gap: 0; }

  /* Modal ocupa más pantalla */
  .modal {
    padding: 1.25rem;
    max-height: 95vh;
    border-radius: 8px;
  }

  .modal-footer { justify-content: stretch; }
  .modal-footer .btn { flex: 1; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-card .number { font-size: 1.2rem; }
  .stat-card .label  { font-size: 0.75rem; }

  thead th, tbody td { padding: 0.6rem 0.75rem; font-size: 0.82rem; }
}
