body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #1d4ed8;
  color: #fff;
  padding: 24px;
}

.sidebar h2 {
  margin-top: 0;
  font-size: 22px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar a {
  color: #fff;
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  transition: 0.2s;
}

.sidebar a:hover {
  background: rgba(255, 255, 255, 0.18);
}

.content {
  flex: 1;
  padding: 24px;
}

.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
  color: #4b5563;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}

.card-kpi {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card-kpi span {
  font-size: 28px;
  font-weight: bold;
}

.grid {
  display: grid;
  gap: 16px;
}

.cards-4 {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.two-col {
  grid-template-columns: 1fr 1fr;
}

.mt {
  margin-top: 18px;
}

.header-row,
.filters-row,
.search-row,
.actions-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.header-row {
  justify-content: space-between;
}

.search-row input,
.filters-row input,
.filters-row select {
  flex: 1;
}

.form-grid {
  display: grid;
  gap: 10px;
}

.form-card {
  max-width: 900px;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  box-sizing: border-box;
  background: #fff;
  font-size: 14px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

button,
.btn {
  background: #1d4ed8;
  color: #fff;
  border: none;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  text-align: center;
  padding: 10px 14px;
  border-radius: 10px;
  transition: 0.2s;
}

button:hover,
.btn:hover {
  background: #1e40af;
}

.btn-secondary {
  background: #6b7280;
}

.btn-secondary:hover {
  background: #4b5563;
}

.btn-danger {
  background: #dc2626;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-small {
  padding: 2px 6px;
  font-size: 11px;
  border-radius: 6px;
}

.flash {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.flash.success {
  background: #dcfce7;
}

.flash.warning {
  background: #fef3c7;
}

.flash.danger {
  background: #fee2e2;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 360px;
}

.hint {
  color: #6b7280;
  font-size: 12px;
}

/* TABLAS */
table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 4px 6px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  vertical-align: middle;
  font-size: 12px;
  line-height: 1.1;
}

th {
  font-weight: 700;
  background: #f9fafb;
}

tr {
  height: 24px;
}

.actions-cell {
  white-space: nowrap;
}

/* TABLAS AÚN MÁS COMPACTAS */
.tabla-compacta th,
.tabla-compacta td {
  padding: 3px 5px;
  font-size: 11px;
  line-height: 1.1;
}

.tabla-compacta tr {
  height: 22px;
}

.tabla-compacta .btn-small {
  padding: 2px 5px;
  font-size: 10px;
}

.badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

.badge-gray {
  background: #6b7280;
}

.badge-blue {
  background: #2563eb;
}

.badge-yellow {
  background: #d97706;
}

.badge-cyan {
  background: #0891b2;
}

.badge-orange {
  background: #ea580c;
}

.badge-green {
  background: #16a34a;
}

.badge-red {
  background: #dc2626;
}

.badge-dark {
  background: #374151;
}

.semaforo {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.semaforo-verde {
  background: #22c55e;
}

.semaforo-amarillo {
  background: #facc15;
}

.semaforo-rojo {
  background: #ef4444;
}

.semaforo-gris {
  background: #9ca3af;
}

.success-soft {
  background: #ecfdf5;
}

.warning-soft {
  background: #fffbeb;
}

.danger-soft {
  background: #fef2f2;
}

.info-soft {
  background: #eff6ff;
}

/* FORMULARIO CLIENTES HORIZONTAL */
.form-grid-clientes-horizontal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  align-items: start;
}

.form-grid-clientes-horizontal textarea {
  grid-column: span 3;
  min-height: 44px;
}

.form-grid-clientes-horizontal button {
  grid-column: span 1;
  align-self: stretch;
}

/* SECCIONES DE FORMULARIOS */
.form-section {
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.form-section h3 {
  margin-bottom: 12px;
  font-size: 16px;
  color: #1d4ed8;
}

/* GRID HORIZONTAL GENERAL */
.form-grid-horizontal {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.adjunto-box {
  padding: 10px 12px;
  background: #eff6ff;
  border-radius: 10px;
}

.inline-form {
  display: inline-block;
  margin: 0;
}

.notas-lista {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nota-item {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 12px;
}

.nota-cabecera {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #374151;
}

.nota-item p {
  margin-top: 0;
  margin-bottom: 10px;
  white-space: pre-wrap;
}

.role-pill {
  display: inline-block;
  margin-left: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e5e7eb;
  font-size: 12px;
}

.alert-card {
  border: 2px solid #fecaca;
}

/* CONFIGURACIÓN */
.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-top: 30px;
}

.config-card {
  background: #2c3e50;
  color: white;
  padding: 30px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  border-radius: 12px;
  text-decoration: none;
  transition: 0.2s;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.config-card:hover {
  background: #34495e;
  transform: translateY(-2px);
}

.config-footer {
  margin-top: 40px;
}

.btn-volver {
  display: inline-block;
  background: #6c757d;
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  text-decoration: none;
  transition: 0.2s;
}

.btn-volver:hover {
  background: #5a6268;
}

/* RESPONSIVE */
@media (max-width: 1100px) {
  .form-grid-clientes-horizontal,
  .form-grid-horizontal {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid-clientes-horizontal textarea {
    grid-column: span 2;
  }

  .form-grid-clientes-horizontal button {
    grid-column: span 2;
  }
}

@media (max-width: 900px) {
  .layout {
    flex-direction: column;
  }

  .sidebar {
    width: auto;
  }

  .two-col {
    grid-template-columns: 1fr;
  }

  .header-row,
  .filters-row,
  .search-row,
  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-cell {
    white-space: normal;
  }
}

@media (max-width: 700px) {
  .form-grid-clientes-horizontal,
  .form-grid-horizontal {
    grid-template-columns: 1fr;
  }

  .form-grid-clientes-horizontal textarea,
  .form-grid-clientes-horizontal button {
    grid-column: span 1;
  }

  .nota-cabecera {
    flex-direction: column;
  }
}