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

.hidden {
  display: none !important;
}

body {
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
  background: linear-gradient(145deg, #e9f0f5 0%, #d9e3ec 100%);
  min-height: 100vh;
  color: #2c3e50;
  line-height: 1.6;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

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

.card-header {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: #1e466e;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-header:after {
  content: "";
  flex: 1;
  height: 2px;
  background: linear-gradient(90deg, #2c7da0, transparent);
  margin-left: 1rem;
}

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: white;
  border-radius: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.12);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-card h1 {
  font-size: 1.8rem;
  color: #1e466e;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: #6b7a8f;
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
  text-align: left;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.4rem;
  color: #2c3e50;
}

.form-group input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  font-size: 1rem;
  transition: border-color 0.2s;
  outline: none;
  background: #f8fafc;
}

.form-group input:focus {
  border-color: #2c7da0;
  background: white;
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: #2c7da0;
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background: #1f5e7a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(44, 125, 160, 0.3);
}

.btn-danger {
  background: #e74c3c;
  color: white;
}

.btn-danger:hover {
  background: #c0392b;
}

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  border-radius: 0.5rem;
}

.error-msg {
  background: #fef2f2;
  color: #dc2626;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

.success-msg {
  background: #f0fdf4;
  color: #16a34a;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 1rem;
  display: none;
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  margin-bottom: 1rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-left h1 {
  font-size: 1.4rem;
  color: #1e466e;
}

.user-badge {
  background: #e8f4f8;
  color: #2c7da0;
  padding: 0.35rem 0.85rem;
  border-radius: 2rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Table */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  background: #f1f5f9;
  padding: 0.65rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

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

tbody tr:hover {
  background: #f8fafc;
}

tbody tr:last-child td {
  border-bottom: none;
}

.empty {
  text-align: center;
  color: #94a3b8;
  padding: 3rem 1rem !important;
  font-style: italic;
}

.stats {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.stat {
  background: #f8fafc;
  border-radius: 0.75rem;
  padding: 0.75rem 1.25rem;
  text-align: center;
  flex: 1;
  min-width: 120px;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: 700;
  color: #2c7da0;
}

.stat-label {
  font-size: 0.8rem;
  color: #6b7a8f;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Form rows */
.form-rows {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.form-row {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  position: relative;
}

.form-row .remove-row {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 50%;
  display: none;
}

.row-cols-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.row-cols-2 .form-group {
  margin-bottom: 0.75rem;
}

.row-cols-2 .form-group:last-child {
  margin-bottom: 0;
}

.form-row .form-group:last-of-type {
  margin-bottom: 0;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn-secondary {
  background: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* Form card full width */
.form-card {
  background: #f8fafc;
  border-radius: 0.75rem;
  padding: 1.5rem;
  border: 1px solid #e2e8f0;
}

.form-card h3 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
  color: #1e466e;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.form-card h4 {
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
  color: #475569;
  font-weight: 600;
}

.form-card .btn {
  margin-top: 0.5rem;
}

.parent-section {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.form-card .form-group {
  margin-bottom: 0.75rem;
}

.form-card .form-group:last-of-type {
  margin-bottom: 0;
}

/* Tipo selector */
.tipo-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tipo-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: all 0.2s;
  background: #f8fafc;
  color: #475569;
}

.tipo-option:hover {
  border-color: #2c7da0;
  background: #e8f4f8;
}

.tipo-option.active {
  border-color: #2c7da0;
  background: #e8f4f8;
  color: #2c7da0;
}

.tipo-option input[type="radio"] {
  display: none;
}

.form-section.hidden {
  display: none;
}

/* Filter select (admin dropdowns, reusable) */
.filter-select {
  width: 100%;
  padding: 0.6rem 0.85rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.6rem;
  font-size: 0.95rem;
  outline: none;
  background: #f8fafc;
}
.filter-select:focus {
  border-color: #2c7da0;
  background: white;
}

/* Sort bar */
.sort-bar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.sort-btn {
  flex: 1;
  padding: 0.6rem 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 0.75rem;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
  background: #f8fafc;
  color: #475569;
}

.sort-btn:hover {
  border-color: #2c7da0;
  background: #e8f4f8;
}

.sort-btn.active {
  border-color: #2c7da0;
  background: #2c7da0;
  color: white;
}

/* ── Responsive ───────────────────────────── */

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .card {
    padding: 1.25rem;
  }

  .card-header {
    font-size: 1.15rem;
  }

  .row-cols-2 {
    grid-template-columns: 1fr;
  }

  .stats {
    flex-direction: column;
  }

  .topbar {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
  }

  .topbar-left {
    flex-direction: column;
    gap: 0.4rem;
  }

  .topbar-left h1 {
    font-size: 1.2rem;
  }

  .topbar-right {
    flex-wrap: wrap;
    justify-content: center;
  }

  .form-card {
    padding: 1rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }

  table {
    font-size: 0.8rem;
  }

  thead th,
  tbody td {
    padding: 0.4rem 0.5rem;
  }

  .login-card {
    padding: 1.5rem;
  }

  .sort-bar {
    flex-direction: column;
  }

  .tipo-option {
    font-size: 0.85rem;
    padding: 0.6rem 0.75rem;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0.75rem;
  }

  .card {
    padding: 0.85rem;
    border-radius: 0.75rem;
  }

  .card-header {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .topbar-left h1 {
    font-size: 1rem;
  }

  .user-badge {
    font-size: 0.75rem;
  }

  .sort-btn {
    font-size: 0.8rem;
    padding: 0.5rem 0.75rem;
  }

  table {
    font-size: 0.65rem;
  }

  thead th,
  tbody td {
    padding: 0.25rem 0.3rem;
  }

  .stat {
    padding: 0.5rem 0.75rem;
    min-width: 80px;
  }

  .stat-num {
    font-size: 1.3rem;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .form-group label {
    font-size: 0.8rem;
  }

  .form-group input {
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
  }

  .tipo-option {
    font-size: 0.8rem;
    padding: 0.5rem 0.6rem;
  }

  .form-row {
    padding: 0.75rem;
  }

  .filter-select {
    font-size: 0.85rem;
    padding: 0.5rem 0.7rem;
  }
}
